Skip to content

Conversation

@throckmorpheus
Copy link
Contributor

Fixes #311 - Vertical slabs crash the game when placed in water (and prevent reloading world)

It was trying to use the block state to index into a map of maps, but wasn't unsetting waterlogged on the indexing block state first, so it ended up dereferencing a null pointer.
From what I can see this fixes both the initial crash and the inability to load back into the world afterwards on all three loaders.

Presumably the same fix will have to be added for the other game versions too.

… water

We weren't unsetting waterlogged on the state we were using to index into the baked model map, so it didn't match and ended up dereferencing a null pointer.
From what I can see this fixes both the initial crash and the inability to load back into the world afterwards.
@CJMinecraft01 CJMinecraft01 added the 1.21.x MC 1.21.x label Jan 3, 2026
Copy link
Owner

@CJMinecraft01 CJMinecraft01 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for spotting this simple fix! 🚀 Just a small comment on using trySetValue over setValue.

@Override
public BakedModel getVerticalSlabModel(BlockState state, Direction side) {
return verticalModels.get(state).get(side);
final var normalisedState = state.setValue(BlockStateProperties.WATERLOGGED, false);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's safer to use trySetValue here in case the state doesn't have the WATERLOGGED property.

Suggested change
final var normalisedState = state.setValue(BlockStateProperties.WATERLOGGED, false);
final var normalisedState = state.trySetValue(BlockStateProperties.WATERLOGGED, false);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

1.21.x MC 1.21.x

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Vertical slabs crash the game when placed in water (and prevent reloading world)

2 participants