From 12ec6c1302fd1a2a27e4e942be125ce86686deae Mon Sep 17 00:00:00 2001 From: Sollace Date: Sat, 28 Apr 2018 16:39:32 +0200 Subject: [PATCH] Break ModelPlayerPony into each different race --- .../java/com/minelittlepony/ForgeProxy.java | 13 -- .../com/minelittlepony/PonyRenderManager.java | 13 +- .../hdskins/gui/RenderPonyModel.java | 6 +- .../model/AbstractPonyModel.java | 21 +-- .../minelittlepony/model/ModelMobPony.java | 18 +- .../java/com/minelittlepony/model/PMAPI.java | 30 +-- .../model/armour/ModelPonyArmor.java | 10 +- .../model/armour/ModelSkeletonPonyArmor.java | 6 +- .../model/armour/ModelZombiePonyArmor.java | 18 +- .../model/armour/PonyArmor.java | 18 +- .../model/capabilities/IModelPegasus.java | 5 + .../model/capabilities/IModelUnicorn.java | 11 ++ .../model/player/ModelAlicorn.java | 152 +++++++++++++++ .../ModelEarthPony.java} | 177 ++++++------------ .../model/player/ModelPegasus.java | 63 +++++++ .../model/player/PlayerModels.java | 13 +- .../model/ponies/ModelHumanPlayer.java | 36 ---- .../model/ponies/ModelIllagerPony.java | 6 +- .../model/ponies/ModelSkeletonPony.java | 5 +- .../model/ponies/ModelVillagerPony.java | 3 +- .../model/ponies/ModelZombiePony.java | 13 +- .../minelittlepony/pony/data/PonyRace.java | 18 +- .../render/layer/AbstractPonyLayer.java | 15 +- .../layer/LayerEntityOnPonyShoulder.java | 12 +- .../render/layer/LayerHeldPonyItem.java | 3 +- .../layer/LayerHeldPonyItemMagical.java | 8 +- .../render/layer/LayerPonyArmor.java | 11 +- .../render/layer/LayerPonyCape.java | 4 +- .../render/layer/LayerPonyCustomHead.java | 3 +- .../render/layer/LayerPonyElytra.java | 3 +- .../render/player/RenderPonyBase.java | 7 +- .../render/player/RenderPonyPlayer.java | 2 + .../render/ponies/RenderPonySkeleton.java | 2 +- 33 files changed, 411 insertions(+), 314 deletions(-) create mode 100644 src/main/java/com/minelittlepony/model/capabilities/IModelPegasus.java create mode 100644 src/main/java/com/minelittlepony/model/capabilities/IModelUnicorn.java create mode 100644 src/main/java/com/minelittlepony/model/player/ModelAlicorn.java rename src/main/java/com/minelittlepony/model/{ponies/ModelPlayerPony.java => player/ModelEarthPony.java} (78%) create mode 100644 src/main/java/com/minelittlepony/model/player/ModelPegasus.java delete mode 100644 src/main/java/com/minelittlepony/model/ponies/ModelHumanPlayer.java diff --git a/src/main/java/com/minelittlepony/ForgeProxy.java b/src/main/java/com/minelittlepony/ForgeProxy.java index f4f314ae..90ad340c 100644 --- a/src/main/java/com/minelittlepony/ForgeProxy.java +++ b/src/main/java/com/minelittlepony/ForgeProxy.java @@ -2,18 +2,13 @@ package com.minelittlepony; import com.mumfrey.liteloader.util.ModUtilities; import net.minecraft.client.model.ModelBiped; -import net.minecraft.client.renderer.entity.RenderManager; -import net.minecraft.client.renderer.entity.layers.LayerRenderer; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; -import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.EntityEquipmentSlot; import net.minecraft.item.ItemStack; import net.minecraftforge.client.ForgeHooksClient; import javax.annotation.Nullable; -import java.util.Optional; -import java.util.function.Function; /** * Proxy class for accessing forge fields and methods. @@ -54,12 +49,4 @@ public class ForgeProxy { return ForgeHooksClient.getArmorModel(entity, item, slot, def); return def; } - - public static Optional>> createShoulderLayer() { - if (forgeLoaded) { - // TODO - } - return Optional.empty(); - } - } diff --git a/src/main/java/com/minelittlepony/PonyRenderManager.java b/src/main/java/com/minelittlepony/PonyRenderManager.java index 178237cb..24950148 100644 --- a/src/main/java/com/minelittlepony/PonyRenderManager.java +++ b/src/main/java/com/minelittlepony/PonyRenderManager.java @@ -5,7 +5,7 @@ import java.util.Map; import com.google.common.collect.Maps; import com.minelittlepony.hdskins.gui.EntityPonyModel; import com.minelittlepony.hdskins.gui.RenderPonyModel; -import com.minelittlepony.model.PMAPI; +import com.minelittlepony.model.player.PlayerModels; import com.minelittlepony.render.player.RenderPonyPlayer; import com.minelittlepony.render.ponies.RenderPonyIllager; import com.minelittlepony.render.ponies.RenderPonyPigman; @@ -52,9 +52,14 @@ public class PonyRenderManager { // Preview on the select skin gui ModUtilities.addRenderer(EntityPonyModel.class, new RenderPonyModel(rm)); - new RenderPonyPlayer(rm, false, "pony", PMAPI.pony); - new RenderPonyPlayer(rm, true, "slimpony", PMAPI.ponySmall); - //TODO: Add skin types for each species? May require model break up. + registerPlayerSkin(rm, PlayerModels.EARTH); + registerPlayerSkin(rm, PlayerModels.PEGASUS); + registerPlayerSkin(rm, PlayerModels.ALICORN); + } + + protected void registerPlayerSkin(RenderManager rm, PlayerModels playerModel) { + new RenderPonyPlayer(rm, false, playerModel.getId(false), playerModel.getModel(false)); + new RenderPonyPlayer(rm, true, playerModel.getId(true), playerModel.getModel(true)); } /** diff --git a/src/main/java/com/minelittlepony/hdskins/gui/RenderPonyModel.java b/src/main/java/com/minelittlepony/hdskins/gui/RenderPonyModel.java index 721b0dee..936611aa 100644 --- a/src/main/java/com/minelittlepony/hdskins/gui/RenderPonyModel.java +++ b/src/main/java/com/minelittlepony/hdskins/gui/RenderPonyModel.java @@ -36,6 +36,10 @@ public class RenderPonyModel extends RenderPlayerModel { Pony thePony = MineLittlePony.getInstance().getManager().getPony(loc, playermodel.profile.getId()); + if (thePony.getRace(false).isHuman()) { + return super.getEntityModel(playermodel); + } + ModelWrapper pm = thePony.getModel(true); pm.apply(thePony.getMetadata()); @@ -44,7 +48,7 @@ public class RenderPonyModel extends RenderPlayerModel { @Override protected LayerRenderer getElytraLayer() { - return new AbstractPonyLayer(this, super.getElytraLayer()) { + return new AbstractPonyLayer(this) { final PonyElytra modelElytra = new PonyElytra(); @Override diff --git a/src/main/java/com/minelittlepony/model/AbstractPonyModel.java b/src/main/java/com/minelittlepony/model/AbstractPonyModel.java index fddb2c83..c9cea49a 100644 --- a/src/main/java/com/minelittlepony/model/AbstractPonyModel.java +++ b/src/main/java/com/minelittlepony/model/AbstractPonyModel.java @@ -74,24 +74,10 @@ public abstract class AbstractPonyModel extends ModelPlayer { */ protected abstract void initPositions(float yOffset, float stretch); - @Override - public void setRotationAngles(float move, float swing, float age, float headYaw, float headPitch, float scale, Entity entity) { - if (doCancelRender()) { - super.setRotationAngles(move, swing, age, headYaw, headPitch, scale, entity); - } - } - public ArmPose getArmPoseForSide(EnumHandSide side) { return side == EnumHandSide.RIGHT ? rightArmPose : leftArmPose; } - /** - * Returns true if the default minecraft handling should be used. - */ - protected boolean doCancelRender() { - return false; - } - /** * Returns true if this model is on the ground and crouching. */ @@ -99,6 +85,13 @@ public abstract class AbstractPonyModel extends ModelPlayer { return isSneak && !isFlying; } + /** + * Checks flying and speed conditions and sets rainboom to true if we're a species with wings and is going faaast. + */ + protected void checkRainboom(Entity entity, float swing) { + rainboom = isFlying(entity) && swing >= 0.9999F; + } + /** * Returns true if the given entity can and is flying, or has an elytra. */ diff --git a/src/main/java/com/minelittlepony/model/ModelMobPony.java b/src/main/java/com/minelittlepony/model/ModelMobPony.java index fbddc04a..dc807eef 100644 --- a/src/main/java/com/minelittlepony/model/ModelMobPony.java +++ b/src/main/java/com/minelittlepony/model/ModelMobPony.java @@ -1,27 +1,33 @@ package com.minelittlepony.model; -import com.minelittlepony.model.ponies.ModelPlayerPony; +import com.minelittlepony.model.player.ModelAlicorn; -import net.minecraft.entity.Entity; +import net.minecraft.util.math.MathHelper; /** * Common class for all humanoid (ponioid?) non-player enemies. * */ -public class ModelMobPony extends ModelPlayerPony { +public class ModelMobPony extends ModelAlicorn { public ModelMobPony() { super(false); } @Override - protected void rotateLegs(float move, float swing, float tick, Entity entity) { - super.rotateLegs(move, swing, tick, entity); - + protected void adjustLegs(float move, float swing, float tick) { + super.adjustLegs(move, swing, tick); rotateRightArm(move, tick); rotateLeftArm(move, tick); } + /** + * Returns true if the angle is to the right? + */ + public boolean islookAngleRight(float move) { + return MathHelper.sin(move / 20f) < 0; + } + /** * Called to update the left arm's final rotation. * Subclasses may replace it with their own implementations. diff --git a/src/main/java/com/minelittlepony/model/PMAPI.java b/src/main/java/com/minelittlepony/model/PMAPI.java index 1523da86..1a2b9c74 100644 --- a/src/main/java/com/minelittlepony/model/PMAPI.java +++ b/src/main/java/com/minelittlepony/model/PMAPI.java @@ -1,10 +1,12 @@ package com.minelittlepony.model; -import com.minelittlepony.model.ponies.ModelHumanPlayer; +import com.minelittlepony.model.player.ModelAlicorn; +import com.minelittlepony.model.player.ModelEarthPony; +import com.minelittlepony.model.player.ModelPegasus; import com.minelittlepony.model.ponies.ModelIllagerPony; -import com.minelittlepony.model.ponies.ModelPlayerPony; import com.minelittlepony.model.ponies.ModelSkeletonPony; import com.minelittlepony.model.ponies.ModelVillagerPony; +import com.minelittlepony.model.ponies.ModelWitchPony; import com.minelittlepony.model.ponies.ModelZombiePony; import java.lang.reflect.Field; @@ -15,17 +17,23 @@ import java.lang.reflect.Field; */ public final class PMAPI { - public static final ModelWrapper - pony = new ModelWrapper(new ModelPlayerPony(false)), - ponySmall = new ModelWrapper(new ModelPlayerPony(true)), + public static final ModelWrapper pony = new ModelWrapper(new ModelAlicorn(false)); + public static final ModelWrapper ponySmall = new ModelWrapper(new ModelAlicorn(true)); - human = new ModelWrapper(new ModelHumanPlayer(false)), - humanSmall = new ModelWrapper(new ModelHumanPlayer(true)), + public static final ModelWrapper earthpony = new ModelWrapper(new ModelEarthPony(false)); + public static final ModelWrapper earthponySmall = new ModelWrapper(new ModelEarthPony(true)); - zombie = new ModelWrapper(new ModelZombiePony()), - skeleton = new ModelWrapper(new ModelSkeletonPony()), - villager = new ModelWrapper(new ModelVillagerPony()), - illager = new ModelWrapper(new ModelIllagerPony()); + public static final ModelWrapper pegasus = new ModelWrapper(new ModelPegasus(false)); + public static final ModelWrapper pegasusSmall = new ModelWrapper(new ModelPegasus(true)); + + public static final ModelWrapper alicorn = new ModelWrapper(new ModelAlicorn(false)); + public static final ModelWrapper alicornSmall = new ModelWrapper(new ModelAlicorn(true)); + + public static final ModelWrapper zombie = new ModelWrapper(new ModelZombiePony()); + public static final ModelWrapper skeleton = new ModelWrapper(new ModelSkeletonPony()); + public static final ModelWrapper villager = new ModelWrapper(new ModelVillagerPony()); + public static final ModelWrapper illager = new ModelWrapper(new ModelIllagerPony()); + public static final ModelWrapper witch = new ModelWrapper(new ModelWitchPony()); public static void init() { for (Field field : PMAPI.class.getFields()) { diff --git a/src/main/java/com/minelittlepony/model/armour/ModelPonyArmor.java b/src/main/java/com/minelittlepony/model/armour/ModelPonyArmor.java index ba5d30fb..2802fc9d 100644 --- a/src/main/java/com/minelittlepony/model/armour/ModelPonyArmor.java +++ b/src/main/java/com/minelittlepony/model/armour/ModelPonyArmor.java @@ -179,14 +179,8 @@ public class ModelPonyArmor extends ModelMobPony { } @Override - protected void rotateLegs(float move, float swing, float tick, Entity entity) { - super.rotateLegs(move, swing, tick, entity); - syncLegs(); - } - - @Override - protected void adjustLegs() { - super.adjustLegs(); + protected void setLegs(float move, float swing, float tick, Entity entity) { + super.setLegs(move, swing, tick, entity); syncLegs(); } diff --git a/src/main/java/com/minelittlepony/model/armour/ModelSkeletonPonyArmor.java b/src/main/java/com/minelittlepony/model/armour/ModelSkeletonPonyArmor.java index 86d32d22..08e3b167 100644 --- a/src/main/java/com/minelittlepony/model/armour/ModelSkeletonPonyArmor.java +++ b/src/main/java/com/minelittlepony/model/armour/ModelSkeletonPonyArmor.java @@ -1,7 +1,5 @@ package com.minelittlepony.model.armour; -import net.minecraft.entity.Entity; - /** * Armour for skeleton ponies. * @@ -9,9 +7,9 @@ import net.minecraft.entity.Entity; public class ModelSkeletonPonyArmor extends ModelPonyArmor { @Override - protected void rotateLegs(float move, float swing, float tick, Entity entity) { - super.rotateLegs(move, swing, tick, entity); + protected void adjustLegs(float move, float swing, float tick) { aimBow(leftArmPose, rightArmPose, tick); + super.adjustLegs(move, swing, tick); } @Override diff --git a/src/main/java/com/minelittlepony/model/armour/ModelZombiePonyArmor.java b/src/main/java/com/minelittlepony/model/armour/ModelZombiePonyArmor.java index dab818d7..3fac3c32 100644 --- a/src/main/java/com/minelittlepony/model/armour/ModelZombiePonyArmor.java +++ b/src/main/java/com/minelittlepony/model/armour/ModelZombiePonyArmor.java @@ -1,20 +1,13 @@ package com.minelittlepony.model.armour; -import net.minecraft.client.model.ModelRenderer; -import net.minecraft.util.math.MathHelper; - public class ModelZombiePonyArmor extends ModelPonyArmor { - private boolean isRight(float move) { - return MathHelper.sin(move / 20f) < 0; - } - // Copied from ModelZombiePony @Override protected void rotateRightArm(float move, float tick) { if (rightArmPose != ArmPose.EMPTY) return; - if (isRight(move)) { + if (islookAngleRight(move)) { rotateArmHolding(bipedRightArm, 1, swingProgress, tick); } else { rotateArmHolding(bipedLeftArm, -1, swingProgress, tick); @@ -29,10 +22,11 @@ public class ModelZombiePonyArmor extends ModelPonyArmor { @Override protected void fixSpecialRotationPoints(float move) { if (rightArmPose != ArmPose.EMPTY) return; - boolean right = isRight(move); - float xchange = right ? 0.5f : -0.5f; - ModelRenderer arm = right ? bipedRightArm : bipedLeftArm; - shiftRotationPoint(arm, xchange, 1.5f, 3); + if (islookAngleRight(move)) { + shiftRotationPoint(bipedRightArm, 0.5F, 1.5F, 3); + } else { + shiftRotationPoint(bipedLeftArm, -0.5F, 1.5F, 3); + } } } diff --git a/src/main/java/com/minelittlepony/model/armour/PonyArmor.java b/src/main/java/com/minelittlepony/model/armour/PonyArmor.java index eccb0ee7..f3f0d9ae 100644 --- a/src/main/java/com/minelittlepony/model/armour/PonyArmor.java +++ b/src/main/java/com/minelittlepony/model/armour/PonyArmor.java @@ -3,23 +3,33 @@ package com.minelittlepony.model.armour; import com.minelittlepony.model.AbstractPonyModel; import com.minelittlepony.pony.data.IPonyData; +import net.minecraft.inventory.EntityEquipmentSlot; + public class PonyArmor { public final AbstractPonyModel chestplate; - public final AbstractPonyModel armour; + public final AbstractPonyModel leggings; public PonyArmor(AbstractPonyModel chest, AbstractPonyModel body) { chestplate = chest; - armour = body; + leggings = body; } public void apply(IPonyData meta) { chestplate.metadata = meta; - armour.metadata = meta; + leggings.metadata = meta; } public void init() { chestplate.init(0, 1); - armour.init(0, 0.5f); + leggings.init(0, 0.5f); + } + + public AbstractPonyModel getArmorForSlot(EntityEquipmentSlot slot) { + if (slot == EntityEquipmentSlot.LEGS) { + return leggings; + } + + return chestplate; } } diff --git a/src/main/java/com/minelittlepony/model/capabilities/IModelPegasus.java b/src/main/java/com/minelittlepony/model/capabilities/IModelPegasus.java new file mode 100644 index 00000000..b84ec9e7 --- /dev/null +++ b/src/main/java/com/minelittlepony/model/capabilities/IModelPegasus.java @@ -0,0 +1,5 @@ +package com.minelittlepony.model.capabilities; + +public interface IModelPegasus { + +} diff --git a/src/main/java/com/minelittlepony/model/capabilities/IModelUnicorn.java b/src/main/java/com/minelittlepony/model/capabilities/IModelUnicorn.java new file mode 100644 index 00000000..a1f16559 --- /dev/null +++ b/src/main/java/com/minelittlepony/model/capabilities/IModelUnicorn.java @@ -0,0 +1,11 @@ +package com.minelittlepony.model.capabilities; + +import com.minelittlepony.render.PonyRenderer; + +import net.minecraft.util.EnumHandSide; + +public interface IModelUnicorn { + PonyRenderer getUnicornArmForSide(EnumHandSide side); + + boolean isCasting(); +} diff --git a/src/main/java/com/minelittlepony/model/player/ModelAlicorn.java b/src/main/java/com/minelittlepony/model/player/ModelAlicorn.java new file mode 100644 index 00000000..3a66c916 --- /dev/null +++ b/src/main/java/com/minelittlepony/model/player/ModelAlicorn.java @@ -0,0 +1,152 @@ +package com.minelittlepony.model.player; + +import com.minelittlepony.model.components.UnicornHorn; +import com.minelittlepony.render.PonyRenderer; +import net.minecraft.entity.Entity; +import net.minecraft.util.EnumHandSide; +import net.minecraft.util.math.MathHelper; + +import static com.minelittlepony.model.PonyModelConstants.*; + +import com.minelittlepony.model.capabilities.IModelUnicorn; + +/** + * Used for both unicorns and alicorns since there's no logical way to keep them distinct and not duplicate stuff. + */ +public class ModelAlicorn extends ModelPegasus implements IModelUnicorn { + + public PonyRenderer unicornArmRight; + public PonyRenderer unicornArmLeft; + + public UnicornHorn horn; + + public ModelAlicorn(boolean smallArms) { + super(smallArms); + } + + @Override + public void init(float yOffset, float stretch) { + super.init(yOffset, stretch); + horn = new UnicornHorn(this, yOffset, stretch); + } + + @Override + protected void rotateLegsOnGround(float move, float swing, float tick, Entity entity) { + super.rotateLegsOnGround(move, swing, tick, entity); + + unicornArmRight.rotateAngleY = 0; + unicornArmLeft.rotateAngleY = 0; + } + + @Override + protected void adjustLegs(float move, float swing, float tick) { + super.adjustLegs(move, swing, tick); + + unicornArmLeft.rotateAngleZ = 0; + unicornArmRight.rotateAngleZ = 0; + + unicornArmLeft.rotateAngleX = 0; + unicornArmRight.rotateAngleX = 0; + } + + @Override + protected void holdItem(float swing) { + if (metadata.hasMagic()) { + boolean both = leftArmPose == ArmPose.ITEM && rightArmPose == ArmPose.ITEM; + + alignArmForAction(unicornArmLeft, leftArmPose, both, swing); + alignArmForAction(unicornArmRight, rightArmPose, both, swing); + } else { + super.holdItem(swing); + } + + horn.setUsingMagic(leftArmPose != ArmPose.EMPTY || rightArmPose != ArmPose.EMPTY); + } + + @Override + protected void swingItem(Entity entity, float swingProgress) { + if (metadata.hasMagic()) { + if (swingProgress > -9990.0F && !isSleeping) { + EnumHandSide mainSide = getMainHand(entity); + + if (getArmPoseForSide(mainSide) == ArmPose.EMPTY) return; + swingArm(getUnicornArmForSide(mainSide)); + } + } else { + super.swingItem(entity, swingProgress); + } + } + + @Override + protected void swingArms(float tick) { + if (isSleeping) return; + + if (!metadata.hasMagic()) { + super.swingArms(tick); + } else { + float cos = MathHelper.cos(tick * 0.09F) * 0.05F + 0.05F; + float sin = MathHelper.sin(tick * 0.067F) * 0.05F; + + if (rightArmPose != ArmPose.EMPTY) { + unicornArmRight.rotateAngleZ += cos; + unicornArmRight.rotateAngleX += sin; + } + + if (leftArmPose != ArmPose.EMPTY) { + unicornArmLeft.rotateAngleZ += cos; + unicornArmLeft.rotateAngleX += sin; + } + } + } + + @Override + public PonyRenderer getUnicornArmForSide(EnumHandSide side) { + return side == EnumHandSide.LEFT ? unicornArmLeft : unicornArmRight; + } + + @Override + public boolean isCasting() { + return metadata.hasMagic(); + } + + @Override + protected void sneakLegs() { + super.sneakLegs(); + unicornArmRight.rotateAngleX += SNEAK_LEG_X_ROTATION_ADJUSTMENT; + unicornArmLeft.rotateAngleX += SNEAK_LEG_X_ROTATION_ADJUSTMENT; + } + + @Override + protected void aimBow(ArmPose leftArm, ArmPose rightArm, float tick) { + if (!metadata.hasMagic()) { + super.aimBow(leftArm, rightArm, tick); + } else if (leftArm == ArmPose.BOW_AND_ARROW || rightArm == ArmPose.BOW_AND_ARROW) { + if (rightArm == ArmPose.BOW_AND_ARROW) aimBowPony(unicornArmRight, tick, true); + if (leftArm == ArmPose.BOW_AND_ARROW) aimBowPony(unicornArmLeft, tick, false); + } + } + + @Override + protected void renderHead(Entity entity, float move, float swing, float age, float headYaw, float headPitch, float scale) { + super.renderHead(entity, move, swing, age, headYaw, headPitch, scale); + horn.render(entity, move, swing, age, headYaw, headPitch, scale); + } + + @Override + protected void initLegTextures() { + super.initLegTextures(); + unicornArmLeft = new PonyRenderer(this, 40, 32).size(64, 64); + unicornArmRight = new PonyRenderer(this, 40, 32).size(64, 64); + boxList.remove(unicornArmRight); + } + + @Override + protected void initLegPositions(float yOffset, float stretch) { + super.initLegPositions(yOffset, stretch); + float armY = THIRDP_ARM_CENTRE_Y - 6; + float armZ = THIRDP_ARM_CENTRE_Z - 2; + + unicornArmLeft .box(FIRSTP_ARM_CENTRE_X - 2, armY, armZ, 4, 12, 4, stretch + .25f).around(5, yOffset + 2, 0); + unicornArmRight.box(FIRSTP_ARM_CENTRE_X - 2, armY, armZ, 4, 12, 4, stretch + .25f).around(-5, yOffset + 2, 0); + } +} diff --git a/src/main/java/com/minelittlepony/model/ponies/ModelPlayerPony.java b/src/main/java/com/minelittlepony/model/player/ModelEarthPony.java similarity index 78% rename from src/main/java/com/minelittlepony/model/ponies/ModelPlayerPony.java rename to src/main/java/com/minelittlepony/model/player/ModelEarthPony.java index 2f8a398f..f2b9ec65 100644 --- a/src/main/java/com/minelittlepony/model/ponies/ModelPlayerPony.java +++ b/src/main/java/com/minelittlepony/model/player/ModelEarthPony.java @@ -1,13 +1,11 @@ -package com.minelittlepony.model.ponies; +package com.minelittlepony.model.player; import com.minelittlepony.model.AbstractPonyModel; import com.minelittlepony.model.BodyPart; import com.minelittlepony.model.armour.ModelPonyArmor; import com.minelittlepony.model.armour.PonyArmor; -import com.minelittlepony.model.components.PegasusWings; import com.minelittlepony.model.components.PonySnout; import com.minelittlepony.model.components.PonyTail; -import com.minelittlepony.model.components.UnicornHorn; import com.minelittlepony.render.PonyRenderer; import com.minelittlepony.render.plane.PlaneRenderer; @@ -21,7 +19,7 @@ import static net.minecraft.client.renderer.GlStateManager.popMatrix; import static net.minecraft.client.renderer.GlStateManager.pushMatrix; import static com.minelittlepony.model.PonyModelConstants.*; -public class ModelPlayerPony extends AbstractPonyModel { +public class ModelEarthPony extends AbstractPonyModel { private final boolean smallArms; @@ -30,15 +28,10 @@ public class ModelPlayerPony extends AbstractPonyModel { public PlaneRenderer upperTorso; public PlaneRenderer neck; - public PonyRenderer unicornArmRight; - public PonyRenderer unicornArmLeft; - public PonyTail tail; public PonySnout snout; - public UnicornHorn horn; - public PegasusWings wings; - public ModelPlayerPony(boolean smallArms) { + public ModelEarthPony(boolean smallArms) { super(smallArms); this.smallArms = smallArms; } @@ -52,15 +45,12 @@ public class ModelPlayerPony extends AbstractPonyModel { public void init(float yOffset, float stretch) { super.init(yOffset, stretch); snout = new PonySnout(this, yOffset, stretch); - horn = new UnicornHorn(this, yOffset, stretch); - wings = new PegasusWings(this, yOffset, stretch); } @Override public void setRotationAngles(float move, float swing, float age, float headYaw, float headPitch, float scale, Entity entity) { super.setRotationAngles(move, swing, age, headYaw, headPitch, scale, entity); - checkRainboom(entity, swing); rotateHead(headYaw, headPitch); float bodySwingRotation = 0; @@ -74,7 +64,7 @@ public class ModelPlayerPony extends AbstractPonyModel { holdItem(swing); swingItem(entity, swingProgress); - if (isCrouching() && !rainboom) { + if (isCrouching()) { adjustBody(BODY_ROTATE_ANGLE_X_SNEAK, BODY_RP_Y_SNEAK, BODY_RP_Z_SNEAK); sneakLegs(); setHead(0, 6, -2); @@ -112,7 +102,6 @@ public class ModelPlayerPony extends AbstractPonyModel { bipedCape.rotationPointY = isSneak ? 2 : isRiding ? -4 : 0; snout.setGender(metadata.getGender()); - wings.setRotationAngles(move, swing, age, headYaw, headPitch, scale, entity); } } @@ -139,13 +128,6 @@ public class ModelPlayerPony extends AbstractPonyModel { copyModelAngles(bipedBody, bipedBodyWear); } - /** - * Checks flying and speed conditions and sets rainboom to true if we're a species with wings and is going faaast. - */ - protected void checkRainboom(Entity entity, float swing) { - rainboom = isFlying(entity) && swing >= 0.9999F; - } - /** * Sets the head rotation angle. */ @@ -180,49 +162,46 @@ public class ModelPlayerPony extends AbstractPonyModel { } protected void setLegs(float move, float swing, float tick, Entity entity) { - rotateLegs(move, swing, tick, entity); - adjustLegs(); + if (isFlying(entity)) { + rotateLegsInFlight(move, swing, tick, entity); + } else { + rotateLegsOnGround(move, swing, tick, entity); + } + + bipedLeftArm.rotateAngleZ = 0; + bipedRightArm.rotateAngleZ = 0; + + adjustLegs(move, swing, tick); } - protected void rotateLegs(float move, float swing, float tick, Entity entity) { - float leftArm; - float rightArm; - float leftLeg; - float rightLeg; + protected void rotateLegsInFlight(float move, float swing, float tick, Entity entity) { + float armX = MathHelper.sin(-swing / 2); + float legX = MathHelper.sin(swing / 2); + bipedLeftArm.rotateAngleX = armX; + bipedRightArm.rotateAngleX = armX; - if (isFlying(entity)) { - if (rainboom) { - rightArm = leftArm = ROTATE_270; - rightLeg = leftLeg = ROTATE_90; - } else { - rightArm = leftArm = MathHelper.sin(-swing / 2); - rightLeg = leftLeg = MathHelper.sin(swing / 2); - } + bipedLeftLeg.rotateAngleX = legX; + bipedRightLeg.rotateAngleX = legX; - bipedLeftLeg.rotateAngleY = bipedRightArm.rotateAngleY = 0.2F; - bipedLeftArm.rotateAngleY = bipedRightLeg.rotateAngleY = -0.2F; - } else { - float pi = PI * (float) Math.pow(swing, 16); + bipedLeftArm.rotateAngleY = -0.2F; + bipedLeftLeg.rotateAngleY = 0.2F; - float mve = move * 0.6662F; // magic number ahoy - float srt = swing / 4; + bipedRightArm.rotateAngleY = 0.2F; + bipedRightLeg.rotateAngleY = -0.2F; + } - leftArm = MathHelper.cos(mve + pi) * srt; - rightArm = MathHelper.cos(mve + PI + pi / 2) * srt; + protected void rotateLegsOnGround(float move, float swing, float tick, Entity entity) { + float pi = PI * (float) Math.pow(swing, 16); - leftLeg = MathHelper.cos(mve + PI - (pi * 0.4f)) * srt; - rightLeg = MathHelper.cos(mve + pi * 0.2f) * srt; + float mve = move * 0.6662F; // magic number ahoy + float srt = swing / 4; - bipedLeftArm.rotateAngleY = 0; - bipedRightArm.rotateAngleY = 0; + float leftArm = MathHelper.cos(mve + pi) * srt; + float rightArm = MathHelper.cos(mve + PI + pi / 2) * srt; - bipedLeftLeg.rotateAngleY = 0; - bipedRightLeg.rotateAngleY = 0; - - unicornArmRight.rotateAngleY = 0; - unicornArmLeft.rotateAngleY = 0; - } + float leftLeg = MathHelper.cos(mve + PI - (pi * 0.4f)) * srt; + float rightLeg = MathHelper.cos(mve + pi * 0.2f) * srt; bipedLeftArm.rotateAngleX = leftArm; bipedRightArm.rotateAngleX = rightArm; @@ -230,14 +209,11 @@ public class ModelPlayerPony extends AbstractPonyModel { bipedLeftLeg.rotateAngleX = leftLeg; bipedRightLeg.rotateAngleX = rightLeg; - bipedLeftArm.rotateAngleZ = 0; - bipedRightArm.rotateAngleZ = 0; + bipedLeftArm.rotateAngleY = 0; + bipedRightArm.rotateAngleY = 0; - unicornArmLeft.rotateAngleZ = 0; - unicornArmRight.rotateAngleZ = 0; - - unicornArmLeft.rotateAngleX = 0; - unicornArmRight.rotateAngleX = 0; + bipedLeftLeg.rotateAngleY = 0; + bipedRightLeg.rotateAngleY = 0; } private float getLegOutset() { @@ -246,11 +222,15 @@ public class ModelPlayerPony extends AbstractPonyModel { return 4; } - protected void adjustLegs() { + protected float getLegSpread() { + return rainboom ? 2 : 1; + } + + protected void adjustLegs(float move, float swing, float tick) { float sin = MathHelper.sin(bipedBody.rotateAngleY) * 5; float cos = MathHelper.cos(bipedBody.rotateAngleY) * 5; - float spread = rainboom ? 2 : 1; + float spread = getLegSpread(); bipedRightArm.rotationPointZ = spread + sin; @@ -278,23 +258,14 @@ public class ModelPlayerPony extends AbstractPonyModel { bipedRightLeg.rotationPointZ = bipedLeftLeg.rotationPointZ = 10; } - - protected void holdItem(float swing) { boolean both = leftArmPose == ArmPose.ITEM && rightArmPose == ArmPose.ITEM; - if (!rainboom && !metadata.hasMagic()) { - alignArmForAction(bipedLeftArm, leftArmPose, both, swing); - alignArmForAction(bipedRightArm, rightArmPose, both, swing); - } else if (metadata.hasMagic()) { - alignArmForAction(unicornArmLeft, leftArmPose, both, swing); - alignArmForAction(unicornArmRight, rightArmPose, both, swing); - } - - horn.setUsingMagic(leftArmPose != ArmPose.EMPTY || rightArmPose != ArmPose.EMPTY); + alignArmForAction(bipedLeftArm, leftArmPose, both, swing); + alignArmForAction(bipedRightArm, rightArmPose, both, swing); } - private void alignArmForAction(ModelRenderer arm, ArmPose pose, boolean both, float swing) { + protected void alignArmForAction(ModelRenderer arm, ArmPose pose, boolean both, float swing) { switch (pose) { case ITEM: float swag = 1; @@ -324,15 +295,11 @@ public class ModelPlayerPony extends AbstractPonyModel { if (getArmPoseForSide(mainSide) == ArmPose.EMPTY) return; - if (metadata.hasMagic()) { - swingArm(getUnicornArmForSide(mainSide)); - } else { - swingArm(getArmForSide(mainSide)); - } + swingArm(getArmForSide(mainSide)); } } - private void swingArm(ModelRenderer arm) { + protected void swingArm(ModelRenderer arm) { float swing = 1 - (float)Math.pow(1 - swingProgress, 3); float deltaX = MathHelper.sin(swing * PI); @@ -352,24 +319,13 @@ public class ModelPlayerPony extends AbstractPonyModel { float sin = MathHelper.sin(tick * 0.067F) * 0.05F; if (rightArmPose != ArmPose.EMPTY) { - - if (metadata.hasMagic()) { - unicornArmRight.rotateAngleZ += cos; - unicornArmRight.rotateAngleX += sin; - } else { - bipedRightArm.rotateAngleZ += cos; - bipedRightArm.rotateAngleX += sin; - } + bipedRightArm.rotateAngleZ += cos; + bipedRightArm.rotateAngleX += sin; } if (leftArmPose != ArmPose.EMPTY) { - if (metadata.hasMagic()) { - unicornArmLeft.rotateAngleZ += cos; - unicornArmLeft.rotateAngleX += sin; - } else { - bipedLeftArm.rotateAngleZ += cos; - bipedLeftArm.rotateAngleX += sin; - } + bipedLeftArm.rotateAngleZ += cos; + bipedLeftArm.rotateAngleX += sin; } } @@ -392,17 +348,10 @@ public class ModelPlayerPony extends AbstractPonyModel { neck.setRotationPoint(NECK_ROT_X + rotateAngleX, rotationPointY, rotationPointZ); } - public PonyRenderer getUnicornArmForSide(EnumHandSide side) { - return side == EnumHandSide.LEFT ? unicornArmLeft : unicornArmRight; - } - /** * Aligns legs to a sneaky position. */ protected void sneakLegs() { - unicornArmRight.rotateAngleX += SNEAK_LEG_X_ROTATION_ADJUSTMENT; - unicornArmLeft.rotateAngleX += SNEAK_LEG_X_ROTATION_ADJUSTMENT; - bipedRightArm.rotateAngleX -= SNEAK_LEG_X_ROTATION_ADJUSTMENT; bipedLeftArm.rotateAngleX -= SNEAK_LEG_X_ROTATION_ADJUSTMENT; @@ -425,14 +374,8 @@ public class ModelPlayerPony extends AbstractPonyModel { protected void aimBow(ArmPose leftArm, ArmPose rightArm, float tick) { if (leftArm == ArmPose.BOW_AND_ARROW || rightArm == ArmPose.BOW_AND_ARROW) { - - if (metadata.hasMagic()) { - if (rightArm == ArmPose.BOW_AND_ARROW) aimBowPony(unicornArmRight, tick, true); - if (leftArm == ArmPose.BOW_AND_ARROW) aimBowPony(unicornArmLeft, tick, false); - } else { - if (rightArm == ArmPose.BOW_AND_ARROW) aimBowPony(bipedRightArm, tick, false); - if (leftArm == ArmPose.BOW_AND_ARROW) aimBowPony(bipedLeftArm, tick, false); - } + if (rightArm == ArmPose.BOW_AND_ARROW) aimBowPony(bipedRightArm, tick, false); + if (leftArm == ArmPose.BOW_AND_ARROW) aimBowPony(bipedLeftArm, tick, false); } } @@ -476,7 +419,6 @@ public class ModelPlayerPony extends AbstractPonyModel { bipedHead.render(scale); bipedHeadwear.render(scale); bipedHead.postRender(scale); - horn.render(entity, move, swing, age, headYaw, headPitch, scale); } protected void renderNeck() { @@ -491,7 +433,6 @@ public class ModelPlayerPony extends AbstractPonyModel { } upperTorso.render(scale); bipedBody.postRender(scale); - wings.render(entity, move, swing, age, headYaw, headPitch, scale); tail.render(metadata.getTail(), scale); } @@ -549,11 +490,6 @@ public class ModelPlayerPony extends AbstractPonyModel { bipedLeftLegwear = new ModelRenderer(this, 0, 48); bipedRightLegwear = new ModelRenderer(this, 0, 32); - - unicornArmLeft = new PonyRenderer(this, 40, 32).size(64, 64); - unicornArmRight = new PonyRenderer(this, 40, 32).size(64, 64); - - boxList.remove(unicornArmRight); } @Override @@ -672,9 +608,6 @@ public class ModelPlayerPony extends AbstractPonyModel { bipedRightLegwear.addBox(armX, armY, armZ, armWidth, 12, armDepth, stretch + 0.25f); bipedRightLegwear.setRotationPoint(-3, yOffset, 0); } - - unicornArmLeft .box(FIRSTP_ARM_CENTRE_X - 2, armY, armZ, 4, 12, 4, stretch + .25f).around(5, yOffset + 2, 0); - unicornArmRight.box(FIRSTP_ARM_CENTRE_X - 2, armY, armZ, 4, 12, 4, stretch + .25f).around(-5, yOffset + 2, 0); } @Override diff --git a/src/main/java/com/minelittlepony/model/player/ModelPegasus.java b/src/main/java/com/minelittlepony/model/player/ModelPegasus.java new file mode 100644 index 00000000..f4f4cb73 --- /dev/null +++ b/src/main/java/com/minelittlepony/model/player/ModelPegasus.java @@ -0,0 +1,63 @@ +package com.minelittlepony.model.player; + +import com.minelittlepony.model.components.PegasusWings; +import net.minecraft.entity.Entity; + +import static com.minelittlepony.model.PonyModelConstants.*; + +import com.minelittlepony.model.capabilities.IModelPegasus; + +public class ModelPegasus extends ModelEarthPony implements IModelPegasus { + public PegasusWings wings; + + public ModelPegasus(boolean smallArms) { + super(smallArms); + } + + @Override + public void init(float yOffset, float stretch) { + super.init(yOffset, stretch); + wings = new PegasusWings(this, yOffset, stretch); + } + + @Override + public boolean isCrouching() { + return super.isCrouching() && !rainboom; + } + + @Override + public void setRotationAngles(float move, float swing, float age, float headYaw, float headPitch, float scale, Entity entity) { + checkRainboom(entity, swing); + + super.setRotationAngles(move, swing, age, headYaw, headPitch, scale, entity); + + if (bipedCape != null) { + wings.setRotationAngles(move, swing, age, headYaw, headPitch, scale, entity); + } + } + + @Override + protected void rotateLegsInFlight(float move, float swing, float tick, Entity entity) { + if (rainboom) { + bipedLeftArm.rotateAngleX = ROTATE_270; + bipedRightArm.rotateAngleX = ROTATE_270; + + bipedLeftLeg.rotateAngleX = ROTATE_90; + bipedRightLeg.rotateAngleX = ROTATE_90; + + bipedLeftArm.rotateAngleY = -0.2F; + bipedLeftLeg.rotateAngleY = 0.2F; + + bipedRightArm.rotateAngleY = 0.2F; + bipedRightLeg.rotateAngleY = -0.2F; + } else { + super.rotateLegsInFlight(move, swing, tick, entity); + } + } + + @Override + protected void renderBody(Entity entity, float move, float swing, float age, float headYaw, float headPitch, float scale) { + super.renderBody(entity, move, swing, age, headYaw, headPitch, scale); + wings.render(entity, move, swing, age, headYaw, headPitch, scale); + } +} diff --git a/src/main/java/com/minelittlepony/model/player/PlayerModels.java b/src/main/java/com/minelittlepony/model/player/PlayerModels.java index 18a2d666..af91e7f7 100644 --- a/src/main/java/com/minelittlepony/model/player/PlayerModels.java +++ b/src/main/java/com/minelittlepony/model/player/PlayerModels.java @@ -4,8 +4,13 @@ import com.minelittlepony.model.PMAPI; import com.minelittlepony.model.ModelWrapper; public enum PlayerModels { - HUMAN("default", "slim", () -> PMAPI.human, () -> PMAPI.humanSmall), - PONY("pony", "slimpony", () -> PMAPI.pony, () -> PMAPI.ponySmall); + /** + * @deprecated Will be removed in a later revision + */ + @Deprecated HUMAN("default", "slim", () -> PMAPI.pony, () -> PMAPI.ponySmall), + EARTH("earthpony", "slimearthpony", () -> PMAPI.earthpony, () -> PMAPI.earthponySmall), + PEGASUS("pegasus", "slimpegasus", () -> PMAPI.pegasus, () -> PMAPI.pegasusSmall), + ALICORN("alicorn", "slimalicorn", () -> PMAPI.alicorn, () -> PMAPI.alicornSmall); private final ModelResolver normal, slim; @@ -20,11 +25,11 @@ public enum PlayerModels { } public ModelWrapper getModel(boolean slim) { - return slim ? this.slim.resolve() : normal.resolve(); + return slim ? this.slim.resolve() : normal.resolve(); } public String getId(boolean useSlimArms) { - return useSlimArms ? slimKey : normalKey; + return useSlimArms ? slimKey : normalKey; } /** diff --git a/src/main/java/com/minelittlepony/model/ponies/ModelHumanPlayer.java b/src/main/java/com/minelittlepony/model/ponies/ModelHumanPlayer.java deleted file mode 100644 index 1fb345bc..00000000 --- a/src/main/java/com/minelittlepony/model/ponies/ModelHumanPlayer.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.minelittlepony.model.ponies; - -import com.minelittlepony.model.AbstractPonyModel; -import com.minelittlepony.model.BodyPart; -import com.minelittlepony.model.armour.PonyArmor; - -public class ModelHumanPlayer extends AbstractPonyModel { - - public ModelHumanPlayer(boolean smallArms) { - super(smallArms); - } - - @Override - protected boolean doCancelRender() { - return true; - } - - @Override - public void transform(BodyPart part) { - } - - @Override - protected void initTextures() { - - } - - @Override - protected void initPositions(float yOffset, float stretch) { - - } - - @Override - public PonyArmor createArmour() { - return new PonyArmor(new ModelHumanPlayer(false), new ModelHumanPlayer(false)); - } -} diff --git a/src/main/java/com/minelittlepony/model/ponies/ModelIllagerPony.java b/src/main/java/com/minelittlepony/model/ponies/ModelIllagerPony.java index 9d1a5fa9..ea355585 100644 --- a/src/main/java/com/minelittlepony/model/ponies/ModelIllagerPony.java +++ b/src/main/java/com/minelittlepony/model/ponies/ModelIllagerPony.java @@ -1,12 +1,14 @@ package com.minelittlepony.model.ponies; +import com.minelittlepony.model.player.ModelAlicorn; + import net.minecraft.client.model.ModelRenderer; import net.minecraft.entity.Entity; import net.minecraft.entity.monster.AbstractIllager; import net.minecraft.util.EnumHandSide; import net.minecraft.util.math.MathHelper; -public class ModelIllagerPony extends ModelPlayerPony { +public class ModelIllagerPony extends ModelAlicorn { public ModelIllagerPony() { super(false); @@ -14,8 +16,8 @@ public class ModelIllagerPony extends ModelPlayerPony { @Override public void setRotationAngles(float move, float swing, float age, float headYaw, float headPitch, float scale, Entity entity) { - super.setRotationAngles(move, swing, age, headYaw, headPitch, scale, entity); + AbstractIllager illager = (AbstractIllager) entity; AbstractIllager.IllagerArmPose pose = illager.getArmPose(); diff --git a/src/main/java/com/minelittlepony/model/ponies/ModelSkeletonPony.java b/src/main/java/com/minelittlepony/model/ponies/ModelSkeletonPony.java index 812ce4a2..eecef93d 100644 --- a/src/main/java/com/minelittlepony/model/ponies/ModelSkeletonPony.java +++ b/src/main/java/com/minelittlepony/model/ponies/ModelSkeletonPony.java @@ -8,7 +8,6 @@ import com.minelittlepony.model.armour.PonyArmor; import net.minecraft.client.model.ModelBiped; import net.minecraft.client.model.ModelRenderer; -import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.monster.AbstractSkeleton; import net.minecraft.init.Items; @@ -46,8 +45,8 @@ public class ModelSkeletonPony extends ModelMobPony { } @Override - protected void rotateLegs(float move, float swing, float ticks, Entity entity) { - super.rotateLegs(move, swing, ticks, entity); + protected void adjustLegs(float move, float swing, float ticks) { + super.adjustLegs(move, swing, ticks); aimBow(leftArmPose, rightArmPose, ticks); } diff --git a/src/main/java/com/minelittlepony/model/ponies/ModelVillagerPony.java b/src/main/java/com/minelittlepony/model/ponies/ModelVillagerPony.java index 0353c930..119a1313 100644 --- a/src/main/java/com/minelittlepony/model/ponies/ModelVillagerPony.java +++ b/src/main/java/com/minelittlepony/model/ponies/ModelVillagerPony.java @@ -5,9 +5,10 @@ import net.minecraft.entity.passive.EntityVillager; import net.minecraft.util.math.MathHelper; import static com.minelittlepony.model.PonyModelConstants.*; +import com.minelittlepony.model.player.ModelAlicorn; import com.minelittlepony.render.plane.PlaneRenderer; -public class ModelVillagerPony extends ModelPlayerPony { +public class ModelVillagerPony extends ModelAlicorn { public PlaneRenderer bag, apron, trinket; diff --git a/src/main/java/com/minelittlepony/model/ponies/ModelZombiePony.java b/src/main/java/com/minelittlepony/model/ponies/ModelZombiePony.java index 8a92cf68..b3f7bb69 100644 --- a/src/main/java/com/minelittlepony/model/ponies/ModelZombiePony.java +++ b/src/main/java/com/minelittlepony/model/ponies/ModelZombiePony.java @@ -4,8 +4,6 @@ import com.minelittlepony.model.ModelMobPony; import com.minelittlepony.model.armour.ModelZombiePonyArmor; import com.minelittlepony.model.armour.PonyArmor; -import net.minecraft.util.math.MathHelper; - public class ModelZombiePony extends ModelMobPony { public ModelZombiePony() { @@ -17,15 +15,11 @@ public class ModelZombiePony extends ModelMobPony { return new PonyArmor(new ModelZombiePonyArmor(), new ModelZombiePonyArmor()); } - private boolean isRight(float move) { - return MathHelper.sin(move / 20) < 0; - } - @Override protected void rotateRightArm(float move, float tick) { if (rightArmPose != ArmPose.EMPTY) return; - if (isRight(move)) { + if (islookAngleRight(move)) { rotateArmHolding(bipedRightArm, 1, swingProgress, tick); } else { rotateArmHolding(bipedLeftArm, -1, swingProgress, tick); @@ -34,18 +28,17 @@ public class ModelZombiePony extends ModelMobPony { @Override protected void rotateLeftArm(float move, float tick) { - + // zombies are unidexterous. } @Override protected void fixSpecialRotationPoints(float move) { if (rightArmPose != ArmPose.EMPTY) return; - if (isRight(move)) { + if (islookAngleRight(move)) { shiftRotationPoint(bipedRightArm, 0.5F, 1.5F, 3); } else { shiftRotationPoint(bipedLeftArm, -0.5F, 1.5F, 3); } - } } diff --git a/src/main/java/com/minelittlepony/pony/data/PonyRace.java b/src/main/java/com/minelittlepony/pony/data/PonyRace.java index 9f86dc20..508f8707 100644 --- a/src/main/java/com/minelittlepony/pony/data/PonyRace.java +++ b/src/main/java/com/minelittlepony/pony/data/PonyRace.java @@ -5,15 +5,15 @@ import com.minelittlepony.model.player.PlayerModels; public enum PonyRace implements ITriggerPixelMapped { HUMAN(0, PlayerModels.HUMAN, false, false), - EARTH(0xf9b131, PlayerModels.PONY,false, false), - PEGASUS(0x88caf0, PlayerModels.PONY, true, false), - UNICORN(0xd19fe4, PlayerModels.PONY, false, true), - ALICORN(0xfef9fc, PlayerModels.PONY, true, true), - CHANGELING(0x282b29, PlayerModels.PONY, true, true), - ZEBRA(0xd0cccf, PlayerModels.PONY, false, false), - REFORMED_CHANGELING(0xcaed5a, PlayerModels.PONY, true, true), - GRIFFIN(0xae9145, PlayerModels.PONY, true, false), - HIPPOGRIFF(0xd6ddac, PlayerModels.PONY, true, false); + EARTH(0xf9b131, PlayerModels.EARTH,false, false), + PEGASUS(0x88caf0, PlayerModels.PEGASUS, true, false), + UNICORN(0xd19fe4, PlayerModels.ALICORN, false, true), + ALICORN(0xfef9fc, PlayerModels.ALICORN, true, true), + CHANGELING(0x282b29, PlayerModels.ALICORN, true, true), + ZEBRA(0xd0cccf, PlayerModels.EARTH, false, false), + REFORMED_CHANGELING(0xcaed5a, PlayerModels.ALICORN, true, true), + GRIFFIN(0xae9145, PlayerModels.PEGASUS, true, false), + HIPPOGRIFF(0xd6ddac, PlayerModels.PEGASUS, true, false); private boolean wings; private boolean horn; diff --git a/src/main/java/com/minelittlepony/render/layer/AbstractPonyLayer.java b/src/main/java/com/minelittlepony/render/layer/AbstractPonyLayer.java index 43621a1c..96ad02f2 100644 --- a/src/main/java/com/minelittlepony/render/layer/AbstractPonyLayer.java +++ b/src/main/java/com/minelittlepony/render/layer/AbstractPonyLayer.java @@ -2,7 +2,6 @@ package com.minelittlepony.render.layer; import com.minelittlepony.ducks.IRenderPony; import com.minelittlepony.model.AbstractPonyModel; -import com.minelittlepony.model.ponies.ModelHumanPlayer; import net.minecraft.client.model.ModelBase; import net.minecraft.client.renderer.entity.RenderLivingBase; @@ -12,24 +11,16 @@ import net.minecraft.entity.EntityLivingBase; public abstract class AbstractPonyLayer implements LayerRenderer { private final RenderLivingBase renderer; - private LayerRenderer layer; - public AbstractPonyLayer(RenderLivingBase renderer, LayerRenderer humanLayer) { + public AbstractPonyLayer(RenderLivingBase renderer) { this.renderer = renderer; - this.layer = humanLayer; } @SuppressWarnings("unchecked") @Override public final void doRenderLayer(EntityLivingBase entity, float move, float swing, float ticks, float age, float headYaw, float headPitch, float scale) { - ModelBase model = renderer.getMainModel(); - if (model instanceof ModelHumanPlayer) { - // render the human layer - layer.doRenderLayer((T)entity, move, swing, ticks, age, headYaw, headPitch, scale); - } else { - // render the pony layer - doPonyRender((T)entity, move, swing, ticks, age, headYaw, headPitch, scale); - } + // render the pony layer + doPonyRender((T)entity, move, swing, ticks, age, headYaw, headPitch, scale); } protected abstract void doPonyRender(T entity, float move, float swing, float ticks, float age, float headYaw, float headPitch, float scale); diff --git a/src/main/java/com/minelittlepony/render/layer/LayerEntityOnPonyShoulder.java b/src/main/java/com/minelittlepony/render/layer/LayerEntityOnPonyShoulder.java index c603cf83..817d350c 100644 --- a/src/main/java/com/minelittlepony/render/layer/LayerEntityOnPonyShoulder.java +++ b/src/main/java/com/minelittlepony/render/layer/LayerEntityOnPonyShoulder.java @@ -1,6 +1,5 @@ package com.minelittlepony.render.layer; -import com.minelittlepony.ForgeProxy; import com.minelittlepony.model.BodyPart; import net.minecraft.client.entity.AbstractClientPlayer; @@ -8,12 +7,9 @@ import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.entity.Render; import net.minecraft.client.renderer.entity.RenderLivingBase; import net.minecraft.client.renderer.entity.RenderManager; -import net.minecraft.client.renderer.entity.layers.LayerEntityOnShoulder; -import net.minecraft.client.renderer.entity.layers.LayerRenderer; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityList; import net.minecraft.entity.EntityLivingBase; -import net.minecraft.entity.player.EntityPlayer; import net.minecraft.nbt.NBTTagCompound; import javax.annotation.Nullable; @@ -26,7 +22,7 @@ public class LayerEntityOnPonyShoulder extends AbstractPonyLayer renderer) { - super(renderer, getForgeLayer(manager)); + super(renderer); renderManager = manager; } @@ -82,10 +78,4 @@ public class LayerEntityOnPonyShoulder extends AbstractPonyLayer getForgeLayer(RenderManager manager) { - return ForgeProxy.createShoulderLayer() - .orElse(LayerEntityOnShoulder::new) - .apply(manager); - } } diff --git a/src/main/java/com/minelittlepony/render/layer/LayerHeldPonyItem.java b/src/main/java/com/minelittlepony/render/layer/LayerHeldPonyItem.java index 428b5fed..a0fc022b 100644 --- a/src/main/java/com/minelittlepony/render/layer/LayerHeldPonyItem.java +++ b/src/main/java/com/minelittlepony/render/layer/LayerHeldPonyItem.java @@ -8,7 +8,6 @@ import net.minecraft.client.model.ModelBiped; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.block.model.ItemCameraTransforms.TransformType; import net.minecraft.client.renderer.entity.RenderLivingBase; -import net.minecraft.client.renderer.entity.layers.LayerHeldItem; import net.minecraft.entity.EntityLivingBase; import net.minecraft.item.ItemStack; import net.minecraft.util.EnumHandSide; @@ -17,7 +16,7 @@ import static net.minecraft.client.renderer.GlStateManager.*; public class LayerHeldPonyItem extends AbstractPonyLayer { public LayerHeldPonyItem(RenderLivingBase livingPony) { - super(livingPony, new LayerHeldItem(livingPony)); + super(livingPony); } @Override diff --git a/src/main/java/com/minelittlepony/render/layer/LayerHeldPonyItemMagical.java b/src/main/java/com/minelittlepony/render/layer/LayerHeldPonyItemMagical.java index 1c039ff2..83491c81 100644 --- a/src/main/java/com/minelittlepony/render/layer/LayerHeldPonyItemMagical.java +++ b/src/main/java/com/minelittlepony/render/layer/LayerHeldPonyItemMagical.java @@ -10,8 +10,8 @@ import static net.minecraft.client.renderer.GlStateManager.translate; import org.lwjgl.opengl.GL14; import com.minelittlepony.ducks.IRenderItem; -import com.minelittlepony.model.AbstractPonyModel; -import com.minelittlepony.model.ponies.ModelPlayerPony; +import com.minelittlepony.model.capabilities.IModelUnicorn; + import net.minecraft.client.Minecraft; import net.minecraft.client.model.ModelBase; import net.minecraft.client.renderer.GlStateManager; @@ -30,7 +30,7 @@ public class LayerHeldPonyItemMagical extends LayerH private boolean isUnicorn() { ModelBase model = getMainModel(); - return model instanceof AbstractPonyModel && ((AbstractPonyModel) model).metadata.hasMagic(); + return model instanceof IModelUnicorn && ((IModelUnicorn) model).isCasting(); } protected void preItemRender(T entity, ItemStack drop, TransformType transform, EnumHandSide hand) { @@ -52,7 +52,7 @@ public class LayerHeldPonyItemMagical extends LayerH */ protected void renderArm(EnumHandSide side) { if (isUnicorn()) { - this.getMainModel().getUnicornArmForSide(side).postRender(0.0625F); + ((IModelUnicorn)getMainModel()).getUnicornArmForSide(side).postRender(0.0625F); } else { super.renderArm(side); } diff --git a/src/main/java/com/minelittlepony/render/layer/LayerPonyArmor.java b/src/main/java/com/minelittlepony/render/layer/LayerPonyArmor.java index b8007727..af314204 100644 --- a/src/main/java/com/minelittlepony/render/layer/LayerPonyArmor.java +++ b/src/main/java/com/minelittlepony/render/layer/LayerPonyArmor.java @@ -11,7 +11,6 @@ import net.minecraft.client.Minecraft; import net.minecraft.client.model.ModelBase; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.entity.RenderLivingBase; -import net.minecraft.client.renderer.entity.layers.LayerBipedArmor; import net.minecraft.client.resources.ResourcePackRepository; import net.minecraft.entity.EntityLivingBase; import net.minecraft.inventory.EntityEquipmentSlot; @@ -39,7 +38,7 @@ public class LayerPonyArmor extends AbstractPonyLaye private ModelWrapper pony; public LayerPonyArmor(RenderLivingBase renderer) { - super(renderer, new LayerBipedArmor(renderer)); + super(renderer); } @Override @@ -60,12 +59,7 @@ public class LayerPonyArmor extends AbstractPonyLaye ItemArmor itemarmor = (ItemArmor) itemstack.getItem(); - AbstractPonyModel modelbase; - if (armorSlot == EntityEquipmentSlot.LEGS) { - modelbase = pony.getArmor().armour; - } else { - modelbase = pony.getArmor().chestplate; - } + AbstractPonyModel modelbase = pony.getArmor().getArmorForSlot(armorSlot); modelbase = getArmorModel(entity, itemstack, armorSlot, modelbase); modelbase.setModelAttributes(pony.getModel()); modelbase.setRotationAngles(move, swing, age, headYaw, headPitch, scale, entity); @@ -167,7 +161,6 @@ public class LayerPonyArmor extends AbstractPonyLaye } private void renderEnchantment(T entity, ModelBase model, float move, float swing, float ticks, float age, float headYaw, float headPitch, float scale) { - getRenderer().bindTexture(ENCHANTED_ITEM_GLINT_RES); GlStateManager.enableBlend(); diff --git a/src/main/java/com/minelittlepony/render/layer/LayerPonyCape.java b/src/main/java/com/minelittlepony/render/layer/LayerPonyCape.java index d7f21109..162e26f8 100644 --- a/src/main/java/com/minelittlepony/render/layer/LayerPonyCape.java +++ b/src/main/java/com/minelittlepony/render/layer/LayerPonyCape.java @@ -6,8 +6,6 @@ import com.minelittlepony.model.ModelWrapper; import net.minecraft.client.entity.AbstractClientPlayer; import net.minecraft.client.renderer.entity.RenderLivingBase; -import net.minecraft.client.renderer.entity.RenderPlayer; -import net.minecraft.client.renderer.entity.layers.LayerCape; import net.minecraft.entity.player.EnumPlayerModelParts; import net.minecraft.init.Items; import net.minecraft.inventory.EntityEquipmentSlot; @@ -21,7 +19,7 @@ import static com.minelittlepony.model.PonyModelConstants.PI; public class LayerPonyCape extends AbstractPonyLayer { public LayerPonyCape(RenderLivingBase entity) { - super(entity, new LayerCape((RenderPlayer) entity)); + super(entity); } @Override diff --git a/src/main/java/com/minelittlepony/render/layer/LayerPonyCustomHead.java b/src/main/java/com/minelittlepony/render/layer/LayerPonyCustomHead.java index 5a8cd881..6d54c9d6 100644 --- a/src/main/java/com/minelittlepony/render/layer/LayerPonyCustomHead.java +++ b/src/main/java/com/minelittlepony/render/layer/LayerPonyCustomHead.java @@ -4,7 +4,6 @@ import com.minelittlepony.ducks.IRenderPony; import com.minelittlepony.model.AbstractPonyModel; import com.minelittlepony.model.BodyPart; import com.minelittlepony.model.ModelWrapper; -import com.minelittlepony.model.ponies.ModelPlayerPony; import com.mojang.authlib.GameProfile; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.block.model.ItemCameraTransforms.TransformType; @@ -46,7 +45,7 @@ public class LayerPonyCustomHead implements LayerRen model.transform(BodyPart.HEAD); model.bipedHead.postRender(0.0625f); - if (model instanceof ModelPlayerPony) { + if (model instanceof AbstractPonyModel) { translate(0, 0.2F, 0); } else { translate(0, 0, 0.15F); diff --git a/src/main/java/com/minelittlepony/render/layer/LayerPonyElytra.java b/src/main/java/com/minelittlepony/render/layer/LayerPonyElytra.java index a26f3dc3..be51dd6e 100644 --- a/src/main/java/com/minelittlepony/render/layer/LayerPonyElytra.java +++ b/src/main/java/com/minelittlepony/render/layer/LayerPonyElytra.java @@ -7,7 +7,6 @@ import net.minecraft.client.entity.AbstractClientPlayer; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.entity.RenderLivingBase; import net.minecraft.client.renderer.entity.layers.LayerArmorBase; -import net.minecraft.client.renderer.entity.layers.LayerElytra; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EnumPlayerModelParts; import net.minecraft.init.Items; @@ -23,7 +22,7 @@ public class LayerPonyElytra extends AbstractPonyLay private PonyElytra modelElytra = new PonyElytra(); public LayerPonyElytra(RenderLivingBase rp) { - super(rp, new LayerElytra(rp)); + super(rp); } @Override diff --git a/src/main/java/com/minelittlepony/render/player/RenderPonyBase.java b/src/main/java/com/minelittlepony/render/player/RenderPonyBase.java index c5e64560..82fa660b 100644 --- a/src/main/java/com/minelittlepony/render/player/RenderPonyBase.java +++ b/src/main/java/com/minelittlepony/render/player/RenderPonyBase.java @@ -5,10 +5,9 @@ import com.minelittlepony.ducks.IRenderManager; import com.minelittlepony.ducks.IRenderPony; import com.minelittlepony.model.AbstractPonyModel; import com.minelittlepony.model.ModelWrapper; -import com.minelittlepony.model.ponies.ModelPlayerPony; import com.minelittlepony.pony.data.Pony; import com.minelittlepony.render.layer.LayerEntityOnPonyShoulder; -import com.minelittlepony.render.layer.LayerHeldPonyItem; +import com.minelittlepony.render.layer.LayerHeldPonyItemMagical; import com.minelittlepony.render.layer.LayerPonyArmor; import com.minelittlepony.render.layer.LayerPonyCape; import com.minelittlepony.render.layer.LayerPonyCustomHead; @@ -45,7 +44,7 @@ public abstract class RenderPonyBase extends RenderPlayer implements IRenderPony protected void addExtraLayers() { addLayer(new LayerPonyArmor<>(this)); - addLayer(new LayerHeldPonyItem<>(this)); + addLayer(new LayerHeldPonyItemMagical<>(this)); addLayer(new LayerArrow(this)); addLayer(new LayerPonyCape(this)); addLayer(new LayerPonyCustomHead<>(this)); @@ -108,7 +107,7 @@ public abstract class RenderPonyBase extends RenderPlayer implements IRenderPony if (player.isEntityAlive() && player.isPlayerSleeping()) return; - if (((ModelPlayerPony) ponyModel).rainboom) { + if (ponyModel.rainboom) { transformPegasusFlight(player, motionX, motionY, motionZ, yaw, pitch, ticks); return; } diff --git a/src/main/java/com/minelittlepony/render/player/RenderPonyPlayer.java b/src/main/java/com/minelittlepony/render/player/RenderPonyPlayer.java index 2754bd57..de9e52f8 100644 --- a/src/main/java/com/minelittlepony/render/player/RenderPonyPlayer.java +++ b/src/main/java/com/minelittlepony/render/player/RenderPonyPlayer.java @@ -51,4 +51,6 @@ public class RenderPonyPlayer extends RenderPonyBase { GlStateManager.rotate(ponyModel.motionPitch, 1, 0, 0); GlStateManager.rotate(((IPonyAnimationHolder)player).getStrafeAmount(ticks), 0, 0, 1); } + + //TODO: transformSwimming() } diff --git a/src/main/java/com/minelittlepony/render/ponies/RenderPonySkeleton.java b/src/main/java/com/minelittlepony/render/ponies/RenderPonySkeleton.java index a871e03c..41ef294f 100644 --- a/src/main/java/com/minelittlepony/render/ponies/RenderPonySkeleton.java +++ b/src/main/java/com/minelittlepony/render/ponies/RenderPonySkeleton.java @@ -28,7 +28,7 @@ public class RenderPonySkeleton extends Rende addLayer(new LayerBipedArmor(this) { @Override protected void initArmor() { - modelLeggings = getPlayerModel().getArmor().armour; + modelLeggings = getPlayerModel().getArmor().leggings; modelArmor = getPlayerModel().getArmor().chestplate; } });