Change Biome Type
#11
So...
When the season changes, the plugin will first change the biomes around all players in a radius, according to viewdistance. Then, using HOOK_CHUNK_AVAILABLE, it will change each chunk as it loads.
Just FYI, the biome changes are so that the client will show, for example, the grass differently, or it will snow, etc. I dont get why it will have to trigger chunk regeneration, though...

I am thinking of making it so that animals will have more chances not spawn, and so that monsters will have a chance to "double spawn".

Thank you all for your time. Beware, I am a noob, so it shall take some time to make it...
Again, thanks
Reply
Thanks given by:
#12
Okay, it should be do-able once we get a function that enumerates through all available chunks that are already loaded.
Reply
Thanks given by:
#13
You cannot change the entire world at once, because the server would have to load all the chunks for the world and re-save them with the new biomes. You need to follow a different approach, you've already mentioned that - first change all the chunks around players and then change each chunk as soon as it gets loaded or generated by the server. Note that you can already keep track of the loaded chunks for each world, simply by using the chunk unloading and loading hooks to store the chunk coords in a table.

There will probably never be a proper API function to enumerate all the loaded chunks, because as soon as such a function call would return, the data could be invalid - another thread may unload the chunk or load another chunk. We could use callback-based API so that you can execute code for each chunk loaded, but in this plugin's case it could be too much of a performance hit.
Reply
Thanks given by:
#14
Then how can one reliably get all currently loaded chunks? Will calculations based off the player's viewdistance work?
Reply
Thanks given by:
#15
You cannot reliably get all loaded chunks. You either want the chunks loaded, and use the cWorld:ChunkStay() function to make sure they are loaded, or keep track of the chunks using the loading and unloading hooks - those are serialized so you're guaranteed that the chunks that you have in your list are loaded. This won't work well with plugin reloads, though.

Alright, making a callback to enumerate all loaded chunks sounds like a good idea in this context.
Reply
Thanks given by:




Users browsing this thread: 2 Guest(s)