Permalink
Browse files

Fixed the marine item renderer.

  • Loading branch information...
Ri5ux committed Oct 23, 2017
1 parent 4e22b1a commit 7c97255c0f362f1abc32f89ae751eb2505821430
@@ -2,119 +2,229 @@
import com.arisux.mdx.lib.client.Model;
import net.minecraft.client.model.ModelBase;
import net.minecraft.client.model.ModelBiped;
import net.minecraft.client.model.ModelRenderer;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.util.EnumHandSide;
import net.minecraft.util.math.MathHelper;
public class ModelMarine extends Model
{
public ModelRenderer bipedHead, bipedHeadwear, bipedBody, bipedRightArm, bipedLeftArm, bipedRightLeg, bipedLeftLeg, bipedEars, bipedCloak;
public int heldItemLeft;
public int heldItemRight;
public boolean isSneak;
public boolean aimedBow;
public ModelRenderer bipedHead;
public ModelRenderer bipedHeadwear;
public ModelRenderer bipedBody;
public ModelRenderer bipedRightArm;
public ModelRenderer bipedLeftArm;
public ModelRenderer bipedRightLeg;
public ModelRenderer bipedLeftLeg;
public ModelBiped.ArmPose leftArmPose;
public ModelBiped.ArmPose rightArmPose;
public boolean isSneak;
public ModelMarine()
{
this.heldItemLeft = 0;
this.heldItemRight = 0;
this.isSneak = false;
this.aimedBow = false;
this.textureWidth = 64;
this.textureHeight = 32;
this.bipedCloak = new ModelRenderer(this, 0, 0);
this.bipedCloak.addBox(-5.0F, 0.0F, -1.0F, 10, 16, 1, 0F);
this.bipedEars = new ModelRenderer(this, 24, 0);
this.bipedEars.addBox(-3.0F, -6.0F, -1.0F, 6, 6, 1, 0F);
this(0.0F);
}
public ModelMarine(float modelSize)
{
this(modelSize, 0.0F, 64, 32);
}
public ModelMarine(float modelSize, float p_i1149_2_, int textureWidthIn, int textureHeightIn)
{
this.leftArmPose = ModelBiped.ArmPose.EMPTY;
this.rightArmPose = ModelBiped.ArmPose.EMPTY;
this.textureWidth = textureWidthIn;
this.textureHeight = textureHeightIn;
this.bipedHead = new ModelRenderer(this, 0, 0);
this.bipedHead.addBox(-4.0F, -8.0F, -4.0F, 8, 8, 8, 0F);
this.bipedHead.setRotationPoint(0.0F, 0.0F, 0.0F);
this.bipedHead.addBox(-4.0F, -8.0F, -4.0F, 8, 8, 8, modelSize);
this.bipedHead.setRotationPoint(0.0F, 0.0F + p_i1149_2_, 0.0F);
this.bipedHeadwear = new ModelRenderer(this, 32, 0);
this.bipedHeadwear.addBox(-4.0F, -8.0F, -4.0F, 8, 8, 8, 0F + 0.5F);
this.bipedHeadwear.setRotationPoint(0.0F, 0.0F, 0.0F);
this.bipedHeadwear.addBox(-4.0F, -8.0F, -4.0F, 8, 8, 8, modelSize + 0.5F);
this.bipedHeadwear.setRotationPoint(0.0F, 0.0F + p_i1149_2_, 0.0F);
this.bipedBody = new ModelRenderer(this, 16, 16);
this.bipedBody.addBox(-4.0F, 0.0F, -2.0F, 8, 12, 4, 0F);
this.bipedBody.setRotationPoint(0.0F, 0.0F, 0.0F);
this.bipedBody.addBox(-4.0F, 0.0F, -2.0F, 8, 12, 4, modelSize);
this.bipedBody.setRotationPoint(0.0F, 0.0F + p_i1149_2_, 0.0F);
this.bipedRightArm = new ModelRenderer(this, 40, 16);
this.bipedRightArm.addBox(-3.0F, -2.0F, -2.0F, 4, 12, 4, 0F);
this.bipedRightArm.setRotationPoint(-5.0F, 2.0F, 0.0F);
this.bipedRightArm.addBox(-3.0F, -2.0F, -2.0F, 4, 12, 4, modelSize);
this.bipedRightArm.setRotationPoint(-5.0F, 2.0F + p_i1149_2_, 0.0F);
this.bipedLeftArm = new ModelRenderer(this, 40, 16);
this.bipedLeftArm.mirror = true;
this.bipedLeftArm.addBox(-1.0F, -2.0F, -2.0F, 4, 12, 4, 0F);
this.bipedLeftArm.setRotationPoint(5.0F, 2.0F, 0.0F);
this.bipedLeftArm.addBox(-1.0F, -2.0F, -2.0F, 4, 12, 4, modelSize);
this.bipedLeftArm.setRotationPoint(5.0F, 2.0F + p_i1149_2_, 0.0F);
this.bipedRightLeg = new ModelRenderer(this, 0, 16);
this.bipedRightLeg.addBox(-2.0F, 0.0F, -2.0F, 4, 12, 4, 0F);
this.bipedRightLeg.setRotationPoint(-1.9F, 12.0F, 0.0F);
this.bipedRightLeg.addBox(-2.0F, 0.0F, -2.0F, 4, 12, 4, modelSize);
this.bipedRightLeg.setRotationPoint(-1.9F, 12.0F + p_i1149_2_, 0.0F);
this.bipedLeftLeg = new ModelRenderer(this, 0, 16);
this.bipedLeftLeg.mirror = true;
this.bipedLeftLeg.addBox(-2.0F, 0.0F, -2.0F, 4, 12, 4, 0F);
this.bipedLeftLeg.setRotationPoint(1.9F, 12.0F, 0.0F);
this.bipedLeftLeg.addBox(-2.0F, 0.0F, -2.0F, 4, 12, 4, modelSize);
this.bipedLeftLeg.setRotationPoint(1.9F, 12.0F + p_i1149_2_, 0.0F);
}
@Override
public void render(Object obj)
/**
* Sets the models various rotation angles then renders the model.
*/
public void render(Entity entityIn, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scale)
{
EntityLivingBase base = (EntityLivingBase) obj;;
this.bipedHead.rotateAngleY = headYaw(obj) / (180F / (float) Math.PI);
this.bipedHead.rotateAngleX = headPitch(obj) / (180F / (float) Math.PI);
this.bipedHeadwear.rotateAngleY = this.bipedHead.rotateAngleY;
this.bipedHeadwear.rotateAngleX = this.bipedHead.rotateAngleX;
this.bipedRightArm.rotateAngleX = MathHelper.cos(swingProgress(obj) * 0.6662F + (float) Math.PI) * 2.0F * swingProgressPrev(obj) * 0.5F;
this.bipedLeftArm.rotateAngleX = MathHelper.cos(swingProgress(obj) * 0.6662F) * 2.0F * swingProgressPrev(obj) * 0.5F;
this.setRotationAngles(limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scale, entityIn);
GlStateManager.pushMatrix();
if (this.isChild)
{
float f = 2.0F;
GlStateManager.scale(0.75F, 0.75F, 0.75F);
GlStateManager.translate(0.0F, 16.0F * scale, 0.0F);
this.bipedHead.render(scale);
GlStateManager.popMatrix();
GlStateManager.pushMatrix();
GlStateManager.scale(0.5F, 0.5F, 0.5F);
GlStateManager.translate(0.0F, 24.0F * scale, 0.0F);
this.bipedBody.render(scale);
this.bipedRightArm.render(scale);
this.bipedLeftArm.render(scale);
this.bipedRightLeg.render(scale);
this.bipedLeftLeg.render(scale);
this.bipedHeadwear.render(scale);
}
else
{
if (entityIn.isSneaking())
{
GlStateManager.translate(0.0F, 0.2F, 0.0F);
}
this.bipedHead.render(scale);
this.bipedBody.render(scale);
this.bipedRightArm.render(scale);
this.bipedLeftArm.render(scale);
this.bipedRightLeg.render(scale);
this.bipedLeftLeg.render(scale);
this.bipedHeadwear.render(scale);
}
GlStateManager.popMatrix();
}
@SuppressWarnings("incomplete-switch")
public void setRotationAngles(float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scaleFactor, Entity entityIn)
{
boolean flag = entityIn instanceof EntityLivingBase && ((EntityLivingBase) entityIn).getTicksElytraFlying() > 4;
this.bipedHead.rotateAngleY = netHeadYaw * 0.017453292F;
if (flag)
{
this.bipedHead.rotateAngleX = -((float) Math.PI / 4F);
}
else
{
this.bipedHead.rotateAngleX = headPitch * 0.017453292F;
}
this.bipedBody.rotateAngleY = 0.0F;
this.bipedRightArm.rotationPointZ = 0.0F;
this.bipedRightArm.rotationPointX = -5.0F;
this.bipedLeftArm.rotationPointZ = 0.0F;
this.bipedLeftArm.rotationPointX = 5.0F;
float f = 1.0F;
if (flag)
{
f = (float) (entityIn.motionX * entityIn.motionX + entityIn.motionY * entityIn.motionY + entityIn.motionZ * entityIn.motionZ);
f = f / 0.2F;
f = f * f * f;
}
if (f < 1.0F)
{
f = 1.0F;
}
this.bipedRightArm.rotateAngleX = MathHelper.cos(limbSwing * 0.6662F + (float) Math.PI) * 2.0F * limbSwingAmount * 0.5F / f;
this.bipedLeftArm.rotateAngleX = MathHelper.cos(limbSwing * 0.6662F) * 2.0F * limbSwingAmount * 0.5F / f;
this.bipedRightArm.rotateAngleZ = 0.0F;
this.bipedLeftArm.rotateAngleZ = 0.0F;
this.bipedRightLeg.rotateAngleX = MathHelper.cos(swingProgress(obj) * 0.6662F) * 1.4F * swingProgressPrev(obj);
this.bipedLeftLeg.rotateAngleX = MathHelper.cos(swingProgress(obj) * 0.6662F + (float) Math.PI) * 1.4F * swingProgressPrev(obj);
this.bipedRightLeg.rotateAngleX = MathHelper.cos(limbSwing * 0.6662F) * 1.4F * limbSwingAmount / f;
this.bipedLeftLeg.rotateAngleX = MathHelper.cos(limbSwing * 0.6662F + (float) Math.PI) * 1.4F * limbSwingAmount / f;
this.bipedRightLeg.rotateAngleY = 0.0F;
this.bipedLeftLeg.rotateAngleY = 0.0F;
this.bipedRightLeg.rotateAngleZ = 0.0F;
this.bipedLeftLeg.rotateAngleZ = 0.0F;
if (this.isRiding)
{
this.bipedRightArm.rotateAngleX += -((float) Math.PI / 5F);
this.bipedLeftArm.rotateAngleX += -((float) Math.PI / 5F);
this.bipedRightLeg.rotateAngleX = -((float) Math.PI * 2F / 5F);
this.bipedLeftLeg.rotateAngleX = -((float) Math.PI * 2F / 5F);
this.bipedRightLeg.rotateAngleX = -1.4137167F;
this.bipedRightLeg.rotateAngleY = ((float) Math.PI / 10F);
this.bipedRightLeg.rotateAngleZ = 0.07853982F;
this.bipedLeftLeg.rotateAngleX = -1.4137167F;
this.bipedLeftLeg.rotateAngleY = -((float) Math.PI / 10F);
this.bipedLeftLeg.rotateAngleZ = -0.07853982F;
}
if (this.heldItemLeft != 0)
this.bipedRightArm.rotateAngleY = 0.0F;
this.bipedRightArm.rotateAngleZ = 0.0F;
switch (this.leftArmPose)
{
this.bipedLeftArm.rotateAngleX = this.bipedLeftArm.rotateAngleX * 0.5F - ((float) Math.PI / 10F) * this.heldItemLeft;
case EMPTY:
this.bipedLeftArm.rotateAngleY = 0.0F;
break;
case BLOCK:
this.bipedLeftArm.rotateAngleX = this.bipedLeftArm.rotateAngleX * 0.5F - 0.9424779F;
this.bipedLeftArm.rotateAngleY = 0.5235988F;
break;
case ITEM:
this.bipedLeftArm.rotateAngleX = this.bipedLeftArm.rotateAngleX * 0.5F - ((float) Math.PI / 10F);
this.bipedLeftArm.rotateAngleY = 0.0F;
}
if (this.heldItemRight != 0)
switch (this.rightArmPose)
{
this.bipedRightArm.rotateAngleX = this.bipedRightArm.rotateAngleX * 0.5F - ((float) Math.PI / 10F) * this.heldItemRight;
case EMPTY:
this.bipedRightArm.rotateAngleY = 0.0F;
break;
case BLOCK:
this.bipedRightArm.rotateAngleX = this.bipedRightArm.rotateAngleX * 0.5F - 0.9424779F;
this.bipedRightArm.rotateAngleY = -0.5235988F;
break;
case ITEM:
this.bipedRightArm.rotateAngleX = this.bipedRightArm.rotateAngleX * 0.5F - ((float) Math.PI / 10F);
this.bipedRightArm.rotateAngleY = 0.0F;
}
this.bipedRightArm.rotateAngleY = 0.0F;
this.bipedLeftArm.rotateAngleY = 0.0F;
float var8;
float var9;
if (this.swingProgress > -9990.0F)
if (this.swingProgress > 0.0F)
{
var8 = this.swingProgress;
this.bipedBody.rotateAngleY = MathHelper.sin(MathHelper.sqrt(var8) * (float) Math.PI * 2.0F) * 0.2F;
EnumHandSide enumhandside = this.getMainHand(entityIn);
ModelRenderer modelrenderer = this.getArmForSide(enumhandside);
float f1 = this.swingProgress;
this.bipedBody.rotateAngleY = MathHelper.sin(MathHelper.sqrt(f1) * ((float) Math.PI * 2F)) * 0.2F;
if (enumhandside == EnumHandSide.LEFT)
{
this.bipedBody.rotateAngleY *= -1.0F;
}
this.bipedRightArm.rotationPointZ = MathHelper.sin(this.bipedBody.rotateAngleY) * 5.0F;
this.bipedRightArm.rotationPointX = -MathHelper.cos(this.bipedBody.rotateAngleY) * 5.0F;
this.bipedLeftArm.rotationPointZ = -MathHelper.sin(this.bipedBody.rotateAngleY) * 5.0F;
this.bipedLeftArm.rotationPointX = MathHelper.cos(this.bipedBody.rotateAngleY) * 5.0F;
this.bipedRightArm.rotateAngleY += this.bipedBody.rotateAngleY;
this.bipedLeftArm.rotateAngleY += this.bipedBody.rotateAngleY;
this.bipedLeftArm.rotateAngleX += this.bipedBody.rotateAngleY;
var8 = 1.0F - this.swingProgress;
var8 *= var8;
var8 *= var8;
var8 = 1.0F - var8;
var9 = MathHelper.sin(var8 * (float) Math.PI);
float var10 = MathHelper.sin(this.swingProgress * (float) Math.PI) * -(this.bipedHead.rotateAngleX - 0.7F) * 0.75F;
this.bipedRightArm.rotateAngleX = (float) (this.bipedRightArm.rotateAngleX - (var9 * 1.2D + var10));
this.bipedRightArm.rotateAngleY += this.bipedBody.rotateAngleY * 2.0F;
this.bipedRightArm.rotateAngleZ = MathHelper.sin(this.swingProgress * (float) Math.PI) * -0.4F;
f1 = 1.0F - this.swingProgress;
f1 = f1 * f1;
f1 = f1 * f1;
f1 = 1.0F - f1;
float f2 = MathHelper.sin(f1 * (float) Math.PI);
float f3 = MathHelper.sin(this.swingProgress * (float) Math.PI) * -(this.bipedHead.rotateAngleX - 0.7F) * 0.75F;
modelrenderer.rotateAngleX = (float) ((double) modelrenderer.rotateAngleX - ((double) f2 * 1.2D + (double) f3));
modelrenderer.rotateAngleY += this.bipedBody.rotateAngleY * 2.0F;
modelrenderer.rotateAngleZ += MathHelper.sin(this.swingProgress * (float) Math.PI) * -0.4F;
}
if (this.isSneak)
@@ -127,7 +237,6 @@ public void render(Object obj)
this.bipedRightLeg.rotationPointY = 9.0F;
this.bipedLeftLeg.rotationPointY = 9.0F;
this.bipedHead.rotationPointY = 1.0F;
this.bipedHeadwear.rotationPointY = 1.0F;
}
else
{
@@ -137,38 +246,67 @@ public void render(Object obj)
this.bipedRightLeg.rotationPointY = 12.0F;
this.bipedLeftLeg.rotationPointY = 12.0F;
this.bipedHead.rotationPointY = 0.0F;
this.bipedHeadwear.rotationPointY = 0.0F;
}
this.bipedRightArm.rotateAngleZ += MathHelper.cos(idleProgress(obj) * 0.09F) * 0.05F + 0.05F;
this.bipedLeftArm.rotateAngleZ -= MathHelper.cos(idleProgress(obj) * 0.09F) * 0.05F + 0.05F;
this.bipedRightArm.rotateAngleX += MathHelper.sin(idleProgress(obj) * 0.067F) * 0.05F;
this.bipedLeftArm.rotateAngleX -= MathHelper.sin(idleProgress(obj) * 0.067F) * 0.05F;
this.bipedRightArm.rotateAngleZ += MathHelper.cos(ageInTicks * 0.09F) * 0.05F + 0.05F;
this.bipedLeftArm.rotateAngleZ -= MathHelper.cos(ageInTicks * 0.09F) * 0.05F + 0.05F;
this.bipedRightArm.rotateAngleX += MathHelper.sin(ageInTicks * 0.067F) * 0.05F;
this.bipedLeftArm.rotateAngleX -= MathHelper.sin(ageInTicks * 0.067F) * 0.05F;
if (this.aimedBow)
if (this.rightArmPose == ModelBiped.ArmPose.BOW_AND_ARROW)
{
var8 = 0.0F;
var9 = 0.0F;
this.bipedRightArm.rotateAngleZ = 0.0F;
this.bipedLeftArm.rotateAngleZ = 0.0F;
this.bipedRightArm.rotateAngleY = -(0.1F - var8 * 0.6F) + this.bipedHead.rotateAngleY;
this.bipedLeftArm.rotateAngleY = 0.1F - var8 * 0.6F + this.bipedHead.rotateAngleY + 0.4F;
this.bipedRightArm.rotateAngleY = -0.1F + this.bipedHead.rotateAngleY;
this.bipedLeftArm.rotateAngleY = 0.1F + this.bipedHead.rotateAngleY + 0.4F;
this.bipedRightArm.rotateAngleX = -((float) Math.PI / 2F) + this.bipedHead.rotateAngleX;
this.bipedLeftArm.rotateAngleX = -((float) Math.PI / 2F) + this.bipedHead.rotateAngleX;
this.bipedRightArm.rotateAngleX -= var8 * 1.2F - var9 * 0.4F;
this.bipedLeftArm.rotateAngleX -= var8 * 1.2F - var9 * 0.4F;
this.bipedRightArm.rotateAngleZ += MathHelper.cos(idleProgress(obj) * 0.09F) * 0.05F + 0.05F;
this.bipedLeftArm.rotateAngleZ -= MathHelper.cos(idleProgress(obj) * 0.09F) * 0.05F + 0.05F;
this.bipedRightArm.rotateAngleX += MathHelper.sin(idleProgress(obj) * 0.067F) * 0.05F;
this.bipedLeftArm.rotateAngleX -= MathHelper.sin(idleProgress(obj) * 0.067F) * 0.05F;
}
else if (this.leftArmPose == ModelBiped.ArmPose.BOW_AND_ARROW)
{
this.bipedRightArm.rotateAngleY = -0.1F + this.bipedHead.rotateAngleY - 0.4F;
this.bipedLeftArm.rotateAngleY = 0.1F + this.bipedHead.rotateAngleY;
this.bipedRightArm.rotateAngleX = -((float) Math.PI / 2F) + this.bipedHead.rotateAngleX;
this.bipedLeftArm.rotateAngleX = -((float) Math.PI / 2F) + this.bipedHead.rotateAngleX;
}
copyModelAngles(this.bipedHead, this.bipedHeadwear);
}
public void setModelAttributes(ModelBase model)
{
super.setModelAttributes(model);
if (model instanceof ModelBiped)
{
ModelBiped modelbiped = (ModelBiped) model;
this.leftArmPose = modelbiped.leftArmPose;
this.rightArmPose = modelbiped.rightArmPose;
this.isSneak = modelbiped.isSneak;
}
}
public void setInvisible(boolean invisible)
{
this.bipedHead.showModel = invisible;
this.bipedHeadwear.showModel = invisible;
this.bipedBody.showModel = invisible;
this.bipedRightArm.showModel = invisible;
this.bipedLeftArm.showModel = invisible;
this.bipedRightLeg.showModel = invisible;
this.bipedLeftLeg.showModel = invisible;
}
draw(bipedHead);
draw(bipedBody);
draw(bipedRightArm);
draw(bipedLeftArm);
draw(bipedRightLeg);
draw(bipedLeftLeg);
draw(bipedHeadwear);
public void postRenderArm(float scale, EnumHandSide side)
{
this.getArmForSide(side).postRender(scale);
}
protected ModelRenderer getArmForSide(EnumHandSide side)
{
return side == EnumHandSide.LEFT ? this.bipedLeftArm : this.bipedRightArm;
}
protected EnumHandSide getMainHand(Entity entityIn)
{
return entityIn instanceof EntityLivingBase ? ((EntityLivingBase) entityIn).getPrimaryHand() : EnumHandSide.RIGHT;
}
}
Oops, something went wrong.

0 comments on commit 7c97255

Please sign in to comment.