Jump to content

[1.19] Question about inventory


Luckydel

Recommended Posts

I would like to add an extra slot of armor

Maybe someone can suggest the classes that I need. And where is it to be initialized. And how to put it all together.

I understand that I can be asking a lot, but I would just need a direction where to dig.

Edited by Luckydel
Link to comment
Share on other sites

Basically you need a Capability which is attached to the Player, you can use a ItemStackHandler to store the ItemStack.
Then you need to add a SlotItemHandler (your Slot) to the Player inventory (Player#inventoryMenu) therefore you need to use Reflection (an AT is here not possible).
Unfortunately i have not yet found a Event which would fired at the correct point to add the Slot. Note that you need to add the Slot on server and on client.

If you set up everything correctly the Slot should be now displayed in the Player Inventory, you should be able to put in Items.
Last but not least you need to render the Slot background in the Inventory, you need to use one of the Screen Events (test which one would be the way to go).

Notes:

  1. The Slot index of you extra Slot should be calculated based on the Slot count of the inventory, to make sure you don't get any conflicts if other Mods add also Slots to the Player Inventory.
  2. I'm not sure if you be able to quick move ItemStacks in your custom Slot, since this is hardcoded in InventoryMenu#quickMoveStack
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.