Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package ruirui.minecraft.livelyanimals;
- import java.util.HashMap;
- import java.util.Map;
- import java.util.Random;
- import java.util.UUID;
- import org.lwjgl.opengl.GL11;
- import net.minecraft.client.model.ModelBase;
- import net.minecraft.client.model.ModelRenderer;
- import net.minecraft.entity.Entity;
- import net.minecraft.entity.EntityLivingBase;
- import net.minecraft.util.MathHelper;
- public class LAModelPig extends ModelBase
- {
- //fields
- ModelRenderer body;
- ModelRenderer FRleg_top;
- ModelRenderer FRleg_bot;
- ModelRenderer FLleg_top;
- ModelRenderer FLleg_bot;
- ModelRenderer BRleg_top;
- ModelRenderer BRleg_bot;
- ModelRenderer BLleg_top;
- ModelRenderer BLleg_bot;
- ModelRenderer belly;
- ModelRenderer tail_base;
- ModelRenderer tail_tip;
- ModelRenderer head;
- ModelRenderer R_ear;
- ModelRenderer L_ear;
- ModelRenderer snout_top;
- ModelRenderer snout_bot;
- Random rand;
- EntityLivingBase entityliving;
- float startingBreath;
- float breath;
- Map uniqueEntities = new HashMap();
- public LAModelPig()
- {
- textureWidth = 64;
- textureHeight = 64;
- body = new ModelRenderer(this, 0, 0);
- body.addBox(-5F, -5F, -9F, 10, 10, 18);
- body.setRotationPoint(0F, 13F, 2F);
- body.setTextureSize(64, 64);
- body.mirror = true;
- setRotation(body, 0F, 0F, 0F);
- FRleg_top = new ModelRenderer(this, 50, 28);
- FRleg_top.addBox(-1.5F, 0F, -1.5F, 3, 7, 3);
- FRleg_top.setRotationPoint(-2.5F, 15F, -4.5F);
- FRleg_top.setTextureSize(64, 64);
- FRleg_top.mirror = true;
- setRotation(FRleg_top, 0F, 0F, 0F);
- FRleg_bot = new ModelRenderer(this, 50, 38);
- FRleg_bot.addBox(-1.5F, 0F, -1.5F, 3, 3, 3);
- FRleg_bot.setRotationPoint(0F, 6F, 0F);
- FRleg_bot.setTextureSize(64, 64);
- FRleg_bot.mirror = true;
- setRotation(FRleg_bot, 0F, 0F, 0F);
- this.FRleg_top.addChild(FRleg_bot);
- FLleg_top = new ModelRenderer(this, 50, 28);
- FLleg_top.addBox(-1.5F, 0F, -1.5F, 3, 7, 3);
- FLleg_top.setRotationPoint(2.5F, 15F, -4.5F);
- FLleg_top.setTextureSize(64, 64);
- FLleg_top.mirror = true;
- setRotation(FLleg_top, 0F, 0F, 0F);
- FLleg_bot = new ModelRenderer(this, 50, 38);
- FLleg_bot.addBox(-1.5F, 0F, -1.5F, 3, 3, 3);
- FLleg_bot.setRotationPoint(0F, 6F, 0F);
- FLleg_bot.setTextureSize(64, 64);
- FLleg_bot.mirror = true;
- setRotation(FLleg_bot, 0F, 0F, 0F);
- this.FLleg_top.addChild(FLleg_bot);
- BRleg_top = new ModelRenderer(this, 50, 44);
- BRleg_top.addBox(-1.5F, 0F, -1.5F, 3, 4, 3);
- BRleg_top.setRotationPoint(-2.5F, 16F, 9F);
- BRleg_top.setTextureSize(64, 32);
- BRleg_top.mirror = true;
- setRotation(BRleg_top, 0F, 0F, 0F);
- BRleg_bot = new ModelRenderer(this, 50, 51);
- BRleg_bot.addBox(-1.5F, 0F, -1.5F, 3, 5, 3);
- BRleg_bot.setRotationPoint(0F, 3F, 0F);
- BRleg_bot.setTextureSize(64, 32);
- BRleg_bot.mirror = true;
- setRotation(BRleg_bot, 0F, 0F, 0F);
- this.BRleg_top.addChild(BRleg_bot);
- BLleg_top = new ModelRenderer(this, 50, 44);
- BLleg_top.addBox(-1.5F, 0F, -1.5F, 3, 4, 3);
- BLleg_top.setRotationPoint(2.473333F, 16F, 9F);
- BLleg_top.setTextureSize(64, 32);
- BLleg_top.mirror = true;
- setRotation(BLleg_top, 0F, 0F, 0F);
- BLleg_bot = new ModelRenderer(this, 50, 51);
- BLleg_bot.addBox(-1.5F, 0F, -1.5F, 3, 5, 3);
- BLleg_bot.setRotationPoint(0F, 3F, 0F);
- BLleg_bot.setTextureSize(64, 32);
- BLleg_bot.mirror = true;
- setRotation(BLleg_bot, 0F, 0F, 0F);
- this.BLleg_top.addChild(BLleg_bot);
- belly = new ModelRenderer(this, 32, 28);
- belly.addBox(-3F, -4.5F, -1F, 6, 10, 3);
- belly.setRotationPoint(0F, 5F, 1.75F);
- belly.setTextureSize(64, 64);
- belly.mirror = true;
- setRotation(belly, 1.570796F, 0F, 0F);
- this.body.addChild(belly);
- tail_base = new ModelRenderer(this, 20, 44);
- tail_base.addBox(-0.5F, -0.5F, 0F, 1, 1, 3);
- tail_base.setRotationPoint(0F, 10F, 10.5F);
- tail_base.setTextureSize(64, 64);
- tail_base.mirror = true;
- setRotation(tail_base, -1.01F, 0F, 0F);
- tail_tip = new ModelRenderer(this, 20, 48);
- tail_tip.addBox(-0.5F, -0.5F, 0F, 1, 1, 3);
- tail_tip.setRotationPoint(0F, 0F, 2.5F);
- tail_tip.setTextureSize(64, 64);
- tail_tip.mirror = true;
- setRotation(tail_tip, -0.347828F, 0F, 0F);
- this.tail_base.addChild(tail_tip);
- head = new ModelRenderer(this, 0, 28);
- head.addBox(-4F, -4F, -8F, 8, 8, 8);
- head.setRotationPoint(0F, 14F, -6F);
- head.setTextureSize(64, 64);
- head.mirror = true;
- setRotation(head, 0F, 0F, 0F);
- R_ear = new ModelRenderer(this, 0, 44);
- R_ear.addBox(-4F, -0.5F, 0F, 4, 1, 6);
- R_ear.setRotationPoint(-3F, -6F, -7F);
- R_ear.setTextureSize(64, 64);
- R_ear.mirror = true;
- setRotation(R_ear, 0.4758862F, 3.004032F, 2.389431F);
- this.head.addChild(R_ear);
- L_ear = new ModelRenderer(this, 0, 44);
- L_ear.addBox(0F, -0.5F, 0F, 4, 1, 6);
- L_ear.setRotationPoint(3F, -6F, -7F);
- L_ear.setTextureSize(64, 64);
- L_ear.mirror = true;
- setRotation(L_ear, -2.617384F, -0.2082002F, 0.781577F);
- this.head.addChild(L_ear);
- snout_top = new ModelRenderer(this, 0, 51);
- snout_top.addBox(-2.5F, -1.5F, -4F, 5, 3, 4);
- snout_top.setRotationPoint(0F, 1F, -8F);
- snout_top.setTextureSize(64, 64);
- snout_top.mirror = true;
- setRotation(snout_top, 0F, 0F, 0F);
- this.head.addChild(snout_top);
- snout_bot = new ModelRenderer(this, 0, 58);
- snout_bot.addBox(-2.5F, 0F, -4F, 5, 1, 4);
- snout_bot.setRotationPoint(0F, 2.5F, -8F);
- snout_bot.setTextureSize(64, 64);
- snout_bot.mirror = true;
- setRotation(snout_bot, 0F, 0F, 0F);
- this.head.addChild(snout_bot);
- }
- public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5)
- {
- super.render(entity, f, f1, f2, f3, f4, f5);
- setRotationAngles(f, f1, f2, f3, f4, f5, entity);
- // Breathing animation
- if(((EntityLivingBase) entity).getHealth() != 0) {
- GL11.glPushMatrix();
- breath = MathHelper.cos(entity.ticksExisted * .1F + randomHelper(entity)) * 0.035F + 1F;
- GL11.glScalef(breath, breath, breath); // Expansion of body
- GL11.glTranslatef(0.0F, 1.0F - breath, 0.0F); // Keeps body centered
- }
- body.render(f5);
- if(((EntityLivingBase) entity).getHealth() != 0) {
- GL11.glPopMatrix();
- }
- FRleg_top.render(f5);
- FLleg_top.render(f5);
- BRleg_top.render(f5);
- BLleg_top.render(f5);
- tail_base.render(f5);
- head.render(f5);
- }
- private void setRotation(ModelRenderer model, float x, float y, float z)
- {
- model.rotateAngleX = x;
- model.rotateAngleY = y;
- model.rotateAngleZ = z;
- }
- public void setRotationAngles (float p_78087_1_, float p_78087_2_, float p_78087_3_, float p_78087_4_, float p_78087_5_, float p_78087_6_, Entity p_78087_7_)
- {
- this.head.rotateAngleX = p_78087_5_ / (180F / (float)Math.PI);
- this.head.rotateAngleY = p_78087_4_ / (180F / (float)Math.PI);
- this.head.rotateAngleX += MathHelper.cos(p_78087_7_.ticksExisted * 0.1F + randomHelper(p_78087_7_)) * 0.025F + 0.025F;
- this.tail_base.rotateAngleX -= MathHelper.cos(p_78087_7_.ticksExisted * 0.1F + randomHelper(p_78087_7_)) * 0.003F;
- float leg_angle = MathHelper.cos(p_78087_1_ * 2.F * 0.6662F) * 1.4F * p_78087_2_;
- float leg_angle2 = MathHelper.cos(p_78087_1_ * 0.6662F * 2.F + (float)Math.PI) * 1.4F * p_78087_2_;
- float leg_angle3 = MathHelper.cos(p_78087_1_ * 2.F ) * p_78087_2_ * 3.F;
- float leg_angle4 = leg_angle3;
- if (leg_angle3 < leg_angle) { leg_angle3 = 0; }
- if (leg_angle4 > leg_angle) { leg_angle4 = 0; }
- this.FLleg_top.rotateAngleX = leg_angle;
- this.FLleg_bot.rotateAngleX = leg_angle3;
- this.FRleg_top.rotateAngleX = leg_angle2;
- this.FRleg_bot.rotateAngleX = leg_angle3;
- this.BLleg_top.rotateAngleX = leg_angle2 + 0.2F;
- this.BLleg_bot.rotateAngleX = leg_angle4 - 0.2F;
- this.BRleg_top.rotateAngleX = leg_angle + 0.2F;
- this.BRleg_bot.rotateAngleX = leg_angle4 - 0.2F;
- }
- public void setLivingAnimations(EntityLivingBase p_78086_1_, float p_78086_2_, float p_78086_3_, float p_78086_4_) {
- }
- /*
- * This function creates a value using each unique entity's
- * Random object. A Hashmap needs to be kept to differentiate
- * between entities. Gonna go back later and try to figure out
- * something more efficient.
- */
- private float randomHelper(Entity entity) {
- if (!uniqueEntities.containsKey(entity.getUniqueID())) {
- if (entity instanceof EntityLivingBase) {
- rand = ((EntityLivingBase) entity).getRNG();
- startingBreath = rand.nextFloat() * (rand.nextInt(5) + 1);
- //System.out.println(startingBreath);
- uniqueEntities.put(entity.getUniqueID(), startingBreath);
- }
- }
- //float test = (Float) uniqueEntities.get(entity.getUniqueID());
- //System.out.println(test);
- return (Float) uniqueEntities.get(entity.getUniqueID());
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement