diff --git a/src/main/java/com/minelittlepony/model/armour/ArmourVariant.java b/src/main/java/com/minelittlepony/model/armour/ArmourVariant.java new file mode 100644 index 00000000..017cefc5 --- /dev/null +++ b/src/main/java/com/minelittlepony/model/armour/ArmourVariant.java @@ -0,0 +1,6 @@ +package com.minelittlepony.model.armour; + +public enum ArmourVariant { + NORMAL, + LEGACY +} diff --git a/src/main/java/com/minelittlepony/model/armour/DefaultPonyArmorTextureResolver.java b/src/main/java/com/minelittlepony/model/armour/DefaultPonyArmorTextureResolver.java index 13e4b102..c5224aac 100644 --- a/src/main/java/com/minelittlepony/model/armour/DefaultPonyArmorTextureResolver.java +++ b/src/main/java/com/minelittlepony/model/armour/DefaultPonyArmorTextureResolver.java @@ -107,6 +107,14 @@ public class DefaultPonyArmorTextureResolver impleme return modId; }); } + + @Override + public ArmourVariant getArmourVariant(ArmorLayer layer, ResourceLocation resolvedTexture) { + if (resolvedTexture.getPath().endsWith("_pony.png")) { + return ArmourVariant.NORMAL; + } + return ArmourVariant.LEGACY; + } } diff --git a/src/main/java/com/minelittlepony/model/armour/IArmorTextureResolver.java b/src/main/java/com/minelittlepony/model/armour/IArmorTextureResolver.java index 0e84ca88..7550d77a 100644 --- a/src/main/java/com/minelittlepony/model/armour/IArmorTextureResolver.java +++ b/src/main/java/com/minelittlepony/model/armour/IArmorTextureResolver.java @@ -15,4 +15,12 @@ public interface IArmorTextureResolver { * Gets the armour texture to be used for the given entity, armour piece, slot, and render layer. */ ResourceLocation getArmorTexture(T entity, ItemStack itemstack, EntityEquipmentSlot slot, ArmorLayer layer, @Nullable String type); + + /** + * Gets the armour variant for the identified texture. + * Either normal for pony-style textures, or legacy for other textures. + */ + default ArmourVariant getArmourVariant(ArmorLayer layer, ResourceLocation resolvedTexture) { + return ArmourVariant.NORMAL; + } } diff --git a/src/main/java/com/minelittlepony/model/armour/ModelPonyArmor.java b/src/main/java/com/minelittlepony/model/armour/ModelPonyArmor.java index d527bd9d..391da5f5 100644 --- a/src/main/java/com/minelittlepony/model/armour/ModelPonyArmor.java +++ b/src/main/java/com/minelittlepony/model/armour/ModelPonyArmor.java @@ -1,17 +1,24 @@ package com.minelittlepony.model.armour; import net.minecraft.client.model.ModelBiped; +import net.minecraft.client.model.ModelRenderer; import net.minecraft.entity.Entity; import com.minelittlepony.model.AbstractPonyModel; import com.minelittlepony.model.capabilities.IModel; import com.minelittlepony.model.capabilities.IModelArmor; +import com.minelittlepony.render.model.PlaneRenderer; import com.minelittlepony.render.model.PonyRenderer; public class ModelPonyArmor extends AbstractPonyModel implements IModelArmor { public PonyRenderer chestPiece; + public ModelRenderer steveRightLeg; + public ModelRenderer steveLeftLeg; + + private ArmourVariant variant = ArmourVariant.NORMAL; + public ModelPonyArmor() { super(false); textureHeight = 32; @@ -28,7 +35,17 @@ public class ModelPonyArmor extends AbstractPonyModel implements IModelArmor { @Override protected void renderBody(Entity entity, float move, float swing, float ticks, float headYaw, float headPitch, float scale) { - chestPiece.render(scale); + if (variant == ArmourVariant.LEGACY) { + bipedBody.render(scale); + upperTorso.render(scale); + } else { + chestPiece.render(scale); + } + } + + @Override + public void setVariant(ArmourVariant variant) { + this.variant = variant; } @Override @@ -38,6 +55,8 @@ public class ModelPonyArmor extends AbstractPonyModel implements IModelArmor { copyModelAngles(mainModel.bipedLeftArm, bipedLeftArm); copyModelAngles(mainModel.bipedRightLeg, bipedRightLeg); copyModelAngles(mainModel.bipedLeftLeg, bipedLeftLeg); + copyModelAngles(mainModel.bipedLeftLeg, steveLeftLeg); + copyModelAngles(mainModel.bipedRightLeg, steveRightLeg); } @Override @@ -54,6 +73,16 @@ public class ModelPonyArmor extends AbstractPonyModel implements IModelArmor { chestPiece = new PonyRenderer(this, 16, 8) .around(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z) .box(-4, 4, -2, 8, 8, 16, stretch); + + // fits the legacy player's torso to our pony bod. + upperTorso = new PlaneRenderer(this, 24, 0); + upperTorso.offset(BODY_CENTRE_X, BODY_CENTRE_Y, BODY_CENTRE_Z) + .around(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z) + .tex(32, 23).east( 4, -4, -4, 8, 8, stretch) + .west(-4, -4, -4, 8, 8, stretch) + .tex(32, 23).south(-4, -4, 4, 8, 8, stretch) + .tex(32, 23).top(-4, -4, -8, 8, 12, stretch); + // it's a little short, so the butt tends to show. :/ } @Override @@ -63,8 +92,33 @@ public class ModelPonyArmor extends AbstractPonyModel implements IModelArmor { bipedLeftLeg = new PonyRenderer(this, 48, 8).flip(); bipedRightLeg = new PonyRenderer(this, 48, 8); + + steveLeftLeg = new PonyRenderer(this, 0, 16).flip(); + steveRightLeg = new PonyRenderer(this, 0, 16); } + @Override + protected void initLegs(float yOffset, float stretch) { + super.initLegs(yOffset, stretch); + + int armLength = getArmLength(); + int armWidth = getArmWidth(); + int armDepth = getArmDepth(); + + float rarmX = getLegRotationX(); + + float armX = THIRDP_ARM_CENTRE_X; + float armY = THIRDP_ARM_CENTRE_Y; + float armZ = BODY_CENTRE_Z / 2 - 1 - armDepth; + + steveLeftLeg .setRotationPoint( rarmX, yOffset, 0); + steveRightLeg.setRotationPoint(-rarmX, yOffset, 0); + + steveLeftLeg .addBox(armX, armY, armZ, armWidth, armLength, armDepth, stretch); + steveRightLeg.addBox(armX - armWidth, armY, armZ, armWidth, armLength, armDepth, stretch); + } + + @Override public void setInVisible() { setVisible(false); @@ -75,14 +129,18 @@ public class ModelPonyArmor extends AbstractPonyModel implements IModelArmor { tail.setVisible(false); upperTorso.isHidden = true; snout.isHidden = true; + steveLeftLeg.showModel = false; + steveRightLeg.showModel = false; } @Override public void showBoots() { bipedRightArm.showModel = true; bipedLeftArm.showModel = true; - bipedRightLeg.showModel = true; - bipedLeftLeg.showModel = true; + bipedRightLeg.showModel = variant == ArmourVariant.NORMAL; + bipedLeftLeg.showModel = variant == ArmourVariant.NORMAL; + steveLeftLeg.showModel = variant == ArmourVariant.LEGACY; + steveRightLeg.showModel = variant == ArmourVariant.LEGACY; } @Override @@ -100,6 +158,11 @@ public class ModelPonyArmor extends AbstractPonyModel implements IModelArmor { public void showSaddle() { chestPiece.showModel = true; neck.showModel = true; + + if (variant == ArmourVariant.LEGACY) { + upperTorso.isHidden = false; + upperTorso.showModel = true; + } } @Override diff --git a/src/main/java/com/minelittlepony/model/capabilities/IModelArmor.java b/src/main/java/com/minelittlepony/model/capabilities/IModelArmor.java index 1a24fd94..b6a2f9fd 100644 --- a/src/main/java/com/minelittlepony/model/capabilities/IModelArmor.java +++ b/src/main/java/com/minelittlepony/model/capabilities/IModelArmor.java @@ -3,6 +3,7 @@ package com.minelittlepony.model.capabilities; import net.minecraft.client.model.ModelBiped; import net.minecraft.inventory.EntityEquipmentSlot; +import com.minelittlepony.model.armour.ArmourVariant; import com.minelittlepony.model.armour.IEquestrianArmor.ArmorLayer; public interface IModelArmor { @@ -18,6 +19,8 @@ public interface IModelArmor { */ void setInVisible(); + void setVariant(ArmourVariant variant); + /** * Prepares an armour model for rendering, first hiding all the pieces and then incrementally showing them as appropriate. * diff --git a/src/main/java/com/minelittlepony/render/layer/LayerPonyArmor.java b/src/main/java/com/minelittlepony/render/layer/LayerPonyArmor.java index 4157f177..a1c01045 100644 --- a/src/main/java/com/minelittlepony/render/layer/LayerPonyArmor.java +++ b/src/main/java/com/minelittlepony/render/layer/LayerPonyArmor.java @@ -62,6 +62,7 @@ public class LayerPonyArmor extends AbstractPonyLaye IArmorTextureResolver resolver = armour instanceof IArmorTextureResolver ? (IArmorTextureResolver)armour : (IArmorTextureResolver)textures; ResourceLocation armourTexture = resolver.getArmorTexture(entity, itemstack, armorSlot, layer, null); + armour.setVariant(resolver.getArmourVariant(layer, armourTexture)); getRenderer().bindTexture(armourTexture); @@ -71,6 +72,8 @@ public class LayerPonyArmor extends AbstractPonyLaye Color.glColor(itemarmor.getColor(itemstack), 1); armour.render(entity, move, swing, ticks, headYaw, headPitch, scale); armourTexture = resolver.getArmorTexture(entity, itemstack, armorSlot, layer, "overlay"); + armour.setVariant(resolver.getArmourVariant(layer, armourTexture)); + getRenderer().bindTexture(armourTexture); }