diff --git a/src/main/java/com/minelittlepony/render/RenderPony.java b/src/main/java/com/minelittlepony/render/RenderPony.java index 881a9804..0a66e052 100644 --- a/src/main/java/com/minelittlepony/render/RenderPony.java +++ b/src/main/java/com/minelittlepony/render/RenderPony.java @@ -96,4 +96,23 @@ public class RenderPony { public float getScaleFactor() { return ponyModel.getSize().getScaleFactor(); } + + public double getNamePlateYOffset(T entity, double initial) { + + // We start by negating the height calculation done by mohjong. + float y = -(entity.height + 0.5F - (entity.isSneaking() ? 0.25F : 0)); + + if (entity.isChild()) { + y += 0.5F; + } + + // Then we add our own offsets. + y += entity.height * getScaleFactor() + 0.25F; + + if (entity.isSneaking()) { + y -= 0.125F; + } + + return initial + y; + } } diff --git a/src/main/java/com/minelittlepony/render/RenderPonyMob.java b/src/main/java/com/minelittlepony/render/RenderPonyMob.java index 83654125..cbf4b1a0 100644 --- a/src/main/java/com/minelittlepony/render/RenderPonyMob.java +++ b/src/main/java/com/minelittlepony/render/RenderPonyMob.java @@ -79,6 +79,11 @@ public abstract class RenderPonyMob extends RenderLiving return MineLittlePony.getInstance().getManager().getPony(getEntityTexture(entity)); } + @Override + protected void renderLivingLabel(T entity, String name, double x, double y, double z, int maxDistance) { + super.renderLivingLabel(entity, name, x, renderPony.getNamePlateYOffset(entity, y), z, maxDistance); + } + @Override @Nonnull protected final ResourceLocation getEntityTexture(T entity) { diff --git a/src/main/java/com/minelittlepony/render/player/RenderPonyPlayer.java b/src/main/java/com/minelittlepony/render/player/RenderPonyPlayer.java index adde2138..f321c727 100644 --- a/src/main/java/com/minelittlepony/render/player/RenderPonyPlayer.java +++ b/src/main/java/com/minelittlepony/render/player/RenderPonyPlayer.java @@ -75,6 +75,11 @@ public class RenderPonyPlayer extends RenderPlayer implements IRenderPony