Remove randomness from mobs and fix some super issues

Also update mappings
This commit is contained in:
Matthew Messinger 2017-06-16 01:35:02 -04:00
parent a165477108
commit 8b99a03e28
9 changed files with 42 additions and 167 deletions

View file

@ -17,7 +17,7 @@ public class ModelIllagerPony extends ModelPlayerPony {
super.setRotationAngles(swing, move, ageInTicks, netHeadYaw, headPitch, scaleFactor, entityIn); super.setRotationAngles(swing, move, ageInTicks, netHeadYaw, headPitch, scaleFactor, entityIn);
AbstractIllager illager = (AbstractIllager) entityIn; AbstractIllager illager = (AbstractIllager) entityIn;
AbstractIllager.IllagerArmPose pose = illager.func_193077_p(); AbstractIllager.IllagerArmPose pose = illager.getArmPose();
boolean rightHanded = illager.getPrimaryHand() == EnumHandSide.RIGHT; boolean rightHanded = illager.getPrimaryHand() == EnumHandSide.RIGHT;

View file

@ -23,7 +23,7 @@ public class RenderPonyEvoker extends RenderPonyMob<EntityEvoker> {
protected void addLayers() { protected void addLayers() {
this.addLayer(new LayerHeldPonyItem(this) { this.addLayer(new LayerHeldPonyItem(this) {
public void doPonyRender(EntityLivingBase entitylivingbaseIn, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale) { 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); super.doPonyRender(entitylivingbaseIn, limbSwing, limbSwingAmount, partialTicks, ageInTicks, netHeadYaw, headPitch, scale);
} }
} }
@ -41,7 +41,7 @@ public class RenderPonyEvoker extends RenderPonyMob<EntityEvoker> {
@Override @Override
protected void preRenderCallback(EntityEvoker entitylivingbaseIn, float partialTickTime) { protected void preRenderCallback(EntityEvoker entitylivingbaseIn, float partialTickTime) {
super.preRenderCallback(entitylivingbaseIn, partialTickTime);
GlStateManager.scale(0.9375F, 0.9375F, 0.9375F); GlStateManager.scale(0.9375F, 0.9375F, 0.9375F);
} }

View file

@ -3,6 +3,7 @@ package com.minelittlepony.renderer;
import com.minelittlepony.model.PMAPI; import com.minelittlepony.model.PMAPI;
import com.minelittlepony.model.pony.ModelIllagerPony; import com.minelittlepony.model.pony.ModelIllagerPony;
import com.minelittlepony.renderer.layer.LayerHeldPonyItem; import com.minelittlepony.renderer.layer.LayerHeldPonyItem;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.client.renderer.entity.RenderManager;
import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.monster.EntityIllusionIllager; import net.minecraft.entity.monster.EntityIllusionIllager;
@ -23,13 +24,15 @@ public class RenderPonyIllusionIllager extends RenderPonyMob<EntityIllusionIllag
@Override @Override
protected void addLayers() { protected void addLayers() {
this.addLayer(new LayerHeldPonyItem(this) { this.addLayer(new LayerHeldPonyItem(this) {
@Override
public void doPonyRender(EntityLivingBase entitylivingbaseIn, float limbSwing, float limbSwingAmount, float partialTicks, public void doPonyRender(EntityLivingBase entitylivingbaseIn, float limbSwing, float limbSwingAmount, float partialTicks,
float ageInTicks, float netHeadYaw, float headPitch, float scale) { float ageInTicks, float netHeadYaw, float headPitch, float scale) {
if (((EntityIllusionIllager) entitylivingbaseIn).func_193082_dl() || ((EntityIllusionIllager) entitylivingbaseIn).func_193096_dj()) { if (((EntityIllusionIllager) entitylivingbaseIn).isSpellcasting() || ((EntityIllusionIllager) entitylivingbaseIn).isAggressive()) {
super.doPonyRender(entitylivingbaseIn, limbSwing, limbSwingAmount, partialTicks, ageInTicks, netHeadYaw, headPitch, scale); super.doPonyRender(entitylivingbaseIn, limbSwing, limbSwingAmount, partialTicks, ageInTicks, netHeadYaw, headPitch, scale);
} }
} }
@Override
protected void translateToHand(EnumHandSide p_191361_1_) { protected void translateToHand(EnumHandSide p_191361_1_) {
((ModelIllagerPony) this.getRenderer().getMainModel()).getArm(p_191361_1_).postRender(0.0625F); ((ModelIllagerPony) this.getRenderer().getMainModel()).getArm(p_191361_1_).postRender(0.0625F);
} }
@ -41,10 +44,15 @@ public class RenderPonyIllusionIllager extends RenderPonyMob<EntityIllusionIllag
return TEXTURE; return TEXTURE;
} }
protected void preRenderCallback(EntityIllusionIllager entitylivingbaseIn, float partialTickTime) {
super.preRenderCallback(entitylivingbaseIn, partialTickTime);
GlStateManager.scale(0.9375F, 0.9375F, 0.9375F);
}
@Override @Override
public void doRender(EntityIllusionIllager entity, double x, double y, double z, float yaw, float partialTicks) { public void doRender(EntityIllusionIllager entity, double x, double y, double z, float yaw, float partialTicks) {
if (entity.isInvisible()) { if (entity.isInvisible()) {
Vec3d[] avec3d = entity.func_193098_a(partialTicks); Vec3d[] avec3d = entity.getRenderLocations(partialTicks);
float f = this.handleRotationFloat(entity, partialTicks); float f = this.handleRotationFloat(entity, partialTicks);
for (int i = 0; i < avec3d.length; ++i) { for (int i = 0; i < avec3d.length; ++i) {
@ -59,7 +67,8 @@ public class RenderPonyIllusionIllager extends RenderPonyMob<EntityIllusionIllag
} }
} }
protected boolean func_193115_c(EntityIllusionIllager p_193115_1_) { @Override
protected boolean isVisible(EntityIllusionIllager p_193115_1_) {
return true; return true;
} }
} }

View file

@ -14,6 +14,7 @@ import net.minecraft.entity.EntityLiving;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import javax.annotation.OverridingMethodsMustInvokeSuper;
public abstract class RenderPonyMob<T extends EntityLiving> extends RenderLiving<T> implements IRenderPony { public abstract class RenderPonyMob<T extends EntityLiving> extends RenderLiving<T> implements IRenderPony {
@ -46,15 +47,18 @@ public abstract class RenderPonyMob<T extends EntityLiving> extends RenderLiving
} }
@Override @Override
@OverridingMethodsMustInvokeSuper
protected void preRenderCallback(T entity, float partialTickTime) { protected void preRenderCallback(T entity, float partialTickTime) {
this.playerModel.getModel().isSneak = false; this.playerModel.getModel().isSneak = false;
this.playerModel.getModel().isFlying = false; this.playerModel.getModel().isFlying = false;
this.playerModel.getModel().isSleeping = false; this.playerModel.getModel().isSleeping = false;
ResourceLocation loc = getEntityTexture(entity); 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; this.shadowSize = 0.4F;
} else { } else {
this.shadowSize = 0.5F; this.shadowSize = 0.5F;

View file

@ -1,9 +1,5 @@
package com.minelittlepony.renderer; 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.model.PMAPI;
import com.minelittlepony.renderer.layer.LayerPonyStrayOverlay; import com.minelittlepony.renderer.layer.LayerPonyStrayOverlay;
import net.minecraft.client.renderer.GlStateManager; 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.entity.monster.EntityWitherSkeleton;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import java.util.Random;
public class RenderPonySkeleton<Skeleton extends AbstractSkeleton> extends RenderPonyMob<Skeleton> { public class RenderPonySkeleton<Skeleton extends AbstractSkeleton> extends RenderPonyMob<Skeleton> {
private static final ResourceLocation SKELETON = new ResourceLocation("minelittlepony", "textures/entity/skeleton/skeleton_pony.png"); private static final ResourceLocation SKELETON = new ResourceLocation("minelittlepony", "textures/entity/skeleton/skeleton_pony.png");
@ -33,30 +27,6 @@ public class RenderPonySkeleton<Skeleton extends AbstractSkeleton> 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 @Override
protected ResourceLocation getTexture(Skeleton entity) { protected ResourceLocation getTexture(Skeleton entity) {
return SKELETON; return SKELETON;

View file

@ -1,9 +1,6 @@
package com.minelittlepony.renderer; package com.minelittlepony.renderer;
import com.minelittlepony.MineLittlePony;
import com.minelittlepony.model.PMAPI; 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.GlStateManager;
import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.client.renderer.entity.RenderManager;
import net.minecraft.entity.passive.EntityVillager; import net.minecraft.entity.passive.EntityVillager;
@ -11,12 +8,14 @@ import net.minecraft.util.ResourceLocation;
public class RenderPonyVillager extends RenderPonyMob<EntityVillager> { public class RenderPonyVillager extends RenderPonyMob<EntityVillager> {
private static final ResourceLocation GENERIC = new ResourceLocation("minelittlepony", "textures/entity/villager/villager_pony.png"); private static final ResourceLocation[] PROFESSIONS = {
private static final ResourceLocation FARMER = new ResourceLocation("minelittlepony", "textures/entity/villager/farmer_pony.png"); new ResourceLocation("minelittlepony", "textures/entity/villager/farmer_pony.png"),
private static final ResourceLocation LIBRARIAN = new ResourceLocation("minelittlepony", "textures/entity/villager/librarian_pony.png"); new ResourceLocation("minelittlepony", "textures/entity/villager/librarian_pony.png"),
private static final ResourceLocation PRIEST = new ResourceLocation("minelittlepony", "textures/entity/villager/priest_pony.png"); new ResourceLocation("minelittlepony", "textures/entity/villager/priest_pony.png"),
private static final ResourceLocation SMITH = new ResourceLocation("minelittlepony", "textures/entity/villager/smith_pony.png"); new ResourceLocation("minelittlepony", "textures/entity/villager/smith_pony.png"),
private static final ResourceLocation BUTCHER = new ResourceLocation("minelittlepony", "textures/entity/villager/butcher_pony.png"); new ResourceLocation("minelittlepony", "textures/entity/villager/butcher_pony.png"),
new ResourceLocation("minelittlepony", "textures/entity/villager/villager_pony.png")
};
public RenderPonyVillager(RenderManager rm) { public RenderPonyVillager(RenderManager rm) {
super(rm, PMAPI.villager); super(rm, PMAPI.villager);
@ -24,40 +23,12 @@ public class RenderPonyVillager extends RenderPonyMob<EntityVillager> {
@Override @Override
protected void preRenderCallback(EntityVillager villager, float partialTicks) { protected void preRenderCallback(EntityVillager villager, float partialTicks) {
if (villager.getGrowingAge() < 0) { super.preRenderCallback(villager, partialTicks);
this.shadowSize = 0.25F;
} else {
if (MineLittlePony.getConfig().showscale) {
this.shadowSize = 0.4F;
} else {
this.shadowSize = 0.5F;
}
}
((ModelVillagerPony) this.mainModel).profession = villager.getProfession();
GlStateManager.scale(0.9375F, 0.9375F, 0.9375F); GlStateManager.scale(0.9375F, 0.9375F, 0.9375F);
} }
@Override @Override
protected ResourceLocation getTexture(EntityVillager villager) { protected ResourceLocation getTexture(EntityVillager entity) {
return getTextureForVillager(villager.getProfession()); return PROFESSIONS[entity.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;
}
} }
} }

View file

@ -1,9 +1,5 @@
package com.minelittlepony.renderer; 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.model.PMAPI;
import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.entity.RenderManager; 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.entity.monster.EntityZombie;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import java.util.Random;
public class RenderPonyZombie<Zombie extends EntityZombie> extends RenderPonyMob<Zombie> { public class RenderPonyZombie<Zombie extends EntityZombie> extends RenderPonyMob<Zombie> {
private static final ResourceLocation ZOMBIE = new ResourceLocation("minelittlepony", "textures/entity/zombie/zombie_pony.png"); private static final ResourceLocation ZOMBIE = new ResourceLocation("minelittlepony", "textures/entity/zombie/zombie_pony.png");
@ -22,50 +16,6 @@ public class RenderPonyZombie<Zombie extends EntityZombie> extends RenderPonyMob
super(rendermanager, PMAPI.zombie); 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 extends Enum<T>> T randEnum(Random rand, Class<T> en) {
T[] values = en.getEnumConstants();
return values[rand.nextInt(values.length)];
}
@Override @Override
protected ResourceLocation getTexture(Zombie zombie) { protected ResourceLocation getTexture(Zombie zombie) {
return ZOMBIE; return ZOMBIE;

View file

@ -1,19 +1,20 @@
package com.minelittlepony.renderer; package com.minelittlepony.renderer;
import com.minelittlepony.model.PMAPI; import com.minelittlepony.model.PMAPI;
import com.minelittlepony.util.Villagers;
import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.client.renderer.entity.RenderManager;
import net.minecraft.entity.monster.EntityZombieVillager; import net.minecraft.entity.monster.EntityZombieVillager;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
public class RenderPonyZombieVillager extends RenderPonyMob<EntityZombieVillager> { public class RenderPonyZombieVillager extends RenderPonyMob<EntityZombieVillager> {
private static final ResourceLocation GENERIC = new ResourceLocation("minelittlepony", "textures/entity/zombie_villager/zombie_villager_pony.png"); private static final ResourceLocation[] PROFESSIONS = {
private static final ResourceLocation FARMER = new ResourceLocation("minelittlepony", "textures/entity/zombie_villager/zombie_farmer_pony.png"); 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"); 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"); 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"); 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"); 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) { public RenderPonyZombieVillager(RenderManager renderManager) {
super(renderManager, PMAPI.villager); super(renderManager, PMAPI.villager);
@ -21,25 +22,7 @@ public class RenderPonyZombieVillager extends RenderPonyMob<EntityZombieVillager
@Override @Override
protected ResourceLocation getTexture(EntityZombieVillager villager) { protected ResourceLocation getTexture(EntityZombieVillager villager) {
return getTextureForVillager(villager.getProfession()); return PROFESSIONS[villager.getProfession()];
}
private ResourceLocation getTextureForVillager(int profession) {
switch (profession) { // getProfession
case Villagers.FARMER:
return FARMER; // applejack
case Villagers.LIBRARIAN:
return LIBRARIAN; // twilight sparkle
case Villagers.PRIEST:
return PRIEST; // fluttershy
case Villagers.BLACKSMITH:
return SMITH; // rarity
case Villagers.BUTCHER:
return BUTCHER; // rainbow dash
case Villagers.GENERIC:
default:
return GENERIC; // pinkie pie
}
} }
@Override @Override

View file

@ -1,12 +0,0 @@
package com.minelittlepony.util;
public interface Villagers {
int FARMER = 0;
int LIBRARIAN = 1;
int PRIEST = 2;
int BLACKSMITH = 3;
int BUTCHER = 4;
int GENERIC = 5;
}