diff --git a/src/main/java/com/minelittlepony/model/AbstractPonyModel.java b/src/main/java/com/minelittlepony/model/AbstractPonyModel.java index 9e54a84f..0349df9e 100644 --- a/src/main/java/com/minelittlepony/model/AbstractPonyModel.java +++ b/src/main/java/com/minelittlepony/model/AbstractPonyModel.java @@ -34,6 +34,7 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IModel { public boolean isFlying; public boolean isSleeping; public boolean isSwimming; + public boolean headGear; /** * Associcated pony data. @@ -656,6 +657,11 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IModel { return rainboom; } + @Override + public boolean hasHeadGear() { + return headGear; + } + @Override public boolean isFlying() { return isFlying && canFly(); diff --git a/src/main/java/com/minelittlepony/model/capabilities/ICapitated.java b/src/main/java/com/minelittlepony/model/capabilities/ICapitated.java index 113101c0..d4906860 100644 --- a/src/main/java/com/minelittlepony/model/capabilities/ICapitated.java +++ b/src/main/java/com/minelittlepony/model/capabilities/ICapitated.java @@ -1,7 +1,18 @@ package com.minelittlepony.model.capabilities; +import javax.annotation.Nullable; + import net.minecraft.client.model.ModelRenderer; public interface ICapitated { + /** + * Gets the head of this capitated object. + */ ModelRenderer getHead(); + + /** + * Returns true if we're wearing any uconventional headgear (ie. a Pumpkin) + */ + boolean hasHeadGear(); + } diff --git a/src/main/java/com/minelittlepony/model/capabilities/IModel.java b/src/main/java/com/minelittlepony/model/capabilities/IModel.java index fd54eebe..0ea73044 100644 --- a/src/main/java/com/minelittlepony/model/capabilities/IModel.java +++ b/src/main/java/com/minelittlepony/model/capabilities/IModel.java @@ -19,7 +19,6 @@ public interface IModel extends ICapitated { */ void transform(BodyPart part); - /** * Returns a new pony armour to go with this model. Called on startup by a model wrapper. */ diff --git a/src/main/java/com/minelittlepony/model/components/ModelPonyHead.java b/src/main/java/com/minelittlepony/model/components/ModelPonyHead.java index 480b1505..4b4bbb51 100644 --- a/src/main/java/com/minelittlepony/model/components/ModelPonyHead.java +++ b/src/main/java/com/minelittlepony/model/components/ModelPonyHead.java @@ -39,6 +39,11 @@ public class ModelPonyHead extends ModelHumanoidHead implements ICapitated { return skeletonHead; } + @Override + public boolean hasHeadGear() { + return false; + } + @Override public void render(Entity entity, float move, float swing, float ticks, float headYaw, float headPitch, float scale) { snout.isHidden = metadata.getRace().isHuman(); @@ -53,4 +58,5 @@ public class ModelPonyHead extends ModelHumanoidHead implements ICapitated { horn.render(scale); } } + } diff --git a/src/main/java/com/minelittlepony/model/components/PonySnout.java b/src/main/java/com/minelittlepony/model/components/PonySnout.java index 9bdb1da3..6b25367c 100644 --- a/src/main/java/com/minelittlepony/model/components/PonySnout.java +++ b/src/main/java/com/minelittlepony/model/components/PonySnout.java @@ -17,11 +17,15 @@ public class PonySnout { private PlaneRenderer mare; private PlaneRenderer stallion; + private final ICapitated head; + public PonySnout(T pony) { this(pony, 0, 0, 0); } public PonySnout(T pony, int x, int y, int z) { + head = pony; + mare = new PlaneRenderer(pony).offset(HEAD_CENTRE_X + x, HEAD_CENTRE_Y + y, HEAD_CENTRE_Z + z); stallion = new PlaneRenderer(pony).offset(HEAD_CENTRE_X + x, HEAD_CENTRE_Y + y, HEAD_CENTRE_Z + z); @@ -55,7 +59,7 @@ public class PonySnout { } public void setGender(PonyGender gender) { - boolean show = !isHidden && MineLittlePony.getConfig().snuzzles; + boolean show = !head.hasHeadGear() && !isHidden && MineLittlePony.getConfig().snuzzles; mare.isHidden = !show || gender == PonyGender.STALLION; stallion.isHidden = !show || gender == PonyGender.MARE; diff --git a/src/main/java/com/minelittlepony/pony/data/Pony.java b/src/main/java/com/minelittlepony/pony/data/Pony.java index d3b1b7b5..ed89c4df 100644 --- a/src/main/java/com/minelittlepony/pony/data/Pony.java +++ b/src/main/java/com/minelittlepony/pony/data/Pony.java @@ -13,6 +13,10 @@ import net.minecraft.client.renderer.texture.ITextureObject; import net.minecraft.client.renderer.texture.TextureUtil; import net.minecraft.client.resources.IResource; import net.minecraft.entity.EntityLivingBase; +import net.minecraft.inventory.EntityEquipmentSlot; +import net.minecraft.item.Item; +import net.minecraft.item.ItemArmor; +import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.BlockPos; @@ -112,6 +116,18 @@ public class Pony { return entity.isInWater() && entity.getEntityWorld().getBlockState(new BlockPos(entity.getPositionEyes(1))).getMaterial() == Material.WATER; } + public boolean isWearingHeadgear(EntityLivingBase entity) { + ItemStack stack = entity.getItemStackFromSlot(EntityEquipmentSlot.HEAD); + + if (stack.isEmpty()) { + return false; + } + + Item item = stack.getItem(); + + return !(item instanceof ItemArmor) || ((ItemArmor)item).getEquipmentSlot() != EntityEquipmentSlot.HEAD; + } + public ModelWrapper getModel(boolean ignorePony) { return getRace(ignorePony).getModel().getModel(smallArms); } diff --git a/src/main/java/com/minelittlepony/render/RenderPonyMob.java b/src/main/java/com/minelittlepony/render/RenderPonyMob.java index 304ca623..ae4020f6 100644 --- a/src/main/java/com/minelittlepony/render/RenderPonyMob.java +++ b/src/main/java/com/minelittlepony/render/RenderPonyMob.java @@ -65,6 +65,7 @@ public abstract class RenderPonyMob extends RenderLiving ponyModel.isSleeping = entity.isPlayerSleeping(); ponyModel.isFlying = pony.isPegasusFlying(entity); ponyModel.isSwimming = pony.isSwimming(entity); + ponyModel.headGear = pony.isWearingHeadgear(entity); super.preRenderCallback(entity, ticks); shadowSize = getShadowScale(); diff --git a/src/main/java/com/minelittlepony/render/player/RenderPonyBase.java b/src/main/java/com/minelittlepony/render/player/RenderPonyBase.java index c0a0485e..25964729 100644 --- a/src/main/java/com/minelittlepony/render/player/RenderPonyBase.java +++ b/src/main/java/com/minelittlepony/render/player/RenderPonyBase.java @@ -74,6 +74,7 @@ public abstract class RenderPonyBase extends RenderPlayer implements IRenderPony ponyModel.isSleeping = player.isPlayerSleeping(); ponyModel.isFlying = pony.isPegasusFlying(player); ponyModel.isSwimming = pony.isSwimming(player); + ponyModel.headGear = pony.isWearingHeadgear(player); super.preRenderCallback(player, ticks); shadowSize = getShadowScale();