Added eye anchor point using the entity's eye height

This commit is contained in:
Vidal committed 2026-02-12 12:14:21 -03:00
1 parent 91762bb1ba
commit eee9b32a5b
3 files changed
+11 -1

No files matched your search

@@ -10,7 +10,8 @@ public enum AnchorPoint {
RIGHT_HAND("Right Hand"), // Right arm/hand position
LEFT_HAND("Left Hand"), // Left arm/hand position
ABOVE_HEAD("Above Head"), // Above the entity
CHEST("Chest"); // Chest level, centered
CHEST("Chest"), // Chest level, centered
EYE("Eye"); // Eye level, centered
private final String displayName;
@@ -55,6 +56,7 @@ public enum AnchorPoint {
case LEFT_HAND: return "ability.anchor.leftHand";
case ABOVE_HEAD: return "ability.anchor.aboveHead";
case CHEST: return "ability.anchor.chest";
case EYE: return "ability.anchor.eye";
default: return name();
}
}
@@ -37,6 +37,7 @@ public class AnchorPointHelper {
private static final float ARM_HEIGHT = 0.75f;
private static final float ABOVE_HEAD_HEIGHT = 1.2f;
private static final float CHEST_HEIGHT = 0.65f;
private static final float EYE_HEIGHT = 0.85f;
// Distance in front for FRONT anchor
private static final float DEFAULT_FRONT_DISTANCE = 1.0f;
@@ -98,6 +99,10 @@ public class AnchorPointHelper {
case CHEST:
y += height * CHEST_HEIGHT;
break;
case EYE:
y += entity.getEyeHeight();
break;
}
// Rotate offsets relative to entity's body yaw
@@ -347,6 +352,8 @@ public class AnchorPointHelper {
return ABOVE_HEAD_HEIGHT;
case CHEST:
return CHEST_HEIGHT;
case EYE:
return EYE_HEIGHT;
default:
return FRONT_HEIGHT;
}