How to Make an Enchantment Save Inventory

Started by Haxuda_02 on

Topic category: Help with Minecraft modding (Java Edition)

Joined Feb 2025
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
How to Make an Enchantment Save Inventory

Hello! Help me make an enchantment that can be cast on any item. And then if the player dies in "gamerule keepInventory False", then all items will drop as usual, and the item with this enchantment will not drop and will remain with the player. Please help me do this. Thank you! 

Joined Jul 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
If there can only be one…
Sun, 10/19/2025 - 09:29

If there can only be one item per player: Make an itemstack player persistent variable, on enchantment of the item set the variable to the item being ennchanted. Then on player respawn, check for item with enchantment in the players inventory, if there is none, add one to inventory and add the enchantment if it keeps it.

For more than one item idk. Make more variables, one for each of them.