Handle collision shape failures during collider baking - #1329
Handle collision shape failures during collider baking#1329MACTEP-ABATAP wants to merge 1 commit into
Conversation
|
|
|
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.
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
|
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.