Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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

  • Author
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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.