mirror of
https://github.com/MineLittlePony/MineLittlePony.git
synced 2024-11-25 22:07:59 +01:00
Split the mob rendering apart into their own classes.
Add some randomness for mob metadata.
This commit is contained in:
parent
f56cea3597
commit
9dd9384d77
7 changed files with 72 additions and 59 deletions
|
@ -204,7 +204,7 @@ public abstract class ModelPony extends ModelPlayer {
|
||||||
rotate(180.0F, 0.0F, 1.0F, 0.0F);
|
rotate(180.0F, 0.0F, 1.0F, 0.0F);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.metadata.getSize() == PonySize.FOAL) {
|
if (this.metadata.getSize() == PonySize.FOAL || isChild) {
|
||||||
if (this.isSneak && !this.isFlying && !this.isArmour) {
|
if (this.isSneak && !this.isFlying && !this.isArmour) {
|
||||||
translate(0.0F, -0.12F, 0.0F);
|
translate(0.0F, -0.12F, 0.0F);
|
||||||
}
|
}
|
||||||
|
|
|
@ -507,7 +507,7 @@ public class pm_newPonyAdv extends ModelPony implements PonyModelConstants {
|
||||||
rotate(180.0F, 0.0F, 1.0F, 0.0F);
|
rotate(180.0F, 0.0F, 1.0F, 0.0F);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.metadata.getSize() == PonySize.FOAL) {
|
if (this.metadata.getSize() == PonySize.FOAL || isChild) {
|
||||||
if (this.isSneak && !this.isFlying && !this.isArmour) {
|
if (this.isSneak && !this.isFlying && !this.isArmour) {
|
||||||
translate(0.0F, -0.12F, 0.0F);
|
translate(0.0F, -0.12F, 0.0F);
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,7 @@ public class pm_zombiePony extends pm_newPonyAdv {
|
||||||
float leftLegRotateAngleX;
|
float leftLegRotateAngleX;
|
||||||
float var8;
|
float var8;
|
||||||
float var9;
|
float var9;
|
||||||
|
// why are zombies flying?
|
||||||
if (this.isFlying && this.metadata.getRace().hasWings()) {
|
if (this.isFlying && this.metadata.getRace().hasWings()) {
|
||||||
if (this.rainboom) {
|
if (this.rainboom) {
|
||||||
rightArmRotateAngleX = ROTATE_270;
|
rightArmRotateAngleX = ROTATE_270;
|
||||||
|
|
|
@ -15,12 +15,11 @@ import net.minecraft.client.renderer.entity.RenderManager;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.entity.EntityLiving;
|
import net.minecraft.entity.EntityLiving;
|
||||||
import net.minecraft.entity.EntityLivingBase;
|
import net.minecraft.entity.EntityLivingBase;
|
||||||
import net.minecraft.entity.monster.EntityPigZombie;
|
|
||||||
import net.minecraft.entity.monster.EntitySkeleton;
|
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
|
||||||
public abstract class RenderPonyMob<T extends EntityLiving> extends RenderLiving implements IRenderPony {
|
public abstract class RenderPonyMob<T extends EntityLiving> extends RenderLiving implements IRenderPony {
|
||||||
|
|
||||||
protected ModelPony mobModel;
|
protected ModelPony mobModel;
|
||||||
protected PlayerModel playerModel;
|
protected PlayerModel playerModel;
|
||||||
|
|
||||||
|
@ -36,68 +35,23 @@ public abstract class RenderPonyMob<T extends EntityLiving> extends RenderLiving
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void doRender(EntityLiving entity, double xPosition, double yPosition, double zPosition, float yaw,
|
public void doRender(Entity entity, double xPosition, double yPosition, double zPosition, float yaw,
|
||||||
float partialTicks) {
|
float partialTicks) {
|
||||||
ItemStack heldItem = entity.getHeldItem();
|
|
||||||
this.playerModel.getModel().heldItemRight = heldItem == null ? 0 : 1;
|
|
||||||
|
|
||||||
this.playerModel.getModel().isSneak = false;
|
|
||||||
this.playerModel.getModel().isFlying = false;
|
|
||||||
|
|
||||||
if (entity instanceof EntitySkeleton) {
|
|
||||||
|
|
||||||
switch (entity.getUniqueID().hashCode() % 3) {
|
|
||||||
case 0:
|
|
||||||
case 1:
|
|
||||||
this.playerModel.getModel().metadata.setRace(PonyRace.UNICORN);
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
this.playerModel.getModel().metadata.setRace(PonyRace.EARTH);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
this.playerModel.getModel().metadata.setRace(PonyRace.EARTH);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (entity instanceof EntityPigZombie) {
|
|
||||||
this.playerModel.getModel().metadata.setGender(PonyGender.STALLION);
|
|
||||||
} else {
|
|
||||||
this.playerModel.getModel().metadata.setGender(PonyGender.MARE);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (entity instanceof EntitySkeleton) {
|
|
||||||
this.playerModel.getModel().metadata.setTail(TailLengths.STUB);
|
|
||||||
} else {
|
|
||||||
this.playerModel.getModel().metadata.setTail(TailLengths.FULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.playerModel.getModel().isSleeping = false;
|
|
||||||
if (MineLittlePony.getConfig().getShowScale().get()) {
|
|
||||||
this.shadowSize = 0.4F;
|
|
||||||
}
|
|
||||||
|
|
||||||
double yOrigin = yPosition;
|
double yOrigin = yPosition;
|
||||||
if (entity.isSneaking()) {
|
if (entity.isSneaking()) {
|
||||||
yOrigin -= 0.125D;
|
yOrigin -= 0.125D;
|
||||||
}
|
}
|
||||||
|
|
||||||
super.doRender(entity, xPosition, yOrigin, zPosition, yaw, partialTicks);
|
super.doRender(entity, xPosition, yOrigin, zPosition, yaw, partialTicks);
|
||||||
this.playerModel.getModel().aimedBow = false;
|
this.playerModel.getModel().aimedBow = false;
|
||||||
this.playerModel.getModel().isSneak = false;
|
this.playerModel.getModel().isSneak = false;
|
||||||
this.playerModel.getModel().heldItemRight = 0;
|
this.playerModel.getModel().heldItemRight = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
@Override
|
|
||||||
public void doRender(Entity entity, double xPosition, double yPosition, double zPosition, float yaw,
|
|
||||||
float partialTicks) {
|
|
||||||
this.doRender((T) entity, xPosition, yPosition, zPosition, yaw, partialTicks);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected abstract ResourceLocation getEntityTexture(T var1);
|
protected abstract ResourceLocation getEntityTexture(T var1);
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@Override
|
@Override
|
||||||
protected ResourceLocation getEntityTexture(Entity var1) {
|
protected final ResourceLocation getEntityTexture(Entity var1) {
|
||||||
return this.getEntityTexture((T) var1);
|
return this.getEntityTexture((T) var1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -105,7 +59,23 @@ public abstract class RenderPonyMob<T extends EntityLiving> extends RenderLiving
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@Override
|
@Override
|
||||||
protected void preRenderCallback(EntityLivingBase entitylivingbaseIn, float partialTickTime) {
|
protected final void preRenderCallback(EntityLivingBase entitylivingbaseIn, float partialTickTime) {
|
||||||
|
|
||||||
|
ItemStack heldItem = entitylivingbaseIn.getHeldItem();
|
||||||
|
this.playerModel.getModel().heldItemRight = heldItem == null ? 0 : 1;
|
||||||
|
|
||||||
|
this.playerModel.getModel().isSneak = false;
|
||||||
|
this.playerModel.getModel().isFlying = false;
|
||||||
|
this.playerModel.getModel().isSleeping = false;
|
||||||
|
|
||||||
|
this.playerModel.getModel().metadata.setRace(PonyRace.EARTH);
|
||||||
|
this.playerModel.getModel().metadata.setGender(PonyGender.MARE);
|
||||||
|
this.playerModel.getModel().metadata.setTail(TailLengths.FULL);
|
||||||
|
|
||||||
|
if (MineLittlePony.getConfig().getShowScale().get()) {
|
||||||
|
this.shadowSize = 0.4F;
|
||||||
|
}
|
||||||
|
|
||||||
preRenderCallback((T) entitylivingbaseIn, partialTickTime);
|
preRenderCallback((T) entitylivingbaseIn, partialTickTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -115,7 +85,7 @@ public abstract class RenderPonyMob<T extends EntityLiving> extends RenderLiving
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@Override
|
@Override
|
||||||
protected void rotateCorpse(EntityLivingBase entity, float xPosition, float yPosition, float zPosition) {
|
protected final void rotateCorpse(EntityLivingBase entity, float xPosition, float yPosition, float zPosition) {
|
||||||
this.rotateCorpse((T) entity, xPosition, yPosition, zPosition);
|
this.rotateCorpse((T) entity, xPosition, yPosition, zPosition);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,15 @@
|
||||||
package com.brohoof.minelittlepony.renderer;
|
package com.brohoof.minelittlepony.renderer;
|
||||||
|
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
import com.brohoof.minelittlepony.PonyManager;
|
import com.brohoof.minelittlepony.PonyManager;
|
||||||
|
import com.brohoof.minelittlepony.PonyRace;
|
||||||
|
import com.brohoof.minelittlepony.TailLengths;
|
||||||
import com.brohoof.minelittlepony.model.PMAPI;
|
import com.brohoof.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;
|
||||||
import net.minecraft.client.renderer.entity.layers.LayerBipedArmor;
|
import net.minecraft.client.renderer.entity.layers.LayerBipedArmor;
|
||||||
import net.minecraft.entity.EntityLivingBase;
|
|
||||||
import net.minecraft.entity.monster.EntitySkeleton;
|
import net.minecraft.entity.monster.EntitySkeleton;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
|
||||||
|
@ -28,10 +31,17 @@ public class RenderPonySkeleton extends RenderPonyMob<EntitySkeleton> {
|
||||||
GlStateManager.scale(1.2F, 1.2F, 1.2F);
|
GlStateManager.scale(1.2F, 1.2F, 1.2F);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Random rand = new Random(skeleton.getUniqueID().hashCode());
|
||||||
|
switch (rand.nextInt() % 3) {
|
||||||
|
case 0:
|
||||||
|
case 1:
|
||||||
|
this.playerModel.getModel().metadata.setRace(PonyRace.UNICORN);
|
||||||
|
this.playerModel.getModel().metadata.setGlowColor(rand.nextInt());
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
this.playerModel.getModel().metadata.setRace(PonyRace.EARTH);
|
||||||
}
|
}
|
||||||
|
this.playerModel.getModel().metadata.setTail(TailLengths.STUB);
|
||||||
protected void a(EntityLivingBase entity, float partialTicks) {
|
|
||||||
this.preRenderCallback((EntitySkeleton) entity, partialTicks);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
package com.brohoof.minelittlepony.renderer;
|
package com.brohoof.minelittlepony.renderer;
|
||||||
|
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
|
import com.brohoof.minelittlepony.PonyGender;
|
||||||
import com.brohoof.minelittlepony.PonyManager;
|
import com.brohoof.minelittlepony.PonyManager;
|
||||||
|
import com.brohoof.minelittlepony.PonyRace;
|
||||||
import com.brohoof.minelittlepony.model.PMAPI;
|
import com.brohoof.minelittlepony.model.PMAPI;
|
||||||
|
|
||||||
import net.minecraft.client.renderer.entity.RenderManager;
|
import net.minecraft.client.renderer.entity.RenderManager;
|
||||||
|
@ -14,10 +18,38 @@ public class RenderPonyZombie extends RenderPonyMob<EntityZombie> {
|
||||||
super(rendermanager, PMAPI.zombie);
|
super(rendermanager, PMAPI.zombie);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void preRenderCallback(EntityZombie entity, float partick) {
|
||||||
|
Random rand = new Random(entity.getUniqueID().hashCode());
|
||||||
|
|
||||||
|
// 50-50 chance for gender
|
||||||
|
this.playerModel.getModel().metadata.setGender(rand.nextBoolean() ? PonyGender.MARE : PonyGender.STALLION);
|
||||||
|
|
||||||
|
switch (rand.nextInt(5)) {
|
||||||
|
case 0:
|
||||||
|
case 1:
|
||||||
|
case 2:
|
||||||
|
this.playerModel.getModel().metadata.setRace(PonyRace.EARTH);
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
this.playerModel.getModel().metadata.setRace(PonyRace.PEGASUS);
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
this.playerModel.getModel().metadata.setRace(PonyRace.UNICORN);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
this.playerModel.getModel().metadata.setGlowColor(rand.nextInt());
|
||||||
|
// Let's play the lottery!
|
||||||
|
if (rand.nextInt(10000) == 0) {
|
||||||
|
this.playerModel.getModel().metadata.setRace(PonyRace.ALICORN);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void rotateCorpse(EntityZombie zombie, float xPosition, float yPosition, float zPosition) {
|
protected void rotateCorpse(EntityZombie zombie, float xPosition, float yPosition, float zPosition) {
|
||||||
|
super.rotateCorpse(zombie, xPosition, yPosition, zPosition);
|
||||||
if (zombie.isConverting()) {
|
if (zombie.isConverting()) {
|
||||||
yPosition += (float) (Math.cos(zombie.ticksExisted * 3.25D) * 3.141592653589793D * 0.25D);
|
yPosition += (float) (Math.cos(zombie.ticksExisted * 3.25D) * Math.PI * 0.25D);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 4.7 KiB After Width: | Height: | Size: 5.1 KiB |
Loading…
Reference in a new issue