Jump to content

[1.7.10] Showing player's arm while holding a specific item.


mGamer426

Recommended Posts

Hello!

 

I created a new item and I created a texture for it. I made two textures: one for displaying the item in the inventory slot, one for displaying the item equipped in third-person and in first-person mode.

The problem is... the item will look much better equipped if the players arm showing too (of course in first person).

So, can you help me?

 

I created a simple code, which is shows the player's arm, but it shows it like... an arm in the player's arm.

Here's the code:

 

public class TestItemRenderer implements IItemRenderer
{
    private static RenderItem renderItem = new RenderItem();
    private ModelBiped modelBipedMain = new ModelBiped(0.0F);
    private static Minecraft mc = Minecraft.getMinecraft();

    @Override
    public boolean handleRenderType(ItemStack item, ItemRenderType type)
    {
        switch (type)
        {
            case INVENTORY:
                return true;
            case EQUIPPED:
                return true;
            case EQUIPPED_FIRST_PERSON:
                return true;
            default:
                return false;
        }
    }

    @Override
    public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper)
    {
        return false;
    }

    @Override
    public void renderItem(ItemRenderType type, ItemStack item, Object... data)
    {
        switch (type)
        {
            case EQUIPPED_FIRST_PERSON:
                renderFirstPersonArm(mc.thePlayer);
        }
    }

    private void renderFirstPersonArm(EntityPlayer player)
    {
        mc.renderEngine.bindTexture(mc.thePlayer.getLocationSkin());

        float f = 1.0F;
        GL11.glColor3f(f, f, f);
        this.modelBipedMain.onGround = 0.0F;
        this.modelBipedMain.setRotationAngles(0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F, player);
        this.modelBipedMain.bipedRightArm.offsetY = 1F;
        this.modelBipedMain.bipedRightArm.render(0.0625F);
    }
}

 

So, this is a little bit offsetted player arm, in the player's arm. Is there any way to override the game's mechanic and don't hide the player's arm while holding the item?

Oh, and by the way here's a picture what happens:

 

ZG0yAiE.png

 

Thanks for any help.

Link to comment
Share on other sites

Hi

I am trying to do the same thing as well, I have 2 posts about this, however they are for version 1.8. I tried using the RenderPlayerAPI because I have seen other mods use this API to modify the renders / drawings of the player model in first person and third person by gaining control of private methods and fields in RenderPlayer, ModelPlayer, and ModelBiped. This API is extremely useful, however I'm yet to see a tutorial by the author or the API users on how to draw new arms in first person. How ironic that the new combat update is doing the same thing! I hope you as well as I can get this working, you might have a better mind than me at this API, as I have only been able to achieve a modified third person render and not a first person render.

Here it is if you'd like to check it out:

http://www.minecraftforum.net/forums/mapping-and-modding/minecraft-mods/1283669-render-player-api

 

Here is a somewhat useful topic on this subject:

http://www.minecraftforge.net/forum/index.php?topic=31095.0

 

Some things to consider is that maybe you could achieve this render by canceling the RenderHandEvent or RenderPlayerEvent.pre and drawing new arms but both those events seem to cause me trouble (the RenderHandEvent, when canceled, doesn't render the player but it renders the hand, which, defeats the purpose). If you need help with the API a bit, just ask!

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

Link to comment
Share on other sites

Actually, I'm fooling around with the first person render with the RenderPlayerAPI right this minute and managed to get it to work, its just that i can only get it to work when I'm not holding an item, when I am holding an item however, I think the arm is not rendered. That's the only thing in our way! So, know you know that its possible with the API to render the arm in a different way, and I have the code if you need it. Contact me if you need further help with the API, whether it be installation or right down to the code.

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

Link to comment
Share on other sites

No problem, I know it took a little figuring for me to do this since there are no proper tutorials for the API. I only got this today! Anyway, here's the code:

Register this class in your client proxy using the RenderPlayerBase registry.

public class YOURCLASS extends RenderPlayerBase
{
    
    //Constructor using the API
    public YOURCLASS(RenderPlayerAPI rpa)
    {
        super(rpa);
    }

    @Override
    public void beforeRenderLeftArm(AbstractClientPlayer player)
    {
        GL11.glScalef(X, Y, Z); //How large is your model?
        GL11.glTranslatef(X, Y, Z); //Position the model where?
        GL11.glRotatef(X, Y, Z); //Rotate the model in which direction?
    }

}

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

Link to comment
Share on other sites

OK, I will, I promise and thanks for the code.

I was looking for stuff in the API earlier, and I found an interface, called RenderPlayer. This contains a lot of methods, and I saw two of them, that are do something with the left arm.

First is: realRenderLeftArm, second is: localRenderLeftArm.

 

I don't know what those are doing, but it's horrible that there isn't any proper tutorials from this API.

localRenderLeftArm is used in a few classes, but I don't know.

 

Thanks again for the code!

Link to comment
Share on other sites

Yes, I have just peeked into the IRenderPlayer interface. This is not what you want to implement in your class, though, rather it is the RenderPlayerBase that you want to extend. It has the method that I have used in my code that I posted earlier. Just extend that, register the class, override the method with your own code and you're good to go! I'll be working on getting the arm to render while holding an item in the meanwhile, if you need any help just post!

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

Link to comment
Share on other sites

I don't know why, but since I posted here: http://www.minecraftforge.net/forum/index.php/topic,29227.0.html

 

Everyone has been mad about RenderPlayerAPI. I mean - I see it everywhere right now. EVERYWHERE.

 

That is not a bad thing, just know for fact that RPA is powerful tool and if you are not planning on using it extensively, stay with the forge.

There is a reason for those hooks in forge. More dependencies = worse.

1.7.10 is no longer supported by forge, you are on your own.

Link to comment
Share on other sites

I don't know why, but since I posted here: http://www.minecraftforge.net/forum/index.php/topic,29227.0.html

 

Everyone has been mad about RenderPlayerAPI. I mean - I see it everywhere right now. EVERYWHERE.

 

That is not a bad thing, just know for fact that RPA is powerful tool and if you are not planning on using it extensively, stay with the forge.

There is a reason for those hooks in forge. More dependencies = worse.

This dependency is not necessarily a bad one, though. It invokes the compatibility with other mods, that is just a mere one of its purposes. It is a very powerful and extremely useful API not only for third person, but for first person and compatibility issues as well. The vanilla renders are so complicated because I myself can't tell whether the first person render is controlled in the ItemRenderer class or the RenderPlayer / ModelPlayer class. Most fields and methods are private and there are too many obfuscated names that when this topic is brung up, there's usually no definate solution it seems like. I still want to try to do this in vanilla though! Wish me luck!

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

Link to comment
Share on other sites

Yeah, I tried it without this API but that not worked at all... So, our only way is to do this whole RenderPlayerAPI thing. RenderPlayerAPI is a good thing, it's useful and everything but our only problem

is... they didn't make a tutorial from the mod and this is annoying. And by the way, thanks for the info EverythingGames... ;-)

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.