Skip to content

fix: normalize Bedrock entity network offsets - #150

Open
HashimTheArab wants to merge 1 commit into
stablefrom
agent/entity-network-offsets
Open

fix: normalize Bedrock entity network offsets#150
HashimTheArab wants to merge 1 commit into
stablefrom
agent/entity-network-offsets

Conversation

@HashimTheArab

@HashimTheArab HashimTheArab commented Jul 16, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • normalize BDS 1.26.30.03 entity spawn and movement positions to base coordinates
  • support player sleep, items, falling blocks, minecarts, boats, and primed TNT offsets
  • decode AddItemActor and MoveActorDelta, preserving partial-axis and client-ACK semantics
  • merge entity metadata and remove actors correctly when unique/runtime IDs differ
  • keep dropped items out of synthetic missed-swing targeting

Follow-up dependency

The currently pinned Dragonfly still emits its older approximations and raw spawn positions. Its offset implementation must be corrected and the pinned revision updated before this PR merges; otherwise the native Dragonfly integration will subtract mismatched values.

Verification

  • go test ./...
  • go vet ./...
  • go test -race ./...
  • codex review --uncommitted (accepted and fixed rotation-only delta handling, item targeting, and unique-ID removal; rejected legacy Dragonfly values as the explicit follow-up dependency)

Summary by CodeRabbit

  • New Features

    • Added support for smoother delta-based entity movement updates.
    • Improved tracking and removal of entities using persistent unique identifiers.
    • Added handling for entity metadata updates, including size and movement-related data.
    • Added position adjustments for players, items, boats, minecarts, and TNT.
  • Bug Fixes

    • Improved vertical positioning accuracy across supported entity types.
    • Prevented item entities from being incorrectly treated as mispredicted targets.
    • Corrected player height calculations to match the latest game behavior.

@coderabbitai

coderabbitai Bot commented Jul 16, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 73327e13-af8e-4bfb-bee6-9dc7aa41dc30

📥 Commits

Reviewing files that changed from the base of the PR and between a27dd7b and b45c731.

📒 Files selected for processing (8)
  • entity/entity.go
  • entity/network_offset.go
  • game/movement.go
  • player/component/acknowledgement/entities.go
  • player/component/combat.go
  • player/component/entities.go
  • player/entities.go
  • player/packet.go
🚧 Files skipped from review as they are similar to previous changes (5)
  • game/movement.go
  • entity/entity.go
  • entity/network_offset.go
  • player/component/combat.go
  • player/component/entities.go

📝 Walkthrough

Walkthrough

Entity tracking now preserves unique IDs and metadata, applies type-specific network offsets, handles delta movement and metadata acknowledgements, routes new actor packets, removes entities by unique ID, and excludes item entities from combat misprediction targets.

Changes

Entity tracking and movement

Layer / File(s) Summary
Entity metadata and network offset contracts
entity/entity.go, entity/network_offset.go, game/movement.go
Entities copy and merge metadata, store unique IDs, and calculate type-specific Y offsets using the updated player height value.
Tracker movement and acknowledgement handling
player/entities.go, player/component/entities.go, player/component/acknowledgement/entities.go
Trackers support unique-ID removal, offset-aware absolute and delta movement, metadata updates, and delta/data acknowledgements.
Packet routing and unique-ID lifecycle
player/packet.go
Actor spawn, delta movement, decoding, and removal handling use network offsets, unique IDs, and delta movement routing.

Combat target filtering

Layer / File(s) Summary
Misprediction target eligibility
player/component/combat.go
Misprediction searches skip entities of type minecraft:item.

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

Sequence Diagram(s)

sequenceDiagram
  participant Server
  participant HandleServerPacket
  participant EntityTrackerComponent
  participant ClientEntityTracker
  Server->>HandleServerPacket: AddActor/AddItemActor/AddPlayer
  HandleServerPacket->>EntityTrackerComponent: create entity with adjusted position and UniqueId
  Server->>HandleServerPacket: MoveActorDelta
  HandleServerPacket->>EntityTrackerComponent: HandleMoveActorDelta(packet)
  EntityTrackerComponent->>ClientEntityTracker: enqueue EntityDeltaPosition
  ClientEntityTracker->>EntityTrackerComponent: MoveEntityDelta(runtimeID, position, flags)
  Server->>HandleServerPacket: RemoveActor(UniqueId)
  HandleServerPacket->>EntityTrackerComponent: RemoveEntityByUniqueID(UniqueId)
Loading
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 14.29% 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: normalizing Bedrock entity network offsets.
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 docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch agent/entity-network-offsets

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.

🧹 Nitpick comments (1)
game/movement.go (1)

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

Document the precise 1.62001 literal.

The change from 1.62 to 1.62001 is a protocol-precision fix, but nothing in the code says so. Without a comment, a future cleanup could "round" this back to 1.62 and silently reintroduce the Y-offset drift this PR fixes.

♻️ Suggested comment
-	DefaultPlayerHeightOffset  = float32(1.62001)
+	// DefaultPlayerHeightOffset matches the exact Y offset BDS 1.26.30.03 applies
+	// to standing player positions on the wire; do not round to 1.62.
+	DefaultPlayerHeightOffset  = float32(1.62001)
🤖 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 `@game/movement.go` at line 21, Add a concise comment directly above
DefaultPlayerHeightOffset documenting that the precise 1.62001 literal is
required for protocol precision and must not be rounded, preserving the current
value.
🤖 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.

Nitpick comments:
In `@game/movement.go`:
- Line 21: Add a concise comment directly above DefaultPlayerHeightOffset
documenting that the precise 1.62001 literal is required for protocol precision
and must not be rounded, preserving the current value.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: b31e6260-e1c5-4fea-b34f-0912842d3cc9

📥 Commits

Reviewing files that changed from the base of the PR and between 10283cc and a27dd7b.

📒 Files selected for processing (11)
  • entity/entity.go
  • entity/network_offset.go
  • entity/network_offset_test.go
  • game/movement.go
  • player/component/acknowledgement/entities.go
  • player/component/combat.go
  • player/component/entities.go
  • player/component/entities_test.go
  • player/entities.go
  • player/packet.go
  • player/packet_entity_offsets_test.go

@HashimTheArab
HashimTheArab force-pushed the agent/entity-network-offsets branch from a27dd7b to 8d34006 Compare July 16, 2026 19:36
@HashimTheArab
HashimTheArab force-pushed the agent/entity-network-offsets branch from 8d34006 to b45c731 Compare July 16, 2026 19: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.

2 participants