Skip to content

Add flow field dynamics to rivers - #106

Open
ETcodehome wants to merge 21 commits into
1.21.1from
riverParticles
Open

Add flow field dynamics to rivers#106
ETcodehome wants to merge 21 commits into
1.21.1from
riverParticles

Conversation

@ETcodehome

@ETcodehome ETcodehome commented Jul 2, 2026

Copy link
Copy Markdown
Owner

Adds simple flow field dynamics to FTF's river generation system.

Rivers that don't have flow are not particularly compelling. There is a significant gameplay improvement if rivers naturally have a flow direction and strength. Addressing the issue downstream of terrain generation via third party mods is often computationally expensive and/or results in a lot of flawed inferences about river directions.

Instead we have made flow behavior simulated with preset hooks for the new behavior.


New preset configuration toggles

image

Implementation Details

  • For any given tile predicts the course of the river ahead a short distance
  • Points a vector towards that predictive point
  • Determines flow strength (slower in middle of lake, faster when approaching level transitions)
  • Stores the additional information per cell on the chunk, sending it to players when chunk is sent.
  • Some limited particles render on river water surfaces showing flow and generally making the surface more lively.

Boat Dynamics

  • We previously had enabled navigable waterfalls by default without opt in toggle to make the survival experience friendlier. This changeset includes a config toggle gate for this.
  • Because boats are client side authoritative the flowfields are sent to the client with each chunk load.
  • Boats react to flow direction and have a limited keel effect allowing them to tack across flows
  • Navigable waterfalls prevents boats sinking while in rivers allowing them to traverse up waterfalls.
  • Higher strength results in the boats moving faster downstream / being resisted heading upstream
riverBoats

Ongoing Validation Tools

Implemented a diagnostic renderer that can be toggled in via flipping the toggle in code.
FlowFieldDebugRenderer.java

image image

At close visual range flow magnitude will be displayed per cell.


Other testing

  • Ensured fabric server loads and works correctly
  • Ensured neoforge server loads and works correctly
  • Ensured oceans don't get spurious flowfields
  • Ensured swamps don't get spurious flow in their stagnant pools
  • Ensured that river forks join sensibly
  • Ensured that lake magnitude diminishes
  • Ensured that rivers don't have flow holes or other issues that stop boats
  • Ensured that particles flow in correct direction (always headed towards the ocean)
  • Ensured boats have a performance floor so you can always head upstream
  • Ensured boats don't reach ridiculous downstream speeds
  • Ensured boats sink in rivers when navigable waterfalls is disabled.
  • Ensured boats do not sink in rivers when navigable waterfalls is enabled.
  • Ensured boats sink outside of rivers when navigable waterfalls is disabled.
  • Ensured boats sink outside of rivers when navigable waterfalls is enabled.
  • Ensured particles don't appear on water cells outside of rivers
  • Ensured particles don't appear when river flow particles is disabled.

Ensured that Paper server could load happily (ignoring the additional flowfield data
image


Performance

Lean. 1 byte per cell of data. Adds a quarter kilobyte per chunk send to players.
Encodes the flowfield information as a single byte flowfield per x z, split 5 bits direction vector, 3 bits magnitude.
Radians encoded in 2^5 (32 states) = 11.6 degree increments, plus 2^3 (8 states) magnitude levels for strength.


Future Work

It's likely prudent in future to include an API for third party mod compatibility. I dabbled with this on the "experimentCreateCompat" branch. The main use case is cross compatibility with Create mod water wheels where flat water could push wheels based on flow strength. The changeset got a little wild because we don't currently have any concept of an api currently and I want to ensure that if we do implement one its structurally sound from day one and suitable as an extensible example. As such I think we should revisit this after the next release when the risks involved are lower.

@ETcodehome ETcodehome changed the title experiment: flowing rivers draft: flowing rivers Jul 21, 2026
@ETcodehome
ETcodehome marked this pull request as ready for review August 15, 2026 01:02
@ETcodehome ETcodehome changed the title draft: flowing rivers Add flow field dynamics to rivers Aug 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant