Climate Damage Effect Engine Documentation - nsporillo/GlobalWarming GitHub Wiki

This page is a work in progress, so far these are my ideas on how to efficiently apply climate damages to the world.

ChunkLoadEvent listener

  • Listen for chunk load events, pass all events to the "Climate Damage Effect Engine".
  • Take a Chunk Snapshot, hand off processing task to another thread.
  • If the temperature threshold is met for any effects, then the chunk will be scanned for features. For example, if the chunk has animals which are now impacted we queue the original state of the animals and the proposed changes.
  • Once the chunk has been processed, merge the proposed changes back onto the main thread where they will be applied if possible.

Every damage effect that's configured will be loaded into memory and will get passed a chunk snapshot when the chunk is loaded. If the configurable temperature preconditions are not met then the async processing is entirely skipped.

Special care is needed to ensure that once we're back on the main thread. If we pass the Entity object, then we need to make sure it isn't dead before we try to change it.

Async processing should still be efficient, if we want to apply a sea level rise then we can first check the biome of the chunk and proceed if it's an ocean variant. Then we want to find the highest blocks and if they are water blocks then queue the block immediately above to replace the air with a water block. Similarly, we should verify the integrity of the blocks we're changing before applying changes. If a player placed dirt blocks in the chunk we're planning to modify, we should not overwrite the players dirt placement.