-1

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)

5
  • Related: gaming.stackexchange.com/questions/226838/…
    – MrLemon
    Commented Jun 7, 2016 at 12:34
  • Why doesn't stat.sneakTime work for you? Is it just that you are unsure how to use it? Or the combination with the armor?
    – MrLemon
    Commented Jun 7, 2016 at 12:36
  • I didn't want to detect if a player wears an armor, I want to detect if a player is crouching wearing an armor
    – iDoomfull
    Commented Jun 7, 2016 at 12:36
  • I know, that's why it's related and not a duplicate.
    – MrLemon
    Commented Jun 7, 2016 at 12:37
  • I am not sure how to use the sneakTime or CrouchOneCm !
    – iDoomfull
    Commented Jun 7, 2016 at 12:38

1 Answer 1

6

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.

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .