1

What's wrong with this command?

Conycon's Avatar Conycon2/19/20 11:36 am history
1 emeralds 271 6
2/20/2020 3:22 am
HoboMaggot's Avatar HoboMaggot
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 &quot, but they are " in minecraft.
Posted by Conycon's Avatar
Conycon
Level 31 : Artisan Button Pusher
3

Create an account or sign in to comment.

6

HoboMaggot
02/20/2020 2:29 am
Level 52 : Grandmaster Blob
history
HoboMaggot's Avatar
Assuming you got the blue wool with something like this command:/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
1
Bertiecrafter
02/20/2020 3:05 am
Level 70 : Legendary Engineer
history
Bertiecrafter's Avatar
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:
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} 1With the /clear command being:
/clear @a blue_wool{my_epic_wool_block:1b}
Note that this command should not be wrapped in /execute
2
HoboMaggot
02/20/2020 3:22 am
Level 52 : Grandmaster Blob
HoboMaggot's Avatar
@p/@a in this context basically mean the same thing.

Do agree with ur other points tho
2
Shuppin
02/19/2020 1:27 pm
Level 1 : New Miner
Shuppin's Avatar
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
1
HoboMaggot
02/20/2020 2:21 am
Level 52 : Grandmaster Blob
HoboMaggot's Avatar
Command blocks still use @p as intended, except it detects for players near the block instead of a player.
1
Conycon
02/19/2020 5:02 pm
Level 31 : Artisan Button Pusher
Conycon's Avatar
I am, I’ll try changing it to @a and see if it works
1
Planet Minecraft

Website

© 2010 - 2024
www.planetminecraft.com

Welcome