Jump to content

Custom armor rendering


shucke

Recommended Posts

Hey guys,

i got a problem with the custom armor renderer.

the helmet and legs works fine but the rotations of the body are a little off when aiming a bow, blocking with a sword and hitting.

this is my model code:

public class ModelDragonPlate extends ModelBiped{

public static final ResourceLocation texture = new ResourceLocation(Reference.MOD_ID, "textures/armor/dragon_plate.png");

ModelRenderer shoulderL;
ModelRenderer hornL1;
ModelRenderer hornL2;
ModelRenderer shoulderR;
ModelRenderer hornR1;
ModelRenderer hornR2;
ModelRenderer braceL;
ModelRenderer braceR;

public ModelDragonPlate(){
	textureWidth = 64;
	textureHeight = 32;

	shoulderL = new ModelRenderer(this, 0, 0);
	shoulderL.addBox(-1.5F, -2.5F, -2.5F, 5, 5, 5);
	shoulderL.setRotationPoint(5F, 2F, 0F);
	shoulderL.setTextureSize(64, 32);
	setRotation(shoulderL, 0F, 0F, 0F);
	shoulderL.mirror = false;
	hornL1 = new ModelRenderer(this, 0, 0);
	hornL1.addBox(3F, -4F, 0.5F, 1, 3, 1);
	hornL1.setRotationPoint(5F, 2F, 0F);
	hornL1.setTextureSize(64, 32);
	hornL1.mirror = true;
	setRotation(hornL1, 0F, 0F, 0F);
	hornL2 = new ModelRenderer(this, 0, 0);
	hornL2.addBox(3F, -4F, -1.5F, 1, 3, 1);
	hornL2.setRotationPoint(5F, 2F, 0F);
	hornL2.setTextureSize(64, 32);
	hornL2.mirror = true;
	setRotation(hornL2, 0F, 0F, 0F);
	shoulderR = new ModelRenderer(this, 0, 0);
	shoulderR.addBox(-3.5F, -2.5F, -2.5F, 5, 5, 5);
	shoulderR.setRotationPoint(-5F, 2F, 0F);
	shoulderR.setTextureSize(64, 32);
	shoulderR.mirror = true;
	setRotation(shoulderR, 0F, 0F, 0F);
	hornR1 = new ModelRenderer(this, 0, 0);
	hornR1.addBox(-4F, -4F, 0.5F, 1, 3, 1);
	hornR1.setRotationPoint(-5F, 2F, 0F);
	hornR1.setTextureSize(64, 32);
	setRotation(hornR1, 0F, 0F, 0F);
	hornR1.mirror = false;
	hornR2 = new ModelRenderer(this, 0, 0);
	hornR2.addBox(-4F, -4F, -1.5F, 1, 3, 1);
	hornR2.setRotationPoint(-5F, 2F, 0F);
	hornR2.setTextureSize(64, 32);
	setRotation(hornR2, 0F, 0F, 0F);
	hornR2.mirror = false;
	braceL = new ModelRenderer(this, 0, 10);
	braceL.addBox(-1.5F, 5F, -2.5F, 5, 1, 5);
	braceL.setRotationPoint(5F, 2F, 0F);
	braceL.setTextureSize(64, 32);
	braceL.mirror = true;
	setRotation(braceL, 0F, 0F, 0F);
	braceR = new ModelRenderer(this, 0, 10);
	braceR.addBox(-3.5F, 5F, -2.5F, 5, 1, 5);
	braceR.setRotationPoint(-5F, 2F, 0F);
	braceR.setTextureSize(64, 32);
	setRotation(braceR, 0F, 0F, 0F);
	braceR.mirror = false;
}

public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5){
	setRotationAngles(f, f1, f2, f3, f4, f5, entity);

	GL11.glPushMatrix();
	TextureHandler.instance.bindTexture(texture);

	shoulderL.render(f5);
	hornL1.render(f5);
	hornL2.render(f5);
	shoulderR.render(f5);
	hornR1.render(f5);
	hornR2.render(f5);
	braceL.render(f5);
	braceR.render(f5);

	GL11.glPopMatrix();
}

private void setRotation(ModelRenderer model, float x, float y, float z){

	model.rotateAngleX = x;
	model.rotateAngleY = y;
	model.rotateAngleZ = z;
}

public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5, Entity entity){

	EntityLivingBase living = (EntityLivingBase) entity;

	ItemStack itemstack = living.getHeldItem();

	this.heldItemRight = living.getHeldItem() == null ? 0 : 1;

	if(living instanceof EntityPlayer){

		EntityPlayer player = (EntityPlayer) living;

		if (living.getHeldItem() != null && player.getItemInUseCount() > 0)
		{
			EnumAction enumaction = itemstack.getItemUseAction();

			if (enumaction == EnumAction.block)
			{
				heldItemRight = 3;
			}
			else if (enumaction == EnumAction.bow)
			{
				this.aimedBow = true;
			}
		}
	}

	super.setRotationAngles(f, f1, f2, f3, f4, f5, entity);


	shoulderL.rotateAngleX = bipedLeftArm.rotateAngleX;
	if (this.heldItemLeft != 0){
		shoulderL.rotateAngleX = this.bipedLeftArm.rotateAngleX * 0.5F - ((float)Math.PI / 10F) * (float)this.heldItemLeft;
	}
	shoulderL.rotateAngleY = bipedLeftArm.rotateAngleY;
	shoulderL.rotateAngleZ = bipedLeftArm.rotateAngleZ;
	hornL1.rotateAngleX = shoulderL.rotateAngleX;
	hornL1.rotateAngleY = shoulderL.rotateAngleY;
	hornL1.rotateAngleZ = shoulderL.rotateAngleZ;
	hornL2.rotateAngleX = shoulderL.rotateAngleX;
	hornL2.rotateAngleY = shoulderL.rotateAngleY;
	hornL2.rotateAngleZ = shoulderL.rotateAngleZ;
	braceL.rotateAngleX = shoulderL.rotateAngleX;
	braceL.rotateAngleY = shoulderL.rotateAngleY;
	braceL.rotateAngleZ = shoulderL.rotateAngleZ;

	shoulderR.rotateAngleX = bipedRightArm.rotateAngleX;
	if (this.heldItemRight != 0){
		shoulderR.rotateAngleX = this.bipedRightArm.rotateAngleX * 0.5F - ((float)Math.PI / 10F) * (float)this.heldItemRight;
	}
	shoulderR.rotateAngleY = bipedRightArm.rotateAngleY;
	shoulderR.rotateAngleZ = bipedRightArm.rotateAngleZ;
	hornR1.rotateAngleX = shoulderR.rotateAngleX;
	hornR1.rotateAngleY = shoulderR.rotateAngleY;
	hornR1.rotateAngleZ = shoulderR.rotateAngleZ;
	hornR2.rotateAngleX = shoulderR.rotateAngleX;
	hornR2.rotateAngleY = shoulderR.rotateAngleY;
	hornR2.rotateAngleZ = shoulderR.rotateAngleZ;
	braceR.rotateAngleX = shoulderR.rotateAngleX;
	braceR.rotateAngleY = shoulderR.rotateAngleY;
	braceR.rotateAngleZ = shoulderR.rotateAngleZ;

	this.aimedBow = false;
}

anyone knows how to fix this?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.