New constructor to give UUID as argument in LivingEntity, now used to specify player UUID

This commit is contained in:
jglrxavpok 2021-02-05 14:32:28 +01:00
parent da3a8b17b2
commit 8a992b3e45
2 changed files with 17 additions and 2 deletions

View File

@ -75,10 +75,26 @@ public abstract class LivingEntity extends Entity implements EquipmentHandler {
setGravity(0.02f, 0.08f, 3.92f);
}
/**
* Constructor which allows to specify an UUID. Only use if you know what you are doing!
*/
public LivingEntity(@NotNull EntityType entityType, @NotNull UUID uuid, @NotNull Position spawnPosition) {
super(entityType, uuid, spawnPosition);
setupAttributes();
setGravity(0.02f, 0.08f, 3.92f);
}
public LivingEntity(@NotNull EntityType entityType) {
this(entityType, new Position());
}
/**
* Constructor which allows to specify an UUID. Only use if you know what you are doing!
*/
public LivingEntity(@NotNull EntityType entityType, @NotNull UUID uuid) {
this(entityType, uuid, new Position());
}
@Override
public void update(long time) {
if (isOnFire()) {

View File

@ -196,8 +196,7 @@ public class Player extends LivingEntity implements CommandSender {
private final PlayerTickEvent playerTickEvent = new PlayerTickEvent(this);
public Player(@NotNull UUID uuid, @NotNull String username, @NotNull PlayerConnection playerConnection) {
super(EntityType.PLAYER);
this.uuid = uuid; // Override Entity#uuid defined in the constructor
super(EntityType.PLAYER, uuid);
this.username = username;
this.playerConnection = playerConnection;