From e016f420a781f489f9bd87f129b90169fdf3f220 Mon Sep 17 00:00:00 2001 From: Matthew Messinger Date: Thu, 29 Dec 2016 03:08:05 -0500 Subject: [PATCH] Fix block heads for humans and add support for rendering items on the head. --- .../mixin/MixinRenderPlayer.java | 2 +- .../renderer/RenderPonyMob.java | 4 ++-- ...onySkull.java => LayerPonyCustomHead.java} | 21 +++++++++---------- .../com/minelittlepony/util/PonyFields.java | 1 - 4 files changed, 13 insertions(+), 15 deletions(-) rename src/main/java/com/minelittlepony/renderer/layer/{LayerPonySkull.java => LayerPonyCustomHead.java} (88%) diff --git a/src/main/java/com/minelittlepony/mixin/MixinRenderPlayer.java b/src/main/java/com/minelittlepony/mixin/MixinRenderPlayer.java index c84b5329..fe50a5fe 100644 --- a/src/main/java/com/minelittlepony/mixin/MixinRenderPlayer.java +++ b/src/main/java/com/minelittlepony/mixin/MixinRenderPlayer.java @@ -54,7 +54,7 @@ public abstract class MixinRenderPlayer extends RenderLivingBase extends RenderLiving this.addLayer(new LayerPonyArmor(this)); this.addLayer(new LayerHeldPonyItem(this)); // this.addLayer(new LayerArrow(this)); - this.addLayer(new LayerPonySkull(this)); + this.addLayer(new LayerPonyCustomHead(this)); this.addLayer(new LayerPonyElytra(this)); } diff --git a/src/main/java/com/minelittlepony/renderer/layer/LayerPonySkull.java b/src/main/java/com/minelittlepony/renderer/layer/LayerPonyCustomHead.java similarity index 88% rename from src/main/java/com/minelittlepony/renderer/layer/LayerPonySkull.java rename to src/main/java/com/minelittlepony/renderer/layer/LayerPonyCustomHead.java index 1dc03b9e..73cf1829 100644 --- a/src/main/java/com/minelittlepony/renderer/layer/LayerPonySkull.java +++ b/src/main/java/com/minelittlepony/renderer/layer/LayerPonyCustomHead.java @@ -17,7 +17,7 @@ import net.minecraft.entity.passive.EntityVillager; import net.minecraft.init.Items; import net.minecraft.inventory.EntityEquipmentSlot; import net.minecraft.item.Item; -import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemArmor; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTUtil; @@ -26,11 +26,11 @@ import net.minecraft.util.EnumFacing; import static net.minecraft.client.renderer.GlStateManager.*; -public class LayerPonySkull implements LayerRenderer { +public class LayerPonyCustomHead implements LayerRenderer { private RenderLivingBase renderer; - public LayerPonySkull(RenderLivingBase renderPony) { + public LayerPonyCustomHead(RenderLivingBase renderPony) { this.renderer = renderPony; } @@ -38,7 +38,7 @@ public class LayerPonySkull implements LayerRenderer { public void doRenderLayer(EntityLivingBase entity, float limbSwing, float p_177141_3_, float partialTicks, float p_177141_5_, float p_177141_6_, float p_177141_7_, float scale) { ItemStack itemstack = entity.getItemStackFromSlot(EntityEquipmentSlot.HEAD); - if (itemstack != null && itemstack.getItem() != null) { + if (!itemstack.isEmpty()) { AbstractPonyModel model = getModel().getModel(); Item item = itemstack.getItem(); @@ -49,15 +49,14 @@ public class LayerPonySkull implements LayerRenderer { model.bipedHead.postRender(0.0625f); if (model instanceof ModelPlayerPony) { translate(0, .2, 0); + } else { + translate(0, 0, .15); } color(1, 1, 1, 1); - if (item instanceof ItemBlock) { - renderBlock(entity, itemstack); - } else if (item == Items.SKULL) { - if (model instanceof ModelPlayerPony) { - translate(0, 0, -.15); - } + if (item == Items.SKULL) { renderSkull(itemstack, isVillager, limbSwing); + } else if (!(item instanceof ItemArmor) || ((ItemArmor)item).getEquipmentSlot() != EntityEquipmentSlot.HEAD) { + renderBlock(entity, itemstack); } popMatrix(); } @@ -65,7 +64,6 @@ public class LayerPonySkull implements LayerRenderer { } private void renderBlock(EntityLivingBase entity, ItemStack itemstack) { - // translate(0, -0.25, 0); rotate(180, 0, 1, 0); scale(0.625, -0.625, -0.625); translate(0, 0.4, -0.21); @@ -74,6 +72,7 @@ public class LayerPonySkull implements LayerRenderer { } private void renderSkull(ItemStack itemstack, boolean isVillager, float limbSwing) { + translate(0, 0, -.14); float f = 1.1875f; scale(f, -f, -f); if (isVillager) { diff --git a/src/main/java/com/minelittlepony/util/PonyFields.java b/src/main/java/com/minelittlepony/util/PonyFields.java index 602aaafd..30bf4e93 100644 --- a/src/main/java/com/minelittlepony/util/PonyFields.java +++ b/src/main/java/com/minelittlepony/util/PonyFields.java @@ -24,7 +24,6 @@ public class PonyFields extends PrivateFields { protected PonyObf(String seargeName, String obfName, String mcpName) { super(seargeName, obfName, mcpName); - // TODO Auto-generated constructor stub } }