Jump to content

Arm texture looks wierd when you mess with player model


fcelon

Recommended Posts

Hello,

I have spent many hours trying to figure out how to rotate palyer's arm. I have already asked on forum, but it seems nobody knows how to do it. Now it seems I have found a solution, but there is a different problem.

@SideOnly(Side.CLIENT)
	@SubscribeEvent(priority=EventPriority.NORMAL, receiveCanceled=true)
	public void onEvent(RenderPlayerEvent.Pre event)
	{
		event.getRenderer().getMainModel().bipedRightArm.isHidden=true;
	}

@SideOnly(Side.CLIENT)
	@SubscribeEvent(priority=EventPriority.NORMAL, receiveCanceled=true)
	public void onEvent(RenderPlayerEvent.Post event)
	{
		EntityPlayer player = event.getEntityPlayer();
		event.getRenderer().getMainModel().bipedRightArm.isHidden=false;
		event.getRenderer().getMainModel().bipedRightArm.rotationPointZ = -MathHelper.sin((float) Math.toRadians(player.renderYawOffset)) * 5.0F;
		event.getRenderer().getMainModel().bipedRightArm.rotationPointY = 20;
		event.getRenderer().getMainModel().bipedRightArm.rotationPointX = -MathHelper.cos((float) Math.toRadians(player.renderYawOffset)) * 5.0F;
		event.getRenderer().getMainModel().bipedRightArm.rotateAngleX = (float) X;
		event.getRenderer().getMainModel().bipedRightArm.rotateAngleY = (float) -Math.toRadians(player.renderYawOffset);
		event.getRenderer().getMainModel().bipedRightArm.rotateAngleZ = (float) Z;
		event.getRenderer().getMainModel().bipedRightArm.renderWithRotation(0.0625F);
		event.getRenderer().getMainModel().bipedRightArm.rotationPointY = 2;
	}

It only works if player's hand is empty. If player is holding any item, texture of the arm starts to look realy wierd. Does anyone know why is this happening and how to fix it?

Thanks for any help.

Link to comment
Share on other sites

Try this, it will fix the texture:

 

event.getRenderer().bindTexture(event.getRenderer().getEntityTexture((AbstractClientPlayer)player));

 

At least it did for me in 1.12 version, where I was getting the weird texture things you describe. Although your code doesn't work entirely for me as intended. It rotates, but I have to eliminate the code that hides the arm in the Pre event or I get nothing rendered at all. But if I do I get two arms rendered. The second one out of position. Weird. But I won't ask in this thread for help since I don't want to hijack your thread.

 

Hope it helps.

Edited by ctbe
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.

Announcements



×
×
  • Create New...

Important Information

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