13rac1 / Minecraft-Water-Erosion

Minecraft Mod - Adds natural water erosion to create streams and waterfalls
https://www.curseforge.com/minecraft/mc-mods/water-erosion
GNU General Public License v3.0
4 stars 1 forks source link

Feature: Implement time since last block change to support "Minimum existence time before erosion" #13

Open 13rac1 opened 4 years ago

13rac1 commented 4 years ago

From https://github.com/13rac1/Minecraft-Water-Erosion/issues/12#issuecomment-590490008

What if water had exist at a specific block position for a minimum period of time before it would erode? I could create a "Minimum existence time before erosion" check by adding a timestamp of last block change.

randomTick() is called on all water blocks, this can result in erosion occurring moments after water flows in an area. This is unrealistic because the erosion process needs time to start soaking the soil/sand before any erosion occurs. Erosion should not occur turn the first X minutes/hours? of a water block's existence.

Gameplay benefit: This enables water-based automatic farms to not erode the farmland soil. Quick flows will just "wash" over the land and never erode anything.

13rac1 commented 4 years ago

I've been thinking about how to best implement this. BlockStates can store the numbers 0 to 15, which isn't enough resolution in this case.

Sadly, abstractions are lies at their core. We still have the responsibility of translating every IBlockState back into a number between 0 and 15 inclusive that will be stored in the world and vice versa for loading.

First idea is an LRU Cache of the last X water blocks updated. Java LRU implementation. Mixin injection into World.setBlockState() to update the timestamps might be enough. Or perhaps the BlockState for a position can be checked to be the same and the timer starts at first randomTick().