Skip to content
This repository was archived by the owner on Feb 19, 2019. It is now read-only.

Commit f7f1310

Browse files
committed
Added getHeadPos method to IEntity
1 parent 5ea8b0d commit f7f1310

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

src/main/java/clientapi/load/mixin/MixinEntity.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,9 @@ public abstract class MixinEntity implements IEntity {
5757
@Shadow public void move(MoverType type, double x, double y, double z) {}
5858
@Shadow public abstract boolean isSprinting();
5959
@Shadow public abstract boolean isRiding();
60+
@Shadow public abstract float getEyeHeight();
6061

61-
private Vec3 pos, prevPos, lastTickPos, motion;
62+
private Vec3 pos, prevPos, lastTickPos, headPos, motion;
6263
private Vec2 rotation, prevRotation;
6364

6465
@Inject(method = "applyEntityCollision", at = @At("HEAD"), cancellable = true)
@@ -133,6 +134,14 @@ public final Vec3 getLastTickPos() {
133134
return lastTickPos.setX(lastTickPosX).setY(lastTickPosY).setZ(lastTickPosZ);
134135
}
135136

137+
@Override
138+
public final Vec3 getHeadPos() {
139+
if (headPos == null)
140+
headPos = new Vec3();
141+
142+
return headPos.setX(posX).setY(posY + getEyeHeight()).setZ(posZ);
143+
}
144+
136145
@Override
137146
public final Vec2 getRotations() {
138147
if (rotation == null)

src/main/java/clientapi/load/mixin/extension/IEntity.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,13 @@ public interface IEntity {
8888
*/
8989
Vec3 getLastTickPos();
9090

91+
/**
92+
* Returns a {@code Vec3} with the world position of this entity's head
93+
*
94+
* @return This entity's head position
95+
*/
96+
Vec3 getHeadPos();
97+
9198
/**
9299
* Converts the entity rotation angles to a {@code Vec2}
93100
*

0 commit comments

Comments
 (0)