Fixed mis-positioned nameplates when sleeping

This commit is contained in:
Sollace 2018-10-28 22:24:40 +02:00
parent c08c2a7180
commit 0f364327e9

View file

@ -14,6 +14,8 @@ import com.minelittlepony.render.layer.LayerPonyArmor;
import com.minelittlepony.render.layer.LayerPonyCape;
import com.minelittlepony.render.layer.LayerPonyCustomHead;
import com.minelittlepony.render.layer.LayerPonyElytra;
import net.minecraft.block.BlockBed;
import net.minecraft.client.entity.AbstractClientPlayer;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.culling.ICamera;
@ -93,6 +95,13 @@ public class RenderPonyPlayer extends RenderPlayer implements IRenderPony<Abstra
@Override
protected void renderLivingLabel(AbstractClientPlayer entity, String name, double x, double y, double z, int maxDistance) {
if (entity.isPlayerSleeping()) {
if (entity.bedLocation != null && entity.getEntityWorld().getBlockState(entity.bedLocation).getBlock() instanceof BlockBed) {
double bedRad = Math.toRadians(entity.getBedOrientationInDegrees());
x += Math.cos(bedRad);
z -= Math.sin(bedRad);
}
}
super.renderLivingLabel(entity, name, x, renderPony.getNamePlateYOffset(entity, y), z, maxDistance);
}