1
What's wrong with this command?
Tried for ages to figure it out:
execute if entity @p[nbt={Inventory:[{tag:{display:{Name:"\"Wool Shield\""}}}]}] run clear @p blue_wool{Inventory:[{tag:{display:{Name:"\"Wool Shield\""}}}]}
PS:I don't know why the " have changed into ", but they are " in minecraft.
execute if entity @p[nbt={Inventory:[{tag:{display:{Name:"\"Wool Shield\""}}}]}] run clear @p blue_wool{Inventory:[{tag:{display:{Name:"\"Wool Shield\""}}}]}
PS:I don't know why the " have changed into ", but they are " in minecraft.
Create an account or sign in to comment.
6
Assuming you got the blue wool with something like this command:
You can use this nbt instead for your selector:
tbh @p instead of @a does the same thing
/give @p minecraft:blue_wool{display:{Name:'{"text":"Wool Shield"}'}} 1
You can use this nbt instead for your selector:
execute if entity @a[nbt={Inventory:[{tag:{display:{Name:'{"text":"Wool Shield"}'}}}]}] run clear @s blue_wool{display:{Name:'{"text":"Wool Shield"}'}}
tbh @p instead of @a does the same thing
Well.... that's a strong statement... @p targets the nearest player, @a targets all players.
Also, "if entity" only detects if an entity exists, it does not set @s to the right player. The actual command is:
Those two adjustments in mind, the /give command should be something like:
Note that this command should not be wrapped in /execute
Also, "if entity" only detects if an entity exists, it does not set @s to the right player. The actual command is:
execute as @a[nbt={Inventory:[{tag:{display:{Name:'{"text":"Wool Shield"}'}}}]}] run clear @s blue_wool{display:{Name:'{"text":"Wool Shield"}'}}
- Also, keep in mind that the Name tag should contain all of the specified JSON. This means that if the name contains colour or any other kinds of styling, it should be specified. If you are in control of the command that creates the wool, it might be worth adding a custom item tag in the "tag" object and using that to target players instead.
- Another note, the /clear command already filters the blocks, you don't have to wrap it in a /execute command here.
Those two adjustments in mind, the /give command should be something like:
/give @p minecraft:blue_wool{display:{Name:'{"text":"Wool Shield"}'},my_epic_wool_block:1b} 1
With the /clear command being:/clear @a blue_wool{my_epic_wool_block:1b}
Note that this command should not be wrapped in /execute
@p/@a in this context basically mean the same thing.
Do agree with ur other points tho
Do agree with ur other points tho
Are you running this through a command block because if so then command blocks have strange behaviour with @p tag
i am not sure how to fix though i would just generally avoid using the @p command with command blocks
i am not sure how to fix though i would just generally avoid using the @p command with command blocks
Command blocks still use @p as intended, except it detects for players near the block instead of a player.
I am, I’ll try changing it to @a and see if it works