Handle collision shape failures during collider baking#1329
Open
MACTEP-ABATAP wants to merge 1 commit into
Open
Handle collision shape failures during collider baking#1329MACTEP-ABATAP wants to merge 1 commit into
MACTEP-ABATAP wants to merge 1 commit into
Conversation
Author
|
Potentially closes #1328 |
|
would it not be better to build a generic block collision hitbox so you still have collisons, depsite the fact that they might not be accurate to the model |
Wrapped collision shape retrieval in defensive error handling so problematic block states do not crash collider baking. This also ensures the temporary block getter state is reset after shape retrieval and treats failed or null shapes as empty collision data.
Author
Changes
Testing
Recommended in-game checks:
Notes for reviewersThis change intentionally prefers a generic full-block collider over either crashing or treating the block as non-solid. The fallback may not perfectly match the block model, but it preserves collision behavior well enough for problematic modded blocks. The Known limitations
|
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.
Summary
Makes Rapier collider baking more defensive when retrieving block collision shapes. Some blocks, especially from mods with complex or multiblock collision logic, may throw while Sable is building physics collider data. Without this, a single bad collision shape can crash collider baking and may leave the temporary block getter state configured for the failed block.
After this PR, collision shape retrieval failures fall back to an empty shape instead of crashing, and the temporary block getter state is always reset after retrieval.
The problem
RapierVoxelColliderBakerytemporarily configuresPhysicsColliderBlockGetterwith the block state being baked, then asks the block for its collision shape.Previously, if either path threw:
BlockSubLevelCollisionShape#getSubLevelCollisionShapeBlockState#getCollisionShapethen
this.level.setup(Blocks.AIR.defaultBlockState())would not run. That could leave the shared block getter in a stale state and crash the caller.A mod returning
nullfor a collision shape would also fail later atshape.isEmpty().Changes
this.level.setup(childState)into the guarded block.finallyblock.Shapes.empty()when shape retrieval fails.nullcollision shapes the same as empty collision shapes.Testing
Not run in-game yet.
Recommended checks:
Notes for reviewers
This change intentionally prefers a safe empty collider over crashing. That means a problematic block may temporarily behave as non-solid for Rapier physics, but the game/server remains alive.
The
finallyblock is the important part of the change: even when a mod throws while building a collision shape,PhysicsColliderBlockGetteris reset back to air before the method returns or continues.Known limitations
BlockState, a fallback result may stay cached for that bakery instance.System.err; this can be replaced with the project logger later if preferred.