Jump to content

Player arm rotation in 3rd person!


FLUFFY2

Recommended Posts

This tutorial by Ichun (the creator of the portalgun mod) shows how to create custom rendered Items. He also shows how to edit the players arm rotation.

Its a bit old but most of the code is still working.

 

 

Good luck :D

Busti

PM's regarding modding questions should belong in the Modder Support sub-forum and won't be answered.

Link to comment
Share on other sites

You want to hold it like a lantern right? Go into the ModelBiped class, and then look into the setRotationAngles function:

 

public void setRotationAngles(float par1, float par2, float par3, float par4, float par5, float par6, Entity par7Entity)

{

    //ALL THAT DIFFERENT UNDERSTANABLE CODE HERE xD

}

 

The second step, is to add new code to the end of the function.

 

public void setRotationAngles(float par1, float par2, float par3, float par4, float par5, float par6, Entity par7Entity)

{

    //ALL THAT DIFFERENT UNDERSTANABLE CODE HERE xD

 

    if(par7Entity instanceof EntityPlayer){ //CHECKING IF THE ENTITY IS A PLAYER

        EntityPlayer player = (EntityPlayer) par7Entity;

        if(player.getCurrectItem().itemID == ItemSometgingasda.item_Lantern.itemID){ //CHECKING IF THE PLAYER IS HOLDING THE LANTERN. CHANGE THAT IF YOU NEED

        this.bipedRightArm.rotateAngleX+=90.0f/180f*3.14f; //APPLYING THE ROTATION TO THE RIGHT ARM :)

    }

}

 

Remember, the new code should be at the end of the setRotationAngles function :).

 

 

Link to comment
Share on other sites

You have to make a new RenderPlayer class with a new ModelBiped class, and attack the new RenderPlayer class to the player.

 

Do it the same as you would register a renderer for a mob, but do it for EntityPlayer instead.

 

Copy RenderPlayer class, and rename it, and tweak a little bit.

Link to comment
Share on other sites

Note that doing so will make your mod incompatible with any other mod that attempts to modify the player's rendering. It is much better for compatibility's sake if you can manage to do what you want using the Forge RenderPlayerEvent hooks. I imagine it would be basically the same, using the post player render event to hook in at the end of rendering to modify the player's arm rotation like GoblinBob mentioned above.

Link to comment
Share on other sites

So far i made:

LanternRenderEventHandler:

 

 

@SideOnly(Side.CLIENT)

@SubscribeEvent

public void lanternHolding(RenderLivingEvent.Pre event)

{

if (!event.isCanceled() && event.entity instanceof EntityPlayer)

{

ItemStack item = event.entity.getHeldItem();

 

if (item == null)

{

return;

}

 

RenderPlayer rp;

 

if (item.getItem() != Lantern.lanternonItem)

{

if (item.getItem() == Lantern.lanternoffItem)

{

rp = (RenderPlayer)event.renderer;

                rp.modelArmorChestplate.heldItemRight = rp.modelArmor.heldItemRight = rp.modelBipedMain.heldItemRight = 6;

}

}

else

{

rp = (RenderPlayer)event.renderer;

                rp.modelArmorChestplate.heldItemRight = rp.modelArmor.heldItemRight = rp.modelBipedMain.heldItemRight = 6;

}

}

}

 

 

 

So in the RenderPlayer some methods are private.

I have to create new one as GoblinBob said and its done?

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.