ITADN

LimitedRegion#spawnEntity of a monster on a peaceful world NPEs during chunk generation, crashing the server (26.2)

#13992Opentastybento 创建于 2026-06-27
status: needs triageversion: 26.2
T
tastybentocommented
### Expected behavior Calling LimitedRegion#spawnEntity(Location, EntityType) from a BlockPopulator during chunk generation should spawn the entity (or, if the entity can't be created, fail gracefully / return null) — regardless of the world's difficulty. This works on easy, normal, and hard. ### Observed/Actual behavior On a peaceful world, calling `LimitedRegion#spawnEntity(...)` with a monster type (e.g. ZOMBIE, DROWNED, GUARDIAN) during chunk generation throws an NPE inside Paper. Peaceful disallows hostile mobs, so the entity factory produces a null entity, and `RegionAccessor#spawnEntity` does not null-check it before calling `entity.absSnapTo(...)`. The exception is raised on a chunk-system worker thread, so it escalates to unrecoverableChunkSystemFailure → "Chunk system crash" → the server shuts down. It is difficulty-dependent: identical code/world spawns the same monster fine on easy/normal/hard, and crashes only on peaceful. Non-monster entities are unaffected. ``` [ERROR]: Encountered an unexpected exception java.lang.RuntimeException: Chunk system crash propagated to tick() at net.minecraft.server.MinecraftServer.processPacketsAndTick(MinecraftServer.java:1682) ~[paper-26.2.jar:26.2-34-2960379] at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1347) ~[paper-26.2.jar:26.2-34-2960379] at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:302) ~[paper-26.2.jar:26.2-34-2960379] at java.base/java.lang.Thread.run(Unknown Source) ~[?:?] Caused by: java.lang.RuntimeException: Chunk system crash propagated from unrecoverableChunkSystemFailure at ca.spottedleaf.moonrise.patches.chunk_system.scheduling.ChunkTaskScheduler.unrecoverableChunkSystemFailure(ChunkTaskScheduler.java:333) ~[paper-26.2.jar:26.2-34-2960379] ... moonrise chunk-system frames ... Caused by: net.minecraft.ReportedException: Chunk system error ... 14 more Caused by: java.lang.NullPointerException: Cannot invoke "net.minecraft.world.entity.Entity.absSnapTo(double, double, double, float, float)" because "entity" is null at org.bukkit.craftbukkit.entity.CraftEntityTypes.lambda$static$1(CraftEntityTypes.java:258) ~[paper-26.2.jar:26.2-34-2960379] at org.bukkit.craftbukkit.entity.CraftEntityTypes.lambda$combine$0(CraftEntityTypes.java:600) ~[paper-26.2.jar:26.2-34-2960379] at org.bukkit.craftbukkit.CraftRegionAccessor.createEntity(CraftRegionAccessor.java:455) ~[paper-26.2.jar:26.2-34-2960379] at org.bukkit.craftbukkit.CraftRegionAccessor.spawn(CraftRegionAccessor.java:367) ~[paper-26.2.jar:26.2-34-2960379] at org.bukkit.craftbukkit.generator.CraftLimitedRegion.spawn(CraftLimitedRegion.java:271) ~[paper-26.2.jar:26.2-34-2960379] at org.bukkit.craftbukkit.CraftRegionAccessor.spawn(CraftRegionAccessor.java:363) ~[paper-26.2.jar:26.2-34-2960379] at org.bukkit.RegionAccessor.spawn(RegionAccessor.java:424) ~[paper-api-26.2.build.34-alpha.jar:?] at org.bukkit.RegionAccessor.spawnEntity(RegionAccessor.java:326) ~[paper-api-26.2.build.34-alpha.jar:?] at <plugin>.MonsterPopulator.populate(MonsterPopulator.java) // BlockPopulator during chunk gen at net.minecraft.world.level.chunk.ChunkGenerator.applyBiomeDecoration(ChunkGenerator.java:471) ~[paper-26.2.jar:26.2-34-2960379] at org.bukkit.craftbukkit.generator.CustomChunkGenerator.applyBiomeDecoration(CustomChunkGenerator.java:306) ~[paper-26.2.jar:26.2-34-2960379] ... chunk status / generation frames ... ``` ### Steps/models to reproduce 1. Start a Paper 26.2 (build 34) server with `difficulty=peaceful` in server.properties. 2. Install a plugin that adds a BlockPopulator which spawns a monster during generation (minimal reproducer below). 3. Generate new chunks for a world that uses the populator (a freshly created world, or any not-yet-generated chunks). Note: already-generated worlds won't re-run the populator, so the crash only appears on first/fresh generation. 4. The server throws the NPE above on a chunk-system worker thread and shuts down (Stopping server, crash report written). 5. Change difficulty to easy (or normal/hard), delete the world, regenerate → no crash; the monster spawns normally. Minimal reproducer plugin: ``` public final class SpawnRepro extends JavaPlugin { @Override public void onEnable() { // Creating the world triggers spawn-area chunk generation -> the populator runs. new WorldCreator("repro_world") .generator(new ChunkGenerator() { @Override public List<BlockPopulator> getDefaultPopulators(World world) { return List.of(new MonsterPopulator()); } }) .createWorld(); } static final class MonsterPopulator extends BlockPopulator { @Override public void populate(WorldInfo info, Random rng, int cx, int cz, LimitedRegion region) { Location loc = new Location(Bukkit.getWorld(info.getUID()), (cx << 4) + 8, 64, (cz << 4) + 8); region.spawnEntity(loc, EntityType.ZOMBIE); // NPE on peaceful; fine on easy/normal/hard } } } ``` ### Plugin and Datapack List ``` > plugins [17:31:37 INFO]: ℹ Server Plugins (32): [17:31:37 INFO]: Bukkit Plugins: [17:31:37 INFO]: - BentoBox, BentoBox-AcidIsland, BentoBox-AOneBlock, BentoBox-Bank, BentoBox-Biomes, BentoBox-Border, BentoBox-Boxed, BentoBox-BSkyBlock, BentoBox-CauldronWitchery, BentoBox-CaveBlock [17:31:37 INFO]: BentoBox-Challenges, BentoBox-Chat, BentoBox-CheckMeOut, BentoBox-ControlPanel, BentoBox-DimensionalTrees, BentoBox-FarmersDance, BentoBox-Greenhouses, BentoBox-InvSwitcher, BentoBox-IslandFly, BentoBox-Level [17:31:37 INFO]: BentoBox-Likes, BentoBox-Limits, BentoBox-MagicCobblestoneGenerator, BentoBox-Parkour, BentoBox-Poseidon, BentoBox-SkyGrid, BentoBox-StrangerRealms, BentoBox-TwerkingForTrees, BentoBox-Visit, BentoBox-VoidPortals [17:31:37 INFO]: BentoBox-Warps, Vault > datapack list [17:32:13 INFO]: There are 3 data pack(s) enabled: [vanilla (built-in)], [file/bukkit (world)], [paper (built-in)] [17:32:13 INFO]: There are no more data packs available ``` ### Paper version ``` > version [17:31:12 INFO]: Checking version, please wait... [17:31:13 INFO]: This server is running Paper version 26.2-34-dev/26.2@2960379 (2026-06-24T12:51:21Z) (Implementing API version 26.2.build.34-alpha) You are running the latest version Previous version: 26.2-25-13f9986 (MC: 26.2) ``` ### Other - Difficulty isolation (verified, all on build 34, same plugin/world, only difficulty changed): | difficulty | spawn-monsters | result | |------------|----------------|----------| | peaceful | false | crash | | peaceful | true | crash | | easy | false | no crash | | easy | true | no crash | - → difficulty=peaceful is the trigger; spawn-monsters is irrelevant. - Severity: this crashes the whole server (chunk-system failure), not just the offending generation task, so a single populator-spawned monster on a peaceful world takes the server down. - Suspected fix: CraftRegionAccessor#spawn/RegionAccessor#spawnEntity should null-check the result of the entity factory (CraftEntityTypes.createEntity at CraftRegionAccessor.java:455) and either skip/return null instead of dereferencing it (absSnapTo on null). Optionally, the factory shouldn't silently return null for a difficulty-disallowed mob during generation. - I searched existing PaperMC issues (absSnapTo, CraftEntityTypes, unrecoverableChunkSystemFailure, LimitedRegion spawnEntity, etc.) and found no existing report for this; the closest (#13978, World#spawn of slimes throwing IllegalArgumentException) is a different, already-fixed bug.
0 条评论