Enchanting Enchantable Items in player inventory

Started by skatric on

Topic category: Help with modding (Java Edition)

Last seen on 09:01, 23. Jun 2024
Joined Oct 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Enchanting Enchantable Items in player inventory

Hi, I made an enchantment in mcreator and made it so every item in game can take this enchantment and I want to add procedure when I right click with item it enchant everything in inventory is this possible ?
I also made item tag for all items if this may help 

ty

Last seen on 14:39, 13. Oct 2024
Joined May 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Yes, this is possible, you…
Thu, 11/02/2023 - 03:26

Yes, this is possible, you can both get the enchantability of an item, and enchant items arbitrarily using functions in MCreator. In your case, you would want to make a procedure that triggers when your item is right clicked. Then, find a 'get contents of entity inventory as itemstack iterator' bracket from the entity management tab.

Essentially, this bracket goes through each item in the player's inventory, and runs a function on each one individually. Inside, you want to first make an if bracket that checks if the itemstack iterator has an enchantability greater than zero, and, if it does, applies your enchantment to the itemstack iterator. (Everything inside needs to use the 'itemstack iterator,' the currently selected item; instead of the 'provided itemstack,' which is the item the player is right clicking.)