Repository navigation
fix: don't publish the motion of an abandoned sub-level collision pass - #1685
Open
Vonix-Network wants to merge 1 commit into
Open
Vonix-Network wants to merge 1 commit into
Vonix-Network wants to merge 1 commit into
Conversation
Vonix-Network
force-pushed
the
fix/sub-level-collision-bounds-guard
branch
from
November 25, 2026 04:28
0c9ce21 to
42f1f30
Compare
…lla collision `SubLevelEntityCollision.collide` builds the block region it walks by inverse transforming the entity's swept box into the sub-level's frame at its previous pose and at its current pose, then unioning the two. When those poses are far apart the union spans the gap between them and stops describing anything real: the ship and the entity are both small, the gap is not. Two changes to that point: 1. Narrow the union before testing it. Only the union is ever enormous -- each half is roughly the size of the entity, because that is what it is, the same box seen from two frames a substep apart. If the union exceeds the existing volume ceiling, fall back to the current-pose box. Collision against where the sub-level actually is keeps working; what is dropped is the sweep back to where it used to be, which is the tunnelling protection across a fast rotation. 2. When even the current-pose box exceeds the ceiling, stop the pass instead of only skipping the walk. The previous `continue` left `collisionInfo.motion` untouched, so the caller -- `Entity.collide` via `sable$collideRedirect` -- went on to expand the entity box by that same motion and hand the result to vanilla block collision. For a motion of the magnitude that produced an enormous region in the first place, that swept AABB spans millions of blocks and the collision iterator never finishes, which is a permanently wedged server tick rather than a slow one. Nothing has been collided at this point: `collisionMotion` is only accumulated inside the walk below, and the entity position is not touched until inside it either. Returning the motion zeroed is therefore the honest result -- the entity does not move this pass. The existing 500^3 ceiling is unchanged in value, now named in SubLevelCollisionConstants alongside the other collision tuning constants. Not changed: the ceiling itself, the substep loop, the per-block SAT, tracking, stepping, and both early returns for players and for non-intersecting cases.
Vonix-Network
force-pushed
the
fix/sub-level-collision-bounds-guard
branch
from
November 25, 2026 04:30
42f1f30 to
26e44df
Compare
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.
What this fixes
An oversized sub-level collision pass is skipped, but the motion that made it oversized is still returned to the caller — which then hands vanilla block collision a swept AABB spanning millions of blocks. The collision iterator never finishes and the server tick never completes.
continueprotects Sable's own loop and nothing else.Root cause
SubLevelEntityCollision.collidebuilds the region it will walk in five steps:fullContextBounds);localBounds;localBounds2;Steps 2 and 3 are the same entity, in the same tick, seen from two frames a substep apart. Each half is therefore roughly the size of the entity. When the two poses are far apart, though, the union spans the gap between them, and its volume stops describing either the ship or the entity.
The existing guard catches that:
The
continueskips the block walk — butcollisionInfo.motionis left untouched. Back inEntity.collide,sable$collideRedirectreturns thatCollisionInfo, and the caller does what vanilla always does with a motion:aabb.expandTowards(motion). So the enormous motion is turned straight back into an enormous swept AABB and handed toLevel.getBlockCollisions/BlockCollisions. For a motion of this magnitude that iterator is effectively unbounded, and the tick never returns.This is a permanent wedge, not a slow tick: the vanilla server watchdog kills the server, and mods that replace the block-collision iterator (Lithium's
ChunkAwareBlockCollisionSweeper, which has no volume cap of its own) show the same non-terminating walk with a different frame in the stack.The change
Two hunks, one file each, no behavioural change on any path that is not already being abandoned.
Narrow the union before testing it. Only the union is ever enormous. If it exceeds the existing ceiling, fall back to
localBounds2— the current-pose box — and test that instead.Collision against where the sub-level actually is keeps working. What is given up is the sweep back to where it used to be, which is the tunnelling protection across a fast rotation. Trading some tunnelling for a wedged server is the right trade at this ceiling.
Stop the pass when even the current-pose box is oversized. Replace the
continuewith a return that zeroes the motion:Returning the motion zeroed is the honest result rather than a workaround, because at this point nothing has happened yet:
collisionMotionis declared outside the loop and only accumulated inside the walk below (collisionMotion.fma(...)per substep), so it is still zero at the guard.sable$setPosSuperRawfor the tracking case), which is below the guard. There is no partial state to unwind.inheritedMotionandfirstCollisions— are null-guarded by both consumers (LivingEntityMixin.sable$beforeAnimationandEntityMixin's TAIL inject), so an early return is consumed exactly like the non-intersecting early return already in the method.The entity does not move for that pass. That is strictly better than moving by millions of blocks.
The
500^3value is unchanged; it is now namedMAX_LOCAL_COLLISION_VOLUMEinSubLevelCollisionConstants, alongside the other collision tuning constants, because it is referenced twice.Verification
:common:compileJavaon this branch: BUILD SUCCESSFUL (Gradle 9.5.0, JDK 21, NeoForm 1.21.1-20240808.144430). Base commit9b1a3d15=mainat time of writing.git diff --name-only: exactly the two files above; 27 insertions, 3 deletions.Evidence
Companion mod (server-side containment while this lands, and the reproduction harness): https://github.com/Vonix-Network/sable-collision-guard
docs/DIAGNOSIS.mdVERDICT=UNBOUNDED, killed at a 12 s ceiling)evidence/A-baseline-unbounded.log,evidence/B-patched-refused.logAABB[1815.55, 67.0, -1.620864198436978E7] -> [2.1967152361004844E7, 9698766.05, -6001.80], i.e. ~2.2e7 blocks of extent, logged 4,291 times.Related issues
Entity.collide→BlockCollisionsviasable$collideRedirect, with players near a moving structure #1629 — same failure mode, different iterator. That report's stack goesEntity.collide→collectColliders→BlockCollisions.computeNext→Level.getChunkForCollisionsviasable$collideRedirect, i.e. vanilla's block-collision iterator never finishing after Sable's redirect. The reporter's own guess — "the collision computation gets an abnormally large AABB" — is exactly the mechanism above. The only difference is which iterator is walking the oversized sweep, and that is decided by installed mods, not by Sable.ServerPlayer.teleportTo(ServerLevel, DDD, FF), which the teleport guard does not wrap, plus a missing world-height clamp. It produces the same symptom (an absurd number reaching collision and chunk access) from a completely different origin: a teleport, not a pose union. This patch would not fix it. It is worth its own fix and I have not touched it here.PhysicsChunkTicketManager.update()deriving chunk tickets fromsubLevel.boundingBox(), which is the sub-level's global box. It never touchesSubLevelEntityCollision; the report itself is explicit that the two do not call into each other. This patch does not affect it.I am listing #1667 and #1607 with the distinction rather than as fixes, because a maintainer should not have to check whether a four-line collision guard really closes a teleport-coordinate bug.
Scope
SubLevelEntityCollision.collideand one constant is touched.500^3is the right number is a separate question from whether an abandoned pass should publish its motion, and mixing them would make this PR harder to review.Suggested follow-up (not done here)
fullContextBoundsis built from the entity's motion before the pose union is computed, so an absurd motion also enlargesconsiderationBoundsand the set of sub-levels tested. The pose-union narrowing above means such a pass is now abandoned cheaply, but clamping the motion on entry would avoid the work entirely. That is a behaviour change for fast-moving entities and does not belong in a bugfix PR.