Skip to content

Reapply the position of an entity that is teleported to another region - #516

Closed
lewisgibson wants to merge 2 commits into
PaperMC:ver/26.2.xfrom
lewisgibson:hanging-entity-reapply-position
Closed

lewisgibson wants to merge 2 commits into
PaperMC:ver/26.2.xfrom
lewisgibson:hanging-entity-reapply-position

Conversation

@lewisgibson

@lewisgibson lewisgibson commented Oct 1, 2026 •

Copy link
Copy Markdown

An item frame, glow item frame or painting that is teleported to another region is discarded. Entity#transform, which positions the copy of an entity that teleportAsync carries across a region border, only calls setPosRaw. snapTo, which the same region teleport and vanilla use, also calls reapplyPosition, which runs the setPos overrides. BlockAttachedEntity#setPos is what moves pos and recomputes the bounding box, so the copy keeps the attached block of the region it left, survives() looks at a block that region owns, fails, and the entity is discarded. The position it would have saved as block_pos is also rejected as too far from the entity on the next hop ("Block-attached entity at invalid position"). Display entities keep the culling box of their old position for the same reason.

The fix is one line in 0001-Region-Threading-Base.patch: call reapplyPosition() after setPosRaw in transform, so a transformed entity is in the state snapTo would have given it.

Tested on ver/26.2.x with two players 3000 blocks apart, entities summoned at the first, /tp'd 6 blocks (same region), then to the second player's region and back, counted at 0.5, 1.5, 3 and 5 seconds after each move. Unpatched, item_frame, glow_item_frame and painting were present after the same region move and gone on every sample after the cross-region teleport and after the move back. With this change all of them are present on every sample through the three moves. end_crystal and leash_knot were present either way, since their survival check does not read pos.

This was done with AI (Claude Opus 5.5 and GPT Astra, high effort). I've reviewed it and tested it myself.

Entity#transform only calls setPosRaw, so item frames, paintings and leash knots keep the block of the region they left and are discarded. See the patch for details.
@lewisgibson lewisgibson closed this Oct 2, 2026
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.

1 participant