[SPIGOT-6891] Crash when importing 1.17 chunks with entities above the world, when a BlockPopulator is active Created: 06/Jan/22  Updated: 29/Jan/22  Resolved: 29/Jan/22

Status: Resolved
Project: Spigot
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Minor
Reporter: Rutger Kok Assignee: Marvin Rieple
Resolution: Fixed Votes: 1
Labels: crash, custom-world-generation, world-conversion
Environment:

N/A (reproduced on both Windows 11 and Ubuntu 20.04.3 LTS)


Attachments: File EmptyBlockPopulator.jar     Text File console-output.txt     Zip Archive world.zip    
Issue Links:
Duplicate
is duplicated by SPIGOT-6908 "Entity {...} is not in the region" s... Resolved
Version: This server is running CraftBukkit version 3395-Spigot-f4ff00f-cc86ab1 (MC: 1.18.1) (Implementing API version 1.18.1-R0.1-SNAPSHOT)
Guidelines Read: Yes

 Description   

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.



 Comments   
Comment by Nathan Wolf [ 24/Jan/22 ]

I have a live server crashing constantly, I'd love to see this PR get pulled.

Comment by Rutger Kok [ 22/Jan/22 ]

Thanks! For sure this will help custom terrain lovers with old worlds.

Comment by Marvin Rieple [ 22/Jan/22 ]

Made a PR for this: craftbukkit#995

Comment by Rutger Kok [ 07/Jan/22 ]

It's an 8 year old world visited by many players, I have no idea how the projectile ended up there. Maybe some kind of farm? As far as I know only arrows experience gravity, so these fireball projectiles can go quite high before their time is up.

Anyways, I just tested and the server also crashes for an entity edited to be at y=320. However, y=319 is fine and doesn't cause a crash.

Comment by FreeSoccerHDX [ 06/Jan/22 ]

Fireball was just infinity flying up ...
Weird to have Entities saved at that high too ^^ 

Comment by Marvin Rieple [ 06/Jan/22 ]

Why / how do you have entities at y level 8783?

Generated at Sun Mar 30 02:32:26 UTC 2025 using Jira 10.3.3#10030003-sha1:d220e3fefc8dfc6d47f522d3b9a20c1455e12b7b.