How can I keep a specific item in my inventory when I die?

Started by CBJaxxx on

Topic category: Help with modding (Java Edition)

Last seen on 18:53, 12. Jan 2024
Joined Mar 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
How can I keep a specific item in my inventory when I die?

I have a coin pouch that holds coins but I want to make it so that if the player dies they will keep their coin pouch and the coins in it, this may have something to do with itemstacks but there is very little documentation on how to use them especially for this purpose. can someone please make my week and help me solve this issue?

Last seen on 09:33, 25. Apr 2024
Joined Mar 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
To do that, I see one…
Fri, 03/31/2023 - 21:37

To do that, I see one solution :

Create a number variable type (I call [nb_item]) in PLAYER_PERSISTENT, set on 0.

Then create the following procedures :

- get the number of coin

Every tick of the player
if have [event/target entity] in his inventory [coin]
	set [nb_coin] to [get item's number in [coin]]

- remove coin from the world

When player death
remove [coin] from [event/target entity] inventory

- give the coin to the player when he reappear

When player reappear
repeat [nb_coin] times :
	Add [coin] to [event/target entity] inventory
Last seen on 14:11, 22. Apr 2024
Joined Jul 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I want to do something…
Thu, 02/15/2024 - 16:07

I want to do something similar but for armor, any way to make the armor keep its enchants when it reappears (preferabley durability too but yeah)