1212import java .util .Map ;
1313
1414public class InnerStairs extends OuterStairs {
15- protected static final Map <Direction , VoxelShape > bottomVoxelShape = getVoxelShapeMapOfY (0.5f );
16- protected static final Map <Direction , VoxelShape > topVoxelShape = getVoxelShapeMapOfY (0f );
17- protected static Map <Direction , VoxelShape > getVoxelShapeMapOfY (double y ) {
15+ protected static final VoxelShape voxelShapeBottomNorth ;
16+ protected static final VoxelShape voxelShapeBottomSouth ;
17+ protected static final VoxelShape voxelShapeBottomEast ;
18+ protected static final VoxelShape voxelShapeBottomWest ;
19+
20+ protected static final VoxelShape voxelShapeTopNorth ;
21+ protected static final VoxelShape voxelShapeTopSouth ;
22+ protected static final VoxelShape voxelShapeTopEast ;
23+ protected static final VoxelShape voxelShapeTopWest ;
24+
25+ protected static Map <Direction , VoxelShape > getVoxelShapeMapOfY ( double y ){
26+ VoxelShape base = VoxelShapes .cuboid (
27+ 0f , 0.5f - y , 0f ,
28+ 1f , 1f - y , 1f
29+ );
1830 return Map .of (
1931 Direction .NORTH , VoxelShapes .union (
20- VoxelShapes .cuboid (0.5f , y , 0f , 1f , y +0.5f , 1f ),
21- VoxelShapes .cuboid (0f , y , 0.5f , 0.5f , y +0.5f , 1f )
32+ base ,
33+ VoxelShapes .cuboid (0.5f , y , 0f , 1f , y + 0.5f , 1f ),
34+ VoxelShapes .cuboid (0f , y , 0.5f , 0.5f , y + 0.5f , 1f )
2235 ), // original
2336 Direction .SOUTH , VoxelShapes .union (
24- VoxelShapes .cuboid (0f , y , 0f , 0.5f , y +0.5f , 1f ),
25- VoxelShapes .cuboid (0.5f , y , 0f , 1f , y +0.5f , 0.5f )
37+ base ,
38+ VoxelShapes .cuboid (0f , y , 0f , 0.5f , y + 0.5f , 1f ),
39+ VoxelShapes .cuboid (0.5f , y , 0f , 1f , y + 0.5f , 0.5f )
2640 ), // reverse original
2741 Direction .EAST , VoxelShapes .union (
28- VoxelShapes .cuboid (0f , y , 0.5f , 1f , y +0.5f , 1f ),
29- VoxelShapes .cuboid (0f , y , 0f , 0.5f , y +0.5f , 0.5f )
42+ base ,
43+ VoxelShapes .cuboid (0f , y , 0.5f , 1f , y + 0.5f , 1f ),
44+ VoxelShapes .cuboid (0f , y , 0f , 0.5f , y + 0.5f , 0.5f )
3045 ), // swap x <-> z + reverse
31- Direction .WEST , VoxelShapes .union (
32- VoxelShapes .cuboid (0f , y , 0f , 1f , y +0.5f , 0.5f ),
33- VoxelShapes .cuboid (0.5f , y , 0.5f , 1f , y +0.5f , 1f )
46+ Direction .WEST , VoxelShapes .union (
47+ base ,
48+ VoxelShapes .cuboid (0f , y , 0f , 1f , y + 0.5f , 0.5f ),
49+ VoxelShapes .cuboid (0.5f , y , 0.5f , 1f , y + 0.5f , 1f )
3450 ) // swap x <-> z
3551 );
3652 }
53+ static {
54+ final Map <Direction , VoxelShape > bottomVoxelShape = getVoxelShapeMapOfY (0.5f );
55+ final Map <Direction , VoxelShape > topVoxelShape = getVoxelShapeMapOfY (0f );
56+
57+ voxelShapeBottomNorth = bottomVoxelShape .get (Direction .NORTH );
58+ voxelShapeBottomSouth = bottomVoxelShape .get (Direction .SOUTH );
59+ voxelShapeBottomEast = bottomVoxelShape .get (Direction .EAST );
60+ voxelShapeBottomWest = bottomVoxelShape .get (Direction .WEST );
61+
62+ voxelShapeTopNorth = topVoxelShape .get (Direction .NORTH );
63+ voxelShapeTopSouth = topVoxelShape .get (Direction .SOUTH );
64+ voxelShapeTopEast = topVoxelShape .get (Direction .EAST );
65+ voxelShapeTopWest = topVoxelShape .get (Direction .WEST );
66+ }
3767
3868 public InnerStairs (Settings settings ) {
3969 super (settings );
@@ -42,8 +72,37 @@ public InnerStairs(Settings settings) {
4272 @ Override
4373 public VoxelShape getOutlineShape (BlockState state , BlockView view , BlockPos pos , ShapeContext context ) {
4474 Direction dir = state .get (FACING );
45- return state .get (Properties .BLOCK_HALF ) == BlockHalf .TOP
46- ? topVoxelShape .get (dir )
47- : bottomVoxelShape .get (dir );
75+ if (state .get (Properties .BLOCK_HALF ) == BlockHalf .BOTTOM ) {
76+ switch (dir ) {
77+ case NORTH -> {
78+ return voxelShapeBottomNorth ;
79+ }
80+ case SOUTH -> {
81+ return voxelShapeBottomSouth ;
82+ }
83+ case EAST -> {
84+ return voxelShapeBottomEast ;
85+ }
86+ case WEST -> {
87+ return voxelShapeBottomWest ;
88+ }
89+ }
90+ } else {
91+ switch (dir ) {
92+ case NORTH -> {
93+ return voxelShapeTopNorth ;
94+ }
95+ case SOUTH -> {
96+ return voxelShapeTopSouth ;
97+ }
98+ case EAST -> {
99+ return voxelShapeTopEast ;
100+ }
101+ case WEST -> {
102+ return voxelShapeTopWest ;
103+ }
104+ }
105+ }
106+ return VoxelShapes .fullCube (); // Fallback, should not happen
48107 }
49108}
0 commit comments