1

Commands: Selected Item Help

LightningBlockO 9/8/21 10:18 pm
2k
9/8/2021 11:21 pm
Hi, I'm really new to this place and mostly came just to ask for some help with a command I'm making for a server with my friends.

I'm not sure if this is the right place to post this but anyways:



I am trying to make a command block detect if a player is holding a custom item. I know a bit of the basics but It won't work for me and I've searched everywhere.

I'm not sure if I am doing something wrong or I messed up the UUID of the actual stuff that is causing it not to work. I'm just not sure why it's not working.

Item: /give @p minecraft:blaze_rod{display:{Name:"[{\"text\":\"The Scorching Sizzler\",\"color\":\"blue\",\"italic\":false}]",Lore:["[{\"text\":\"Worker Grade Weapon\",\"color\":\"blue\",\"italic\":false}]:","[{\"text\":\"(Unsellable)\",\"color\":\"dark_red\",\"italic\":false}]"]}, Enchantments:[{id:fire_aspect,lvl:10}], AttributeModifiers:[{Slot:"mainhand", AttributeName:"generic.max_health", Amount:-0.8, Operation:1, UUID:[I; -1, -1, -1, -1]}]} 1

Repeating Command Block: /execute if entity @a[nbt={SelectedItem:{id:"minecraft:blaze_rod", tag:{display:{Name: '[{"text":"The Scorching Sizzler","color":blue","italic":false}]', Lore: ['[{"text":"Worker Grade Weapon","italic":"false,"color":"blue"}]']}}}}] run effect give @a[nbt={SelectedItem:{id:"minecraft:blaze_rod", tag:{display:{Name: '[{"text":"The Scorching Sizzler","color":blue","italic":false}]', Lore: ['[{"text":"Worker Grade Weapon","italic":false,"color":"blue"}]']}}}}] minecraft:fire_resistance 1 255 true

(Version 17.1)

If my commands aren't working at all, then is there another way I could make it so the command block adds fire resistance to the person holding the custom item?

I appreciate any help!
Posted by
LightningBlockO
Level 1 : New Miner
0

  Have something to say?

JoinSign in

3

HoboMaggot
09/08/2021 10:31 pm
Level 55 : Grandmaster Blob
I suggest you only detect if the player is holding an item with custom nbt as that allows the game to check the item using less nbt (the more nbt, the more laggier the game will become, especially if you're checking for many at the same time, as the game is checking every single player slot for that specific item and specific nbt.

Commands:

/give @p minecraft:blaze_rod{custom_tag:1b}/execute if entity @a[nbt={SelectedItem:{id:"minecraft:blaze_rod", tag:{custom_tag:1b}}] run COmmands
4
LightningBlockO
09/08/2021 11:17 pm
Level 1 : New Miner
Thank you so much. I did some scrambling around and it actually is working now. :D
1
LightningBlockO
09/08/2021 11:21 pm
Level 1 : New Miner
Here are the commands:

The Actual item: /give @p minecraft:blaze_rod{custom_tag:1b, display:{Name:"[{\"text\":\"The Scorching Sizzler\",\"color\":\"blue\",\"italic\":false}]",Lore:["[{\"text\":\"Worker Grade Weapon\",\"color\":\"blue\",\"italic\":false}]","[{\"text\":\"(Unsellable)\",\"color\":\"dark_red\",\"italic\":false}]"]}, Enchantments:[{id:fire_aspect,lvl:10}], AttributeModifiers:[{Slot:"mainhand", AttributeName:"generic.max_health", Amount:-0.8, Operation:1, UUID:[​I; -1, -1, -1, -1]}]} 1

This is the repeating command block: /execute if entity @a[​nbt={SelectedItem:{id:"minecraft:blaze_rod", tag:{custom_tag:1b}}}] run effect give @a[​nbt={SelectedItem:{id:"minecraft:blaze_rod", tag:{custom_tag:1b}}}] minecraft:fire_resistance 1 255 true

Again thank you so much!
1

Welcome