Jump to content

Recommended Posts

Posted (edited)

Hi there. I'm wanting to create 'slots' that exist on the player's back and hip so that they may equip a weapon in either. So if I equip an item on my back slot, it should then render in game on my back. I'm trying to think about how to do this. I see there's an

Minecraft.getInstance().getItemRenderer()

with multiple different render() methods, most of which I think are GUI related. I do see it has this:

render(ItemStack pItemStack, ItemCameraTransforms.TransformType pTransformType, boolean pLeftHand, MatrixStack pMatrixStack, IRenderTypeBuffer pBuffer, int pCombinedLight, int pCombinedOverlay, IBakedModel pModel)

which might be want I should use. Although, I'm unsure how to get/create an IRenderTypeBuffer.

 

I found this outdated mod that did exactly what I'm looking to do, where he has the item being represented by a BipedModel. Is this the same approach that should be taken in 1.16.5? I'm not sure if it's possible, but I'd like to avoid the rendered items as being entities (I'm not sure if that even makes sense, to be honest), ideally for performance (in my head, if I had 100 players in an area, there'd be 200 entities by default since each could have a rendered weapon on their back or hip. If this is the only solution, I could make a culling system of sorts). Here's what I'm wanting to essentially accomplish:

wNMIT.png

 

Thanks for any input! 

 

Edit:

I've found the HeldItemLayer class which, I believe, renders held items. I'm thinking I can create my own LayerRenderer that's essentially mimicking this but at a different place on the player.

Edited by Jimmeh
Posted
10 minutes ago, diesieben07 said:

This is the route I would suggest as well.

Question with this. If I make a WornItemLayer extends LayerRenderer, I implement the following render method:

@Override
    public void render(MatrixStack pMatrixStack,
                       IRenderTypeBuffer pBuffer,
                       int pPackedLight,
                       Entity pLivingEntity,
                       float pLimbSwing,
                       float pLimbSwingAmount,
                       float pPartialTicks,
                       float pAgeInTicks,
                       float pNetHeadYaw,
                       float pHeadPitch) {
        if(this.equipped == null) return;

        //Get the player's facing direction
        //Reverse that to know the direction the location offset will be for positioning
        //Rotate the item 135 degrees

        final float rotation = this.minecraft.player.yBodyRot;
    }

I don't think this will work for multiplayer, as in, it won't render other players' equipped items on my screen, since I'm getting the local player from Minecraft. Can you think of a way so that this may be applied to all players? Perhaps some sort of loop through viewable players each render() call?

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.