mojira.dev
MC-260322

Execute on origin does not work for non-living entities

If you summon an area effect cloud, and set its Owner tag to a non-LivingEntity's UUID, then run this command:

/execute as @e[type=minecraft:area_effect_cloud] on origin run say hi

The entity with the UUID will not say anything, and nor will the AEC.

However, if you copy a player's UUID into the Owner of the AEC, it works fine and produces the result:

[Player] hi

If you then set the AEC's Owner back to the non-LivingEntity, it continues to act as if the player was the origin, and produce the same result:

[Player] hi

Exact commands to reproduce:

summon minecraft:area_effect_cloud ~ ~ ~ {Age: -2147483648, Duration: -1, WaitTime: -2147483648, Tags:["hi"]}
summon block_display ~ ~ ~ {Tags:["hi"]}

data modify entity @e[type=area_effect_cloud, tag=hi, limit=1] Owner set from entity @e[type=block_display, tag=hi, limit=1] UUID

execute as @e[type=area_effect_cloud, tag=hi] on origin run say hi
### Expected output: [Block Display] hi
### Actual output: nothing

data modify entity @e[type=area_effect_cloud, tag=hi, limit=1] Owner set from entity @s UUID

execute as @e[type=area_effect_cloud, tag=hi] on origin run say hi
### Expected output: [Player] hi
### Actual output: [Player] hi

data modify entity @e[type=area_effect_cloud, tag=hi, limit-1] Owner set from entity @e[type=block_display, tag=hi, limit=1] UUID

execute as @e[type=area_effect_cloud, tag=hi] on origin run say hi
### Expected output: [Block Display] hi
### Actual output: [Player] hi

This behaviour resets when you reload the world.

Linked issues

Comments 3

that is MC-226344 but for area effect cloud.

this entity has a cache for the owner. 

it could remember the answer when it is the first time getting its owner and it wont do that again.

 

maybe this bug could be fixed by invalidating the cache here.

[media]

adding some thing like this.owner = null; here to invalidate the cache

 
this bug affects some other entities that have owners.

The problem is that the area effect cloud's set & get methods for its owner require that the entity is living, despite there being no place in the code where `LivingEntity` specific class members are used for the AEC's owner. 

[media]

The ideal solution here would be to remove the instance check, remove the `LivingEntity` type cast, and swap the types to `Entity` instead, therefore letting us set the owner to any entity, and use `execute on origin` to access it.

TorNato

(Unassigned)

Confirmed

Platform

Low

Commands

23w07a, 23w43b, 24w13a, 1.21.4

Retrieved