Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

[1.8] Techne Model Not Corresponding To Player


Recommended Posts


I have a techne model and rendered it during the RenderPlayerEvent. The model is 100% correct, but the model doesn't stay on the player's back, as it is a backpack model. I want it to be physically attached to the player's back so that wherever the player is moving, looking, etc., the backpack is always in the correct position. Here is my model code and rendering code:



public class ModelPlayerBackpack extends ModelBase

protected static final ResourceLocation RESOURCE_LOCATION = new ResourceLocation(Main.MOD_ID + ":" + "textures/player/playerbackpack.png");

protected ModelRenderer baseOne;
protected ModelRenderer baseTwo;
protected ModelRenderer sideOne;
protected ModelRenderer sideTwo;
protected ModelRenderer pouchOne;
protected ModelRenderer pouchTwo;

public ModelPlayerBackpack()
	this.textureWidth = 64;
	this.textureHeight = 64;

	this.baseOne = new ModelRenderer(this, 0, 52);
	this.baseOne.addBox(-3.0F, -5.5F, -0.5F, 6, 11, 1);
	this.baseOne.setRotationPoint(0.0F, 6.0F, 2.5F);
	this.baseOne.setTextureSize(64, 64);
	this.baseOne.mirror = true;
	this.setRotation(this.baseOne, 0.0F, 0.0F, 0.0F);

	this.baseTwo = new ModelRenderer(this, 0, 42);
	this.baseTwo.addBox(-2.5F, -4.5F, -0.5F, 5, 9, 1);
	this.baseTwo.setRotationPoint(0.0F, 6.0F, 3.5F);
	this.baseTwo.setTextureSize(64, 64);
	this.baseTwo.mirror = true;
	this.setRotation(this.baseTwo, 0.0F, 0.0F, 0.0F);

	this.sideOne = new ModelRenderer(this, 0, 32);
	this.sideOne.addBox(-1.0F, -4.0F, 0.0F, 2, 8, 2);
	this.sideOne.setRotationPoint(4.0F, 6.0F, 3.0F);
	this.sideOne.setTextureSize(64, 64);
	this.sideOne.mirror = true;
	this.setRotation(this.sideOne, 0.0F, 0.0F, 0.0F);

	this.sideTwo = new ModelRenderer(this, 0, 32);
	this.sideTwo.addBox(-1.0F, -4.0F, 0.0F, 2, 8, 2);
	this.sideTwo.setRotationPoint(-4.0F, 6.0F, 3.0F);
	this.sideTwo.setTextureSize(64, 64);
	this.sideTwo.mirror = true;
	this.setRotation(this.sideTwo, 0.0F, 0.0F, 0.0F);

	this.pouchOne = new ModelRenderer(this, 14, 59);
	this.pouchOne.addBox(-2.0F, -1.5F, 0.0F, 4, 3, 2);
	this.pouchOne.setRotationPoint(0.0F, 4.0F, 4.0F);
	this.pouchOne.setTextureSize(64, 64);
	this.pouchOne.mirror = true;
	this.setRotation(this.pouchOne, 0.0F, 0.0F, 0.0F);

	this.pouchTwo = new ModelRenderer(this, 14, 59);
	this.pouchTwo.addBox(-2.0F, -1.5F, 0.0F, 4, 3, 2);
	this.pouchTwo.setRotationPoint(0.0F, 8.0F, 4.0F);
	this.pouchTwo.setTextureSize(64, 64);
	this.pouchTwo.mirror = true;
	this.setRotation(this.pouchTwo, 0.0F, 0.0F, 0.0F);

public void setRotation(ModelRenderer par1ModelRenderer, float par2Float, float par3Float, float par4Float)
	par1ModelRenderer.rotateAngleX = par2Float;
	par1ModelRenderer.rotateAngleY = par3Float;
	par1ModelRenderer.rotateAngleZ = par4Float;

public void setRotationAngles(float par1Float, float par2Float, float par3Float, float par4Float, float par5Float, float par6Float, Entity par7Entity)
	super.setRotationAngles(par1Float, par2Float, par3Float, par4Float, par5Float, par6Float, par7Entity);

public void render(Entity par1Entity, float par2Float, float par3Float, float par4Float, float par5Float, float par6Float, float par7Float)
	super.render(par1Entity, par2Float, par3Float, par4Float, par5Float, par6Float, par7Float);
	this.setRotationAngles(par2Float, par3Float, par4Float, par5Float, par6Float, par7Float, par1Entity);




public class RenderModelPlayerBackpack 

private ModelPlayerBackpack modelPlayerBackpack = new ModelPlayerBackpack();

public void renderPlayerEvent(RenderPlayerEvent.Pre par1RenderPlayerEvent)
	this.modelPlayerBackpack.render(Minecraft.getMinecraft().thePlayer, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F);


Development of Plugins [2012 - 2014] Development of Mods [2012 - Current]

Link to comment
Share on other sites

It looks like the problem is with this line:

this.modelPlayerBackpack.render(Minecraft.getMinecraft().thePlayer, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F);


You aren't rotating the model at all (the 0's), you need to make one of those (not sure which one, experimenting should do the trick though) the player's Y rotation. I'm going to assume it's the second one though.

Link to comment
Share on other sites

Ah, this could be the problem:


This is the code from the armor stand.

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_)
        if (p_78087_7_ instanceof EntityArmorStand)
            EntityArmorStand entityarmorstand = (EntityArmorStand)p_78087_7_;
            this.bipedHead.rotateAngleX = 0.017453292F * entityarmorstand.getHeadRotation().getX();
            this.bipedHead.rotateAngleY = 0.017453292F * entityarmorstand.getHeadRotation().getY();
            this.bipedHead.rotateAngleZ = 0.017453292F * entityarmorstand.getHeadRotation().getZ();
            this.bipedHead.setRotationPoint(0.0F, 1.0F, 0.0F);
            this.bipedBody.rotateAngleX = 0.017453292F * entityarmorstand.getBodyRotation().getX();
            this.bipedBody.rotateAngleY = 0.017453292F * entityarmorstand.getBodyRotation().getY();
            this.bipedBody.rotateAngleZ = 0.017453292F * entityarmorstand.getBodyRotation().getZ();
            this.bipedLeftArm.rotateAngleX = 0.017453292F * entityarmorstand.getLeftArmRotation().getX();
            this.bipedLeftArm.rotateAngleY = 0.017453292F * entityarmorstand.getLeftArmRotation().getY();
            this.bipedLeftArm.rotateAngleZ = 0.017453292F * entityarmorstand.getLeftArmRotation().getZ();
            this.bipedRightArm.rotateAngleX = 0.017453292F * entityarmorstand.getRightArmRotation().getX();
            this.bipedRightArm.rotateAngleY = 0.017453292F * entityarmorstand.getRightArmRotation().getY();
            this.bipedRightArm.rotateAngleZ = 0.017453292F * entityarmorstand.getRightArmRotation().getZ();
            this.bipedLeftLeg.rotateAngleX = 0.017453292F * entityarmorstand.getLeftLegRotation().getX();
            this.bipedLeftLeg.rotateAngleY = 0.017453292F * entityarmorstand.getLeftLegRotation().getY();
            this.bipedLeftLeg.rotateAngleZ = 0.017453292F * entityarmorstand.getLeftLegRotation().getZ();
            this.bipedLeftLeg.setRotationPoint(1.9F, 11.0F, 0.0F);
            this.bipedRightLeg.rotateAngleX = 0.017453292F * entityarmorstand.getRightLegRotation().getX();
            this.bipedRightLeg.rotateAngleY = 0.017453292F * entityarmorstand.getRightLegRotation().getY();
            this.bipedRightLeg.rotateAngleZ = 0.017453292F * entityarmorstand.getRightLegRotation().getZ();
            this.bipedRightLeg.setRotationPoint(-1.9F, 11.0F, 0.0F);
            copyModelAngles(this.bipedHead, this.bipedHeadwear);


You'll notice it doesn't call super.setRotationAngles (like you did), the reason for that is because super.setRotationAngles does nothing, it's an empty method. So in your implementation of it, you need to do what the armor stand did, rotation the model parts of your model according to the entity that wears it.

Link to comment
Share on other sites

Not working. This just makes the individual model parts spin on its axis / rotation points. I need something that will turn the whole model based on player rotation yaw.

public void setRotationAngles(float par1Float, float par2Float, float par3Float, float par4Float, float par5Float, float par6Float, Entity par7Entity)
if (par7Entity instanceof EntityPlayer)
            EntityPlayer entityplayer = (EntityPlayer) par7Entity;
            this.baseOne.rotateAngleY = 0.017453292F * entityplayer.rotationYaw;
            this.baseTwo.rotateAngleY = 0.017453292F * entityplayer.rotationYaw;
            this.sideOne.rotateAngleY = 0.017453292F * entityplayer.rotationYaw;
            this.sideTwo.rotateAngleY = 0.017453292F * entityplayer.rotationYaw;
            this.pouchOne.rotateAngleY = 0.017453292F * entityplayer.rotationYaw;
            this.pouchTwo.rotateAngleY = 0.017453292F * entityplayer.rotationYaw;

Development of Plugins [2012 - 2014] Development of Mods [2012 - Current]

Link to comment
Share on other sites

If I set all the rotation offset points to the same area, my model renders oddly. Besides, if I did that I would just be able to call GL.glRotated to rotate the whole model and would achieve the same thing. The armor stand needs to rotate its specific parts and I need to rotate the thing as a whole with the player.

Development of Plugins [2012 - 2014] Development of Mods [2012 - Current]

Link to comment
Share on other sites

Why dont you use the mainpart.addChild() method? That whay all parts will stay at their places when you rotate the mainPart. That way you only have to worry about one rotation.


Also keep in mind that the rotation point of the player is the exact centre of the player model, while your model is separated a fair bit from that point!



- N2ConfigAPI

- Meachanical Crafting Table



- CollectionUtils



- InGameConfigManager

Link to comment
Share on other sites

I'll give you a way to do this easier.


Build your model in Techne where the backpack is on the players back in the right spot.  Heck use the model biped as a start.


Change your model to extend modelbiped.  Reset all the base models parts (such as leg, body, ect) to size zero.


When the player is rendered, send a call to render your backpack when applicable. 


If you use the renderlivingentity event, be sure to put a marker on your render version or you will get an infinite loops.


This oversimplifies it, such as leaving our your render class, ect. 



The reason to do this is there is no need to do anything with calculating positions, rotations, sneak, riding, ect.  The base code takes care of it for you.  Easy as can be.

Long time Bukkit & Forge Programmer

Happy to try and help

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.

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.