From 8b99a03e28af2e1d875b09416f9f4266d057fa28 Mon Sep 17 00:00:00 2001 From: Matthew Messinger Date: Fri, 16 Jun 2017 01:35:02 -0400 Subject: [PATCH] Remove randomness from mobs and fix some super issues Also update mappings --- .../model/pony/ModelIllagerPony.java | 2 +- .../renderer/RenderPonyEvoker.java | 4 +- .../renderer/RenderPonyIllusionIllager.java | 17 +++++-- .../renderer/RenderPonyMob.java | 8 ++- .../renderer/RenderPonySkeleton.java | 30 ----------- .../renderer/RenderPonyVillager.java | 51 ++++--------------- .../renderer/RenderPonyZombie.java | 50 ------------------ .../renderer/RenderPonyZombieVillager.java | 35 ++++--------- .../com/minelittlepony/util/Villagers.java | 12 ----- 9 files changed, 42 insertions(+), 167 deletions(-) delete mode 100644 src/main/java/com/minelittlepony/util/Villagers.java diff --git a/src/main/java/com/minelittlepony/model/pony/ModelIllagerPony.java b/src/main/java/com/minelittlepony/model/pony/ModelIllagerPony.java index 4c309c33..067880c7 100644 --- a/src/main/java/com/minelittlepony/model/pony/ModelIllagerPony.java +++ b/src/main/java/com/minelittlepony/model/pony/ModelIllagerPony.java @@ -17,7 +17,7 @@ public class ModelIllagerPony extends ModelPlayerPony { super.setRotationAngles(swing, move, ageInTicks, netHeadYaw, headPitch, scaleFactor, entityIn); AbstractIllager illager = (AbstractIllager) entityIn; - AbstractIllager.IllagerArmPose pose = illager.func_193077_p(); + AbstractIllager.IllagerArmPose pose = illager.getArmPose(); boolean rightHanded = illager.getPrimaryHand() == EnumHandSide.RIGHT; diff --git a/src/main/java/com/minelittlepony/renderer/RenderPonyEvoker.java b/src/main/java/com/minelittlepony/renderer/RenderPonyEvoker.java index c0330819..917461ee 100644 --- a/src/main/java/com/minelittlepony/renderer/RenderPonyEvoker.java +++ b/src/main/java/com/minelittlepony/renderer/RenderPonyEvoker.java @@ -23,7 +23,7 @@ public class RenderPonyEvoker extends RenderPonyMob { protected void addLayers() { this.addLayer(new LayerHeldPonyItem(this) { public void doPonyRender(EntityLivingBase entitylivingbaseIn, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale) { - if (((EntitySpellcasterIllager) entitylivingbaseIn).func_193082_dl()) { + if (((EntitySpellcasterIllager) entitylivingbaseIn).isSpellcasting()) { super.doPonyRender(entitylivingbaseIn, limbSwing, limbSwingAmount, partialTicks, ageInTicks, netHeadYaw, headPitch, scale); } } @@ -41,7 +41,7 @@ public class RenderPonyEvoker extends RenderPonyMob { @Override protected void preRenderCallback(EntityEvoker entitylivingbaseIn, float partialTickTime) { - + super.preRenderCallback(entitylivingbaseIn, partialTickTime); GlStateManager.scale(0.9375F, 0.9375F, 0.9375F); } diff --git a/src/main/java/com/minelittlepony/renderer/RenderPonyIllusionIllager.java b/src/main/java/com/minelittlepony/renderer/RenderPonyIllusionIllager.java index 4db154f3..0029c415 100644 --- a/src/main/java/com/minelittlepony/renderer/RenderPonyIllusionIllager.java +++ b/src/main/java/com/minelittlepony/renderer/RenderPonyIllusionIllager.java @@ -3,6 +3,7 @@ package com.minelittlepony.renderer; import com.minelittlepony.model.PMAPI; import com.minelittlepony.model.pony.ModelIllagerPony; import com.minelittlepony.renderer.layer.LayerHeldPonyItem; +import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.monster.EntityIllusionIllager; @@ -23,13 +24,15 @@ public class RenderPonyIllusionIllager extends RenderPonyMob extends RenderLiving implements IRenderPony { @@ -46,15 +47,18 @@ public abstract class RenderPonyMob extends RenderLiving } @Override + @OverridingMethodsMustInvokeSuper protected void preRenderCallback(T entity, float partialTickTime) { this.playerModel.getModel().isSneak = false; this.playerModel.getModel().isFlying = false; this.playerModel.getModel().isSleeping = false; ResourceLocation loc = getEntityTexture(entity); - this.playerModel.apply(MineLittlePony.getInstance().getManager().getPonyFromResourceRegistry(loc).metadata); + this.playerModel.apply(MineLittlePony.getInstance().getManager().getPony(loc).getMetadata()); - if (MineLittlePony.getConfig().showscale) { + if (mainModel.isChild) { + this.shadowSize = 0.25F; + } else if (MineLittlePony.getConfig().showscale) { this.shadowSize = 0.4F; } else { this.shadowSize = 0.5F; diff --git a/src/main/java/com/minelittlepony/renderer/RenderPonySkeleton.java b/src/main/java/com/minelittlepony/renderer/RenderPonySkeleton.java index 23736ac0..44fb05da 100644 --- a/src/main/java/com/minelittlepony/renderer/RenderPonySkeleton.java +++ b/src/main/java/com/minelittlepony/renderer/RenderPonySkeleton.java @@ -1,9 +1,5 @@ package com.minelittlepony.renderer; -import com.minelittlepony.PonyGender; -import com.minelittlepony.PonyRace; -import com.minelittlepony.PonySize; -import com.minelittlepony.TailLengths; import com.minelittlepony.model.PMAPI; import com.minelittlepony.renderer.layer.LayerPonyStrayOverlay; import net.minecraft.client.renderer.GlStateManager; @@ -14,8 +10,6 @@ import net.minecraft.entity.monster.EntityStray; import net.minecraft.entity.monster.EntityWitherSkeleton; import net.minecraft.util.ResourceLocation; -import java.util.Random; - public class RenderPonySkeleton extends RenderPonyMob { private static final ResourceLocation SKELETON = new ResourceLocation("minelittlepony", "textures/entity/skeleton/skeleton_pony.png"); @@ -33,30 +27,6 @@ public class RenderPonySkeleton extends Rende }); } - @Override - protected void preRenderCallback(Skeleton skeleton, float partialTicks) { - super.preRenderCallback(skeleton, partialTicks); - - Random rand = new Random(skeleton.getUniqueID().hashCode()); - this.playerModel.getModel().metadata.setGender(rand.nextBoolean() ? PonyGender.MARE : PonyGender.STALLION); - switch (rand.nextInt(4)) { - case 0: - case 1: - this.playerModel.getModel().metadata.setRace(PonyRace.UNICORN); - break; - case 2: - this.playerModel.getModel().metadata.setRace(PonyRace.EARTH); - break; - case 3: - this.playerModel.getModel().metadata.setRace(PonyRace.PEGASUS); - } - PonySize[] sizes = PonySize.values(); - PonySize size = sizes[rand.nextInt(sizes.length)]; - this.playerModel.getModel().metadata.setSize(size == PonySize.FOAL ? PonySize.NORMAL : size); - this.playerModel.getModel().metadata.setTail(TailLengths.STUB); - this.playerModel.getModel().metadata.setGlowColor(rand.nextInt()); - } - @Override protected ResourceLocation getTexture(Skeleton entity) { return SKELETON; diff --git a/src/main/java/com/minelittlepony/renderer/RenderPonyVillager.java b/src/main/java/com/minelittlepony/renderer/RenderPonyVillager.java index 11bab18a..03554aae 100644 --- a/src/main/java/com/minelittlepony/renderer/RenderPonyVillager.java +++ b/src/main/java/com/minelittlepony/renderer/RenderPonyVillager.java @@ -1,9 +1,6 @@ package com.minelittlepony.renderer; -import com.minelittlepony.MineLittlePony; import com.minelittlepony.model.PMAPI; -import com.minelittlepony.model.pony.ModelVillagerPony; -import com.minelittlepony.util.Villagers; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.entity.passive.EntityVillager; @@ -11,12 +8,14 @@ import net.minecraft.util.ResourceLocation; public class RenderPonyVillager extends RenderPonyMob { - private static final ResourceLocation GENERIC = new ResourceLocation("minelittlepony", "textures/entity/villager/villager_pony.png"); - private static final ResourceLocation FARMER = new ResourceLocation("minelittlepony", "textures/entity/villager/farmer_pony.png"); - private static final ResourceLocation LIBRARIAN = new ResourceLocation("minelittlepony", "textures/entity/villager/librarian_pony.png"); - private static final ResourceLocation PRIEST = new ResourceLocation("minelittlepony", "textures/entity/villager/priest_pony.png"); - private static final ResourceLocation SMITH = new ResourceLocation("minelittlepony", "textures/entity/villager/smith_pony.png"); - private static final ResourceLocation BUTCHER = new ResourceLocation("minelittlepony", "textures/entity/villager/butcher_pony.png"); + private static final ResourceLocation[] PROFESSIONS = { + new ResourceLocation("minelittlepony", "textures/entity/villager/farmer_pony.png"), + new ResourceLocation("minelittlepony", "textures/entity/villager/librarian_pony.png"), + new ResourceLocation("minelittlepony", "textures/entity/villager/priest_pony.png"), + new ResourceLocation("minelittlepony", "textures/entity/villager/smith_pony.png"), + new ResourceLocation("minelittlepony", "textures/entity/villager/butcher_pony.png"), + new ResourceLocation("minelittlepony", "textures/entity/villager/villager_pony.png") + }; public RenderPonyVillager(RenderManager rm) { super(rm, PMAPI.villager); @@ -24,40 +23,12 @@ public class RenderPonyVillager extends RenderPonyMob { @Override protected void preRenderCallback(EntityVillager villager, float partialTicks) { - if (villager.getGrowingAge() < 0) { - this.shadowSize = 0.25F; - } else { - if (MineLittlePony.getConfig().showscale) { - this.shadowSize = 0.4F; - } else { - this.shadowSize = 0.5F; - } - } - ((ModelVillagerPony) this.mainModel).profession = villager.getProfession(); - + super.preRenderCallback(villager, partialTicks); GlStateManager.scale(0.9375F, 0.9375F, 0.9375F); } @Override - protected ResourceLocation getTexture(EntityVillager villager) { - return getTextureForVillager(villager.getProfession()); - } - - private ResourceLocation getTextureForVillager(int profession) { - switch (profession) { - case Villagers.FARMER: - return FARMER; - case Villagers.LIBRARIAN: - return LIBRARIAN; - case Villagers.PRIEST: - return PRIEST; - case Villagers.BLACKSMITH: - return SMITH; - case Villagers.BUTCHER: - return BUTCHER; - case Villagers.GENERIC: - default: - return GENERIC; - } + protected ResourceLocation getTexture(EntityVillager entity) { + return PROFESSIONS[entity.getProfession()]; } } diff --git a/src/main/java/com/minelittlepony/renderer/RenderPonyZombie.java b/src/main/java/com/minelittlepony/renderer/RenderPonyZombie.java index 36822192..23cc1df0 100644 --- a/src/main/java/com/minelittlepony/renderer/RenderPonyZombie.java +++ b/src/main/java/com/minelittlepony/renderer/RenderPonyZombie.java @@ -1,9 +1,5 @@ package com.minelittlepony.renderer; -import com.minelittlepony.PonyGender; -import com.minelittlepony.PonyRace; -import com.minelittlepony.PonySize; -import com.minelittlepony.TailLengths; import com.minelittlepony.model.PMAPI; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.entity.RenderManager; @@ -11,8 +7,6 @@ import net.minecraft.entity.monster.EntityHusk; import net.minecraft.entity.monster.EntityZombie; import net.minecraft.util.ResourceLocation; -import java.util.Random; - public class RenderPonyZombie extends RenderPonyMob { private static final ResourceLocation ZOMBIE = new ResourceLocation("minelittlepony", "textures/entity/zombie/zombie_pony.png"); @@ -22,50 +16,6 @@ public class RenderPonyZombie extends RenderPonyMob super(rendermanager, PMAPI.zombie); } - @Override - protected void preRenderCallback(Zombie entity, float partick) { - super.preRenderCallback(entity, partick); - Random rand = new Random(entity.getUniqueID().hashCode()); - - // 50-50 chance for gender - this.playerModel.getModel().metadata.setGender(rand.nextBoolean() ? PonyGender.MARE : PonyGender.STALLION); - - // races - switch (rand.nextInt(2) + 2) { - case 0: - case 1: - this.playerModel.getModel().metadata.setRace(PonyRace.EARTH); - break; - case 2: - this.playerModel.getModel().metadata.setRace(PonyRace.PEGASUS); - break; - case 3: - this.playerModel.getModel().metadata.setRace(PonyRace.UNICORN); - break; - } - // Let's play the lottery! - if (rand.nextInt(10000) == 0) { - this.playerModel.getModel().metadata.setRace(PonyRace.ALICORN); - } - // sizes - if (entity.isChild()) { - this.playerModel.getModel().metadata.setSize(PonySize.FOAL); - } else { - PonySize size = randEnum(rand, PonySize.class); - this.playerModel.getModel().metadata.setSize(size != PonySize.FOAL ? size : PonySize.NORMAL); - } - this.playerModel.getModel().metadata.setTail(randEnum(rand, TailLengths.class)); - - // glow - this.playerModel.getModel().metadata.setGlowColor(rand.nextInt()); - - } - - private static > T randEnum(Random rand, Class en) { - T[] values = en.getEnumConstants(); - return values[rand.nextInt(values.length)]; - } - @Override protected ResourceLocation getTexture(Zombie zombie) { return ZOMBIE; diff --git a/src/main/java/com/minelittlepony/renderer/RenderPonyZombieVillager.java b/src/main/java/com/minelittlepony/renderer/RenderPonyZombieVillager.java index 36cae438..f2abb3b5 100644 --- a/src/main/java/com/minelittlepony/renderer/RenderPonyZombieVillager.java +++ b/src/main/java/com/minelittlepony/renderer/RenderPonyZombieVillager.java @@ -1,19 +1,20 @@ package com.minelittlepony.renderer; import com.minelittlepony.model.PMAPI; -import com.minelittlepony.util.Villagers; import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.entity.monster.EntityZombieVillager; import net.minecraft.util.ResourceLocation; public class RenderPonyZombieVillager extends RenderPonyMob { - private static final ResourceLocation GENERIC = new ResourceLocation("minelittlepony", "textures/entity/zombie_villager/zombie_villager_pony.png"); - private static final ResourceLocation FARMER = new ResourceLocation("minelittlepony", "textures/entity/zombie_villager/zombie_farmer_pony.png"); - private static final ResourceLocation LIBRARIAN = new ResourceLocation("minelittlepony", "textures/entity/zombie_villager/zombie_librarian_pony.png"); - private static final ResourceLocation PRIEST = new ResourceLocation("minelittlepony", "textures/entity/zombie_villager/zombie_priest_pony.png"); - private static final ResourceLocation SMITH = new ResourceLocation("minelittlepony", "textures/entity/zombie_villager/zombie_smith_pony.png"); - private static final ResourceLocation BUTCHER = new ResourceLocation("minelittlepony", "textures/entity/zombie_villager/zombie_butcher_pony.png"); + private static final ResourceLocation[] PROFESSIONS = { + new ResourceLocation("minelittlepony", "textures/entity/zombie_villager/zombie_farmer_pony.png"), + new ResourceLocation("minelittlepony", "textures/entity/zombie_villager/zombie_librarian_pony.png"), + new ResourceLocation("minelittlepony", "textures/entity/zombie_villager/zombie_priest_pony.png"), + new ResourceLocation("minelittlepony", "textures/entity/zombie_villager/zombie_smith_pony.png"), + new ResourceLocation("minelittlepony", "textures/entity/zombie_villager/zombie_butcher_pony.png"), + new ResourceLocation("minelittlepony", "textures/entity/zombie_villager/zombie_villager_pony.png") + }; public RenderPonyZombieVillager(RenderManager renderManager) { super(renderManager, PMAPI.villager); @@ -21,25 +22,7 @@ public class RenderPonyZombieVillager extends RenderPonyMob