enchanting items only when in main hand

Started by ShiggyP on

Topic category: Help with MCreator software

Joined Feb 2024
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
enchanting items only when in main hand

I have been attempting failing miserably to create a system in which when a player hold an item it would add +1 sharpness to that item and when it is not in their main hand it reverts to its original level of sharpness including 0. Does anybody know any workarounds or plugins for the most recent mcreator  version on 1.21.1.

Joined Jul 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
i think you would have to…
Sat, 11/01/2025 - 17:18

i think you would have to set up an 'on player tick update' procedure that scans the players inventory, adding a level of sharpness to the item if held, and then removing sharpness when it is no longer held and adding back the original level after the fact.

Joined Feb 2024
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I basically have what you…
Sat, 11/01/2025 - 19:11

I basically have what you said down to enchanting in hand working its the disenchanting and the retaining that's the problem
https://postimg.cc/7CHY7TD4

Joined Jul 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
if item is enchantable will…
Sat, 11/01/2025 - 20:05

if item is enchantable will not work on items that are already enchanted i believe, 

also when you're adding and removing enchantments from an itemstack variable it will only effect the stored variable data, not the actual item that the variable is based on

i think it would be better to do item stack iterator, there's a block that lets you run as item stack iterator for every item in a player's inventory. If the itemstack iterator is enchantable or enchanted and item stack iterator = item held in main hand then you add one level, and give it an nbt true/false tag set to true. then for every itemstack iterator that isn't in your mainhand and has that nbt tag set to true, set it to false and remove 1 level of the enchant

Joined Feb 2024
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
oh ok thank you ill try that…
Sat, 11/01/2025 - 20:07

oh ok thank you ill try that