From 17ee345c11b8cd05d54707a3c20766ab51d548f3 Mon Sep 17 00:00:00 2001 From: Matthew Messinger Date: Thu, 24 Nov 2016 02:01:23 -0500 Subject: [PATCH] Add the vindicator and evoker ponies --- .../java/com/minelittlepony/IPonyData.java | 10 + .../com/minelittlepony/MineLittlePony.java | 12 +- .../java/com/minelittlepony/PonyData.java | 22 +-- .../minelittlepony/PonyDataSerialzier.java | 26 +++ .../mixin/MixinRenderPlayer.java | 2 +- .../model/pony/ModelEvokerPony.java | 55 ++++++ .../model/pony/ModelIllagerPony.java | 172 ++++++++++++++++++ .../model/pony/ModelVindicatorPony.java | 41 +++++ .../renderer/RenderPonyEvoker.java | 58 ++++++ .../renderer/RenderPonyVindicator.java | 54 ++++++ .../renderer/layer/LayerHeldPonyItem.java | 56 +++--- .../textures/entity/illager/evoker_pony.png | Bin 0 -> 1586 bytes .../entity/illager/evoker_pony.png.mcmeta | 6 + .../entity/illager/vindicator_pony.png | Bin 0 -> 1296 bytes 14 files changed, 471 insertions(+), 43 deletions(-) create mode 100644 src/main/java/com/minelittlepony/IPonyData.java create mode 100644 src/main/java/com/minelittlepony/PonyDataSerialzier.java create mode 100644 src/main/java/com/minelittlepony/model/pony/ModelEvokerPony.java create mode 100644 src/main/java/com/minelittlepony/model/pony/ModelIllagerPony.java create mode 100644 src/main/java/com/minelittlepony/model/pony/ModelVindicatorPony.java create mode 100644 src/main/java/com/minelittlepony/renderer/RenderPonyEvoker.java create mode 100644 src/main/java/com/minelittlepony/renderer/RenderPonyVindicator.java create mode 100644 src/main/resources/assets/minelittlepony/textures/entity/illager/evoker_pony.png create mode 100644 src/main/resources/assets/minelittlepony/textures/entity/illager/evoker_pony.png.mcmeta create mode 100644 src/main/resources/assets/minelittlepony/textures/entity/illager/vindicator_pony.png diff --git a/src/main/java/com/minelittlepony/IPonyData.java b/src/main/java/com/minelittlepony/IPonyData.java new file mode 100644 index 00000000..20b253ac --- /dev/null +++ b/src/main/java/com/minelittlepony/IPonyData.java @@ -0,0 +1,10 @@ +package com.minelittlepony; + +import net.minecraft.client.resources.data.IMetadataSection; + +/** + * Dummy interface so gson won't go crazy + */ +public interface IPonyData extends IMetadataSection { + +} diff --git a/src/main/java/com/minelittlepony/MineLittlePony.java b/src/main/java/com/minelittlepony/MineLittlePony.java index 971fc179..f4cffa9f 100644 --- a/src/main/java/com/minelittlepony/MineLittlePony.java +++ b/src/main/java/com/minelittlepony/MineLittlePony.java @@ -6,10 +6,12 @@ import com.minelittlepony.gui.PonySettingPanel; import com.minelittlepony.hdskins.gui.EntityPonyModel; import com.minelittlepony.hdskins.gui.GuiSkinsMineLP; import com.minelittlepony.hdskins.gui.RenderPonyModel; +import com.minelittlepony.renderer.RenderPonyEvoker; import com.minelittlepony.renderer.RenderPonyPigman; import com.minelittlepony.renderer.RenderPonySkeleton; import com.minelittlepony.renderer.RenderPonyVex; import com.minelittlepony.renderer.RenderPonyVillager; +import com.minelittlepony.renderer.RenderPonyVindicator; import com.minelittlepony.renderer.RenderPonyZombie; import com.minelittlepony.renderer.RenderPonyZombieVillager; import com.minelittlepony.util.MineLPLogger; @@ -21,12 +23,15 @@ import com.voxelmodpack.hdskins.gui.GuiSkins; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.client.resources.IReloadableResourceManager; +import net.minecraft.client.resources.data.MetadataSerializer; import net.minecraft.client.settings.KeyBinding; +import net.minecraft.entity.monster.EntityEvoker; import net.minecraft.entity.monster.EntityHusk; import net.minecraft.entity.monster.EntityPigZombie; 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.EntityWitherSkeleton; import net.minecraft.entity.monster.EntityZombie; import net.minecraft.entity.monster.EntityZombieVillager; @@ -68,6 +73,9 @@ public class MineLittlePony { IReloadableResourceManager irrm = (IReloadableResourceManager) Minecraft.getMinecraft().getResourceManager(); irrm.registerReloadListener(this.ponyManager); + + MetadataSerializer ms = Minecraft.getMinecraft().getResourcePackRepository().rprMetadataSerializer; + ms.registerMetadataSectionType(new PonyDataSerialzier(), IPonyData.class); } void postInit(Minecraft minecraft) { @@ -104,9 +112,11 @@ public class MineLittlePony { ModUtilities.addRenderer(EntityWitherSkeleton.class, new RenderPonySkeleton.Wither(rm)); MineLPLogger.info("Skeletons are now ponies."); } - + if (this.config.illagers) { ModUtilities.addRenderer(EntityVex.class, new RenderPonyVex(rm)); + ModUtilities.addRenderer(EntityEvoker.class, new RenderPonyEvoker(rm)); + ModUtilities.addRenderer(EntityVindicator.class, new RenderPonyVindicator(rm)); } } diff --git a/src/main/java/com/minelittlepony/PonyData.java b/src/main/java/com/minelittlepony/PonyData.java index e4fd04ee..fb077160 100644 --- a/src/main/java/com/minelittlepony/PonyData.java +++ b/src/main/java/com/minelittlepony/PonyData.java @@ -4,8 +4,9 @@ import java.awt.image.BufferedImage; import java.util.Map; import com.google.common.collect.ImmutableBiMap; +import net.minecraft.client.resources.data.IMetadataSection; -public class PonyData { +public class PonyData implements IPonyData { private static final Map RACE_COLORS = ImmutableBiMap. builder() .put(0xf9b131, PonyRace.EARTH) @@ -32,10 +33,6 @@ public class PonyData { private PonySize size = PonySize.NORMAL; private int glowColor = 0x4444aa; - private int textureWidth; - - private int textureHeight; - public PonyRace getRace() { return race; } @@ -80,15 +77,7 @@ public class PonyData { this.glowColor = glowColor & 0xffffff; } - public int getTextureWidth() { - return textureWidth; - } - - public int getTextureHeight() { - return textureHeight; - } - - public static PonyData parse(BufferedImage image) { + static PonyData parse(BufferedImage image) { PonyData data = new PonyData(); int race = TriggerPixels.RACE.readColor(image); @@ -110,9 +99,6 @@ public class PonyData { if (color != 0x000000) data.glowColor = color; - data.textureWidth = image.getWidth(); - data.textureHeight = image.getHeight(); - return data; } @@ -125,7 +111,7 @@ public class PonyData { private int x, y; - private TriggerPixels(int x, int y) { + TriggerPixels(int x, int y) { this.x = x; this.y = y; } diff --git a/src/main/java/com/minelittlepony/PonyDataSerialzier.java b/src/main/java/com/minelittlepony/PonyDataSerialzier.java new file mode 100644 index 00000000..c48fe4da --- /dev/null +++ b/src/main/java/com/minelittlepony/PonyDataSerialzier.java @@ -0,0 +1,26 @@ +package com.minelittlepony; + +import com.google.gson.Gson; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonElement; +import com.google.gson.JsonParseException; +import net.minecraft.client.resources.data.IMetadataSectionSerializer; + +import java.lang.reflect.Type; + +public class PonyDataSerialzier implements IMetadataSectionSerializer { + + public static final String NAME = "pony"; + + @Override + public String getSectionName() { + return NAME; + } + + @Override + public PonyData deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { + return context.deserialize(json, PonyData.class); + } + +} + diff --git a/src/main/java/com/minelittlepony/mixin/MixinRenderPlayer.java b/src/main/java/com/minelittlepony/mixin/MixinRenderPlayer.java index a36e7200..97e9f852 100644 --- a/src/main/java/com/minelittlepony/mixin/MixinRenderPlayer.java +++ b/src/main/java/com/minelittlepony/mixin/MixinRenderPlayer.java @@ -57,7 +57,7 @@ public abstract class MixinRenderPlayer extends RenderLivingBase(this)); + this.addLayer(new LayerHeldPonyItem(this)); this.addLayer(new LayerArrow(this)); this.addLayer(new LayerPonyCape(this)); this.addLayer(new LayerPonySkull(this)); diff --git a/src/main/java/com/minelittlepony/model/pony/ModelEvokerPony.java b/src/main/java/com/minelittlepony/model/pony/ModelEvokerPony.java new file mode 100644 index 00000000..bee76080 --- /dev/null +++ b/src/main/java/com/minelittlepony/model/pony/ModelEvokerPony.java @@ -0,0 +1,55 @@ +package com.minelittlepony.model.pony; + +import com.minelittlepony.renderer.HornGlowRenderer; +import net.minecraft.entity.Entity; +import net.minecraft.entity.monster.EntityEvoker; +import org.lwjgl.opengl.GL11; + +import static net.minecraft.client.renderer.GlStateManager.*; + +public class ModelEvokerPony extends ModelIllagerPony { + + private HornGlowRenderer[] hornglow; + + public ModelEvokerPony() { + hornglow = new HornGlowRenderer[2]; + for (int i = 0; i < hornglow.length; i++) { + hornglow[i] = new HornGlowRenderer(this, 60, 3); + hornglow[i].setRotationPoint(0F, 1F, -5F); + } + hornglow[0].addBox(-0.5F, -12.0F, 3F, 1, 4, 1, 0.5F); + hornglow[1].addBox(-0.5F, -12.0F, 3F, 1, 3, 1, 0.8F); + } + + @Override + public void render(Entity entityIn, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scale) { + super.render(entityIn, limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scale); + EntityEvoker evoker = (EntityEvoker) entityIn; + + if (evoker.isCastingSpell()) { + GL11.glPushAttrib(24577); + disableTexture2D(); + disableLighting(); + enableBlend(); + + float red = (glowColor >> 16 & 255) / 255.0F; + float green = (glowColor >> 8 & 255) / 255.0F; + float blue = (glowColor & 255) / 255.0F; + blendFunc(GL11.GL_SRC_ALPHA, 1); + + this.illagerHead.postRender(scale); + this.horn.postRender(scale); + + color(red, green, blue, 0.4F); + this.hornglow[0].render(scale); + color(red, green, blue, 0.2F); + this.hornglow[1].render(scale); + + enableTexture2D(); + enableLighting(); + disableBlend(); + popAttrib(); + } + } + +} diff --git a/src/main/java/com/minelittlepony/model/pony/ModelIllagerPony.java b/src/main/java/com/minelittlepony/model/pony/ModelIllagerPony.java new file mode 100644 index 00000000..0b745d4f --- /dev/null +++ b/src/main/java/com/minelittlepony/model/pony/ModelIllagerPony.java @@ -0,0 +1,172 @@ +package com.minelittlepony.model.pony; + +import com.minelittlepony.model.PonyModelConstants; +import net.minecraft.client.model.ModelBase; +import net.minecraft.client.model.ModelRenderer; +import net.minecraft.entity.Entity; +import net.minecraft.util.EnumHandSide; +import net.minecraft.util.math.MathHelper; + +public abstract class ModelIllagerPony extends ModelBase { + + public boolean isUnicorn; + public int glowColor; + + public ModelRenderer illagerHead; + public ModelRenderer illagerBody; + public ModelRenderer leftForeLeg; + public ModelRenderer rightForeLeg; + public ModelRenderer leftHindLeg; + public ModelRenderer rightHindLeg; + public ModelRenderer tail; + public ModelRenderer horn; + + ModelIllagerPony() { + textureWidth = 64; + textureHeight = 64; + + this.setTextureOffset("head.ear1", 24, 4); + this.setTextureOffset("head.ear2", 0, 4); + this.setTextureOffset("head.snuzzle.mare1", 48, 21); + this.setTextureOffset("head.snuzzle.mare2", 49, 20); + this.setTextureOffset("head.snuzzle.stallion", 48, 16); + + illagerHead = new ModelRenderer(this, "head"); + illagerHead.setRotationPoint(0F, 1F, -5F); + illagerHead.setTextureOffset(0, 0).addBox(-4F, -6F, -5F, 8, 8, 8); + // headwear + illagerHead.setTextureOffset(32, 0).addBox(-4F, -6F, -5F, 8, 8, 8, 0.5F); + illagerHead.addBox("ear1", 2F, -8F, 0F, 2, 2, 2); + illagerHead.addBox("ear2", -4F, -8F, 0F, 2, 2, 2); + illagerHead.addBox("snuzzle.mare1", -2F, -0F, -6F, 4, 2, 1); + illagerHead.addBox("snuzzle.mare2", -1F, -1F, -6F, 2, 1, 1); + illagerHead.addBox("snuzzle.stallion", -2F, -1F, -6F, 4, 3, 1); + + horn = new ModelRenderer(this, 60, 3); + horn.addBox(-0.5F, -11.0F, -2F, 1, 4, 1); + horn.rotateAngleX = 0.5F; + + this.illagerHead.addChild(horn); + + ModelRenderer illagerNeck = new ModelRenderer(this, 0, 40); + illagerNeck.addBox(-2F, 0F, -6F, 4, 4, 4); + illagerNeck.rotateAngleX = PonyModelConstants.NECK_ROT_X; + + illagerBody = new ModelRenderer(this); + illagerBody.setTextureOffset(0, 16).addBox(-4F, 4F, -5F, 8, 8, 16); + illagerBody.addChild(illagerNeck); + + leftForeLeg = new ModelRenderer(this, 32, 16); + leftForeLeg.addBox(0F, 0F, -2F, 4, 12, 4).setRotationPoint(0F, 12F, -3F); + + rightForeLeg = new ModelRenderer(this, 32, 48); + rightForeLeg.addBox(-2F, 0F, -2F, 4, 12, 4).setRotationPoint(-2F, 12F, -3F); + + leftHindLeg = new ModelRenderer(this, 0, 16); + leftHindLeg.addBox(-2F, 0F, -2F, 4, 12, 4).setRotationPoint(2F, 12F, 8F); + + rightHindLeg = new ModelRenderer(this, 0, 48); + rightHindLeg.addBox(-2F, 0F, -2F, 4, 12, 4).setRotationPoint(-2F, 12F, 8F); + + ModelRenderer tailStub = new ModelRenderer(this, 52, 24); + tailStub.addBox(-0.5F, -1F, -0.5F, 2, 4, 2).setRotationPoint(0F, 0F, 2F); + tailStub.rotateAngleX = (float) Math.PI / -3; + + + this.setTextureOffset("tail.1qtr", 48, 24); + this.setTextureOffset("tail.half", 48, 32); + this.setTextureOffset("tail.3qtr", 48, 40); + this.setTextureOffset("tail.full", 48, 48); + + tail = new ModelRenderer(this, "tail"); + tail.setRotationPoint(0F, 4F, 11F); + tail.addBox("1qtr", -1.5F, -2F, 2F, 4, 4, 4); + tail.addBox("half", -1.5F, 2F, 2F, 4, 4, 4); + tail.addBox("3qtr", -1.5F, 6F, 2F, 4, 4, 4); + tail.addBox("full", -1.5F, 10F, 2F, 4, 4, 4); + tail.addChild(tailStub); + + + + } + + @Override + public void render(Entity entityIn, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scale) { + setRotationAngles(limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scale, entityIn); + + illagerHead.render(scale); + illagerBody.render(scale); + leftForeLeg.render(scale); + rightForeLeg.render(scale); + leftHindLeg.render(scale); + rightHindLeg.render(scale); + tail.render(scale); + +// mr.render(scale); + } + + @Override + public void setRotationAngles(float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scaleFactor, Entity entityIn) { + + final float PI = (float) Math.PI; + + float headRotateAngleY = netHeadYaw * PI / 180; + float headRotateAngleX = headPitch * PI / 180; + + final float max = 0.5f; + final float min = -1.25f; + headRotateAngleX = Math.min(headRotateAngleX, max); + headRotateAngleX = Math.max(headRotateAngleX, min); + this.illagerHead.rotateAngleY = headRotateAngleY; + this.illagerHead.rotateAngleX = headRotateAngleX; + + this.tail.rotateAngleZ = MathHelper.cos(limbSwing * 0.8F) * 0.2F * limbSwingAmount; + + float bodySwingRotation = 0.0F; + if (this.swingProgress > -9990.0F) { + bodySwingRotation = MathHelper.sin(MathHelper.sqrt(this.swingProgress) * PI * 2.0F) * 0.2F; + } + + this.illagerBody.rotateAngleY = bodySwingRotation * 0.2F; + this.illagerBody.rotateAngleY = bodySwingRotation * 0.2F; + + + this.tail.rotateAngleY = bodySwingRotation; + + + this.setLegs(limbSwing, limbSwingAmount); + this.tail.rotateAngleX = 0.5F * limbSwingAmount; + + + this.tail.rotateAngleX += MathHelper.sin(ageInTicks * 0.067F) * 0.05F; + + + } + + private void setLegs(float move, float swing) { + this.rotateLegs(move, swing); +// this.adjustLegs(); + } + + private void rotateLegs(float move, float swing) { + final float PI = (float) Math.PI; + float swag = (float) Math.pow(swing, 16.0D); + float raQuad = PI * swag * 0.5F; + float laQuad = PI * swag; + float rlQuad = PI * swag * 0.2F; + float llQuad = PI * swag * -0.4F; + + + this.rightForeLeg.rotateAngleX = MathHelper.cos(move * 0.6662F + (float) Math.PI + raQuad) * 0.45F * swing; + this.leftForeLeg.rotateAngleX = MathHelper.cos(move * 0.6662F + laQuad) * 0.45F * swing; + this.rightHindLeg.rotateAngleX = MathHelper.cos(move * 0.6662F + rlQuad) * 0.45F * swing; + this.leftHindLeg.rotateAngleX = MathHelper.cos(move * 0.6662F + PI + llQuad) * 0.45F * swing; + this.rightForeLeg.rotateAngleZ = 0.0F; + + this.leftForeLeg.rotateAngleZ = 0.0F; + } + + public ModelRenderer getArm(EnumHandSide side) { + return side == EnumHandSide.LEFT ? this.leftForeLeg : this.rightForeLeg; + } +} diff --git a/src/main/java/com/minelittlepony/model/pony/ModelVindicatorPony.java b/src/main/java/com/minelittlepony/model/pony/ModelVindicatorPony.java new file mode 100644 index 00000000..3533c0fd --- /dev/null +++ b/src/main/java/com/minelittlepony/model/pony/ModelVindicatorPony.java @@ -0,0 +1,41 @@ +package com.minelittlepony.model.pony; + +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.monster.EntityVindicator; +import net.minecraft.util.EnumHandSide; +import net.minecraft.util.math.MathHelper; + +public class ModelVindicatorPony extends ModelIllagerPony { + + @Override + public void setRotationAngles(float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scaleFactor, Entity entityIn) { + super.setRotationAngles(limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scaleFactor, entityIn); + + EntityVindicator vindicator = (EntityVindicator) entityIn; + if (vindicator.isAggressive()) { + float f = MathHelper.sin(this.swingProgress * (float) Math.PI); + float f1 = MathHelper.sin((1.0F - (1.0F - this.swingProgress) * (1.0F - this.swingProgress)) * (float) Math.PI); + this.rightForeLeg.rotateAngleZ = 0.0F; + this.leftForeLeg.rotateAngleZ = 0.0F; + + if (((EntityLivingBase) entityIn).getPrimaryHand() == EnumHandSide.RIGHT) { + this.rightForeLeg.rotateAngleX = -1.8849558F + MathHelper.cos(ageInTicks * 0.09F) * 0.15F; +// this.leftForeLeg.rotateAngleX = -0.0F + MathHelper.cos(ageInTicks * 0.19F) * 0.5F; + this.rightForeLeg.rotateAngleX += f * 2.2F - f1 * 0.4F; +// this.leftForeLeg.rotateAngleX += f * 1.2F - f1 * 0.4F; + } else { +// this.rightForeLeg.rotateAngleX = -0.0F + MathHelper.cos(ageInTicks * 0.19F) * 0.5F; + this.leftForeLeg.rotateAngleX = -1.8849558F + MathHelper.cos(ageInTicks * 0.09F) * 0.15F; +// this.rightForeLeg.rotateAngleX += f * 1.2F - f1 * 0.4F; + this.leftForeLeg.rotateAngleX += f * 2.2F - f1 * 0.4F; + } + + this.rightForeLeg.rotateAngleZ += MathHelper.cos(ageInTicks * 0.09F) * 0.05F + 0.05F; + this.leftForeLeg.rotateAngleZ -= MathHelper.cos(ageInTicks * 0.09F) * 0.05F + 0.05F; + this.rightForeLeg.rotateAngleX += MathHelper.sin(ageInTicks * 0.067F) * 0.05F; + this.leftForeLeg.rotateAngleX -= MathHelper.sin(ageInTicks * 0.067F) * 0.05F; + } + } + +} diff --git a/src/main/java/com/minelittlepony/renderer/RenderPonyEvoker.java b/src/main/java/com/minelittlepony/renderer/RenderPonyEvoker.java new file mode 100644 index 00000000..924a7780 --- /dev/null +++ b/src/main/java/com/minelittlepony/renderer/RenderPonyEvoker.java @@ -0,0 +1,58 @@ +package com.minelittlepony.renderer; + +import com.minelittlepony.PonyData; +import com.minelittlepony.PonyDataSerialzier; +import com.minelittlepony.model.pony.ModelEvokerPony; +import com.minelittlepony.model.pony.ModelIllagerPony; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.client.renderer.entity.RenderLiving; +import net.minecraft.client.renderer.entity.RenderManager; +import net.minecraft.client.resources.IResource; +import net.minecraft.client.resources.IResourceManager; +import net.minecraft.entity.monster.EntityEvoker; +import net.minecraft.util.ResourceLocation; + +import java.io.IOException; + +public class RenderPonyEvoker extends RenderLiving { + + private static final ResourceLocation EVOKER = new ResourceLocation("minelittlepony", "textures/entity/illager/evoker_pony.png"); + + public RenderPonyEvoker(RenderManager rendermanagerIn) { + super(rendermanagerIn, new ModelEvokerPony(), 0.5F); + } + + @Override + public void doRender(EntityEvoker entity, double x, double y, double z, float entityYaw, float partialTicks) { + ModelIllagerPony model = (ModelIllagerPony) this.getMainModel(); + + IResourceManager resources = Minecraft.getMinecraft().getResourceManager(); + try { + model.glowColor = 0x4444aa; + model.isUnicorn = false; + IResource resource = resources.getResource(EVOKER); + if (resource.hasMetadata()) { + PonyData meta = resource.getMetadata(PonyDataSerialzier.NAME); + model.isUnicorn = meta.hasMagic(); + model.glowColor = meta.getGlowColor(); + } + } catch (IOException e) { + e.printStackTrace(); + } + + super.doRender(entity, x, y, z, entityYaw, partialTicks); + } + + @Override + protected ResourceLocation getEntityTexture(EntityEvoker entity) { + return EVOKER; + } + + @Override + protected void preRenderCallback(EntityEvoker entitylivingbaseIn, float partialTickTime) { + + GlStateManager.scale(0.9375F, 0.9375F, 0.9375F); + } + +} diff --git a/src/main/java/com/minelittlepony/renderer/RenderPonyVindicator.java b/src/main/java/com/minelittlepony/renderer/RenderPonyVindicator.java new file mode 100644 index 00000000..47095f51 --- /dev/null +++ b/src/main/java/com/minelittlepony/renderer/RenderPonyVindicator.java @@ -0,0 +1,54 @@ +package com.minelittlepony.renderer; + +import com.minelittlepony.PonyData; +import com.minelittlepony.PonyDataSerialzier; +import com.minelittlepony.model.pony.ModelIllagerPony; +import com.minelittlepony.model.pony.ModelVindicatorPony; +import com.minelittlepony.renderer.layer.LayerHeldPonyItem; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.client.renderer.entity.RenderLiving; +import net.minecraft.client.renderer.entity.RenderManager; +import net.minecraft.client.resources.IResource; +import net.minecraft.client.resources.IResourceManager; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.monster.EntityVindicator; +import net.minecraft.util.EnumHandSide; +import net.minecraft.util.ResourceLocation; + +import java.io.IOException; + +public class RenderPonyVindicator extends RenderLiving { + + private static final ResourceLocation VINDICATOR = new ResourceLocation("minelittlepony", "textures/entity/illager/vindicator_pony.png"); + + public RenderPonyVindicator(RenderManager renderManager) { + super(renderManager, new ModelVindicatorPony(), 0.5F); + + this.addLayer(new LayerHeldPonyItem(this) { + @Override + public void doRenderLayer(EntityLivingBase vindicator, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale) { + + if (((EntityVindicator) vindicator).isAggressive()) { + super.doRenderLayer(vindicator, limbSwing, limbSwingAmount, partialTicks, ageInTicks, netHeadYaw, headPitch, scale); + } + } + + @Override + protected void translateToHand(EnumHandSide side) { + ((ModelIllagerPony) this.livingPonyEntity.getMainModel()).getArm(side).postRender(0.0625F); + } + }); + } + + @Override + protected ResourceLocation getEntityTexture(EntityVindicator entity) { + return VINDICATOR; + } + + @Override + protected void preRenderCallback(EntityVindicator entitylivingbaseIn, float partialTickTime) { + GlStateManager.scale(0.9375F, 0.9375F, 0.9375F); + } + +} diff --git a/src/main/java/com/minelittlepony/renderer/layer/LayerHeldPonyItem.java b/src/main/java/com/minelittlepony/renderer/layer/LayerHeldPonyItem.java index 3d6bcde3..d31987ea 100644 --- a/src/main/java/com/minelittlepony/renderer/layer/LayerHeldPonyItem.java +++ b/src/main/java/com/minelittlepony/renderer/layer/LayerHeldPonyItem.java @@ -1,19 +1,13 @@ package com.minelittlepony.renderer.layer; -import static net.minecraft.client.renderer.GlStateManager.*; - -import org.lwjgl.opengl.GL11; -import org.lwjgl.opengl.GL14; - import com.minelittlepony.PonyData; import com.minelittlepony.ducks.IRenderPony; import com.minelittlepony.model.AbstractPonyModel; import com.minelittlepony.model.BodyPart; -import com.minelittlepony.model.PlayerModel; import com.minelittlepony.model.pony.ModelHumanPlayer; import com.minelittlepony.model.pony.ModelPlayerPony; - import net.minecraft.client.Minecraft; +import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelBiped; import net.minecraft.client.model.ModelRenderer; import net.minecraft.client.renderer.GlStateManager; @@ -26,10 +20,14 @@ import net.minecraft.client.renderer.entity.layers.LayerRenderer; import net.minecraft.entity.EntityLivingBase; import net.minecraft.item.ItemStack; import net.minecraft.util.EnumHandSide; +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL14; + +import static net.minecraft.client.renderer.GlStateManager.*; public class LayerHeldPonyItem implements LayerRenderer { - private final RenderLivingBase livingPonyEntity; + protected final RenderLivingBase livingPonyEntity; private LayerHeldItem held; public LayerHeldPonyItem(RenderLivingBase livingPony) { @@ -39,9 +37,9 @@ public class LayerHeldPonyItem implements LayerRenderer { @Override public void doRenderLayer(EntityLivingBase entity, float p_177141_2_, float p_177141_3_, - float partialTicks, float p_177141_5_, float p_177141_6_, float p_177141_7_, float scale) { - PlayerModel pony = ((IRenderPony) livingPonyEntity).getPony(); - if (pony.getModel() instanceof ModelHumanPlayer) { + float partialTicks, float p_177141_5_, float p_177141_6_, float p_177141_7_, float scale) { + ModelBase model = livingPonyEntity.getMainModel(); + if (model instanceof ModelHumanPlayer) { held.doRenderLayer(entity, p_177141_2_, p_177141_3_, partialTicks, p_177141_5_, p_177141_6_, p_177141_7_, scale); return; @@ -52,9 +50,12 @@ public class LayerHeldPonyItem implements LayerRenderer { ItemStack left = mainRight ? itemOff : itemMain; ItemStack right = mainRight ? itemMain : itemOff; - if (left != null || right != null) { + if (!left.isEmpty() || !right.isEmpty()) { pushMatrix(); - pony.getModel().transform(BodyPart.LEGS); + if (model instanceof AbstractPonyModel) { + ((AbstractPonyModel) model).transform(BodyPart.LEGS); + } + if (this.livingPonyEntity.getMainModel().isChild) { translate(0, 0.625, 0); rotate(-20, -1, 0, 0); @@ -71,22 +72,15 @@ public class LayerHeldPonyItem implements LayerRenderer { private void renderHeldItem(EntityLivingBase entity, ItemStack drop, ItemCameraTransforms.TransformType transform, EnumHandSide hand) { if (!drop.isEmpty()) { GlStateManager.pushMatrix(); - AbstractPonyModel thePony = ((IRenderPony) this.livingPonyEntity).getPony().getModel(); - PonyData metadata = thePony.metadata; - boolean isUnicorn = metadata.hasMagic(); - if (isUnicorn) { - ModelPlayerPony playerModel = (ModelPlayerPony) thePony; - ModelRenderer unicornarm = hand == EnumHandSide.LEFT ? playerModel.unicornArmLeft : playerModel.unicornArmRight; - unicornarm.postRender(0.0625F); - } else { - ((ModelBiped) this.livingPonyEntity.getMainModel()).postRenderArm(0.0625F, hand); - } + translateToHand(hand); + if (entity.isSneaking()) { GlStateManager.translate(0.0F, 0.2F, 0.0F); } GlStateManager.rotate(-90.0F, 1.0F, 0.0F, 0.0F); GlStateManager.rotate(180.0F, 0.0F, 1.0F, 0.0F); + boolean isUnicorn = isUnicorn(this.livingPonyEntity.getMainModel()); boolean isLeft = hand == EnumHandSide.LEFT; if (isUnicorn) { GlStateManager.translate(isLeft ? -0.6F : 0.1F, 1, -.5); @@ -96,12 +90,28 @@ public class LayerHeldPonyItem implements LayerRenderer { Minecraft.getMinecraft().getItemRenderer().renderItemSide(entity, drop, transform, isLeft); if (isUnicorn) { + PonyData metadata = ((AbstractPonyModel)this.livingPonyEntity.getMainModel()).metadata; this.renderItemGlow(entity, drop, transform, hand, metadata.getGlowColor()); } GlStateManager.popMatrix(); } } + private static boolean isUnicorn(ModelBase model) { + return model instanceof AbstractPonyModel && ((AbstractPonyModel) model).metadata.hasMagic(); + } + + protected void translateToHand(EnumHandSide hand) { + AbstractPonyModel thePony = ((IRenderPony) this.livingPonyEntity).getPony().getModel(); + if (thePony.metadata.hasMagic()) { + ModelPlayerPony playerModel = (ModelPlayerPony) thePony; + ModelRenderer unicornarm = hand == EnumHandSide.LEFT ? playerModel.unicornArmLeft : playerModel.unicornArmRight; + unicornarm.postRender(0.0625F); + } else { + ((ModelBiped) this.livingPonyEntity.getMainModel()).postRenderArm(0.0625F, hand); + } + } + public void renderItemGlow(EntityLivingBase entity, ItemStack drop, ItemCameraTransforms.TransformType transform, EnumHandSide hand, int glowColor) { // enchantments mess up the rendering diff --git a/src/main/resources/assets/minelittlepony/textures/entity/illager/evoker_pony.png b/src/main/resources/assets/minelittlepony/textures/entity/illager/evoker_pony.png new file mode 100644 index 0000000000000000000000000000000000000000..7df9cf2336b7fb30323ab48a6608dcd232e5fff7 GIT binary patch literal 1586 zcmV-22F>}2P)p*}1;0r| zK~#9!?OI<*TUQwW-Sn1C)4)PWvKdxlU0-~-GK%H46ANYF%b+47I3HHT)fPrdUCW4r zJ_*_fH$^uny5gHHZWM*R_)?e*o6U`_k(GkA28UT|*s?B7Gqvm4LvqgUJ-N9zG1tVz z{2<)(C-;8m`kaq90>A2&sL-G{hy1fw$E1X0{~>% zgLAiCu*baUlG-r1(vF%~C&IP~*kfK)!HNXpsDhOMK-e~cnph`$P6BbkNPes9l5W3v z;>kT$x%b^w^lWTk$U6qJFtmRGaH-p5mj{7B2moM@c>w^E!C6285KMnY0&#(okc;x! zz!Gpu>H&Ml(6iN;oV}@T>@=!i1)bf=;4GWvsBH=f#L*?S5ng#SVF3VnJ&3uvIcl=( zYNjP*LP|+ouD!`DLP-JubVx0x%6znVhJ5tZX#xO(yq>hV*0bO8EDJqT-5BzY<;%XH zqLjtg2~`45{R=ldSBQ!0RVaXfJcjGNSXy?T)zdd0HyL2 zT~Zq>E8D4q4BIBqA+^Aar6Fp}yeZz_=sB|NAt|MV4ylDj0A)FWIP(iU3E4uHJ*xV& zmJcX4t_N?ivN9AZEn%l17F+oQ;>`I~!Aj^FuZeZCka)TFCI(m9Ger@i6*g(vKjTy7 z5$Edet9*$e0VCgB#G&7Rrj9acM&l;|0IRRPi3{%xn?^>%`W-g#yUyc`pzFa~7__w$ z&T0f@7;RX;^S^`TLc3lbk&ytVXGpG!n-Q$&{lI-{F)b^w4|R2z$1 z6j`4cv(Nhkst`{Cue_e(N+@TYCS3p^Ts=Li8}8^*0Dz01{00CR?teXvsO`c(<1-vQ zRn(|W4_#6lQHEMdilGyv3VIxe5sExa5dl^%1hf>*MR^{R!C6K^)_FiE@(>=!VHFXj zfGSuuU#2F5vup`u%-ohEOKA@rpC1tbKyhDQ8Dk(260|ZzoiXUn{P_Hcs!m_>nwy(7 z+r^(kKd3s6dXA+%w9auPBO!$VFW;!1Qzm%Sa}4i2e$0IY?>X;%?t0^T9gXfe7lfVFTK?wXq2`8sTNq$s)X0r_Gr{;yCCJ9-^k zxDt7)%u5IWwAFts^qo9_fyjP5tB)po>cOrSlo_gF*DRN<6XenB*g`ezpjJ`#OMu6f z$W!z=4zTiGAb@C*px0m4OCVQN2-xcci1{QJX1@n)Q>I{=1r%aC+z5ppgM|t#)ONTL z3VlAoq7s<87S#d@d_KX_Gu53u#saWwQ7u3*mMkrRF(EA51_+U1pt_L{iA9>@%Uu` zKy%=%?)|>Ehx509V&?(8@|oJoG7r#Gv=Aihx;&s5?*c>_|8w2>2?YuBA^h6kj!!V- zdq7SE@Oy)~;vh=fYDBHg&|LNkLqSr~1ZaK_xFJ5sO8H_zdA2!U2V@flOYVGt>3Kjl=BF48;o1bV)_gYd z(fXxI{#q6?`W&gfK}6GhLglk~g@8SdlHVJ2TlWdT-?;V+a9j7Kogwni_%K?rfC>Q> k0xASl2&fQHAwUcN0m*~1c1Pg(CjbBd07*qoM6N<$g7U-NlmGw# literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/minelittlepony/textures/entity/illager/evoker_pony.png.mcmeta b/src/main/resources/assets/minelittlepony/textures/entity/illager/evoker_pony.png.mcmeta new file mode 100644 index 00000000..6a6d5d41 --- /dev/null +++ b/src/main/resources/assets/minelittlepony/textures/entity/illager/evoker_pony.png.mcmeta @@ -0,0 +1,6 @@ +{ + "pony": { + "race": "unicorn", + "glowColor": 3730130 + } +} \ No newline at end of file diff --git a/src/main/resources/assets/minelittlepony/textures/entity/illager/vindicator_pony.png b/src/main/resources/assets/minelittlepony/textures/entity/illager/vindicator_pony.png new file mode 100644 index 0000000000000000000000000000000000000000..2818f105ae729409e4feea017fa89280165564e1 GIT binary patch literal 1296 zcmV+r1@HQaP)VGd000McNliru;0qW70yrR_n+5;?1f5Al zK~#9!?OM-k+g2R^JWp-RvL&{X;DZMWl!ehtAP~Gk3#0U~9?aNUmO0Afw?S?!!`aRISD4F5Jl0f6ItI6IS2{O%1= z)-w{5=WuYiO!AXB&z;BH^_ME}9OnZ7@O~cSACCh7p1*!>d3|5E0i`Tqn9JMsmz3jt3V2phS5g3gNH~JkuUDN%fL(d<`h_xAsh3E;9_0g#)u6=$D z2mc&cUY|4ab;WmWNEYA%20)-SX&0Ibpbol)B@%gSJ`@? zwGO6a0M00?k2#<}@1~q`<@oDocKqpVZCfdBXZpNTw{MdEo#Q&ZJrcvxqCJ##Q;YB>$cL}0g)zxl}%o%#A1qcOx@c zs#I{#@5k))#jXd+X!HW2(F-V)mWc{{{RUue4tVuScYf@rvMO${S)^$iymj-20`S(& z8!G*JWCpt$eYYf&`Kx&(&txDycmU+{2J?LgkEy{6p&%`k%EYt|Fap>~;NRCi_#X=k zI6XXUYYpF>JCOGFAZ=~I_wJp#PRL6Te}pQ9%0%?M4rnzC7zXMVvVhV}Hf96o_X3@i z;_)fb{!gs-|Jur}WBUbdKEK^Lec20G*|3>kTwy@3$h8k#>jInGJ8hNQoLdO^;oEOI z(+g~F@3g#_m3ysxlUAPpZ0}E7dycNKfHZ(aF0G_RCG{nVDH)tAz%#W1K^hdKN|WTfcq?fZF%e9CEd+b z*SY`;mbC)*-GY2}9RcjOuXX{+omoH#1*q2K^)^1(29mW1pIc16T^Xn}*wrAIU3;iI zcDj{xWJf3_#&P}XS12BptGRe0h+m)WV_P$->r-U7ay{z3sB zo(QURPBHxtQU?@|%8C^@4ZM*XbcBHT!fh0f%7`!AR*jwH`$ly@&v%9G$}j0PVpInh zS%T}*pjQVtp$-7r-zE*f0|@&i literal 0 HcmV?d00001