How to have different inventories

Started by BMAgamer on

Topic category: Help with modding (Java Edition)

Last seen on 00:43, 9. Jun 2024
Joined Aug 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
How to have different inventories

So I want to make it that when the player enters a certain dimension, their inventory is cleared, but when they go back to the overworld, their original inventory is replenished. How would I do this.

Last seen on 16:12, 15. Oct 2024
Joined May 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
There's almost certainly a…
Mon, 10/09/2023 - 16:03

There's almost certainly a better way of saving large numbers of item slots... but if you're willing to brute force it, you can make 36 player-persistent itemstack variables, one for each inventory slot. When the player enters the dimension, before you clear their inventory, set each of these variables to the item in the corresponding slot. When they return from your custom dimension, run a procedure that puts each item variable back in its corresponding slot.

You can find variables in their own tab in the main workspace. Again though, it may be worth looking into better solutions. (Though I can say I've tried stuff like this, and it will work.)