Repository navigation
Reapply the position of an entity that is teleported to another region - #516
Closed
lewisgibson wants to merge 2 commits into
Closed
lewisgibson wants to merge 2 commits into
lewisgibson wants to merge 2 commits into
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 thatteleportAsynccarries across a region border, only callssetPosRaw.snapTo, which the same region teleport and vanilla use, also callsreapplyPosition, which runs thesetPosoverrides.BlockAttachedEntity#setPosis what movesposand 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 asblock_posis also rejected as too far from the entity on the next hop ("Block-attached entity at invalid position").Displayentities keep the culling box of their old position for the same reason.The fix is one line in
0001-Region-Threading-Base.patch: callreapplyPosition()aftersetPosRawintransform, so a transformed entity is in the statesnapTowould 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_frameandpaintingwere 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_crystalandleash_knotwere present either way, since their survival check does not readpos.This was done with AI (Claude Opus 5.5 and GPT Astra, high effort). I've reviewed it and tested it myself.