Skip to content

[Crash] NullPointerException in RapierVoxelColliderBakery when processing Pixelmon MultiBlocks #1328

Description

@MACTEP-ABATAP

Context

Description

A server crash occurs when Sable's physics pipeline attempts to build physics data for a MultiBlock from the Pixelmon mod.

When a Pixelmon multiblock updates or is placed, Sable triggers RapierVoxelColliderBakery.buildPhysicsDataForBlock which eventually calls getCollisionShape. Pixelmon's implementation of getShape for multiblocks attempts to query the BlockGetter for an adjacent blockstate, which returns null. This results in a NullPointerException when Pixelmon tries to invoke .getBlock() on that null state.

While the lack of null-safety is technically on Pixelmon's side, Sable is the one triggering the shape query (possibly during a state or context where Pixelmon doesn't expect it). Adding a safety check or a try-catch for third-party block shape queries during collider generation might prevent the server from crashing entirely.

Environment

  • Minecraft: 1.21.1
  • Modloader: NeoForge
  • Sable Version: 2.0.3 (specifically sable_rapier@1.21.1-2.0.3)
  • Pixelmon Version: 9.3.16

Steps to Reproduce

  1. Install Sable (2.0.3) and Pixelmon (9.3.16) on a NeoForge 1.21.1 server.
  2. Trigger a block state update involving a Pixelmon MultiBlock (e.g., placing or destroying a PC, Healer, or similar multiblock structure).
  3. The server instantly crashes as Sable attempts to handle the block change.

Crash Report

Click to expand relevant Stacktrace
java.lang.NullPointerException: Cannot invoke "net.minecraft.world.level.block.state.BlockState.getBlock()" because the return value of "net.minecraft.world.level.BlockGetter.getBlockState(net.minecraft.core.BlockPos)" is null
	at TRANSFORMER/pixelmon@9.3.16/com.pixelmonmod.pixelmon.blocks.MultiBlock.getMultiBlockBoundingBox(MultiBlock.java:116)
	at TRANSFORMER/pixelmon@9.3.16/com.pixelmonmod.pixelmon.blocks.MultiBlock.getShape(MultiBlock.java:95)
	at TRANSFORMER/minecraft@1.21.1/net.minecraft.world.level.block.state.BlockBehaviour$BlockStateBase.getShape(BlockBehaviour.java:650)
	at TRANSFORMER/minecraft@1.21.1/net.minecraft.world.level.block.state.BlockBehaviour$BlockStateBase.getShape(BlockBehaviour.java:646)
	at TRANSFORMER/minecraft@1.21.1/net.minecraft.world.level.block.state.BlockBehaviour.getCollisionShape(BlockBehaviour.java:322)
	at TRANSFORMER/minecraft@1.21.1/net.minecraft.world.level.block.state.BlockBehaviour$BlockStateBase.getCollisionShape(BlockBehaviour.java:658)
	at TRANSFORMER/sable_rapier@1.21.1-2.0.3/dev.ryanhcode.sable.physics.impl.rapier.collider.RapierVoxelColliderBakery.buildPhysicsDataForBlock(RapierVoxelColliderBakery.java:72)
	at java.base/java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1708)
	at TRANSFORMER/minecraft@1.21.1/net.minecraft.Util$8.apply(Util.java:795)
	at TRANSFORMER/sable_rapier@1.21.1-2.0.3/dev.ryanhcode.sable.physics.impl.rapier.collider.RapierVoxelColliderBakery.getPhysicsDataForBlock(RapierVoxelColliderBakery.java:98)
	at TRANSFORMER/sable_rapier@1.21.1-2.0.3/dev.ryanhcode.sable.physics.impl.rapier.RapierPhysicsPipeline.handleBlockChange(RapierPhysicsPipeline.java:395)
	at TRANSFORMER/sable@2.0.3/dev.ryanhcode.sable.sublevel.system.SubLevelPhysicsSystem.handleBlockChange(SubLevelPhysicsSystem.java:472)

### Crash Report

https://mclo.gs/Fc4rCN1

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: crashSomething crashes my game

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions