0

I am trying to create a few modified weapons/items in Minecraft, so that when you hit something (left click) with the specific item, it executes a command. I have already found a few answers that make it so that if you use a specific item it executes a command, but that applies for every single one of that item; for example, if a blaze rod gives you strength, every blaze rod in the game will give you strength. Is there a way to do this with only one item?

6
  • This can be achieved using plugins. Is this possible for you?
    – MrParrot
    Oct 16 '21 at 16:46
  • It depends on how you are getting the item. If it is trough commands, yes, you can mark that specific item with a tag. If you aren't using /give, then you are able to rename the item in an anvil, but that means anyone renaming the item would be able to use the special one. There might be a way to transform a random blaze rod into a special one by a certain %, if that works for you.
    – BunnyMerz
    Oct 16 '21 at 17:32
  • @BunnyMerz This would work... but I am not sure how to do it, exactly. Oct 17 '21 at 0:39
  • @MrParrot Unfortunately, I am on a server and only certain plugins can be imported, so it really matters which one. Oct 17 '21 at 0:39
  • "This would work" Which of the 3 solutions do you want? Tagged item, Named item or random drop?
    – BunnyMerz
    Oct 17 '21 at 0:45
1

Easy.

Give yourself a blaze rod that has a very special tag and then iterate through the players to see if they are holding the the speical blaze rod.

say give @s blaze_rod{Unbreakable:3b} 1 gives you a blaze rod with unbreakable 3b tag.

run this in a tick function now execute as @a[nbt={SelectedItem:{id:minecraft:blaze_rod,Count:1,tag:{Unbreakable:3b}}}] run effect give @s strength 2 255 true

This would give effect strength level 255 to anyone who is holding the rod.

Hope this helps.

1
  • You can actually use custom nbt tags, instead of applying impossible values on existing tags. For example, give @s blaze_rod{mytag:1b} 1 can be tested with execute if entity @a[nbt={SelectedItem:{id:minecraft:blaze_rod,Count:1,tag:{mytag:1b}}}]
    – ginkgo
    Dec 28 '21 at 21:38

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.