Skip to content

Use bedsim submodule for movement simulation - #153

Merged
HashimTheArab merged 15 commits into
devfrom
cursor/use-bedsim-submodule-0ffa
Jul 21, 2026
Merged

Use bedsim submodule for movement simulation#153
HashimTheArab merged 15 commits into
devfrom
cursor/use-bedsim-submodule-0ffa

Conversation

@HashimTheArab

@HashimTheArab HashimTheArab commented Jul 21, 2026

Copy link
Copy Markdown
Collaborator

Summary

Wires oomph-ac/bedsim into the monorepo as a git submodule and replaces the duplicated movement physics in anticheat/player/simulation with a thin bedsim adapter.

Also removes the now-dead sim-only helpers/constants that only served the inlined physics (BBClipCollide, MCSin/MCCos, bounce/step/climb constants, etc.).

What this replaces

  • Inlined tick physics: collisions, stepping, edge avoidance, glide, teleport, knockback/jump application
  • That was the ~750-line simulation/movement.go duplication Hashim called out

What intentionally stays in Oomph

These are not a second physics engine; they are caller/policy or shared non-sim utilities:

  • player/component/movement.go — input parsing, sprint timing, impulse clamps, corrections, teleports/KB bookkeeping
  • utils.BlockName / friction / climbable — still used by combat/world interaction; adapter feeds them into bedsim via BlockSemantics
  • Liquid exemption in the adapter — bedsim already has liquid sim, but stable Oomph does not yet expose swimming / second-layer liquid state. Enabling bedsim liquids without that wiring would diverge. Follow-up: wire state (from feat/liquid-simulation without its duplicated physics) and drop the exemption.

Exemptions checked

bedsim’s simulationIsReliable still covers the same non-liquid cases as Oomph:

  • bamboo nearby
  • non-survival / non-adventure gamemode
  • flying / just-disabled flight / noclip / not alive

Test plan

  • go vet ./... in anticheat
  • go test ./... in anticheat
  • go test ./... in bedsim
  • make lint (anticheat + transferproxy)
  • In-game smoke: ground movement, jump, sprint, sneak edge, elytra, knockback, teleport, creative/fly exemption, bamboo exemption, liquid still exempt/reset
Open in Web Open in Cursor 

Summary by CodeRabbit

  • New Features
    • Enabled bedsim-powered, server-authoritative movement simulation, including improved liquid/swimming handling and better elytra/gliding behavior.
  • Bug Fixes
    • Improved collision and ray/AABB intersection accuracy across movement and combat hit detection by updating the underlying bounding-box math.
  • Documentation
    • Updated README with bedsim integration notes and updated guidance for movement/liquids known-issues exemptions.
  • Chores / Tests
    • Pinned/upgraded the beds im submodule, refreshed Go dependencies (Go 1.26.1), added bounding-box interception unit tests, and added transferproxy lint configuration.

Float32-native bedsim adapter

The bedsim submodule now points at the standalone float32-native conversion. The adapter passes Oomph’s existing mgl32 movement state and float32 scalars directly into bedsim. Anticheat geometry now uses Dragonfly’s cube.BBox32 through the temporary oomph-ac/dragonfly replace, removing both float32-cube and the former float64 vector and bounding-box round trips. This includes the breaking bedsim provider-interface change to Dragonfly float32 boxes.

Replace the duplicated anticheat movement physics with oomph-ac/bedsim
via a git submodule and go.mod replace, keeping Oomph's liquid exemption
until swimming/liquid-layer state is wired through the adapter.

Co-authored-by: Hashim <hashim@lunarbedrock.com>
@coderabbitai

coderabbitai Bot commented Jul 21, 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 vendors bedsim, migrates anticheat geometry to Dragonfly BBox32 types, adds shared raycast utilities, introduces liquid and world-layer adapters, delegates player movement simulation to bedsim, and removes superseded movement helpers.

Changes

Bedsim movement and geometry migration

Layer / File(s) Summary
Bedsim dependency and project wiring
.gitmodules, bedsim, */go.mod, README.md, transferproxy/.golangci.yml
Bedsim is vendored and wired into modules; documentation and lint configuration are updated.
Dragonfly geometry contracts and world access
anticheat/entity/..., anticheat/player/..., anticheat/utils/..., anticheat/world/...
Bounding boxes, positions, collision caches, world queries, placement checks, and secondary liquid-layer updates use Dragonfly cube types.
Raycast and bounding-box utilities
anticheat/game/{aabb.go,bbox_trace.go,raytrace.go}, anticheat/player/component/combat.go, anticheat/utils/unsafe.go
Shared BBox32 intersection and conversion helpers replace external raycast utilities and unsafe result mutation.
Bedsim state and provider adapter
anticheat/player/simulation/bedsim_adapter.go
Movement state conversion, provider implementations, liquid access, simulation execution, and result application are added.
Movement simulation delegation and validation
anticheat/player/simulation/*, anticheat/player/component/movement_liquid_test.go, anticheat/player/player_test.go
Movement ticks delegate to bedsim, outcome handling is preserved, and liquid, no-clip, and interaction-position behavior are tested.
Removal of superseded movement helpers
anticheat/game/{aabb.go,math.go,minecraft.go,movement.go}
Legacy collision clipping, distance, trigonometric-table, and movement-constant definitions are removed.

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

Sequence Diagram(s)

sequenceDiagram
  participant PlayerMovement
  participant BedsimAdapter
  participant BedsimSimulator
  participant WorldProvider
  PlayerMovement->>BedsimAdapter: convert movement and player state
  BedsimAdapter->>BedsimSimulator: run SimulateState
  BedsimSimulator->>WorldProvider: query blocks, liquids, and collisions
  WorldProvider-->>BedsimSimulator: return world data
  BedsimSimulator-->>BedsimAdapter: return state and outcome
  BedsimAdapter-->>PlayerMovement: apply simulated state
Loading

Possibly related PRs

  • oomph-ac/oomph#145: Related liquid movement, swimming state, and secondary block-layer integration.
  • oomph-ac/oomph#151: Overlapping block-breaking timing and underwater detection changes.

Suggested reviewers: flonja, justtaldevelops, t14raptor, cjmustard

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 47.73% 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
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.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: integrating bedsim as the movement simulation backend.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch cursor/use-bedsim-submodule-0ffa

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

Drop collision/math/constants that only existed for the inlined movement
sim, fix a pre-existing gofmt lint failure, and align transferproxy's
golangci config with anticheat so CI can pass.

Co-authored-by: Hashim <hashim@lunarbedrock.com>
@TrixNEW
TrixNEW requested review from Furzide and cooldogedev July 21, 2026 01:25
@oomph-ac oomph-ac deleted a comment from TrixNEW Jul 21, 2026
@HashimTheArab
HashimTheArab marked this pull request as ready for review July 21, 2026 02:31
Comment thread anticheat/player/simulation/bedsim_adapter.go Outdated
Comment thread anticheat/example/default/go.mod

@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

🤖 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 `@anticheat/player/simulation/bedsim_adapter.go`:
- Line 202: Update the coordinate conversion at the visible pos32 initialization
and the related helper conversions below to explicitly cast each df_cube.Pos
integer coordinate to float32 before constructing float_cube.Pos, ensuring all
positional assignments type-check.
🪄 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: c8dc591e-0b6f-4d04-92d6-859478e61271

📥 Commits

Reviewing files that changed from the base of the PR and between 59921d8 and 51386ce.

📒 Files selected for processing (2)
  • anticheat/player/simulation/bedsim_adapter.go
  • bedsim
🚧 Files skipped from review as they are similar to previous changes (1)
  • bedsim

Comment thread anticheat/player/simulation/bedsim_adapter.go Outdated

@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

Caution

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

⚠️ Outside diff range comments (1)
anticheat/world/world.go (1)

86-112: 🗄️ Data Integrity & Integration | 🔴 Critical | 🏗️ Heavy lift

World.Block likely passes world coordinates where chunk-local coordinates are required.

c.Block(uint8(pos[0]), int16(pos[1]), uint8(pos[2]), 0) truncates the full world x/z coordinate to a byte instead of masking to the chunk-local range. Chunk-internal block storage (Dragonfly/Minecraft convention) expects local coordinates in [0, 15] relative to the chunk (worldX & 15), not the raw world coordinate cast to uint8. As soon as pos[0]/pos[2] fall outside [0, 255] (i.e., almost anywhere in the world) or go negative, this returns the wrong block (or wraps unpredictably), since uint8(pos[0]) != pos[0] & 15. The line-range summary itself notes this replaced a previously "converted position (blockPos-derived)" — consistent with local-coordinate masking having been dropped in this migration.

Since World.Block backs virtually every collision/interaction/anti-cheat check (BlockCollisions, PlaceBlock, ValidateInteraction, break-time calc, water detection, and the bedsim world provider), this would corrupt block lookups across the board.

🐛 Proposed fix
 	// TODO: Implement and account for multi-layer blocks.
-	rid := c.Block(uint8(pos[0]), int16(pos[1]), uint8(pos[2]), 0)
+	rid := c.Block(uint8(pos[0]&15), int16(pos[1]), uint8(pos[2]&15), 0)

Please confirm the exact local-coordinate contract of the chunk lookup API in use here (e.g. via the ChunkInfo/chunk.Chunk type this wraps) to validate the fix.

#!/bin/bash
# Locate the ChunkInfo type / w.Chunk(...) definition to inspect the Block method's coordinate contract.
rg -n -A5 -B2 'type ChunkInfo' anticheat/world
rg -n -A10 'func .*\) Chunk\(' anticheat/world
rg -nP '\bBlock\(uint8|\bBlock\(x, y, z' anticheat/world
🤖 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 `@anticheat/world/world.go` around lines 86 - 112, Update World.Block’s c.Block
lookup to pass chunk-local x/z coordinates by masking the world coordinates to
the 0–15 range, while preserving the existing y coordinate and layer argument.
Use the chunk API’s local-coordinate contract confirmed from the wrapped Chunk
type, and ensure negative and large world positions resolve consistently to
their containing chunk’s local block.
🤖 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 `@anticheat/player/world.go`:
- Around line 341-343: Update the prevPos initialization alongside currPos so it
derives from the player’s previous-tick position, using the existing
LastPos()/Pos() movement pattern and retaining the same height offset; leave
currPos based on the current position so face detection compares both ticks.

---

Outside diff comments:
In `@anticheat/world/world.go`:
- Around line 86-112: Update World.Block’s c.Block lookup to pass chunk-local
x/z coordinates by masking the world coordinates to the 0–15 range, while
preserving the existing y coordinate and layer argument. Use the chunk API’s
local-coordinate contract confirmed from the wrapped Chunk type, and ensure
negative and large world positions resolve consistently to their containing
chunk’s local block.
🪄 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: b8afea95-8fca-4eb4-9589-ab024e98da31

📥 Commits

Reviewing files that changed from the base of the PR and between 51386ce and 42199fc.

⛔ Files ignored due to path filters (4)
  • anticheat/example/default/go.sum is excluded by !**/*.sum
  • anticheat/example/dragonfly/go.sum is excluded by !**/*.sum
  • anticheat/go.sum is excluded by !**/*.sum
  • example-proxy/go.sum is excluded by !**/*.sum
📒 Files selected for processing (22)
  • anticheat/entity/entity.go
  • anticheat/example/default/go.mod
  • anticheat/example/dragonfly/go.mod
  • anticheat/game/aabb.go
  • anticheat/game/bbox_trace.go
  • anticheat/game/bbox_trace_test.go
  • anticheat/game/raytrace.go
  • anticheat/go.mod
  • anticheat/player/component/combat.go
  • anticheat/player/component/movement.go
  • anticheat/player/component/world.go
  • anticheat/player/movement.go
  • anticheat/player/simulation/bedsim_adapter.go
  • anticheat/player/world.go
  • anticheat/utils/collisions/collisions.go
  • anticheat/utils/collisions/register.go
  • anticheat/utils/unsafe.go
  • anticheat/utils/world.go
  • anticheat/world/convert.go
  • anticheat/world/world.go
  • bedsim
  • example-proxy/go.mod
💤 Files with no reviewable changes (2)
  • anticheat/world/convert.go
  • anticheat/utils/unsafe.go

Comment thread anticheat/player/world.go Outdated
@HashimTheArab

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 21, 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.

@NopeNotDark

Copy link
Copy Markdown
Contributor

Needs in-game smoke test, other than that LGTM!

@HashimTheArab
HashimTheArab changed the base branch from stable to dev July 21, 2026 22:36
@HashimTheArab
HashimTheArab merged commit 2beb42b into dev Jul 21, 2026
2 checks passed
@NopeNotDark
NopeNotDark deleted the cursor/use-bedsim-submodule-0ffa branch August 11, 2026 08:36
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.

5 participants