A way for world generators to not be forced to run in an async task #6556
Labels
BC break
Breaks API compatibility
Category: API
Related to the plugin API
Type: Enhancement
Contributes features or other improvements to PocketMine-MP
Problem description
Some generators, like
Flat
, do not require an async task, and using an async task to just copy a chunk is a waste of resources.There may be other cases where it might be desirable to run parts of, or all, of generation on the main thread, such as when creating entities or tiles during a generation step (e.g. paintings or chests).
Proposed solution
Make
Generator->generateChunk()
andGenerator->populateChunk()
returnPromise
, so that individual generators can decide how they want to do async generation. This could be a promise resolved immediately on the main thread with a chunk copy, aPopulationTask
, or perhaps some other mechanism entirely.It may be more complex than this (e.g. a chunk source may be needed for adjacent chunks), but that's the basic premise.
Alternative solutions that don't require API changes
The text was updated successfully, but these errors were encountered: