1
Command help
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
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
3
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}}}]
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}}}]
That fixed most of the problems :) thanks. I will be able to continue from here
Your welcome
