diff --git a/src/main/java/com/minelittlepony/client/model/AbstractPonyModel.java b/src/main/java/com/minelittlepony/client/model/AbstractPonyModel.java index f9332dd9..2eba9455 100644 --- a/src/main/java/com/minelittlepony/client/model/AbstractPonyModel.java +++ b/src/main/java/com/minelittlepony/client/model/AbstractPonyModel.java @@ -2,6 +2,7 @@ package com.minelittlepony.client.model; import com.minelittlepony.client.model.armour.ModelPonyArmour; import com.minelittlepony.client.model.armour.ArmourWrapper; +import com.minelittlepony.client.model.components.PonyEars; import com.minelittlepony.client.model.components.PonySnout; import com.minelittlepony.client.model.components.PonyTail; import com.minelittlepony.client.transform.PonyTransformation; @@ -33,6 +34,7 @@ public abstract class AbstractPonyModel extends ClientPo protected IPart tail; protected PonySnout snout; + protected IPart ears; public AbstractPonyModel(boolean arms) { super(0, arms); @@ -569,8 +571,8 @@ public abstract class AbstractPonyModel extends ClientPo } protected void initEars(PonyRenderer head, float yOffset, float stretch) { - head.tex(12, 16).box(-4, -6, 1, 2, 2, 2, stretch) // right ear - .flip().box( 2, -6, 1, 2, 2, 2, stretch); // left ear + ears = new PonyEars(head, false); + ears.init(yOffset, stretch); } protected void initTail(float yOffset, float stretch) { diff --git a/src/main/java/com/minelittlepony/client/model/ModelMobPony.java b/src/main/java/com/minelittlepony/client/model/IMobModel.java similarity index 63% rename from src/main/java/com/minelittlepony/client/model/ModelMobPony.java rename to src/main/java/com/minelittlepony/client/model/IMobModel.java index 9f0c2239..101fcea8 100644 --- a/src/main/java/com/minelittlepony/client/model/ModelMobPony.java +++ b/src/main/java/com/minelittlepony/client/model/IMobModel.java @@ -1,20 +1,14 @@ package com.minelittlepony.client.model; import net.minecraft.client.model.Cuboid; -import net.minecraft.entity.LivingEntity; import net.minecraft.util.math.MathHelper; -import com.minelittlepony.client.model.races.ModelAlicorn; +import com.minelittlepony.model.PonyModelConstants; /** - * Common class for all humanoid (ponioid?) non-player enemies. - * + * Common interface for all undead enemies. */ -public abstract class ModelMobPony extends ModelAlicorn { - - public ModelMobPony() { - super(false); - } +public interface IMobModel { /** * Rotates the provided arm to the correct orientation for holding an item. @@ -24,9 +18,9 @@ public abstract class ModelMobPony extends ModelAlicorn< * @param swingProgress How far we are through the current swing * @param ticks Render partial ticks */ - protected void rotateArmHolding(Cuboid arm, float direction, float swingProgress, float ticks) { - float swing = MathHelper.sin(swingProgress * PI); - float roll = MathHelper.sin((1 - (1 - swingProgress) * (1 - swingProgress)) * PI); + default void rotateArmHolding(Cuboid arm, float direction, float swingProgress, float ticks) { + float swing = MathHelper.sin(swingProgress * PonyModelConstants.PI); + float roll = MathHelper.sin((1 - (1 - swingProgress) * (1 - swingProgress)) * PonyModelConstants.PI); float cos = MathHelper.cos(ticks * 0.09F) * 0.05F + 0.05F; float sin = MathHelper.sin(ticks * 0.067F) / 10; diff --git a/src/main/java/com/minelittlepony/client/model/components/PonyEars.java b/src/main/java/com/minelittlepony/client/model/components/PonyEars.java new file mode 100644 index 00000000..fe2b5459 --- /dev/null +++ b/src/main/java/com/minelittlepony/client/model/components/PonyEars.java @@ -0,0 +1,51 @@ +package com.minelittlepony.client.model.components; + +import net.minecraft.client.model.Cuboid; +import net.minecraft.client.model.Model; + +import com.minelittlepony.client.util.render.PonyRenderer; +import com.minelittlepony.model.ICapitated; +import com.minelittlepony.model.IPart; + +import java.util.UUID; + +public class PonyEars implements IPart { + + private final PonyRenderer head; + private final boolean bat; + + private PonyRenderer right; + private PonyRenderer left; + + public > PonyEars(PonyRenderer head, boolean bat) { + this.head = head; + this.bat = bat; + } + + @Override + public void init(float yOffset, float stretch) { + right = head.child().tex(12, 16).box(-4, -6, 1, 2, 2, 2, stretch); + + if (bat) { + right.tex(0, 3).box(-3.5F, -6.49F, 1.001F, 1, 1, 1, stretch) + .tex(0, 5).box(-2.998F, -6.49F, 2.001F, 1, 1, 1, stretch); + } + + left = head.child().flip().tex(12, 16).box( 2, -6, 1, 2, 2, 2, stretch); + + if (bat) { + left.tex(0, 3).box( 2.5F, -6.49F, 1.001F, 1, 1, 1, stretch) + .tex(0, 5).box( 1.998F, -6.49F, 2.001F, 1, 1, 1, stretch); + } + } + + @Override + public void renderPart(float scale, UUID interpolatorId) { + } + + @Override + public void setVisible(boolean visible) { + right.visible = visible; + left.visible = visible; + } +} diff --git a/src/main/java/com/minelittlepony/client/model/components/PonySnout.java b/src/main/java/com/minelittlepony/client/model/components/PonySnout.java index ea1beff1..436ab9b9 100644 --- a/src/main/java/com/minelittlepony/client/model/components/PonySnout.java +++ b/src/main/java/com/minelittlepony/client/model/components/PonySnout.java @@ -6,11 +6,12 @@ import net.minecraft.client.model.Model; import com.minelittlepony.client.MineLittlePony; import com.minelittlepony.client.util.render.plane.PlaneRenderer; import com.minelittlepony.model.ICapitated; +import com.minelittlepony.model.IPart; import com.minelittlepony.pony.meta.Gender; -import static com.minelittlepony.model.PonyModelConstants.*; +import java.util.UUID; -public class PonySnout { +public class PonySnout implements IPart { public boolean isHidden = false; @@ -38,6 +39,7 @@ public class PonySnout { stallion.rotate(x, y, z); } + @Override public void init(float yOffset, float stretch) { mare.around(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z) .tex(10, 14).south(-2, 2, -5, 4, 2, stretch) @@ -58,6 +60,10 @@ public class PonySnout { .tex(13, 13) .east( 2, 1, -5, 3, 1, stretch); } + @Override + public void renderPart(float scale, UUID interpolatorId) { + } + public void setGender(Gender gender) { boolean show = !head.hasHeadGear() && !isHidden && MineLittlePony.getInstance().getConfig().snuzzles.get(); diff --git a/src/main/java/com/minelittlepony/client/model/entities/ModelEnderStallion.java b/src/main/java/com/minelittlepony/client/model/entities/ModelEnderStallion.java index 738dfedb..ee20c0df 100644 --- a/src/main/java/com/minelittlepony/client/model/entities/ModelEnderStallion.java +++ b/src/main/java/com/minelittlepony/client/model/entities/ModelEnderStallion.java @@ -113,7 +113,7 @@ public class ModelEnderStallion extends ModelSkeletonPony { } @Override - protected void rotateArmHolding(Cuboid arm, float direction, float swingProgress, float ticks) { + public void rotateArmHolding(Cuboid arm, float direction, float swingProgress, float ticks) { arm.pitch = -0.3707964F; arm.pitch += 0.4F + MathHelper.sin(ticks * 0.067F) / 10; } diff --git a/src/main/java/com/minelittlepony/client/model/entities/ModelIllagerPony.java b/src/main/java/com/minelittlepony/client/model/entities/ModelIllagerPony.java index 12b3a666..e60b2046 100644 --- a/src/main/java/com/minelittlepony/client/model/entities/ModelIllagerPony.java +++ b/src/main/java/com/minelittlepony/client/model/entities/ModelIllagerPony.java @@ -5,9 +5,13 @@ import net.minecraft.entity.mob.IllagerEntity; import net.minecraft.util.Arm; import net.minecraft.util.math.MathHelper; -import com.minelittlepony.client.model.ModelMobPony; +import com.minelittlepony.client.model.races.ModelAlicorn; -public class ModelIllagerPony extends ModelMobPony { +public class ModelIllagerPony extends ModelAlicorn { + + public ModelIllagerPony() { + super(false); + } @Override public void setAngles(T illager, float move, float swing, float ticks, float headYaw, float headPitch, float scale) { diff --git a/src/main/java/com/minelittlepony/client/model/entities/ModelSkeletonPony.java b/src/main/java/com/minelittlepony/client/model/entities/ModelSkeletonPony.java index c78c46a0..4f234903 100644 --- a/src/main/java/com/minelittlepony/client/model/entities/ModelSkeletonPony.java +++ b/src/main/java/com/minelittlepony/client/model/entities/ModelSkeletonPony.java @@ -7,16 +7,17 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.Arm; import net.minecraft.util.Hand; -import com.minelittlepony.client.model.ModelMobPony; +import com.minelittlepony.client.model.IMobModel; +import com.minelittlepony.client.model.races.ModelAlicorn; -public class ModelSkeletonPony extends ModelMobPony { +public class ModelSkeletonPony extends ModelAlicorn implements IMobModel { public boolean isUnicorn; public boolean isWithered; public ModelSkeletonPony() { - super(); + super(false); attributes.armWidth = 2; attributes.armDepth = 2; attributes.armRotationX = 3F; diff --git a/src/main/java/com/minelittlepony/client/model/entities/ModelVillagerPony.java b/src/main/java/com/minelittlepony/client/model/entities/ModelVillagerPony.java index 6ed0d95c..101b5707 100644 --- a/src/main/java/com/minelittlepony/client/model/entities/ModelVillagerPony.java +++ b/src/main/java/com/minelittlepony/client/model/entities/ModelVillagerPony.java @@ -7,22 +7,45 @@ import net.minecraft.util.math.MathHelper; import net.minecraft.village.VillagerDataContainer; import net.minecraft.village.VillagerProfession; -import com.minelittlepony.client.model.ModelMobPony; +import com.minelittlepony.client.model.components.BatWings; +import com.minelittlepony.client.model.components.PonyEars; +import com.minelittlepony.client.model.races.ModelAlicorn; +import com.minelittlepony.client.render.entities.villager.PonyTextures; +import com.minelittlepony.client.util.render.PonyRenderer; import com.minelittlepony.client.util.render.plane.PlaneRenderer; -import com.minelittlepony.pony.meta.Wearable; +import com.minelittlepony.model.IPart; +import com.minelittlepony.pony.meta.Race; -public class ModelVillagerPony extends ModelMobPony implements ModelWithHat { +public class ModelVillagerPony extends ModelAlicorn implements ModelWithHat { - public PlaneRenderer apron; - public PlaneRenderer trinket; + private PlaneRenderer apron; + private PlaneRenderer trinket; + private IPart batWings; - private VillagerProfession profession; + public ModelVillagerPony() { + super(false); + } - public boolean special; - public boolean special2; + @Override + public IPart getWings() { + if (getMetadata().getRace() == Race.BATPONY) { + return batWings; + } + return super.getWings(); + } - public boolean hatVisible; + @Override + protected void initWings(float yOffset, float stretch) { + super.initWings(yOffset, stretch); + batWings = new BatWings<>(this, yOffset, stretch); + } + + @Override + protected void initEars(PonyRenderer head, float yOffset, float stretch) { + ears = new PonyEars(head, true); + ears.init(yOffset, stretch); + } @Override protected void shakeBody(float move, float swing, float bodySwing, float ticks) { @@ -33,45 +56,20 @@ public class ModelVillagerPony e @Override public void animateModel(T entity, float limbSwing, float limbSwingAmount, float partialTickTime) { - profession = entity.getVillagerData().getProfession(); - special = entity.hasCustomName() && "Derpy".equals(entity.getCustomName().getString()); - special2 = special && entity.getUuid().getLeastSignificantBits() % 20 == 0; - attributes.visualHeight = special2 ? 2.3F : 2; + boolean special = PonyTextures.isBestPony(entity); + + VillagerProfession profession = entity.getVillagerData().getProfession(); + + attributes.visualHeight = PonyTextures.isCrownPony(entity) ? 2.3F : 2; + apron.visible = !special && profession == VillagerProfession.BUTCHER; + trinket.visible = !special && !apron.visible && profession != VillagerProfession.NONE && profession != VillagerProfession.NITWIT; } @Override protected void renderBody(float scale) { super.renderBody(scale); - - if (!special && profession != VillagerProfession.NONE && profession != VillagerProfession.NITWIT) { - if (profession == VillagerProfession.BUTCHER) { - apron.render(scale); - } else { - trinket.render(scale); - } - } - } - - @Override - public boolean isWearing(Wearable wearable) { - - if (wearable == Wearable.SADDLE_BAGS) { - return !special && profession != VillagerProfession.NONE && ( - profession == VillagerProfession.CARTOGRAPHER - || profession == VillagerProfession.FARMER - || profession == VillagerProfession.FISHERMAN - || profession == VillagerProfession.LIBRARIAN - || profession == VillagerProfession.SHEPHERD); - } - - if (wearable == Wearable.MUFFIN) { - return special2; - } - if (wearable == Wearable.VILLAGER) { - return hatVisible; - } - - return super.isWearing(wearable); + apron.render(scale); + //trinket.render(scale); } @Override @@ -90,17 +88,14 @@ public class ModelVillagerPony e @Override public void setHatVisible(boolean visible) { - hatVisible = visible; } @Override public void setAngles(T entity, float move, float swing, float ticks, float headYaw, float headPitch, float scale) { super.setAngles(entity, move, swing, ticks, headYaw, headPitch, scale); - boolean isHeadRolling = false; - if (entity instanceof AbstractTraderEntity) { - isHeadRolling = ((AbstractTraderEntity)entity).getHeadRollingTimeLeft() > 0; - } + boolean isHeadRolling = entity instanceof AbstractTraderEntity + && ((AbstractTraderEntity)entity).getHeadRollingTimeLeft() > 0; if (isHeadRolling) { float roll = 0.3F * MathHelper.sin(0.45F * ticks); diff --git a/src/main/java/com/minelittlepony/client/model/entities/ModelZombiePony.java b/src/main/java/com/minelittlepony/client/model/entities/ModelZombiePony.java index 0d7e378e..c4a08331 100644 --- a/src/main/java/com/minelittlepony/client/model/entities/ModelZombiePony.java +++ b/src/main/java/com/minelittlepony/client/model/entities/ModelZombiePony.java @@ -1,15 +1,20 @@ package com.minelittlepony.client.model.entities; -import com.minelittlepony.client.model.ModelMobPony; +import com.minelittlepony.client.model.IMobModel; +import com.minelittlepony.client.model.races.ModelAlicorn; import com.minelittlepony.client.util.render.AbstractRenderer; import net.minecraft.entity.mob.HostileEntity; import net.minecraft.util.math.MathHelper; -public class ModelZombiePony extends ModelMobPony { +public class ModelZombiePony extends ModelAlicorn implements IMobModel { public boolean isPegasus; + public ModelZombiePony() { + super(false); + } + @Override public void animateModel(Zombie entity, float move, float swing, float ticks) { isPegasus = entity.getUuid().getLeastSignificantBits() % 30 == 0; diff --git a/src/main/java/com/minelittlepony/client/model/entities/ModelZombieVillagerPony.java b/src/main/java/com/minelittlepony/client/model/entities/ModelZombieVillagerPony.java index 5c805083..89169279 100644 --- a/src/main/java/com/minelittlepony/client/model/entities/ModelZombieVillagerPony.java +++ b/src/main/java/com/minelittlepony/client/model/entities/ModelZombieVillagerPony.java @@ -3,9 +3,10 @@ package com.minelittlepony.client.model.entities; import net.minecraft.entity.mob.ZombieVillagerEntity; import net.minecraft.util.math.MathHelper; +import com.minelittlepony.client.model.IMobModel; import com.minelittlepony.client.util.render.AbstractRenderer; -public class ModelZombieVillagerPony extends ModelVillagerPony { +public class ModelZombieVillagerPony extends ModelVillagerPony implements IMobModel { @Override protected void rotateLegs(float move, float swing, float ticks, ZombieVillagerEntity entity) { diff --git a/src/main/java/com/minelittlepony/client/model/gear/ChristmasHat.java b/src/main/java/com/minelittlepony/client/model/gear/ChristmasHat.java index badb6305..82d1f32e 100644 --- a/src/main/java/com/minelittlepony/client/model/gear/ChristmasHat.java +++ b/src/main/java/com/minelittlepony/client/model/gear/ChristmasHat.java @@ -82,7 +82,7 @@ public class ChristmasHat extends AbstractGear { } @Override - public Identifier getTexture(T entity, IGearRenderContext context) { + public Identifier getTexture(T entity, IRenderContext context) { return TEXTURE; } diff --git a/src/main/java/com/minelittlepony/client/model/gear/IGearRenderContext.java b/src/main/java/com/minelittlepony/client/model/gear/IGearRenderContext.java deleted file mode 100644 index 3581f0ae..00000000 --- a/src/main/java/com/minelittlepony/client/model/gear/IGearRenderContext.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.minelittlepony.client.model.gear; - -import net.minecraft.entity.Entity; -import net.minecraft.util.Identifier; - -import com.minelittlepony.model.gear.IGear; - -public interface IGearRenderContext { - - IGearRenderContext NULL = (e, g) -> null; - - Identifier getDefaultTexture(T entity, IGear gear); -} diff --git a/src/main/java/com/minelittlepony/client/model/gear/IRenderContext.java b/src/main/java/com/minelittlepony/client/model/gear/IRenderContext.java new file mode 100644 index 00000000..9eca7d00 --- /dev/null +++ b/src/main/java/com/minelittlepony/client/model/gear/IRenderContext.java @@ -0,0 +1,18 @@ +package com.minelittlepony.client.model.gear; + +import net.minecraft.entity.Entity; +import net.minecraft.util.Identifier; + +import com.minelittlepony.model.IModel; +import com.minelittlepony.model.gear.IGear; + +public interface IRenderContext { + + IRenderContext NULL = (e, g) -> null; + + default boolean shouldRender(M model, T entity, IGear gear) { + return gear.canRender(model, entity); + } + + Identifier getDefaultTexture(T entity, IGear gear); +} diff --git a/src/main/java/com/minelittlepony/client/model/gear/Muffin.java b/src/main/java/com/minelittlepony/client/model/gear/Muffin.java index de767a33..6730bbd3 100644 --- a/src/main/java/com/minelittlepony/client/model/gear/Muffin.java +++ b/src/main/java/com/minelittlepony/client/model/gear/Muffin.java @@ -44,7 +44,7 @@ public class Muffin extends AbstractGear implements IStackable { } @Override - public Identifier getTexture(T entity, IGearRenderContext context) { + public Identifier getTexture(T entity, IRenderContext context) { return TEXTURE; } diff --git a/src/main/java/com/minelittlepony/client/model/gear/SaddleBags.java b/src/main/java/com/minelittlepony/client/model/gear/SaddleBags.java index 566b95ab..837940ba 100644 --- a/src/main/java/com/minelittlepony/client/model/gear/SaddleBags.java +++ b/src/main/java/com/minelittlepony/client/model/gear/SaddleBags.java @@ -136,7 +136,7 @@ public class SaddleBags extends AbstractGear { } @Override - public Identifier getTexture(T entity, IGearRenderContext context) { + public Identifier getTexture(T entity, IRenderContext context) { return context.getDefaultTexture(entity, this); } diff --git a/src/main/java/com/minelittlepony/client/model/gear/Stetson.java b/src/main/java/com/minelittlepony/client/model/gear/Stetson.java index e8dae282..ab78e9c8 100644 --- a/src/main/java/com/minelittlepony/client/model/gear/Stetson.java +++ b/src/main/java/com/minelittlepony/client/model/gear/Stetson.java @@ -39,7 +39,7 @@ public class Stetson extends AbstractGear implements IStackable { } @Override - public Identifier getTexture(T entity, IGearRenderContext context) { + public Identifier getTexture(T entity, IRenderContext context) { return TEXTURE; } diff --git a/src/main/java/com/minelittlepony/client/model/gear/VillagerHat.java b/src/main/java/com/minelittlepony/client/model/gear/VillagerHat.java deleted file mode 100644 index d1f5b61a..00000000 --- a/src/main/java/com/minelittlepony/client/model/gear/VillagerHat.java +++ /dev/null @@ -1,51 +0,0 @@ -package com.minelittlepony.client.model.gear; - -import net.minecraft.entity.Entity; -import net.minecraft.util.Identifier; -import net.minecraft.village.VillagerDataContainer; - -import com.minelittlepony.client.util.render.PonyRenderer; -import com.minelittlepony.model.BodyPart; -import com.minelittlepony.model.IModel; -import com.minelittlepony.pony.meta.Wearable; - -import java.util.UUID; - -public class VillagerHat extends AbstractGear { - - private static final Identifier TEXTURE = new Identifier("minelittlepony", "textures/models/antlers.png"); - - private PonyRenderer hat; - - @Override - public void init(float yOffset, float stretch) { - hat = new PonyRenderer(this, 30, 47) - .around(0, 0, 0) - .box(-8, -8, -6, 16, 16, 1, stretch); - hat.pitch = -1.5707964F; - } - - @Override - public boolean canRender(IModel model, Entity entity) { - return model.isWearing(Wearable.VILLAGER); - } - - @Override - public BodyPart getGearLocation() { - return BodyPart.HEAD; - } - - @Override - public Identifier getTexture(T entity, IGearRenderContext context) { - if (entity instanceof VillagerDataContainer) { - return context.getDefaultTexture(entity, this); - } - return TEXTURE; - } - - @Override - public void renderPart(float scale, UUID interpolatorId) { - hat.render(scale); - } - -} diff --git a/src/main/java/com/minelittlepony/client/model/gear/WitchHat.java b/src/main/java/com/minelittlepony/client/model/gear/WitchHat.java index 0c7ce793..1f47c8e9 100644 --- a/src/main/java/com/minelittlepony/client/model/gear/WitchHat.java +++ b/src/main/java/com/minelittlepony/client/model/gear/WitchHat.java @@ -50,7 +50,7 @@ public class WitchHat extends AbstractGear implements IStackable { } @Override - public Identifier getTexture(T entity, IGearRenderContext context) { + public Identifier getTexture(T entity, IRenderContext context) { return WITCH_TEXTURES; } diff --git a/src/main/java/com/minelittlepony/client/model/races/ModelAlicorn.java b/src/main/java/com/minelittlepony/client/model/races/ModelAlicorn.java index b7848000..79eca995 100644 --- a/src/main/java/com/minelittlepony/client/model/races/ModelAlicorn.java +++ b/src/main/java/com/minelittlepony/client/model/races/ModelAlicorn.java @@ -1,18 +1,24 @@ package com.minelittlepony.client.model.races; import com.minelittlepony.client.model.components.PegasusWings; +import com.minelittlepony.model.IPart; import com.minelittlepony.model.IPegasus; import net.minecraft.entity.LivingEntity; public class ModelAlicorn extends ModelUnicorn implements IPegasus { - public PegasusWings> wings; + protected IPart wings; public ModelAlicorn(boolean smallArms) { super(smallArms); } + @Override + public IPart getWings() { + return wings; + } + @Override public void init(float yOffset, float stretch) { super.init(yOffset, stretch); @@ -28,7 +34,7 @@ public class ModelAlicorn extends ModelUnicorn implem super.setAngles(entity, move, swing, ticks, headYaw, headPitch, scale); if (canFly()) { - wings.setRotationAndAngles(attributes.isGoingFast, attributes.interpolatorId, move, swing, 0, ticks); + getWings().setRotationAndAngles(attributes.isGoingFast, attributes.interpolatorId, move, swing, 0, ticks); } } @@ -37,13 +43,13 @@ public class ModelAlicorn extends ModelUnicorn implem super.renderBody(scale); if (canFly()) { - wings.renderPart(scale, attributes.interpolatorId); + getWings().renderPart(scale, attributes.interpolatorId); } } @Override public void setVisible(boolean visible) { super.setVisible(visible); - wings.setVisible(visible); + getWings().setVisible(visible); } } diff --git a/src/main/java/com/minelittlepony/client/model/races/ModelBatpony.java b/src/main/java/com/minelittlepony/client/model/races/ModelBatpony.java index 2dfaae7b..8c2ff36c 100644 --- a/src/main/java/com/minelittlepony/client/model/races/ModelBatpony.java +++ b/src/main/java/com/minelittlepony/client/model/races/ModelBatpony.java @@ -3,6 +3,7 @@ package com.minelittlepony.client.model.races; import net.minecraft.entity.LivingEntity; import com.minelittlepony.client.model.components.BatWings; +import com.minelittlepony.client.model.components.PonyEars; import com.minelittlepony.client.util.render.PonyRenderer; import com.minelittlepony.pony.meta.Wearable; @@ -19,15 +20,8 @@ public class ModelBatpony extends ModelPegasus { @Override protected void initEars(PonyRenderer head, float yOffset, float stretch) { - head.child() - .tex(12, 16).box(-4, -6, 1, 2, 2, 2, stretch) // right ear - .tex(0, 3).box(-3.5F, -6.49F, 1.001F, 1, 1, 1, stretch) - .tex(0, 5).box(-2.998F, -6.49F, 2.001F, 1, 1, 1, stretch); - - head.child().flip() - .tex(12, 16).box( 2, -6, 1, 2, 2, 2, stretch) // left ear - .tex(0, 3).box( 2.5F, -6.49F, 1.001F, 1, 1, 1, stretch) - .tex(0, 5).box( 1.998F, -6.49F, 2.001F, 1, 1, 1, stretch); + ears = new PonyEars(head, true); + ears.init(yOffset, stretch); } @Override diff --git a/src/main/java/com/minelittlepony/client/model/races/ModelPegasus.java b/src/main/java/com/minelittlepony/client/model/races/ModelPegasus.java index 2c349d3e..a42bf1b8 100644 --- a/src/main/java/com/minelittlepony/client/model/races/ModelPegasus.java +++ b/src/main/java/com/minelittlepony/client/model/races/ModelPegasus.java @@ -1,18 +1,24 @@ package com.minelittlepony.client.model.races; import com.minelittlepony.client.model.components.PegasusWings; +import com.minelittlepony.model.IPart; import com.minelittlepony.model.IPegasus; import net.minecraft.entity.LivingEntity; public class ModelPegasus extends ModelEarthPony implements IPegasus { - public PegasusWings> wings; + protected IPart wings; public ModelPegasus(boolean smallArms) { super(smallArms); } + @Override + public IPart getWings() { + return wings; + } + @Override public void init(float yOffset, float stretch) { super.init(yOffset, stretch); @@ -26,18 +32,18 @@ public class ModelPegasus extends ModelEarthPony impl @Override public void setAngles(T entity, float move, float swing, float ticks, float headYaw, float headPitch, float scale) { super.setAngles(entity, move, swing, ticks, headYaw, headPitch, scale); - wings.setRotationAndAngles(attributes.isGoingFast, entity.getUuid(), move, swing, 0, ticks); + getWings().setRotationAndAngles(attributes.isGoingFast, entity.getUuid(), move, swing, 0, ticks); } @Override protected void renderBody(float scale) { super.renderBody(scale); - wings.renderPart(scale, attributes.interpolatorId); + getWings().renderPart(scale, attributes.interpolatorId); } @Override public void setVisible(boolean visible) { super.setVisible(visible); - wings.setVisible(visible); + getWings().setVisible(visible); } } diff --git a/src/main/java/com/minelittlepony/client/render/IPonyRender.java b/src/main/java/com/minelittlepony/client/render/IPonyRender.java index c378175a..238b11b9 100644 --- a/src/main/java/com/minelittlepony/client/render/IPonyRender.java +++ b/src/main/java/com/minelittlepony/client/render/IPonyRender.java @@ -2,7 +2,7 @@ package com.minelittlepony.client.render; import com.minelittlepony.client.model.IPonyModel; import com.minelittlepony.client.model.ModelWrapper; -import com.minelittlepony.client.model.gear.IGearRenderContext; +import com.minelittlepony.client.model.gear.IRenderContext; import com.minelittlepony.model.BodyPart; import com.minelittlepony.model.PonyModelConstants; import com.minelittlepony.model.gear.IGear; @@ -13,7 +13,7 @@ import net.minecraft.client.render.entity.model.EntityModel; import net.minecraft.entity.LivingEntity; import net.minecraft.util.Identifier; -public interface IPonyRender & IPonyModel> extends PonyModelConstants, IGearRenderContext { +public interface IPonyRender & IPonyModel> extends PonyModelConstants, IRenderContext { /** * Gets the wrapped pony model for this renderer. diff --git a/src/main/java/com/minelittlepony/client/render/entities/villager/AbstractVillagerRenderer.java b/src/main/java/com/minelittlepony/client/render/entities/villager/AbstractVillagerRenderer.java index 3c3a3481..f4b460e8 100644 --- a/src/main/java/com/minelittlepony/client/render/entities/villager/AbstractVillagerRenderer.java +++ b/src/main/java/com/minelittlepony/client/render/entities/villager/AbstractVillagerRenderer.java @@ -5,6 +5,7 @@ import net.minecraft.client.render.entity.model.ModelWithHat; import net.minecraft.entity.mob.MobEntity; import net.minecraft.util.Identifier; import net.minecraft.village.VillagerDataContainer; +import net.minecraft.village.VillagerProfession; import com.minelittlepony.client.model.ClientPonyModel; import com.minelittlepony.client.render.entities.RenderPonyMob; @@ -30,14 +31,33 @@ public abstract class AbstractVillagerRenderer< addFeature(new ClothingLayer<>(this, entityType)); } + @Override + public boolean shouldRender(M model, T entity, IGear gear) { + + boolean special = PonyTextures.isBestPony(entity); + + if (gear == LayerGear.SADDLE_BAGS) { + VillagerProfession profession = entity.getVillagerData().getProfession(); + return !special && profession != VillagerProfession.NONE && ( + profession == VillagerProfession.CARTOGRAPHER + || profession == VillagerProfession.FARMER + || profession == VillagerProfession.FISHERMAN + || profession == VillagerProfession.LIBRARIAN + || profession == VillagerProfession.SHEPHERD); + } + + if (gear == LayerGear.MUFFIN) { + return PonyTextures.isCrownPony(entity); + } + + return super.shouldRender(model, entity, gear); + } + @Override public Identifier getDefaultTexture(T villager, IGear gear) { if (gear == LayerGear.SADDLE_BAGS) { return ClothingLayer.getClothingTexture(villager, entityType); } - if (gear == LayerGear.VILLAGER_HAT) { - return ClothingLayer.getHatTexture(villager, entityType); - } return super.getDefaultTexture(villager, gear); } diff --git a/src/main/java/com/minelittlepony/client/render/entities/villager/PonyTextures.java b/src/main/java/com/minelittlepony/client/render/entities/villager/PonyTextures.java index 81c8a802..c8dde2ed 100644 --- a/src/main/java/com/minelittlepony/client/render/entities/villager/PonyTextures.java +++ b/src/main/java/com/minelittlepony/client/render/entities/villager/PonyTextures.java @@ -18,7 +18,7 @@ import java.util.Optional; /** * Cached pool of villager textures. */ -class PonyTextures implements ITextureSupplier { +public class PonyTextures implements ITextureSupplier { private final ITextureSupplier formatter; @@ -45,14 +45,8 @@ class PonyTextures implements IT @Override public Identifier supplyTexture(T entity) { - if (entity.hasCustomName()) { - String name = entity.getCustomName().getString(); - if ("Derpy".equals(name) || (entity.isBaby() && "Dinky".equals(name))) { - if (entity.isBaby()) { - return egg2; - } - return egg; - } + if (isBestPony(entity)) { + return entity.isBaby() ? egg2 : egg; } VillagerData t = entity.getVillagerData(); @@ -95,4 +89,16 @@ class PonyTextures implements IT return Optional.of(texture); } + + public static boolean isBestPony(LivingEntity entity) { + if (!entity.hasCustomName()) { + return false; + } + String name = entity.getCustomName().getString(); + return "Derpy".equals(name) || (entity.isBaby() && "Dinky".equals(name)); + } + + public static boolean isCrownPony(LivingEntity entity) { + return isBestPony(entity) && entity.getUuid().getLeastSignificantBits() % 20 == 0; + } } diff --git a/src/main/java/com/minelittlepony/client/render/layer/LayerGear.java b/src/main/java/com/minelittlepony/client/render/layer/LayerGear.java index d47834cc..2cca72c0 100644 --- a/src/main/java/com/minelittlepony/client/render/layer/LayerGear.java +++ b/src/main/java/com/minelittlepony/client/render/layer/LayerGear.java @@ -11,7 +11,6 @@ import com.minelittlepony.client.model.gear.ChristmasHat; import com.minelittlepony.client.model.gear.Muffin; import com.minelittlepony.client.model.gear.SaddleBags; import com.minelittlepony.client.model.gear.Stetson; -import com.minelittlepony.client.model.gear.VillagerHat; import com.minelittlepony.client.model.gear.WitchHat; import com.minelittlepony.client.render.IPonyRender; import com.minelittlepony.model.BodyPart; @@ -30,15 +29,13 @@ public class LayerGear & IPonyM public static final IGear MUFFIN = new Muffin(); public static final IGear STETSON = new Stetson(); public static final IGear ANTLERS = new ChristmasHat(); - public static final IGear VILLAGER_HAT = new VillagerHat(); private static List gears = Lists.newArrayList( SADDLE_BAGS, WITCH_HAT, MUFFIN, STETSON, - ANTLERS, - VILLAGER_HAT + ANTLERS ); public LayerGear(IPonyRender renderer) { @@ -57,7 +54,7 @@ public class LayerGear & IPonyM Map renderStackingOffsets = new HashMap<>(); for (IGear gear : gears) { - if (gear.canRender(model, entity)) { + if (getContext().shouldRender(model, entity, gear)) { GlStateManager.pushMatrix(); model.transform(gear.getGearLocation()); model.getBodyPart(gear.getGearLocation()).applyTransform(scale); diff --git a/src/main/java/com/minelittlepony/model/IPegasus.java b/src/main/java/com/minelittlepony/model/IPegasus.java index 96423050..0d3ff076 100644 --- a/src/main/java/com/minelittlepony/model/IPegasus.java +++ b/src/main/java/com/minelittlepony/model/IPegasus.java @@ -14,6 +14,11 @@ public interface IPegasus extends IModel { return (getAttributes().isSwimming || isFlying() || getAttributes().isCrouching) && !getAttributes().isGliding; } + /** + * Gets the wings of this pegasus/flying creature + */ + IPart getWings(); + /** * Determines angle used to animate wing flaps whilst flying/swimming. * diff --git a/src/main/java/com/minelittlepony/model/gear/IGear.java b/src/main/java/com/minelittlepony/model/gear/IGear.java index ee4b073b..77f8bcb1 100644 --- a/src/main/java/com/minelittlepony/model/gear/IGear.java +++ b/src/main/java/com/minelittlepony/model/gear/IGear.java @@ -3,7 +3,7 @@ package com.minelittlepony.model.gear; import net.minecraft.entity.Entity; import net.minecraft.util.Identifier; -import com.minelittlepony.client.model.gear.IGearRenderContext; +import com.minelittlepony.client.model.gear.IRenderContext; import com.minelittlepony.model.BodyPart; import com.minelittlepony.model.IModel; import com.minelittlepony.model.IPart; @@ -29,7 +29,7 @@ public interface IGear extends IPart { * Gets the texture to use for this wearable. * Return null to use the same as the primary model. */ - Identifier getTexture(T entity, IGearRenderContext context); + Identifier getTexture(T entity, IRenderContext context); /** * Orients this wearable. diff --git a/src/main/java/com/minelittlepony/pony/meta/Wearable.java b/src/main/java/com/minelittlepony/pony/meta/Wearable.java index 9f162789..d8fae8c2 100644 --- a/src/main/java/com/minelittlepony/pony/meta/Wearable.java +++ b/src/main/java/com/minelittlepony/pony/meta/Wearable.java @@ -11,7 +11,6 @@ public enum Wearable implements ITriggerPixelMapped { HAT (0x64), ANTLERS (0x96), SADDLE_BAGS (0xC8), - VILLAGER (0x11), STETSON (0xFA); private int triggerValue;