Mojira Archive
MCM-1615

execute if/unless entity false positives after teleporting sender

Partner Rank:
2

Partner Team Reporting:
Everbloom Games

Verification builds:
1.19.60

Summary:
The execute if/unless entity subcommands sometimes gives false positives due to evaluating the selector at the wrong position, when run inside a function that teleports the sender.

Impact:
This is unintuitive behavior that makes things difficult to debug (I spent at least 45 minutes of debugging trying to find the problem). For now, we can partially get around it by using as <selector> instead of if entity <selector> to cancel the execution if the selector fails. No easy workaround for unless entity.

Repro Steps:

  1. Create a function test/tp_bug with the following contents:
# Teleport sender .5 blocks on XZ axes, if not occupied by blocks
tp @s ~.5 ~ ~.5 true
# Say the name of the entity in chat if the sender is at the original position (the teleport failed)
say selector: @s[r=0.1]
# Say selector failed/selector passed according to whether the above selector failed/passed
execute unless entity @s[r=0.1] run say selector failed
execute if entity @s[r=0.1] run say selector passed
  1. Call the function in chat (wrap in an execute to avoid another bug with running functions from chat): execute run function test/tp_bug
  2. Run the function again, when right next to a block on the positive x or z axes

Observed Results:

It always says "selector passed", regardless of whether the selector found an entity in the say command, implying that if/unless entity assumes the execution position to be the same as the sender, instead of the function's execution position.

Expected Results:

It will say `selector passed` if and only if the say command above prints your name after the colon, as they're both testing for the same selector in the same context.

Regression Build:

N/A

Screenshots / Videos Attached:

No

Unresolved

Energyxxer

2022-12-15, 06:11 PM

2022-12-15, 10:01 PM

0

0

-

-