mojira.dev
MC-231283

Sneak Detection Inconsistency Between Scoreboards and Predicates

Summary:

The 'minecraft.custom:minecraft.sneak_time' scoreboard objective is triggered when crouching while flying in creative. Additionally, the scoreboard objective is NOT triggered when a player stands under a slab, unless they are holding the designated sneak key.

On the other hand, the 'is_sneaking' flag for predicates is unable to detect crouching during creative flight, but does detect a player standing in a 1.5 block space without holding the sneak key. This behaviour is inconsistent.

 

Steps to Reproduce:

1. Enter creative mode.

2. Create a new scoreboard objective using this command:

scoreboard objectives add sneakTest minecraft.custom:minecraft.sneak_time

3. Place a repeating, always active command block and type the following command into it:

execute if score @p sneakTest matches 1.. run say SNEAKING

4. Attach a chain, always active command block to the repeating command block, and enter this command into it:

scoreboard players reset @a sneakTest

5. Finally, fly up and then press your designated crouching key in order to fly down again. The repeating command block will be triggered by this, and the word 'SNEAKING' will appear in the chat. This shows that the sneak_time scoreboard detects sneaking during creative flight.

6. A predicate can now be created and placed into a datapack to verify that they do not detect sneaking during creative flight:

{
  "condition": "minecraft:entity_properties",
  "entity": "this",
  "predicate": {
    "flags": {
      "is_sneaking": true
    }
  }
}

A function or command block would then need to test for the predicate and run a command when triggered. If done correctly, the predicate will detect crouching on the ground, but will not detect crouching during creative flight.

Similar steps can be taken to verify scoreboard and predicate crouch-detection behaviour when standing in a 1.5 block space (under a slab).

 

The expected behaviour here would be for scoreboards and predicates to be consistent in their detection of crouching. They should either both detect sneaking based on key-press (current scoreboard behaviour), or both detect sneaking based on the player hitbox (current predicate behaviour).

However, a nicer fix would be to rename 'minecraft.custom:minecraft.sneak_time' to more accurately portray its real behaviour (for instance 'minecraft.custom:minecraft.sneak_attempt_time'). This would allow both behaviours to be leveraged by datapack makers.

Attachments

Comments 4

Personally I think it's nice to be able to distinguish between the two cases, if they worked identically it would not be possible to do so

Is this how replying works?
I agree that the behaviours should not actually be changed. I think it would be really nice to have an option between the two, and personally would benefit from the current scoreboard behaviour not being altered. 
This is why I suggested the option of renaming the scoreboard to better reflect what it actually does.

Can confirm in 1.18.1

Still an issue as of 1.19.1

user-f5d8c

rorybd

(Unassigned)

Community Consensus

(Unassigned)

command, predicate, scoreboard, sneaking

1.17, 1.17.1 Release Candidate 2, 1.17.1, 1.18.1, 1.19.1, ..., 1.20, 1.20.2, 1.20.3 Release Candidate 1, 1.20.4, 1.21.1

Retrieved