[SPIGOT-5569] WorldInitEvent only calls after a few chunks were generated when a world is first created Created: 09/Feb/20  Updated: 17/May/21  Resolved: 17/May/21

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

Type: Bug Priority: Minor
Reporter: Leonard Assignee: Unassigned
Resolution: Fixed Votes: 0
Labels: 1.15, api, event, spigot, worldinitevent
Environment:

Windows 10,

java -d64 -Xms3072M -Xmx3072M -DIReallyKnowWhatIAmDoingISwear -jar spigot-1.15.1.jar
PAUSE

 

Additionally, a linux cloud machine with 5GB.

 


Attachments: File WIE-1.jar     File WIE.jar     PNG File screenshot-1.png    
Version: This server is running CraftBukkit version git-Spigot-492a779-e7202cd (MC: 1.15.1) (Implementing API version 1.15.1-R0.1-SNAPSHOT)
Guidelines Read: Yes

 Description   

When WorldInitEvent is called on a new world, a random number of chunks in the spawn area will already be generated. 

 

Attached is a plugin that will log event calls from WorldInitEvent and ChunkLoadEvent. ChunkLoadEvent will call a random number of times before worldinitevent for a new world. 



 Comments   
Comment by Marvin Rieple [ 17/May/21 ]

Made a PR for this: https://hub.spigotmc.org/stash/projects/SPIGOT/repos/craftbukkit/pull-requests/844/overview

Comment by Leonard [ 21/Jun/20 ]

Are you sure that doesn't just generate chunks to create the spawn point?

Comment by Marvin Rieple [ 14/Jun/20 ]

And what if we add flag to the RegionFileCache, during the spawn point finding, if this Flag is present new chunks are saved to a temporary folder. When trying to load a chunk it will first try to find a present chunk in the normal region folder, if no chunk is present it will search in the temporary folder. After the spawn point is found, it will set the flag back to normal and will deleted the chunks in the temporary folder. This way the Spawn point is present and no chunks are permanently generated before WorldInitEvent. The down sites of this method is that the spawn chunks are generated twice and if a Bonus chest is present, it needs also to be re placed.

But if this solutions is suitable, I can implement it.

 

As a temporary fix for Leonard, you can set a "dummy" spawn point via ChunkGenerator#getFixedSpawnLocation(World, Random), this way no spawn chunks should get generated (in theory, I only looked in the code not tested it). And in the WorldInitEvent (or other place) you generated the spawn point your self.

Comment by Leonard [ 26/Apr/20 ]

But what solution did this thread agree on? Are we adding a new event or are we changing worldinitevent?

Comment by md_5 [ 26/Apr/20 ]

The source is managed on Stash, see README.md

Comment by Leonard [ 26/Apr/20 ]

Are we supposed to open a pull request on github or....?

Comment by Leonard [ 10/Apr/20 ]

Is there any update on whether or not this issue will be solved?

Comment by TheCreeperCow [ 23/Feb/20 ]

This really depends on the usage of this event if it's used in the terms of world generation modification it's crucial this gets done correctly otherwise I can't think of a proper usage for it however another thing to consider is the fact how the event is described in the documentation. This event should be called prior to any chunk loading and it's not doing that breaking that promise I think we need to either go with not having a spawn or making a other event that will call prior to chunk loading but doing so will make the naming scheme look bad so I'd personally go for option 1 with the knowledge stuff is gonna break

Comment by md_5 [ 22/Feb/20 ]

As part of the world init process, the world spawn position needs to be found.
Finding the world spawn position requires loading chunks so that the hypothetical spawn position can be tested to see whether it is suitable or not.

Yes, the WorldInitEvent could be moved before this, but then the world will not have a spawn (or populators or border) when the event is called

Comment by TheCreeperCow [ 17/Feb/20 ]

Can reproduce and confirm

PASTEBIN: https://pastebin.com/iQ1df3WT

EDIT: To make sure nothing was editing the results i created a fully new server instance and it still happend here is the log output https://pastebin.com/2W0pCapp

Comment by Leonard [ 12/Feb/20 ]

Yes. Though if it matters, I did disable nether and end.

Comment by md_5 [ 12/Feb/20 ]

Are you generating a fresh world?

Comment by Leonard [ 12/Feb/20 ]

Tried a server with no plugins, but the worldiniteventtester plugin. Same result.

What kind of stack traces do I call on? Do I call one inside ChunkLoad and WorldInitEvent?

https://pastebin.com/MaUTdjit

Changed the plugin a bit and got a stack trace.

New plugin has been attached

Comment by md_5 [ 11/Feb/20 ]

Cannot reproduce on my clean server.
I suggest you add more debug to your plugin such as world name and stack traces. I also suggest you remove other plugins from your server.

Comment by Leonard [ 11/Feb/20 ]

It is definitely present on the latest version of 1.15.2

And it can be so so bad: https://pastebin.com/rfYs7cL3

The new version I'm using is "CraftBukkit version git-Spigot-c574e08-708be69 (MC: 1.15.2) (Implementing API version 1.15.2-R0.1-SNAPSHOT)".

Comment by md_5 [ 09/Feb/20 ]

Cannot reproduce on latest version of 1.15.2, and reviewing the code shows the event is called before any chunks are loaded

Generated at Sat Apr 05 09:38:20 UTC 2025 using Jira 10.3.3#10030003-sha1:d220e3fefc8dfc6d47f522d3b9a20c1455e12b7b.