Skip to content

feat(block): add lava as a fluid and its contact with water - #152

Open
xRookieFight wants to merge 2 commits into
devfrom
feat/lava
Open

feat(block): add lava as a fluid and its contact with water#152
xRookieFight wants to merge 2 commits into
devfrom
feat/lava

Conversation

@xRookieFight

Copy link
Copy Markdown
Contributor

Description

The liquid engine only knew about water. Lava existed as a block constant nobody flowed, and the code that cared about standing in it only ever matched the still source id.

  • WaterState is now LiquidState, carrying which fluid the cell holds. The spread engine is unchanged in shape; what differs per fluid is how far it reaches (decay 1 for water, 2 for lava, so overworld lava stops three cells out), how fast it moves (lava steps once every six liquid ticks), and that only water forms a new source between two of them.
  • Contact turns lava to rock: water pouring in from above makes obsidian of a source and cobblestone of a flow, lava arriving in water makes stone, and water arriving in lava makes obsidian or cobblestone the same way. Contact is judged one way per rule so the two can never fight over one cell.
  • liquid_states is built once and shared, so gameplay code asks is_lava_id/is_water_id instead of comparing against the still source id. Lava damage, drowning, mining-underwater and the "is this safe to stand on" spawn check all now see flowing cells too - previously a player standing in flowing lava took nothing.
  • place_lava mirrors place_water through the same per-world task.

The existing water tests are unchanged apart from the renames, so the water behaviour they pin is provably the same.

Related issue

Fixes #124

Checklist

  • v -check . is clean
  • v test server/block, server/session/blocks_test.v, break_animation_test.v are green
  • Follows the conventions in AGENTS.md (OOP, pub/capitalized exports, no import cycles, minimal comments)
  • Cross-session gameplay state is only mutated on its owning world's actor thread (via world_call/wr.submit/WorldTx), never through a global Hub actor
  • No unrelated changes bundled in

Buckets are untouched: there is no in-game placement path for water either yet, so lava follows the same API-only route until there is one.

// mix_into resolves one fluid arriving where the other already is. Lava
// arriving in water sets into stone; water arriving in lava makes obsidian of
// a source and cobblestone of anything flowing.
fn (mut m LiquidManager) mix_into(arriving LiquidState, existing LiquidState, x int, y int, z int) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lava -> stone branch is unreachable and its test hides that

}

// place_lava does the same for a lava source.
fn (mut h Hub) place_lava(x int, y int, z int) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

has no callers at all

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants