Adjust nameplate positioning on ponies.

This commit is contained in:
Sollace 2018-09-05 11:33:48 +02:00
parent ac3a7c7668
commit c74f05873e
3 changed files with 29 additions and 0 deletions

View file

@ -96,4 +96,23 @@ public class RenderPony<T extends EntityLivingBase> {
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;
}
}

View file

@ -79,6 +79,11 @@ public abstract class RenderPonyMob<T extends EntityLiving> 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) {

View file

@ -75,6 +75,11 @@ public class RenderPonyPlayer extends RenderPlayer implements IRenderPony<Abstra
}
}
@Override
protected void renderLivingLabel(AbstractClientPlayer entity, String name, double x, double y, double z, int maxDistance) {
super.renderLivingLabel(entity, name, x, renderPony.getNamePlateYOffset(entity, y), z, maxDistance);
}
@Override
public void doRenderShadowAndFire(Entity player, double x, double y, double z, float yaw, float ticks) {
if (player.isRiding() && ((AbstractClientPlayer)player).isPlayerSleeping()) {