Replacing item1 with item2 when item1 breaks

Started by An Alien on

Topic category: Help with modding (Java Edition)

Last seen on 10:34, 19. Jul 2022
Joined Jul 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Replacing item1 with item2 when item1 breaks
Wed, 07/06/2022 - 21:33 (edited)

Hi.

I wanted to know how can I replace an item with another one when the first one breaks. I also want it to be in the same slot. So for example, if item1 was in the slot 4, the new item is replaced in the slot 4. Or if it was in the offhand (left hand usually), it replaces in the offhand too.

Thank you. :D

Edited by An Alien on Wed, 07/06/2022 - 21:33
Last seen on 05:05, 30. Oct 2022
Joined Mar 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Set a global trigger "when…
Thu, 07/07/2022 - 23:15

Set a global trigger "when item breaks" and check if [provided itemstack] is the item you are looking for.  If so, set a new item in whatever slot you want. Most items will break as they are used, so will be in "main-hand".  For other types of items, use the appropriate slot.

 

If you want the replacement item to be a "broken" version of the original you'll want to copy over any NBT tags. 

I go over this in a reply to a similar topic here.