-1

I was wondering how I could make my "molten iron sword" (a carrot on a stick) change my "Strong iron armor" (Iron armor with CustomModelData of 2 and other nbt properties) into my "Molten Iron Armour" (Iron Armor with a CustomModelData of 1 and other nbt properties) by right-clicking and also changing back to "Strong iron armor" when right-clicked for a second time (With Molten Iron Armour on).

1

You can set up a a scoreboard objective that keeps track of uses of carrots on a stick with this command:

/scoreboard objectives add carrots minecraft.used:minecraft.carrot_on_a_stick

You could then execute these commands in a function that executes every tick:

#tag players with strong armor who used a carrot on a stick
tag @a[scores={carrots=1..},nbt={Inventory:[{Slot:100b,id:"minecraft:iron_boots",<strong NBT>},{Slot:101b,id:"minecraft:iron_leggings",<strong NBT>},{Slot:102b,id:"minecraft:iron_chestplate",<strong NBT>},{Slot:103b,id:"minecraft:iron_helmet",<strong NBT>}]}] add strongArmor

#tag players with molten armor who used a carrot on a stick
tag @a[scores={carrots=1..},nbt={Inventory:[{Slot:100b,id:"minecraft:iron_boots",<molten NBT>},{Slot:101b,id:"minecraft:iron_leggings",<molten NBT>},{Slot:102b,id:"minecraft:iron_chestplate",<molten NBT>},{Slot:103b,id:"minecraft:iron_helmet",<molten NBT>}]}] add moltenArmor

#set the armor of any player who used a carrot on a stick and has the moltenArmor tag to strong armor
replaceitem entity @a[tag=moltenArmor] armor.head <strong helmet>
replaceitem entity @a[tag=moltenArmor] armor.chest <strong chestplate>
replaceitem entity @a[tag=moltenArmor] armor.legs <strong leggings>
replaceitem entity @a[tag=moltenArmor] armor.feet <strong boots>

#set the armor of any player who used a carrot on a stick and has the strongArmor tag to molten armor
replaceitem entity @a[tag=strongArmor] armor.head <molten helmet>
replaceitem entity @a[tag=strongArmor] armor.chest <molten chestplate>
replaceitem entity @a[tag=strongArmor] armor.legs <molten leggings>
replaceitem entity @a[tag=strongArmor] armor.feet <molten boots>

#remove the tags
tag remove @a strongArmor
tag remove @a moltenArmor

#set the scoreboard objective "carrots" back to 0 for all players
scoreboard players set @a carrots 0
  • Comments are not for extended discussion; this conversation has been moved to chat. If you need to better specify the requirements of your question, edit your question, but not in a way that invalidates current answers or makes the question too broad. – Wrigglenite Aug 20 at 11:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.