Keep an item after dying

Started by TheDuckKnight_Mc on

Topic category: Help with Minecraft modding (Java Edition)

Active 3 years ago
Joined Feb 2020
Points:
788

User statistics:

  • Modifications: 0
  • Forum topics: 27
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 58
Keep an item after dying

I attempted to make a little box that you can carry around and open with a right click, simple enough. My idea was, that if you held the box in your off hand when you died, you would keep the box after dying, along with its contents, but I can't figure out how to do it. I am quite sure you have to use the "entity dies" and "player respawns" global triggers, as well as some player_persistent global variables to store the items, but I still struggle with getting the procedure / procedures right. What could be a solution? Any and all help would be great.

Active 2 years ago
Joined Nov 2018
Points:
972

User statistics:

  • Modifications: 0
  • Forum topics: 4
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 572
When the entity dies store…
Sun, 02/14/2021 - 19:40

When the entity dies store the box as a global itemstack variable.

Remove the box from the player's inventory.

 

When the player respawns give the player the itemstack variable.

Active 3 years ago
Joined Feb 2020
Points:
788

User statistics:

  • Modifications: 0
  • Forum topics: 27
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 58
I did try but it did not…
Mon, 02/15/2021 - 08:09

I did try but it did not work. Maybe I'm stupid. Probably I'm stupid. Yeah I am, I am stupid.

Active 3 years ago
Joined Feb 2020
Points:
788

User statistics:

  • Modifications: 0
  • Forum topics: 27
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 58
Yeah it worked I am indeed…
Mon, 02/15/2021 - 08:45

Yeah it worked I am indeed stupid

Active 1 year ago
Joined Aug 2022
Points:
332

User statistics:

  • Modifications: 0
  • Forum topics: 3
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 7
what was your code?(i have a…
Thu, 05/04/2023 - 00:37

what was your code?(i have a similar problem with and enchantment)