feat: centralize vanilla movement block semantics - #11
Conversation
📝 WalkthroughWalkthroughThe PR introduces consolidated block movement semantics, adds built-in handlers for special blocks, updates simulator movement logic to use semantic properties, and replaces the previous block metadata provider interface. ChangesMovement semantics
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant Simulation
participant DefaultBlockSemantics
participant block.Resolve
Simulation->>DefaultBlockSemantics: request BlockMovementSemantics
DefaultBlockSemantics->>block.Resolve: resolve block movement properties
block.Resolve-->>DefaultBlockSemantics: return MovementSemantics
DefaultBlockSemantics-->>Simulation: provide movement properties
Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
simulation.go (1)
1001-1005: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick winUse
BlockCollisionsfor cobweb contact detection.The full-block cube at Line 1005 can apply cobweb slowdown when the player intersects an empty part of a semantic cobweb block. Resolve the block-local collision boxes with
WorldProvider.BlockCollisions(pos), translate each box byposVec3(pos), and test those world-space boxes againstbb.Proposed fix
- if bb.IntersectsWith(cube.Box32(0, 0, 0, 1, 1, 1).Translate(posVec3(pos))) { - insideCobweb = true + for _, collision := range s.World.BlockCollisions(pos) { + if bb.IntersectsWith(collision.Translate(posVec3(pos))) { + insideCobweb = true + break + } }Based on learnings,
WorldProvider.BlockCollisions(pos)returns block-local boxes and requires translation before world-space intersection. As per coding guidelines, collision methods must provide consistent collision information.🤖 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 `@simulation.go` around lines 1001 - 1005, Update the cobweb contact logic around blockMovementSemantics and bb.IntersectsWith to use s.WorldProvider.BlockCollisions(pos) instead of a full-block cube. Translate each returned block-local collision box by posVec3(pos), and apply cobweb slowdown only when bb intersects at least one translated box.Sources: Coding guidelines, Learnings
🤖 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 `@simulation.go`:
- Around line 1001-1005: Update the cobweb contact logic around
blockMovementSemantics and bb.IntersectsWith to use
s.WorldProvider.BlockCollisions(pos) instead of a full-block cube. Translate
each returned block-local collision box by posVec3(pos), and apply cobweb
slowdown only when bb intersects at least one translated box.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 61e2de1a-e556-4785-98c0-78d732da403e
⛔ Files ignored due to path filters (1)
go.sumis excluded by!**/*.sum
📒 Files selected for processing (15)
README.mdblock.goblock/bounce.goblock/climbable.goblock/contact.goblock/friction.goblock/ground.goblock/semantics.goblock_semantics_test.gogo.modinterfaces.goliquid_test.gosimulation.gosimulator.gosimulator_test.go
💤 Files with no reviewable changes (1)
- block.go
Summary
Validation
This PR intentionally does not preserve the old BlockName/BlockFriction/BlockClimbable provider interface.
Summary by CodeRabbit
New Features
Bug Fixes
Documentation