Repository navigation
Reset stored positions before placing entities during async teleport - #555
Open
Cherry7593 wants to merge 1 commit into
Open
Cherry7593 wants to merge 1 commit into
Cherry7593 wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.
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.
Cause
Entity#resetStoredPositions()clears cached physics positions (mainSupportingBlockPos,movementThisTick, andlastClimbablePosonLivingEntity) so they do not trip region thread checks after a teleport. WhileteleportSyncSameRegioncallsresetStoredPositions()immediately after updating the position, async teleports and player respawns (Entity#transform,ServerPlayer#respawn, andEntity#placeInAsync) currently only reset them later inpostChangeDimension()— afterplaceSingleSync()has already calleddestination.addDuringTeleport(this).When an entity (for example, a player wearing Soul Speed boots) is placed into the destination region via
placeInAsyncwhile nearby players immediately start tracking it, the following call chain runs beforepostChangeDimension():If the stale
mainSupportingBlockPosfrom before the teleport/respawn still points to a loaded chunk in another region of the destination world,Entity#getOnPosreturns that stale off-region position andLocationPredicate#matchesthrows anIllegalStateException, crashing the region tick task and triggering a server shutdown.Fix
node.root.resetStoredPositions()beforenode.root.placeSingleSync(...)inEntity#placeInAsync, covering async teleports, portal transitions, player respawns, and passenger trees beforeaddDuringTeleportruns.this.resetStoredPositions()inEntity#transform(Vec3, Float, Float, Vec3)right afterthis.setOldPosAndRot(), matchingteleportSyncSameRegion.resetStoredPositions()call inpostChangeDimension()as a safe no-op for other callers.Verification
Entity.javahunks and line-offset headers in0001-Region-Threading-Base.patch.Patch and Build) on this PR.