Skip to content

fix: normalize Bedrock entity network offsets - #150

Merged
NopeNotDark merged 1 commit into
stablefrom
agent/entity-network-offsets
Aug 17, 2026
Merged

fix: normalize Bedrock entity network offsets#150
NopeNotDark merged 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 tracking additional entity types, including items, boats, minecarts, falling blocks, players, and TNT.
    • Improved entity movement tracking with delta-position updates, teleport handling, and network offsets.
    • Added metadata updates for entity dimensions and player status flags.
    • Added unique-ID-based entity removal and enhanced item-actor tracking.
  • Bug Fixes

    • Prevented item entities from being selected as combat targets.
    • Improved movement and position accuracy for tracked entities.

@coderabbitai

coderabbitai Bot commented Jul 16, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@NopeNotDark, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 50 minutes

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: f394c26f-b963-43e2-9087-31e76a4e381f

📥 Commits

Reviewing files that changed from the base of the PR and between 5c7ae7f and b9dba26.

📒 Files selected for processing (1)
  • anticheat/player/component/entities.go
📝 Walkthrough

Walkthrough

Entity tracking now supports unique IDs, metadata updates, network offsets, item actors, delta movement, and new acknowledgements. Packet registration and removal use centralized entity configuration. Combat misprediction searches exclude item entities.

Changes

Entity tracking and movement

Layer / File(s) Summary
Entity metadata and network offset contracts
anticheat/entity/*, anticheat/game/movement.go, anticheat/utils/bit.go
Entity now uses Config, stores UniqueId and NetworkOffset, clones and merges metadata, and adjusts network positions by entity type and metadata flags.
Tracker movement and acknowledgement handling
anticheat/player/component/acknowledgement/entities.go, anticheat/player/component/entities.go, anticheat/player/entities.go
Trackers maintain unique-ID mappings, apply absolute and delta movement, update metadata and dimensions, and send delta or data acknowledgements.
Packet routing and unique-ID lifecycle
anticheat/player/packet.go
Packet decoding handles item actors and delta movement. Entity registration uses trackEntity, and removal uses unique IDs.

Combat target filtering

Layer / File(s) Summary
Misprediction target eligibility
anticheat/player/component/combat.go
Mispredicted-entity searches skip item entities.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant ServerDecode
  participant trackEntity
  participant EntityTrackerComponent
  participant EntityDeltaPosition
  ServerDecode->>trackEntity: register actor or item actor
  trackEntity->>EntityTrackerComponent: add configured entity
  ServerDecode->>EntityTrackerComponent: route MoveActorDelta
  EntityTrackerComponent->>EntityDeltaPosition: enqueue delta acknowledgement
  EntityDeltaPosition->>EntityTrackerComponent: apply optional axis deltas and teleport state
Loading
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 22.22% 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 clearly and concisely describes the pull request's 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 💡 1
📝 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

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.

@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 2 times, most recently from 8d34006 to b45c731 Compare July 16, 2026 19:36
@coderabbitai coderabbitai Bot mentioned this pull request Aug 11, 2026
@NopeNotDark
NopeNotDark force-pushed the agent/entity-network-offsets branch from b45c731 to 5c7ae7f Compare August 11, 2026 10:57
@NopeNotDark

Copy link
Copy Markdown
Contributor

updated to sync with stable

@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/component/entities.go`:
- Around line 34-40: Update AddEntity to remove any existing entity associated
with ent.UniqueId before inserting the new rid mapping, using
RemoveEntityByUniqueID or the established equivalent. Preserve cleanup of the
prior entity at rid so entities and runtimeIDs remain one-to-one.
🪄 Autofix

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: 1b9ab0e5-1bb1-4e48-81f9-cd9cd16e5e38

📥 Commits

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

📒 Files selected for processing (11)
  • anticheat/entity/entity.go
  • anticheat/entity/metadata.go
  • anticheat/entity/network_offset.go
  • anticheat/entity/type.go
  • anticheat/game/movement.go
  • anticheat/player/component/acknowledgement/entities.go
  • anticheat/player/component/combat.go
  • anticheat/player/component/entities.go
  • anticheat/player/entities.go
  • anticheat/player/packet.go
  • anticheat/utils/bit.go

Comment thread anticheat/player/component/entities.go
@NopeNotDark
NopeNotDark force-pushed the agent/entity-network-offsets branch from 5c7ae7f to b9dba26 Compare August 11, 2026 11:04
@NopeNotDark

Copy link
Copy Markdown
Contributor

@coderabbitai

@coderabbitai

coderabbitai Bot commented Aug 11, 2026

Copy link
Copy Markdown

@NopeNotDark: I will review the updated changes.

⚠️ Action not completed

Review rate limited.

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
NopeNotDark merged commit abfb9ed into stable Aug 17, 2026
2 checks passed
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.

3 participants