1

Command help

HeadBodyScript 3/13/21 4:13 pm
171
3/17/2021 12:50 pm
First post idk where to post this but I need help

I am not sure if this is a bug or if I need to do something so if you do know please help



I have an item: minecraft:crossbow

With the name: Glock-18-Standard



When I try to detect a player holding it it only works when the item has been renamed with an anvil, not when given with the /replace or give



My full result will be to test if the crossbow with a specific name is loaded with an arrow or now



/execute if entity @a[​nbt={SelectedItem:{tag:{display:{Name:"{\"text\":\"Glock-18-Standard\"}"}}}}] run say hi
replaceitem entity @p weapon.mainhand minecraft:crossbow{display:{Name:'[{"text":"Glock-18-Standard"}]'}}



The >run say hi at the end is to test if it works but as said, it doesn't unless prev stated



The end full result should look like this with score gun is a reload, there will be a chain command removing 1 point each time this command fully triggers




Repeating command block : execute if score @p gun1 matches 1.. run execute as @p[​nbt={SelectedItem:{tag:{display:{Name:'[{"text":"Glock-18-Standard","italic":true}]'},Charged:0}}}] run replaceitem entity @s[​nbt={SelectedItem:{tag:{display:{Name:'[{"text":"Glock-18-Standard","italic":true}]'},Charged:0}}}] weapon.mainhand minecraft:crossbow{display:{Name:'[{"text":"Glock-18-Standard","italic":true}]'},Charged:1,ChargedProjectiles:[{id:"minecraft:arrow",Count:1}]}

So it checks if the player has a score of at least 1, than if the player is holding the correct item (identified by name) it will replace that item with a loaded one
Posted by
HeadBodyScript
Level 56 : Grandmaster Cupcake
106

  Have something to say?

JoinSign in

3

3XX3
03/13/2021 7:48 pm
Level 21 : Expert Artist
Check for crossbow: /execute if entity @a[nbt={SelectedItem:{tag:{display:{Name:'{"text":"Glock-18-Standard"}'}}}}]

Replace: /replaceitem entity @p weapon.mainhand crossbow{display:{Name:'{"text":"Glock-18-Standard"}'}} 1



---------------------------

/execute if score @p gun1 matches 1.. run execute as @p[nbt={SelectedItem:{tag:{display:{Name:'{"text":"Glock-18-Standard"}'},Charged:1b}}}]
2
HeadBodyScript
03/16/2021 7:04 pm
They/Them • Level 56 : Grandmaster Cupcake
That fixed most of the problems :) thanks. I will be able to continue from here
2
3XX3
03/17/2021 12:50 pm
Level 21 : Expert Artist
Your welcome
1

Welcome