Help me with modifying player inventory slot

Started by Ziadod on

Topic category: Help with Minecraft modding (Java Edition)

Joined Oct 2025
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Help me with modifying player inventory slot

So I have been 5 hours trying to figure out how to get a random slot in the player's inventory each time he breaks a block and apply the sharpness I enchantment on that randomly chosen slot if it has an item and not empty. It just won't work; no errors, but it won't work.
Can anyone tell me what is wrong with my code and how to fix it? Here is my code:

Joined Dec 2014
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
so, in mcreator when you set…
Tue, 10/14/2025 - 21:40

so, in mcreator when you set an item to a variable, it actually copies it.

so you're not modifying the item by modifying the variable,

try using this block at the end,