mojira.dev
MC-261024

/execute if loaded does not guarantee entities are loaded

The bug

According to the changelog, the execute if loaded command "checks if the position given is fully loaded (in regard to both blocks and entities)". However in some cases entities have not finished loading.

How to reproduce

  1. Create a new flat world

  2. Place a repeating command block at world spawn with the following command. Set it to always active.

    /execute if loaded 1000 0 0 unless entity @e[type=pig] run say Chunk is loaded but entity is not!
  3. Teleport to 1000 0 0 and summon a pig there

    /teleport @s 1000 0 0
    /summon pig 1000 0 0 {NoAI:1b}
  4. Leave and rejoin the world

  5. Teleport to the nether and a bit later teleport back
    ❌ Notice that in both cases for one tick the chunk was loaded but the pig wasn't. In more complex worlds with more entities this can take an unpredictable amount of ticks.

Comments 1

This is a very important fix for mapmakers and datapack developers. We don't have a consistent way to check that all entities in an area are loaded and I believe "execute if loaded" was supposed to be the solution. If this check is inconsistent (as it appears to be) then much of its utility will be lost.

Misode

slicedlime

Confirmed

Platform

Important

Commands

1.19.4

1.20 Pre-release 2

Retrieved