Skip to content

Commit

Permalink
šŸ› Fix issue where some blocks (slabs, leaves, and vines) were mappingā€¦
Browse files Browse the repository at this point in the history
ā€¦ incorrectly

Fixes #94
  • Loading branch information
fnar committed Aug 29, 2024
1 parent ae459a9 commit 18c9d67
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ public static IBlockState parse(JsonElement e) {
.getStateFromMeta(meta);

if (name.contains("leaves")) {
blockState.withProperty(BlockLeaves.DECAYABLE, false);
return blockState.withProperty(BlockLeaves.DECAYABLE, false);
}

return blockState;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,63 +18,63 @@ public static IBlockState map(SlabBlock slabBlock) {
IBlockState blockState = minecraftBlock.getDefaultState();
switch (slabBlock.getBlockType()) {
case STONE_SLAB:
blockState.withProperty(BlockStoneSlab.VARIANT, BlockStoneSlab.EnumType.STONE);
blockState = blockState.withProperty(BlockStoneSlab.VARIANT, BlockStoneSlab.EnumType.STONE);
break;
case SANDSTONE_SLAB:
blockState.withProperty(BlockStoneSlab.VARIANT, BlockStoneSlab.EnumType.SAND);
blockState = blockState.withProperty(BlockStoneSlab.VARIANT, BlockStoneSlab.EnumType.SAND);
break;
case PETRIFIED_OAK_SLAB:
blockState.withProperty(BlockStoneSlab.VARIANT, BlockStoneSlab.EnumType.WOOD);
blockState = blockState.withProperty(BlockStoneSlab.VARIANT, BlockStoneSlab.EnumType.WOOD);
break;
case COBBLESTONE_SLAB:
blockState.withProperty(BlockStoneSlab.VARIANT, BlockStoneSlab.EnumType.COBBLESTONE);
blockState = blockState.withProperty(BlockStoneSlab.VARIANT, BlockStoneSlab.EnumType.COBBLESTONE);
break;
case BRICK_SLAB:
blockState.withProperty(BlockStoneSlab.VARIANT, BlockStoneSlab.EnumType.BRICK);
blockState = blockState.withProperty(BlockStoneSlab.VARIANT, BlockStoneSlab.EnumType.BRICK);
break;
case STONE_BRICK_SLAB:
blockState.withProperty(BlockStoneSlab.VARIANT, BlockStoneSlab.EnumType.SMOOTHBRICK);
blockState = blockState.withProperty(BlockStoneSlab.VARIANT, BlockStoneSlab.EnumType.SMOOTHBRICK);
break;
case NETHER_BRICK_SLAB:
blockState.withProperty(BlockStoneSlab.VARIANT, BlockStoneSlab.EnumType.NETHERBRICK);
blockState = blockState.withProperty(BlockStoneSlab.VARIANT, BlockStoneSlab.EnumType.NETHERBRICK);
break;
case QUARTZ_SLAB:
blockState.withProperty(BlockStoneSlab.VARIANT, BlockStoneSlab.EnumType.QUARTZ);
blockState = blockState.withProperty(BlockStoneSlab.VARIANT, BlockStoneSlab.EnumType.QUARTZ);
break;
case RED_SANDSTONE_SLAB:
case SMOOTH_RED_SANDSTONE_SLAB:
blockState.withProperty(BlockStoneSlabNew.VARIANT, BlockStoneSlabNew.EnumType.RED_SANDSTONE);
blockState = blockState.withProperty(BlockStoneSlabNew.VARIANT, BlockStoneSlabNew.EnumType.RED_SANDSTONE);
break;
case OAK_SLAB:
blockState.withProperty(BlockWoodSlab.VARIANT, BlockPlanks.EnumType.OAK);
blockState = blockState.withProperty(BlockWoodSlab.VARIANT, BlockPlanks.EnumType.OAK);
break;
case SPRUCE_SLAB:
blockState.withProperty(BlockWoodSlab.VARIANT, BlockPlanks.EnumType.SPRUCE);
blockState = blockState.withProperty(BlockWoodSlab.VARIANT, BlockPlanks.EnumType.SPRUCE);
break;
case BIRCH_SLAB:
blockState.withProperty(BlockWoodSlab.VARIANT, BlockPlanks.EnumType.BIRCH);
blockState = blockState.withProperty(BlockWoodSlab.VARIANT, BlockPlanks.EnumType.BIRCH);
break;
case JUNGLE_SLAB:
blockState.withProperty(BlockWoodSlab.VARIANT, BlockPlanks.EnumType.JUNGLE);
blockState = blockState.withProperty(BlockWoodSlab.VARIANT, BlockPlanks.EnumType.JUNGLE);
break;
case ACACIA_SLAB:
blockState.withProperty(BlockWoodSlab.VARIANT, BlockPlanks.EnumType.ACACIA);
blockState = blockState.withProperty(BlockWoodSlab.VARIANT, BlockPlanks.EnumType.ACACIA);
break;
case DARK_OAK_SLAB:
blockState.withProperty(BlockWoodSlab.VARIANT, BlockPlanks.EnumType.DARK_OAK);
blockState = blockState.withProperty(BlockWoodSlab.VARIANT, BlockPlanks.EnumType.DARK_OAK);
break;
case PURPUR_SLAB:
blockState.withProperty(BlockPurpurSlab.VARIANT, BlockPurpurSlab.Variant.DEFAULT);
blockState = blockState.withProperty(BlockPurpurSlab.VARIANT, BlockPurpurSlab.Variant.DEFAULT);
break;
default:
}

if (!slabBlock.isFullBlock() && slabBlock.isTop()) {
blockState.withProperty(BlockWoodSlab.HALF, BlockSlab.EnumBlockHalf.TOP);
blockState = blockState.withProperty(BlockWoodSlab.HALF, BlockSlab.EnumBlockHalf.TOP);
}

if (slabBlock.isFullBlock() && slabBlock.isSeamless()) {
blockState.withProperty(BlockStoneSlab.SEAMLESS, true);
blockState = blockState.withProperty(BlockStoneSlab.SEAMLESS, true);
}

return blockState;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,11 @@

public class VineBlockMapper1_12 {
static IBlockState map(Direction dir) {
IBlockState vine = Blocks.VINE.getDefaultState();
vine.withProperty(BlockVine.UP, dir == Direction.UP);
vine.withProperty(BlockVine.NORTH, dir == Direction.NORTH);
vine.withProperty(BlockVine.EAST, dir == Direction.EAST);
vine.withProperty(BlockVine.SOUTH, dir == Direction.SOUTH);
vine.withProperty(BlockVine.WEST, dir == Direction.WEST);
return vine;
return Blocks.VINE.getDefaultState()
.withProperty(BlockVine.UP, dir == Direction.UP)
.withProperty(BlockVine.NORTH, dir == Direction.NORTH)
.withProperty(BlockVine.EAST, dir == Direction.EAST)
.withProperty(BlockVine.SOUTH, dir == Direction.SOUTH)
.withProperty(BlockVine.WEST, dir == Direction.WEST);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,11 @@

public class VineBlockMapper1_14 {
static BlockState map(Direction dir) {
BlockState vine = Blocks.VINE.getDefaultState();
vine.with(VineBlock.UP, dir == Direction.UP);
vine.with(VineBlock.NORTH, dir == Direction.NORTH);
vine.with(VineBlock.EAST, dir == Direction.EAST);
vine.with(VineBlock.SOUTH, dir == Direction.SOUTH);
vine.with(VineBlock.WEST, dir == Direction.WEST);
return vine;
return Blocks.VINE.getDefaultState()
.with(VineBlock.UP, dir == Direction.UP)
.with(VineBlock.NORTH, dir == Direction.NORTH)
.with(VineBlock.EAST, dir == Direction.EAST)
.with(VineBlock.SOUTH, dir == Direction.SOUTH)
.with(VineBlock.WEST, dir == Direction.WEST);
}
}

1 comment on commit 18c9d67

@KameiB
Copy link

@KameiB KameiB commented on 18c9d67 Sep 2, 2024

Choose a reason for hiding this comment

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

A very obscure bug...
Nice finding!

Please sign in to comment.