[SPIGOT-4534] CreatureSpawnEvent's with SpawnReason CHUNK_GEN are no longer occurring. Created: 16/Dec/18  Updated: 17/Dec/18  Resolved: 17/Dec/18

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

Type: Bug Priority: Minor
Reporter: Jesse Prescott Assignee: Unassigned
Resolution: Fixed Votes: 1
Labels: None

Issue Links:
Relates
relates to SPIGOT-4533 SpawnCreatureEvent not firing for Vil... Resolved
Version: This server is running CraftBukkit version git-Spigot-140f654-b446cb5 (MC: 1.13.2) (Implementing API version 1.13.2-R0.1-SNAPSHOT)
Guidelines Read: Yes

 Description   

CreatureSpawnEvent's used to have the SpawnReason as "CHUNK_GEN" if the creature being spawned was due to first-time chunk generation. Now, no creatures fire the event with "CHUNK_GEN" at all.

 

Recreating:

1) Fresh Spigot/CraftBukkit install with no other plugins.

2) Create a basic plugin with the following event registered to the PluginManager:

@EventHandler(priority = EventPriority.MONITOR)
public void onCreatureSpawnEvent(CreatureSpawnEvent event) { 

   Bukkit.broadcastMessage(event.getSpawnReason().name());
} 

3) Confirm that you are receiving spawn reasons such as "NATURAL" in the chat.

4) Observe that as you load new chunks in a new world, the spawn reason "CHUNK_GEN" is missing.



 Comments   
Comment by md_5 [ 17/Dec/18 ]

Should be resolved now.
In future please open separate tickets for new issues.

Comment by Jesse Prescott [ 17/Dec/18 ]

Just to confirm, the fix seems to call CHUNK_GEN anytime a creature is spawned due to a chunk loading? Previous behaviour was that CHUNK_GEN is called once and only once when a chunk is generated for the first time; subsequent creature spawns due to chunk loading were using NATURAL.

Is that going to be new behaviour? If so, it might be an idea to update the javadoc for SpawnReason to make this clear.

Comment by md_5 [ 16/Dec/18 ]

Because generatoraccess is not world

It'll be fixed soon

Comment by Jesse Prescott [ 16/Dec/18 ]

So how come the previous patches no longer work?

https://hub.spigotmc.org/stash/projects/SPIGOT/repos/craftbukkit/browse/nms-patches/WorldGenVillagePieces.patch

Comment by Jesse Prescott [ 16/Dec/18 ]

Can confirm CraftBukkit 1.12.2 does fire CHUNK_GEN events.

Comment by Jesse Prescott [ 16/Dec/18 ]

I'm just testing previous versions of CraftBukkit to confirm the bug was introduced in 1.13 onwards and i'll get back to you.

Interesting, so was the world gen not isolated from the rest of the server from 1.12.2 and below?
The problem is for any creatures such as the Villager, that do only spawn because of CHUNK_GEN would have a lack of events to capture the spawning of them. The reason i noticed the bug was because an algorithm I had made to inject a custom villager into naturally generated villages stopped working.

Comment by md_5 [ 16/Dec/18 ]

Presumably since 1.13

The problem is chunk gen is isolated from the rest of the server.
The only fix for this is to fire all events in a row when the new chunk is first loaded

Comment by Jesse Prescott [ 16/Dec/18 ]

Possibly related to: https://hub.spigotmc.org/jira/browse/SPIGOT-4533

Generated at Tue Apr 22 04:20:15 UTC 2025 using Jira 10.3.5#10030005-sha1:190c783f2bd6c69cd5accdb70f97e48812a78d14.