I try to make a sort of ability that implies wearing a special chestplate! When a player wear it and crouch, the ability shoud be activated! I just want to know how can I testfor crouching (the "stat.sneakTime" or "CrouchOneCm" scoreboard doesn't help me)
1 Answer
To tag only those wearing the special chestplate, have these two commands repeating in this order:
/scoreboard players tag @a[tag=SpecialChestplate] remove SpecialChestplate
/scoreboard players tag @a add SpecialChestplate {Inventory:[{Slot:102b,tag:{display:{Name:"Special Chestplate"}}}]}
You should replace tag:{display:{Name:"Special Chestplate"}}
with the data you want to identify your chestplate by (e.g: lore, enchantments), I've just used the name "Special Chestplate" for this example.
To check for who's sneaking, first create a stat.sneakTime
objective:
/scoreboard objectives add SneakTime stat.sneakTime
Then, add onto your repeating command blocks in this order:
/say @a[tag=SpecialChestplate,score_SneakTime_min=1]
/scoreboard players set @a[score_SneakTime_min=1] SneakTime 0
The second command will set SneakTime
to 0 at the end of the tick, meaning that only players who are currently sneaking will have a SneakTime
of 1 for the next tick. If a player stops sneaking, their SneakTime
will go to 0.
The /say
command is where you should put the blocks for your ability, using the @a[tag=SpecialChestplate,score_SneakTime_min=1]
selector.
stat.sneakTime
work for you? Is it just that you are unsure how to use it? Or the combination with the armor?