mojira.dev
MC-256095

Effect duration on players decreased by 1 before a command can see it, but not on mobs

When an effect is applied (eg by a tipped arrow) commands can detect the effect with the full duration on mobs, but for players, the duration has already decreased one tick.

Steps to reproduce:

  1. Run the following commands:

    /give @s bow
    /give @s tipped_arrow{CustomPotionEffects:[{Id:27,Duration:5,Amplifier:0b}]} 10
    /setblock ~ ~ ~1 repeating_command_block[facing=south]{auto:1b,Command:'execute as @e[nbt={ActiveEffects:[{Id:27}]}] run tellraw @p {"nbt":"ActiveEffects[{Id:27}].Duration","entity":"@s"}'}
    /setblock ~ ~ ~2 chain_command_block[facing=south]{auto:1b,Command:'effect clear @e unluck'}
    /give @s bow
    /give @s tipped_arrow{CustomPotionEffects:[{Id:27,Duration:5,Amplifier:0b}]} 10
    /setblock ~ ~ ~1 repeating_command_block[facing=south]{auto:1b,Command:'execute as @e[nbt={ActiveEffects:[{Id:27}]}] run tellraw @p {"nbt":"ActiveEffects[{Id:27}].Duration","entity":"@s"}'}
    /setblock ~ ~ ~2 chain_command_block[facing=south]{auto:1b,Command:'effect clear @e unluck'}
  2. Shoot a mob

  3. ✔ it returns "5" in chat

  4. Shoot a player (eg yourself)

  5. ❌ it returns "4" in chat, meaning that the duration has already decreased

This is problematic for 2 instances:

  1. A duration of 1 tick can be detected on mobs, but not players.

  2. If the duration is set to a specific value (eg to the score of a shooter), it will not return the correct value.

Attachments

Comments 1

Not sure why you set the category to statistics, because it's completely unrelated to those.

user-f2760

(Unassigned)

Confirmed

Statistics

1.19.2

Retrieved