From c74f05873e1cd7cfb350e2d3e69926c871254a77 Mon Sep 17 00:00:00 2001 From: Sollace Date: Wed, 5 Sep 2018 11:33:48 +0200 Subject: [PATCH] Adjust nameplate positioning on ponies. --- .../com/minelittlepony/render/RenderPony.java | 19 +++++++++++++++++++ .../minelittlepony/render/RenderPonyMob.java | 5 +++++ .../render/player/RenderPonyPlayer.java | 5 +++++ 3 files changed, 29 insertions(+) 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