Uploaded image for project: 'Spigot'
  1. Spigot
  2. SPIGOT-6891

Crash when importing 1.17 chunks with entities above the world, when a BlockPopulator is active

XMLWordPrintable

    • This server is running CraftBukkit version 3395-Spigot-f4ff00f-cc86ab1 (MC: 1.18.1) (Implementing API version 1.18.1-R0.1-SNAPSHOT)
    • Yes

      When the server attempts to import a chunk from Minecraft 1.17 (or maybe also earlier, not tested) and it encounters an entity above the world, the server will crash if a (plugin-provided) org.bukkit.generator.BlockPopulator instance is active for that world. It crashes with java.lang.IllegalStateException: Entity EntitySmallFireball['Small Fireball'/13, l='ServerLevel[world]', x=-8017.32, y=8783.24, z=2132.08] is not in the region (or similar).

      This seems quite specific, but it means that a server with a custom BlockPopulator cannot read parts of old worlds. I get similar crashes multiple times per day due to players visiting old chunks, with different projectile entities: arrows, fireballs, wither skulls, etc. For the past week, I've been trying to pinpoint the issue.

      The issue does not happen if the plugin providing the BlockPopulator instance is removed. The issue also does not happen if I manually edit the region files (using an external program, NBTExplorer) to remove the entity above the world.

      To help reproducing the issue, I've attached a world with the offending region file. The spawn of the world was moved so that the chunk is loaded on startup, making the server crash without requiring player movement.

      The server is not able to write the crash report to disk, nor to finish writing the log file, so I've attached the output of the console. I've also attached an example plugin that triggers the issue; it's just an empty block populator.

      Steps to reproduce

      • Download the attached world, use it as the main world.
      • Download the attached plugin, place it in the plugins folder.
      • Start the server, and watch it crash before it is finished loading the spawn area.

      Source code of the example plugin that triggers the issue (use with the provided world):

      import java.util.Random;

      import org.bukkit.event.EventHandler;
      import org.bukkit.event.Listener;
      import org.bukkit.event.world.WorldInitEvent;
      import org.bukkit.generator.BlockPopulator;
      import org.bukkit.generator.LimitedRegion;
      import org.bukkit.generator.WorldInfo;
      import org.bukkit.plugin.java.JavaPlugin;

      public class Startup extends JavaPlugin implements Listener {

          @Override
          public void onEnable() {
              getServer().getPluginManager().registerEvents(this, this);
      {{    }}}

          @EventHandler
          public void onWorldInitEvent(WorldInitEvent event) {
              event.getWorld().getPopulators().add(new BlockPopulator() {
                  @Override
                  public void populate(WorldInfo worldInfo, Random random, int chunkX, int chunkZ, LimitedRegion area) {
                      // Empty!
      {{            }}}
              });
      {{    }}}
      }

      Speculation of cause:

      Loading old chunks triggers Mojangs retrogen magic, which triggers the logic for custom block population, which triggers the entity-out-of-region check in org.bukkit.craftbukkit.v1_18_R1.generator.CraftLimitedRegion.saveEntities.

        1. world.zip
          6.61 MB
        2. EmptyBlockPopulator.jar
          4 kB
        3. console-output.txt
          271 kB

            DerFrZocker Marvin Rieple
            rutgerkok Rutger Kok
            Votes:
            1 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: