Override Player#getAcquirable

This commit is contained in:
TheMode 2021-04-23 11:51:14 +02:00
parent 129f720295
commit cad488bb5d
2 changed files with 11 additions and 2 deletions

View File

@ -125,7 +125,8 @@ public class Entity implements Viewable, Tickable, EventHandler, DataContainer,
private long ticks;
private final EntityTickEvent tickEvent = new EntityTickEvent(this);
private final AcquirableEntity acquirableEntity = new AcquirableEntity(this);
// Not final in order to be modifiable in subclasses, use at your own risk
protected AcquirableEntity acquirable = new AcquirableEntity(this);
/**
* Lock used to support #switchEntityType
@ -1574,7 +1575,7 @@ public class Entity implements Viewable, Tickable, EventHandler, DataContainer,
}
public @NotNull AcquirableEntity getAcquirable() {
return acquirableEntity;
return acquirable;
}
public enum Pose {

View File

@ -27,6 +27,7 @@ import net.minestom.server.collision.BoundingBox;
import net.minestom.server.command.CommandManager;
import net.minestom.server.command.CommandSender;
import net.minestom.server.effects.Effects;
import net.minestom.server.entity.acquirable.AcquirablePlayer;
import net.minestom.server.entity.damage.DamageType;
import net.minestom.server.entity.fakeplayer.FakePlayer;
import net.minestom.server.entity.vehicle.PlayerVehicleInformation;
@ -185,6 +186,8 @@ public class Player extends LivingEntity implements CommandSender, Localizable,
this.username = username;
this.playerConnection = playerConnection;
this.acquirable = new AcquirablePlayer(this);
setBoundingBox(0.6f, 1.8f, 0.6f);
setRespawnPoint(new Position(0, 0, 0));
@ -2455,6 +2458,11 @@ public class Player extends LivingEntity implements CommandSender, Localizable,
return lastKeepAlive;
}
@Override
public @NotNull AcquirablePlayer getAcquirable() {
return (AcquirablePlayer) super.getAcquirable();
}
@Override
public @NotNull HoverEvent<ShowEntity> asHoverEvent(@NotNull UnaryOperator<ShowEntity> op) {
return HoverEvent.showEntity(ShowEntity.of(EntityType.PLAYER, this.uuid, this.displayName));