diff --git a/src/client/java/com/minelittlepony/client/model/AbstractPonyModel.java b/src/client/java/com/minelittlepony/client/model/AbstractPonyModel.java index fbc52714..5f294cfa 100644 --- a/src/client/java/com/minelittlepony/client/model/AbstractPonyModel.java +++ b/src/client/java/com/minelittlepony/client/model/AbstractPonyModel.java @@ -18,8 +18,6 @@ import com.minelittlepony.pony.IPonyData; import com.minelittlepony.pony.meta.Size; import com.minelittlepony.util.math.MathUtil; -import javax.annotation.Nullable; - import net.minecraft.client.renderer.entity.model.ModelBase; import net.minecraft.client.renderer.entity.model.ModelPlayer; import net.minecraft.client.renderer.entity.model.ModelRenderer; @@ -50,7 +48,7 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IClientMo /** * Associated pony data. */ - public IPonyData metadata = new PonyData(); + private IPonyData metadata = new PonyData(); /** * Vertical pitch whilst flying. @@ -274,12 +272,6 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IClientMo return bipedHead; } - @Nullable - @Override - public ModelRenderer getBody() { - return bipedBody; - } - @Override public void setPitch(float pitch) { motionPitch = pitch; @@ -469,6 +461,18 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IClientMo alignArmForAction(bipedRightArm, rightArmPose, leftArmPose, both, swing, -1); } + @Override + public ModelRenderer getBodyPart(BodyPart part) { + switch (part) { + default: + case HEAD: return bipedHead; + case NECK: return neck; + case TAIL: + case LEGS: + case BODY: return bipedBody; + } + } + /** * Aligns an arm for the appropriate arm pose * @@ -764,6 +768,11 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IClientMo return metadata; } + @Override + public void apply(IPonyData meta) { + metadata = meta; + } + @Override public boolean isCrouching() { return isCrouching; diff --git a/src/client/java/com/minelittlepony/client/model/IClientModel.java b/src/client/java/com/minelittlepony/client/model/IClientModel.java index 1ac95209..48b625b1 100644 --- a/src/client/java/com/minelittlepony/client/model/IClientModel.java +++ b/src/client/java/com/minelittlepony/client/model/IClientModel.java @@ -2,9 +2,11 @@ package com.minelittlepony.client.model; import net.minecraft.client.renderer.entity.model.ModelRenderer; +import com.minelittlepony.model.BodyPart; import com.minelittlepony.model.ICapitated; import com.minelittlepony.model.IModel; public interface IClientModel extends IModel, ICapitated { + ModelRenderer getBodyPart(BodyPart part); } diff --git a/src/client/java/com/minelittlepony/client/model/ModelWrapper.java b/src/client/java/com/minelittlepony/client/model/ModelWrapper.java index 8a9ab0aa..3f57c4ba 100644 --- a/src/client/java/com/minelittlepony/client/model/ModelWrapper.java +++ b/src/client/java/com/minelittlepony/client/model/ModelWrapper.java @@ -51,7 +51,7 @@ public class ModelWrapper implements IModelWrapper { init(); } - body.metadata = meta; + body.apply(meta); armor.apply(meta); } diff --git a/src/client/java/com/minelittlepony/client/model/armour/PonyArmor.java b/src/client/java/com/minelittlepony/client/model/armour/PonyArmor.java index e0669358..4ea2926c 100644 --- a/src/client/java/com/minelittlepony/client/model/armour/PonyArmor.java +++ b/src/client/java/com/minelittlepony/client/model/armour/PonyArmor.java @@ -16,8 +16,8 @@ public class PonyArmor implements IEquestrianArmour { @Override public void apply(IPonyData meta) { - outerLayer.metadata = meta; - innerLayer.metadata = meta; + outerLayer.apply(meta); + innerLayer.apply(meta); } @Override diff --git a/src/client/java/com/minelittlepony/client/model/components/ModelPonyHead.java b/src/client/java/com/minelittlepony/client/model/components/ModelPonyHead.java index 1c4b17eb..4791b093 100644 --- a/src/client/java/com/minelittlepony/client/model/components/ModelPonyHead.java +++ b/src/client/java/com/minelittlepony/client/model/components/ModelPonyHead.java @@ -5,8 +5,6 @@ import com.minelittlepony.client.util.render.PonyRenderer; import com.minelittlepony.model.ICapitated; import com.minelittlepony.pony.IPonyData; -import javax.annotation.Nullable; - import net.minecraft.client.renderer.entity.model.ModelHumanoidHead; import net.minecraft.client.renderer.entity.model.ModelRenderer; import net.minecraft.entity.Entity; @@ -41,12 +39,6 @@ public class ModelPonyHead extends ModelHumanoidHead implements ICapitated extends AbstractPonyLayer if (gear.canRender(model, entity)) { GlStateManager.pushMatrix(); model.transform(gear.getGearLocation()); - gear.getOriginBodyPart(model).postRender(scale); + model.getBodyPart(gear.getGearLocation()).postRender(scale); if (gear instanceof IStackable) { BodyPart part = gear.getGearLocation(); diff --git a/src/client/java/com/minelittlepony/client/render/layer/LayerPonyCape.java b/src/client/java/com/minelittlepony/client/render/layer/LayerPonyCape.java index c0948705..1e4ebd3e 100644 --- a/src/client/java/com/minelittlepony/client/render/layer/LayerPonyCape.java +++ b/src/client/java/com/minelittlepony/client/render/layer/LayerPonyCape.java @@ -33,7 +33,7 @@ public class LayerPonyCape extends AbstractPonyLayer { model.transform(BodyPart.BODY); translatef(0, 0.24F, 0); - model.getBody().postRender(scale); + model.getBodyPart(BodyPart.BODY).postRender(scale); double capeX = player.prevChasingPosX + (player.chasingPosX - player.prevChasingPosX) * scale - (player.prevPosX + (player.posX - player.prevPosX) * scale); double capeY = player.prevChasingPosY + (player.chasingPosY - player.prevChasingPosY) * scale - (player.prevPosY + (player.posY - player.prevPosY) * scale); diff --git a/src/main/java/com/minelittlepony/model/ICapitated.java b/src/main/java/com/minelittlepony/model/ICapitated.java index 3b607e6c..39270e67 100644 --- a/src/main/java/com/minelittlepony/model/ICapitated.java +++ b/src/main/java/com/minelittlepony/model/ICapitated.java @@ -1,19 +1,11 @@ package com.minelittlepony.model; -import javax.annotation.Nullable; - public interface ICapitated { /** * Gets the head of this capitated object. */ ModelRenderer getHead(); - /** - * Gets the main body - */ - @Nullable - ModelRenderer getBody(); - /** * Returns true if we're wearing any unconventional headgear (ie. a Pumpkin) */ diff --git a/src/main/java/com/minelittlepony/model/IModel.java b/src/main/java/com/minelittlepony/model/IModel.java index 319ed481..3cef5621 100644 --- a/src/main/java/com/minelittlepony/model/IModel.java +++ b/src/main/java/com/minelittlepony/model/IModel.java @@ -39,6 +39,11 @@ public interface IModel { */ IPonyData getMetadata(); + /** + * Sets the pony metadata object associated with this model. + */ + void apply(IPonyData meta); + /** * Returns true if this model is on the ground and crouching. */ diff --git a/src/main/java/com/minelittlepony/model/IUnicorn.java b/src/main/java/com/minelittlepony/model/IUnicorn.java index bbeefb3a..f0db94a8 100644 --- a/src/main/java/com/minelittlepony/model/IUnicorn.java +++ b/src/main/java/com/minelittlepony/model/IUnicorn.java @@ -11,7 +11,9 @@ public interface IUnicorn extends IModel { /** * Returns true if this model is being applied to a race that can use magic. */ - boolean canCast(); + default boolean canCast() { + return getMetadata().hasMagic(); + } /** * Returns true if this model is currently using magic (horn is lit). @@ -22,5 +24,7 @@ public interface IUnicorn extends IModel { /** * Gets the preferred magic color for this mode. */ - int getMagicColor(); + default int getMagicColor() { + return getMetadata().getGlowColor(); + } }