[SPIGOT-3807] LivingEntity#getEyeLocation() doesn't take gliding into account Created: 09/Feb/18  Updated: 10/Feb/18  Resolved: 10/Feb/18

Status: Resolved
Project: Spigot
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Minor
Reporter: Anrza Assignee: Unassigned
Resolution: Fixed Votes: 0
Labels: None


 Description   

The method in CraftBukkit:

public Location getEyeLocation() {
        Location loc = getLocation();
        loc.setY(loc.getY() + getEyeHeight());
        return loc;
    }

public double getEyeHeight() {
        return getHandle().getHeadHeight();
    }

For players, getEyeHeight() returns 1.62 if you're flying and not sneaking, same as if you weren't flying. It returns 1.54 if you're flying and sneaking, same as if you weren't flying.

 

As a sidenote, EntityHuman#getHeadHeight() looks like this:

public float getHeadHeight() {
    float f = 1.62F;
    if (this.isSleeping()) {
        f = 0.2F;
    } else if (!this.isSneaking() && this.length != 1.65F) {
        if (this.cP() || this.length == 0.6F) {
            f = 0.4F;
        }
    } else {
        f -= 0.08F;
    }

    return f;
}

And cP() is returns the same thing as LivingEntity#isGliding(). So I think that it should return the correct eye location if you're not sneaking.


Generated at Sun Mar 30 17:54:37 UTC 2025 using Jira 10.3.3#10030003-sha1:d220e3fefc8dfc6d47f522d3b9a20c1455e12b7b.