Implement entity eye height based on boundingbox

This commit is contained in:
themode 2020-12-29 20:42:41 +01:00
parent 78ed12887d
commit 835a769080
8 changed files with 3 additions and 18 deletions

View File

@ -90,7 +90,6 @@ public abstract class Entity implements Viewable, EventHandler, DataContainer, P
protected float gravityAcceleration; protected float gravityAcceleration;
protected float gravityTerminalVelocity; protected float gravityTerminalVelocity;
protected int gravityTickCount; // Number of tick where gravity tick was applied protected int gravityTickCount; // Number of tick where gravity tick was applied
protected float eyeHeight;
private boolean autoViewable; private boolean autoViewable;
private final int id; private final int id;
@ -1208,20 +1207,13 @@ public abstract class Entity implements Viewable, EventHandler, DataContainer, P
/** /**
* Gets the entity eye height. * Gets the entity eye height.
* <p>
* Default to {@link BoundingBox#getHeight()}x0.85
* *
* @return the entity eye height * @return the entity eye height
*/ */
public float getEyeHeight() { public float getEyeHeight() {
return eyeHeight; return boundingBox.getHeight() * 0.85f;
}
/**
* Changes the entity eye height.
*
* @param eyeHeight the entity eye height
*/
public void setEyeHeight(float eyeHeight) {
this.eyeHeight = eyeHeight;
} }
/** /**

View File

@ -202,7 +202,6 @@ public class Player extends LivingEntity implements CommandSender {
this.playerConnection = playerConnection; this.playerConnection = playerConnection;
setBoundingBox(0.6f, 1.8f, 0.6f); setBoundingBox(0.6f, 1.8f, 0.6f);
setEyeHeight(1.62f);
setRespawnPoint(new Position(0, 0, 0)); setRespawnPoint(new Position(0, 0, 0));

View File

@ -9,6 +9,5 @@ public class EntityCaveSpider extends EntityCreature implements Monster {
public EntityCaveSpider(Position spawnPosition) { public EntityCaveSpider(Position spawnPosition) {
super(EntityType.CAVE_SPIDER, spawnPosition); super(EntityType.CAVE_SPIDER, spawnPosition);
setBoundingBox(0.7f, 0.5f, 0.7f); setBoundingBox(0.7f, 0.5f, 0.7f);
setEyeHeight(0.45f);
} }
} }

View File

@ -9,6 +9,5 @@ public class EntityEndermite extends EntityCreature implements Monster {
public EntityEndermite(Position spawnPosition) { public EntityEndermite(Position spawnPosition) {
super(EntityType.ENDERMITE, spawnPosition); super(EntityType.ENDERMITE, spawnPosition);
setBoundingBox(0.4f, 0.3f, 0.4f); setBoundingBox(0.4f, 0.3f, 0.4f);
setEyeHeight(0.13f);
} }
} }

View File

@ -16,7 +16,6 @@ public class EntityGhast extends EntityCreature implements Monster {
public EntityGhast(Position spawnPosition) { public EntityGhast(Position spawnPosition) {
super(EntityType.GHAST, spawnPosition); super(EntityType.GHAST, spawnPosition);
setBoundingBox(4, 4, 4); setBoundingBox(4, 4, 4);
setEyeHeight(2.6f);
} }
@NotNull @NotNull

View File

@ -9,6 +9,5 @@ public class EntitySilverfish extends EntityCreature implements Monster {
public EntitySilverfish(Position spawnPosition) { public EntitySilverfish(Position spawnPosition) {
super(EntityType.SILVERFISH, spawnPosition); super(EntityType.SILVERFISH, spawnPosition);
setBoundingBox(0.4f, 0.3f, 0.4f); setBoundingBox(0.4f, 0.3f, 0.4f);
setEyeHeight(0.13f);
} }
} }

View File

@ -16,7 +16,6 @@ public class EntitySpider extends EntityCreature implements Monster {
public EntitySpider(Position spawnPosition) { public EntitySpider(Position spawnPosition) {
super(EntityType.SPIDER, spawnPosition); super(EntityType.SPIDER, spawnPosition);
setBoundingBox(1.4f, 0.9f, 1.4f); setBoundingBox(1.4f, 0.9f, 1.4f);
setEyeHeight(0.65f);
} }
@NotNull @NotNull

View File

@ -16,7 +16,6 @@ public class EntityWitch extends EntityCreature implements Monster {
public EntityWitch(Position spawnPosition) { public EntityWitch(Position spawnPosition) {
super(EntityType.WITCH, spawnPosition); super(EntityType.WITCH, spawnPosition);
setBoundingBox(0.6f, 1.95f, 0.6f); setBoundingBox(0.6f, 1.95f, 0.6f);
setEyeHeight(1.62f);
} }
@NotNull @NotNull