Skip to content

implement liquid movement simulation - #145

Closed
NopeNotDark wants to merge 14 commits into
stablefrom
feat/liquid-simulation
Closed

implement liquid movement simulation#145
NopeNotDark wants to merge 14 commits into
stablefrom
feat/liquid-simulation

Conversation

@NopeNotDark

@NopeNotDark NopeNotDark commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Allows movement simulation to remain fully functional in liquid environments, preserving accurate player movement behavior within Oomph

Summary by CodeRabbit

  • New Features

    • Enhanced swimming: updated hitbox sizing, swim intent/state tracking, and improved liquid jump behavior.
    • Added distinct underwater/lava movement speeds with dolphin-boost acceleration and Depth Strider–tuned underwater traversal.
    • Extended Bedrock block updates to an additional storage layer (including “extra” sub-chunk blocks).
  • Bug Fixes

    • Refined liquid movement physics (flow/drag/levitation, collisions, and liquid exit probing) and improved gating via effective jumping.
    • Improved packet handling so movement effects apply to the correct player, and block acknowledgements apply to the intended storage layer.

@coderabbitai

coderabbitai Bot commented Jul 14, 2026

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

The PR adds Bedrock layer-1 block update handling and storage, extends movement state for swimming and liquid speeds, processes dolphin boost effects, synchronizes swimming flags, and introduces water/lava movement simulation with flow, drag, gravity, and collision behavior.

Changes

Layered world updates and acknowledgement flow

Layer / File(s) Summary
Layered block storage and acknowledgement flow
world/world.go, player/component/acknowledgement/block.go, player/component/world.go
World block access and mutation select layer 0 or 1, while update batching routes, flushes, acknowledges, and cleans up layer-specific updates.

Swimming state and movement speed integration

Layer / File(s) Summary
Swimming state and movement speed integration
player/movement.go, player/component/movement.go, player/component/acknowledgement/movement.go, player/packet.go
Movement interfaces and authoritative state expose swimming and liquid speed values, process movement effects, update swimming flags, and reset transfer state.

Liquid traversal and physics

Layer / File(s) Summary
Liquid traversal and physics
player/simulation/movement.go, game/movement.go
Movement simulation detects water and lava contact, applies flow and liquid travel, models collisions and motion, and adjusts sneak, jump, and movement tuning.

Estimated code review effort: 4 (Complex) | ~60 minutes

Sequence Diagram(s)

sequenceDiagram
  participant ServerPacket
  participant Player
  participant MovementComponent
  participant World
  ServerPacket->>Player: MovementEffect
  Player->>MovementComponent: ServerUpdate(packet)
  MovementComponent->>MovementComponent: apply swimming and dolphin boost state
  Player->>World: read touching liquid blocks
  Player->>MovementComponent: simulate liquid travel
  MovementComponent-->>Player: update velocity and movement state
Loading
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 12.50% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: adding liquid movement simulation and related movement handling.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/liquid-simulation

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
world/world.go (1)

94-127: 🚀 Performance & Scalability | 🔵 Trivial

BlockLayer mutates the override map on every cache miss — unnecessary allocation in a read path.

When a chunk hasn't been seen in blockUpdates/extraBlockUpdates yet, BlockLayer eagerly creates an empty inner map for it (updates[chunkPos] = make(...)) even though it's just reading. SetBlockLayer already lazily creates this map when an actual override is written (Lines 144-146), so the read-path allocation is pure overhead — and it now happens for two layers instead of one, and is exercised far more heavily since player/simulation/movement.go's new liquid-detection helpers (touchingLiquidBlocks, liquidAt) call BlockLayer many times per tick, per player.

♻️ Proposed fix
 	chunkPos := protocol.ChunkPos{int32(blockPos[0]) >> 4, int32(blockPos[2]) >> 4}
 	updates := w.blockUpdates
 	if layer == 1 {
 		updates = w.extraBlockUpdates
 	}
-	blockUpdates, found := updates[chunkPos]
-	if found {
-		if b, ok := blockUpdates[df_cube.Pos(blockPos)]; ok {
-			return b
-		}
-	} else {
-		updates[chunkPos] = make(map[df_cube.Pos]world.Block)
-	}
+	if blockUpdates, found := updates[chunkPos]; found {
+		if b, ok := blockUpdates[df_cube.Pos(blockPos)]; ok {
+			return b
+		}
+	}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@world/world.go` around lines 94 - 127, Remove the eager inner-map allocation
from the cache-miss branch in World.BlockLayer. Keep BlockLayer read-only when
no override exists, and rely on SetBlockLayer’s existing lazy initialization
when an override is written.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@player/simulation/movement.go`:
- Around line 555-558: Update liquidFlowSideClosed to call
p.World().Block(pos).Model().FaceSolid(pos, pos.Face(side), p.World())
unconditionally, removing the block.Stairs type assertion and stairs-only gating
so all block models, including IronBars, can determine whether the side is
closed.

---

Nitpick comments:
In `@world/world.go`:
- Around line 94-127: Remove the eager inner-map allocation from the cache-miss
branch in World.BlockLayer. Keep BlockLayer read-only when no override exists,
and rely on SetBlockLayer’s existing lazy initialization when an override is
written.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 6a55e410-0a81-41d5-9df7-f1c95a26c14e

📥 Commits

Reviewing files that changed from the base of the PR and between ef2fc2f and 6354488.

📒 Files selected for processing (8)
  • player/component/acknowledgement/block.go
  • player/component/acknowledgement/movement.go
  • player/component/movement.go
  • player/component/world.go
  • player/movement.go
  • player/packet.go
  • player/simulation/movement.go
  • world/world.go

Comment thread anticheat/player/simulation/movement.go

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
player/simulation/movement.go (1)

65-92: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Clear glide state for airborne liquid entries.

This branch returns before the existing glide handling, but only clears gliding when movement.OnGround() is true. An airborne player entering water or lava therefore retains Gliding/GlideBoost; after leaving the liquid, the stale glide state can resume without a new glide input. (raw.githubusercontent.com)

🐛 Proposed fix
-	if movement.Gliding() && movement.OnGround() {
+	if movement.Gliding() {
 		movement.SetGliding(false)
 		movement.SetGlideBoost(0)
 	}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@player/simulation/movement.go` around lines 65 - 92, Update the
liquid-contact branch in the movement simulation so entering water or lava
always clears the glide state before returning, regardless of
movement.OnGround(). In the existing movement.Gliding() handling, remove the
on-ground condition while preserving the resets for Gliding and GlideBoost.
🧹 Nitpick comments (1)
player/simulation/movement.go (1)

132-140: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Align climb telemetry with the updated jump condition.

The branch now uses EffectiveJumping(), but the debug output still labels and prints PressingJump(). Auto-jump or other effective-jump states will therefore produce misleading diagnostics. (raw.githubusercontent.com)

-		p.Dbg.Notify(..., "added climb velocity: %v (collided=%v pressingJump=%v)", ..., movement.PressingJump())
+		p.Dbg.Notify(..., "added climb velocity: %v (collided=%v effectiveJumping=%v)", ..., movement.EffectiveJumping())
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@player/simulation/movement.go` around lines 132 - 140, Update the
climb-related debug output near the vertical velocity assignment to use
EffectiveJumping() instead of PressingJump(), including the corresponding
telemetry label, so auto-jump and other effective-jump states are reported
consistently with the branch condition.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@player/simulation/movement.go`:
- Around line 65-92: Update the liquid-contact branch in the movement simulation
so entering water or lava always clears the glide state before returning,
regardless of movement.OnGround(). In the existing movement.Gliding() handling,
remove the on-ground condition while preserving the resets for Gliding and
GlideBoost.

---

Nitpick comments:
In `@player/simulation/movement.go`:
- Around line 132-140: Update the climb-related debug output near the vertical
velocity assignment to use EffectiveJumping() instead of PressingJump(),
including the corresponding telemetry label, so auto-jump and other
effective-jump states are reported consistently with the branch condition.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 36addafd-e451-4f9c-9678-5bff666c6f3b

📥 Commits

Reviewing files that changed from the base of the PR and between dca5711 and a4d1480.

📒 Files selected for processing (3)
  • game/movement.go
  • player/component/movement.go
  • player/simulation/movement.go
💤 Files with no reviewable changes (1)
  • game/movement.go
🚧 Files skipped from review as they are similar to previous changes (1)
  • player/component/movement.go

@HashimTheArab

Copy link
Copy Markdown
Collaborator

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 15, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@oomph-ac oomph-ac deleted a comment from TrixNEW Jul 15, 2026
@oomph-ac oomph-ac deleted a comment from coderabbitai Bot Jul 15, 2026
@NopeNotDark

Copy link
Copy Markdown
Contributor Author
  • Bubble Colum's are currently not supported due to the fact that they're not implemented in dragonfly.

@NopeNotDark
NopeNotDark marked this pull request as draft July 15, 2026 02:58
@NopeNotDark
NopeNotDark marked this pull request as ready for review July 15, 2026 02:58
@NopeNotDark

Copy link
Copy Markdown
Contributor Author

Can we get some approvals and testers 😅

@Superomarking

Copy link
Copy Markdown
Collaborator

Can we get some approvals and testers 😅

Due to the current state of my region, I am unable to test/review anything, maybe @didntpot is nice enough to test this and give proper feedback!

@TrixNEW

TrixNEW commented Jul 20, 2026

Copy link
Copy Markdown
Collaborator

newcoolboys is the most annoying for me
atm
he's always pushing his luck but never
quite far enough to warrant punishing
him

Cakey Bot Yesterday at 8:23 AM
Member Banned
@Newcoolboys (newcoolboys)
Banned By: dktapps
Reason: incessant trolling
User ID: 1322395273528347 - Guild ID: 2347812391247895923 - Yesterday at 8:23 AM

@HashimTheArab

Copy link
Copy Markdown
Collaborator

merged in bedsim

@NopeNotDark
NopeNotDark deleted the feat/liquid-simulation branch July 23, 2026 20:40
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.

4 participants