How to make certain things not drop when you die

Started by artimoid on

Topic category: Help with Minecraft modding (Java Edition)

Joined Dec 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
How to make certain things not drop when you die

For example: I have weapons and armor on me, as well as mushrooms or any other things. I want the armor and weapons to remain with me and the rest to fall when I die. How can I do this?

Joined May 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Funnily enough I did…
Fri, 12/08/2023 - 12:29

Funnily enough I did something very similar with death-proof equipment. It's a bit complicated, but the basic idea is:

  • You create a couple of player-persistant itemstack variables, and set them to the special items on player update tick if they're wearing or holding the item. (And then reset them to air whenever this is no longer true.) It's important they're player-persistant, or they'll reset to air on death, which kind of defeats the purpose.
  • Then, when the player dies, you run a procedure that kills any item entities that are of your special equipment. (To prevent duping.) You'll probably want a tag for this.
  • When the player respawns, you then go through each itemstack variable, adding one of that itemstack to the player's inventory. 

Questions?