Skip to content

Commit

Permalink
refactor: remove BlockFace#getBlockFaceByStairDirectionValue, some fi…
Browse files Browse the repository at this point in the history
…elds in VoxelShapes are also made private now
  • Loading branch information
smartcmd committed Dec 30, 2024
1 parent a232734 commit 8f0502e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
5 changes: 0 additions & 5 deletions api/src/main/java/org/allaymc/api/block/data/BlockFace.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ public enum BlockFace {

private static final BlockFace[] HORIZONTAL_BLOCK_FACES = {NORTH, EAST, SOUTH, WEST};
private static final BlockFace[] VERTICAL_BLOCK_FACES = {UP, DOWN};
private static final BlockFace[] STAIR_DIRECTION_VALUE_TO_BLOCK_FACE = {EAST, WEST, SOUTH, NORTH};

private final int horizontalIndex;
private final Vector3ic offset;
Expand Down Expand Up @@ -74,10 +73,6 @@ public static BlockFace[] getVerticalBlockFaces() {
return VERTICAL_BLOCK_FACES;
}

public static BlockFace getBlockFaceByStairDirectionValue(int value) {
return STAIR_DIRECTION_VALUE_TO_BLOCK_FACE[value];
}

/**
* Add current block face offset to the given pos.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@
public final class VoxelShapes {

// Stairs
public static final Map<BlockFace, VoxelShape> UPWARDS_STAIR_SHAPES = new EnumMap<>(BlockFace.class);
public static final Map<BlockFace, VoxelShape> DOWNWARDS_STAIR_SHAPES = new EnumMap<>(BlockFace.class);
private static final BlockFace[] STAIR_DIRECTION_VALUE_TO_BLOCK_FACE = {BlockFace.EAST, BlockFace.WEST, BlockFace.SOUTH, BlockFace.NORTH};
private static final Map<BlockFace, VoxelShape> UPWARDS_STAIR_SHAPES = new EnumMap<>(BlockFace.class);
private static final Map<BlockFace, VoxelShape> DOWNWARDS_STAIR_SHAPES = new EnumMap<>(BlockFace.class);

private static final VoxelShape UPWARDS_STAIR_SHAPE = VoxelShape.builder()
.solid(0, 0, 0, 1, 1, 1)
Expand All @@ -39,7 +40,7 @@ public final class VoxelShapes {

public static VoxelShape buildStairShape(BlockState stairBlockState) {
var isDownwards = stairBlockState.getPropertyValue(BlockPropertyTypes.UPSIDE_DOWN_BIT);
var face = BlockFace.getBlockFaceByStairDirectionValue(stairBlockState.getPropertyValue(BlockPropertyTypes.WEIRDO_DIRECTION));
var face = STAIR_DIRECTION_VALUE_TO_BLOCK_FACE[stairBlockState.getPropertyValue(BlockPropertyTypes.WEIRDO_DIRECTION)];
return isDownwards ? DOWNWARDS_STAIR_SHAPES.get(face) : UPWARDS_STAIR_SHAPES.get(face);
}

Expand Down

0 comments on commit 8f0502e

Please sign in to comment.