From 7fbc14ca0113222fc7574219cc8a132593c08452 Mon Sep 17 00:00:00 2001 From: Sollace Date: Sat, 28 Apr 2018 23:00:01 +0200 Subject: [PATCH] Added a model for witches (current texture is a placeholder until we can get Zebras) --- .../com/minelittlepony/PonyRenderManager.java | 4 + .../model/ponies/ModelWitchPony.java | 72 ++++++++++++++++++ .../minelittlepony/render/RenderPonyMob.java | 7 +- .../layer/LayerHeldPonyItemMagical.java | 2 +- .../render/ponies/RenderPonyWitch.java | 49 ++++++++++++ .../textures/entity/witch_pony.png | Bin 0 -> 620 bytes 6 files changed, 132 insertions(+), 2 deletions(-) create mode 100644 src/main/java/com/minelittlepony/model/ponies/ModelWitchPony.java create mode 100644 src/main/java/com/minelittlepony/render/ponies/RenderPonyWitch.java create mode 100644 src/main/resources/assets/minelittlepony/textures/entity/witch_pony.png diff --git a/src/main/java/com/minelittlepony/PonyRenderManager.java b/src/main/java/com/minelittlepony/PonyRenderManager.java index 24950148..0f58ce31 100644 --- a/src/main/java/com/minelittlepony/PonyRenderManager.java +++ b/src/main/java/com/minelittlepony/PonyRenderManager.java @@ -12,6 +12,7 @@ import com.minelittlepony.render.ponies.RenderPonyPigman; import com.minelittlepony.render.ponies.RenderPonySkeleton; import com.minelittlepony.render.ponies.RenderPonyVex; import com.minelittlepony.render.ponies.RenderPonyVillager; +import com.minelittlepony.render.ponies.RenderPonyWitch; import com.minelittlepony.render.ponies.RenderPonyZombie; import com.minelittlepony.render.ponies.RenderPonyZombieVillager; import com.mumfrey.liteloader.util.ModUtilities; @@ -28,6 +29,7 @@ import net.minecraft.entity.monster.EntitySkeleton; import net.minecraft.entity.monster.EntityStray; import net.minecraft.entity.monster.EntityVex; import net.minecraft.entity.monster.EntityVindicator; +import net.minecraft.entity.monster.EntityWitch; import net.minecraft.entity.monster.EntityWitherSkeleton; import net.minecraft.entity.monster.EntityZombie; import net.minecraft.entity.monster.EntityZombieVillager; @@ -69,10 +71,12 @@ public class PonyRenderManager { if (config.villagers) { pushNewRenderer(rm, EntityVillager.class, new RenderPonyVillager(rm)); + pushNewRenderer(rm, EntityWitch.class, new RenderPonyWitch(rm)); pushNewRenderer(rm, EntityZombieVillager.class, new RenderPonyZombieVillager(rm)); MineLittlePony.logger.info("Villagers are now ponies."); } else { restoreRenderer(EntityVillager.class); + restoreRenderer(EntityWitch.class); restoreRenderer(EntityZombieVillager.class); } diff --git a/src/main/java/com/minelittlepony/model/ponies/ModelWitchPony.java b/src/main/java/com/minelittlepony/model/ponies/ModelWitchPony.java new file mode 100644 index 00000000..6eb206ac --- /dev/null +++ b/src/main/java/com/minelittlepony/model/ponies/ModelWitchPony.java @@ -0,0 +1,72 @@ +package com.minelittlepony.model.ponies; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.texture.TextureManager; +import net.minecraft.entity.Entity; +import net.minecraft.entity.monster.EntityWitch; +import net.minecraft.util.ResourceLocation; + +import static com.minelittlepony.model.PonyModelConstants.HEAD_RP_X; +import static com.minelittlepony.model.PonyModelConstants.HEAD_RP_Y; +import static com.minelittlepony.model.PonyModelConstants.HEAD_RP_Z; + +import com.minelittlepony.render.PonyRenderer; + +public class ModelWitchPony extends ModelVillagerPony { + + private static final ResourceLocation WITCH_TEXTURES = new ResourceLocation("textures/entity/witch.png"); + + private PonyRenderer witchHat; + + public ModelWitchPony() { + super(); + } + + public void setRotationAngles(float move, float swing, float age, float headYaw, float headPitch, float scale, Entity entity) { + rightArmPose = ArmPose.EMPTY; + leftArmPose = ((EntityWitch) entity).getHeldItemMainhand().isEmpty() ? ArmPose.EMPTY : ArmPose.ITEM; + + super.setRotationAngles(move, swing, age, headYaw, headPitch, scale, entity); + if (leftArmPose != ArmPose.EMPTY) { + if (!canCast()) { + bipedRightArm.rotateAngleX = -2 * (float)Math.PI/3; + bipedRightArm.offsetZ = 0.1f; + } + unicornArmRight.offsetZ = -0.1f; + } + } + + @Override + public void render(Entity entityIn, float move, float swing, float age, float headYaw, float headPitch, float scale) { + super.render(entityIn, move, swing, age, headYaw, headPitch, scale); + + copyModelAngles(bipedHead, witchHat); + + TextureManager tex = Minecraft.getMinecraft().getRenderManager().renderEngine; + tex.bindTexture(WITCH_TEXTURES); + witchHat.render(scale * 1.3f); + } + + @Override + protected void initTextures() { + super.initTextures(); + witchHat = new PonyRenderer(this).size(64, 128); + } + + @Override + protected void initPositions(float yOffset, float stretch) { + super.initPositions(yOffset, stretch); + witchHat.offset(-5, -6, -7) + .around(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z - 2) + .tex(0, 64).box(0, 0, 0, 10, 2, 10, stretch) + .child(0).offset(-5, -5, -7).around(1.75F, -4, 2) + .tex(0, 76).box(0, 0, 0, 7, 4, 7, stretch) + .rotate(-0.05235988F, 0, 0.02617994F) + .child(0).offset(-5, -4, -7).around(1.75F, -4, 2) + .tex(0, 87).box(0, 0, 0, 4, 4, 4, stretch) + .rotate(-0.10471976F, 0, 0.05235988F) + .child(0).offset(-5, -2, -7).around(1.75F, -2, 2) + .tex(0, 95).box(0, 0, 0, 1, 2, 1, stretch) + .rotate(-0.20943952F, 0, 0.10471976F); + } +} diff --git a/src/main/java/com/minelittlepony/render/RenderPonyMob.java b/src/main/java/com/minelittlepony/render/RenderPonyMob.java index 5dd8c40d..eb1326b6 100644 --- a/src/main/java/com/minelittlepony/render/RenderPonyMob.java +++ b/src/main/java/com/minelittlepony/render/RenderPonyMob.java @@ -3,6 +3,7 @@ package com.minelittlepony.render; import com.minelittlepony.MineLittlePony; import com.minelittlepony.ducks.IRenderPony; import com.minelittlepony.model.ModelWrapper; +import com.minelittlepony.render.layer.LayerHeldPonyItem; import com.minelittlepony.render.layer.LayerHeldPonyItemMagical; import com.minelittlepony.render.layer.LayerPonyArmor; import com.minelittlepony.render.layer.LayerPonyCustomHead; @@ -29,10 +30,14 @@ public abstract class RenderPonyMob extends RenderLiving protected void addLayers() { addLayer(new LayerPonyArmor<>(this)); - addLayer(new LayerHeldPonyItemMagical<>(this)); // addLayer(new LayerArrow(this)); addLayer(new LayerPonyCustomHead<>(this)); addLayer(new LayerPonyElytra<>(this)); + addLayer(createItemHoldingLayer()); + } + + protected LayerHeldPonyItem createItemHoldingLayer() { + return new LayerHeldPonyItemMagical<>(this); } @Override diff --git a/src/main/java/com/minelittlepony/render/layer/LayerHeldPonyItemMagical.java b/src/main/java/com/minelittlepony/render/layer/LayerHeldPonyItemMagical.java index e4f1b1da..3e371e39 100644 --- a/src/main/java/com/minelittlepony/render/layer/LayerHeldPonyItemMagical.java +++ b/src/main/java/com/minelittlepony/render/layer/LayerHeldPonyItemMagical.java @@ -28,7 +28,7 @@ public class LayerHeldPonyItemMagical extends LayerH super(livingPony); } - private boolean isUnicorn() { + protected boolean isUnicorn() { ModelBase model = getMainModel(); return model instanceof IModelUnicorn && ((IModelUnicorn) model).canCast(); } diff --git a/src/main/java/com/minelittlepony/render/ponies/RenderPonyWitch.java b/src/main/java/com/minelittlepony/render/ponies/RenderPonyWitch.java new file mode 100644 index 00000000..cdfd4e3c --- /dev/null +++ b/src/main/java/com/minelittlepony/render/ponies/RenderPonyWitch.java @@ -0,0 +1,49 @@ +package com.minelittlepony.render.ponies; + +import com.minelittlepony.model.PMAPI; +import com.minelittlepony.render.RenderPonyMob; +import com.minelittlepony.render.layer.LayerHeldPonyItem; +import com.minelittlepony.render.layer.LayerHeldPonyItemMagical; + +import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.client.renderer.block.model.ItemCameraTransforms.TransformType; +import net.minecraft.client.renderer.entity.RenderManager; +import net.minecraft.entity.monster.EntityWitch; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumHandSide; +import net.minecraft.util.ResourceLocation; + +public class RenderPonyWitch extends RenderPonyMob { + + private static final ResourceLocation WITCH_TEXTURES = new ResourceLocation("minelittlepony", "textures/entity/witch_pony.png"); + + public RenderPonyWitch(RenderManager manager) { + super(manager, PMAPI.witch); + } + + @Override + protected LayerHeldPonyItem createItemHoldingLayer() { + return new LayerHeldPonyItemMagical(this) { + @Override + protected void preItemRender(EntityWitch entity, ItemStack drop, TransformType transform, EnumHandSide hand) { + if (isUnicorn()) { + GlStateManager.translate(-0.1F, 0.7F, 0); + GlStateManager.rotate(110, 1, 0, 0); + } else { + GlStateManager.translate(-0.2F, -0.3F, -0.7F); + } + } + }; + } + + @Override + protected void preRenderCallback(EntityWitch entity, float ticks) { + super.preRenderCallback(entity, ticks); + GlStateManager.scale(0.9375F, 0.9375F, 0.9375F); + } + + @Override + protected ResourceLocation getTexture(EntityWitch entity) { + return WITCH_TEXTURES; + } +} diff --git a/src/main/resources/assets/minelittlepony/textures/entity/witch_pony.png b/src/main/resources/assets/minelittlepony/textures/entity/witch_pony.png new file mode 100644 index 0000000000000000000000000000000000000000..215d140060ac2ce9cb9b3e7d26a09349a8699960 GIT binary patch literal 620 zcmeAS@N?(olHy`uVBq!ia0vp^4j|0I1|(Ny7T#lEU^4b}aSW-r^>&t_-w^`=*J4pV z2WQ{IvO5@gg;*c4e3_E5R5$z)lZeTch3=0yJT|-yQdT_dB6adi-{Xq6H~c=iOIa4a z+4}rupY6=tduH;_-o3guVb8odvoCjlop;ZE-;B5YFQ=^6yn3o_)!*6MisFPd_kElF z_WQ4R<&yVJ6K?$wVA%9Gg<*+6!`aWv%f*%$%)7O3yM>@4C(KrbL59pFyfN`nX)>TiFLq6H+;!n3%CO{8f7L zIxx-QEQ8xkwqgm*>l^k?Hd(5A-6LCnlP811Pwi_fx0aWA8C5eJzs_HM?31l6H>(1F z&{gIgHC5&37^=*w8P;f)ai5(&Lxkb2l}N)EWwou`N9Ku|sISUmNYUw^Wm8`~^X~O^ zm+#zOwZ2~G$&-mi_K}wL0t|0?;)EOQG7V0p0|UI8TOs zHuGNT#j-HOeU1V}2^efhVTf^D78Td2e|+QL&rA!9OT+~PHRX+C&ler+czZu<>#Ls9 zrM)~}S@)m){#107m+$R-@dH6A=Q*Qh>4-I4mt||1+5NrxfKZyl{YaRZAUffi`a!$t z5)47zf4rV>$1PhIA7jGo^zX5Bv^+x=i@|GE0b%owUh4p4O%0FK_b>cdeSQCV{