The syntax for clear is as following:
/clear [player] [item] [data] [maxCount] [dataTag]
Your command is as following:
/clear @a torch 1 1 {display:{Name:"Special Torch"}}
You are trying to clear (for everyone in the server) torches with a data value of 1, a max count of 1 and a name of "Special Torch".
Seeing as there are no torches with a data value of 1, try using the following:
/clear @a torch 0 1 {display:{Name:"Special Torch"}}
There is a way to do this in vanilla using commands. I got the general idea from betathedata on reddit, but the commands below are my own implementation of the technique.
This method relies on the fact, that a villager without trade offers has no trade interface, but right-clicking it will still count as "talking" to him. Therefore, having an invisible villager at your location while holding a specific item will do the trick.
Scoreboard objectives
For this to work, we need three objectives set up.
scoreboard objectives add holdingItem dummy
scoreboard objectives add holdTime stat.playOneMinute
scoreboard objectives add rightClick stat.talkedToVillager
The first two are for tracking when a player has just selected a specific item, the third one is what we want to unobtrusively set to 1.
Clock commands
First, set up a fill clock large enough to run at least 8 commands. Start off with
scoreboard players set @a holdingItem 0
scoreboard players set @a holdingItem 1 {SelectedItem:{id:minecraft:iron_ingot}}
scoreboard players reset @a[score_holdingItem=0] holdTime
Replace the SelectedItem
tag with whatever you like. You can add multiple of this second command if you want it to work for multiple items.
execute @a[score_holdTime=1] ~ ~ ~ summon Villager ~ ~ ~ {CustomName:"RightClicky",Offers:{Recipes:[]},NoAI:1,Silent:1,ActiveEffects:[{Id:14,Duration:9999,ShowParticles:0b},{Id:11,Amplifier:4,Duration:9999,ShowParticles:0b}]}
execute @a[score_holdTime_min=2] ~ ~ ~ tp @e[type=Villager,name=RightClicky,r=2,c=1] @a[c=1]
execute @a[score_holdingItem=0] ~ ~ ~ tp @e[type=Villager,name=RightClicky,r=2,c=1] ~ -100 ~
The first will summon a villager called RightClicky, who does not move, does not speak and has Invisibility and Resistance V (=Invulnerability), when you swap to the item(s) you specified above.
The second and third commands will either teleport that Villager to you, or into the void (killing him without particle effects showing), depending on whether you are still holding your item or not. This teleporting causes the villager to lag behind you a little, so it does not always work when you are running.
After putting in these commands, your RightClick
score will go up every time you right click while holding your item. At this point, place any commands that are supposed to be triggered by the right-click. Use @a[score_RightClick_min=1]
for targetting. For example:
effect @a[score_RightClick_min=1] minecraft:jump_boost 10 5
At the very end of your clock, run
scoreboard players set @a RightClick 0
to reset the system to detect another right-click.
Detecting a Left-Click should also possible. After summoning the villager, you can detect if a player hits it, as detailed in this question. Putting the two together is left as an exercise to the reader.
Best Answer
Here is a solution that will give anyone wearing a leather chestplate named
Hero's Tunic
the tagWearing
. This tag can then be used to target that person for the effect. Commands are for 1.12.2.Note: Using only these commands, if a player ever wears the chestplate, they will be tagged and the effect will be applied forever, even if no longer wearing the chestplate. (unless the tag is manually removed via a command)
Make command block that is RepeatUnconditionalAlways Active with command:
Here is an example command that gives them a level 2 slowness effect for 1 second. This will be a constant effect if the command is placed into a RepeatUnconditionalAlways Active command block:
To remove the tag from a player:
Replace
<player_name>
with the name of the player that you want to remove the tag from.To remove the tag from all players:
Edit: Response to comments.
To have more tags for more pieces of armor you would change the first command:
Replace
<tagName>
with whatever name you like. You could use numbers if wanted. (Wearing1
,Wearing2
, etc) You could also use other names that describe whatever you like.Example:
WearingHerosTunic
You can use a different tag for each different chest plate.Then use those tags in the other commands: