17
17
import net .minecraft .world .level .block .state .properties .SlabType ;
18
18
import net .minecraft .world .level .block .state .properties .StairsShape ;
19
19
import net .minecraft .world .phys .HitResult ;
20
+ import org .jspecify .annotations .Nullable ;
20
21
import platinpython .rgbblocks .tileentity .RGBTileEntity ;
21
22
import platinpython .rgbblocks .util .Color ;
22
23
import platinpython .rgbblocks .util .registries .TileEntityRegistry ;
23
24
24
25
public final class RGBBlockUtils {
25
- public static BlockEntity newBlockEntity (BlockPos pos , BlockState state ) {
26
+ public static @ Nullable BlockEntity newBlockEntity (BlockPos pos , BlockState state ) {
26
27
return TileEntityRegistry .RGB .get ().create (pos , state );
27
28
}
28
29
29
30
public static void setPlacedBy (
30
31
Level worldIn ,
31
32
BlockPos pos ,
32
33
BlockState state ,
33
- LivingEntity placer ,
34
+ @ Nullable LivingEntity placer ,
34
35
ItemStack stack
35
36
) {
36
37
BlockEntity tileEntity = worldIn .getBlockEntity (pos );
37
- if (stack .hasTag () && tileEntity instanceof RGBTileEntity ) {
38
- ((RGBTileEntity ) tileEntity ).setColor (stack .getTag ().getInt ("color" ));
38
+ if (stack .hasTag () && tileEntity instanceof RGBTileEntity rgbTileEntity ) {
39
+ // noinspection DataFlowIssue
40
+ rgbTileEntity .setColor (stack .getTag ().getInt ("color" ));
39
41
}
40
42
}
41
43
@@ -56,15 +58,15 @@ public static ItemStack getCloneItemStack(
56
58
return stack ;
57
59
}
58
60
59
- public static float [] getBeaconColorMultiplier (
61
+ public static float @ Nullable [] getBeaconColorMultiplier (
60
62
BlockState state ,
61
63
LevelReader world ,
62
64
BlockPos pos ,
63
65
BlockPos beaconPos
64
66
) {
65
67
BlockEntity tileEntity = world .getBlockEntity (pos );
66
- if (tileEntity instanceof RGBTileEntity ) {
67
- return new Color ((( RGBTileEntity ) tileEntity ) .getColor ()).getRGBColorComponents ();
68
+ if (tileEntity instanceof RGBTileEntity rgbTileEntity ) {
69
+ return new Color (rgbTileEntity .getColor ()).getRGBColorComponents ();
68
70
} else {
69
71
return null ;
70
72
}
@@ -122,18 +124,11 @@ public static boolean slabSkipRenderingAdjacentGlassSlab(
122
124
return true ;
123
125
}
124
126
125
- switch (side ) {
126
- case UP :
127
- case DOWN :
128
- return (state .getValue (SlabBlock .TYPE ) != adjacentBlockState .getValue (SlabBlock .TYPE ));
129
- case NORTH :
130
- case EAST :
131
- case SOUTH :
132
- case WEST :
133
- return (state .getValue (SlabBlock .TYPE ) == adjacentBlockState .getValue (SlabBlock .TYPE ));
134
- }
135
-
136
- return false ;
127
+ return switch (side ) {
128
+ case UP , DOWN -> (state .getValue (SlabBlock .TYPE ) != adjacentBlockState .getValue (SlabBlock .TYPE ));
129
+ case NORTH , EAST , SOUTH , WEST ->
130
+ (state .getValue (SlabBlock .TYPE ) == adjacentBlockState .getValue (SlabBlock .TYPE ));
131
+ };
137
132
}
138
133
139
134
public static boolean slabSkipRenderingAdjacentGlassStairs (
@@ -157,9 +152,9 @@ public static boolean slabSkipRenderingAdjacentGlassStairs(
157
152
if (state .getValue (SlabBlock .TYPE ) == SlabType .BOTTOM
158
153
&& adjacentBlockState .getValue (StairBlock .HALF ) == Half .BOTTOM ) {
159
154
return true ;
160
- } else if ( state . getValue ( SlabBlock . TYPE ) == SlabType . TOP
161
- && adjacentBlockState .getValue (StairBlock . HALF ) == Half .TOP ) {
162
- return true ;
155
+ } else {
156
+ return state .getValue (SlabBlock . TYPE ) == SlabType .TOP
157
+ && adjacentBlockState . getValue ( StairBlock . HALF ) == Half . TOP ;
163
158
}
164
159
}
165
160
@@ -221,9 +216,9 @@ public static boolean stairSkipRenderingAdjacentGlassSlab(
221
216
if (adjacentBlockState .getValue (SlabBlock .TYPE ) == SlabType .TOP
222
217
&& state .getValue (StairBlock .HALF ) == Half .TOP ) {
223
218
return true ;
224
- } else if ( adjacentBlockState . getValue ( SlabBlock . TYPE ) == SlabType . BOTTOM
225
- && state .getValue (StairBlock . HALF ) == Half .BOTTOM ) {
226
- return true ;
219
+ } else {
220
+ return adjacentBlockState .getValue (SlabBlock . TYPE ) == SlabType .BOTTOM
221
+ && state . getValue ( StairBlock . HALF ) == Half . BOTTOM ;
227
222
}
228
223
}
229
224
@@ -419,10 +414,10 @@ public static boolean stairSkipRenderingAdjacentGlassStairs(
419
414
} else if (adjacentBlockState .getValue (StairBlock .FACING ) == state .getValue (StairBlock .FACING )
420
415
&& adjacentBlockState .getValue (StairBlock .SHAPE ) != StairsShape .OUTER_RIGHT ) {
421
416
return true ;
422
- } else if ( adjacentBlockState . getValue ( StairBlock . FACING )
423
- == state .getValue (StairBlock .FACING ). getOpposite ( )
424
- && state .getValue (StairBlock .SHAPE ) == StairsShape . OUTER_LEFT ) {
425
- return true ;
417
+ } else {
418
+ return adjacentBlockState .getValue (StairBlock .FACING )
419
+ == state .getValue (StairBlock .FACING ). getOpposite ()
420
+ && state . getValue ( StairBlock . SHAPE ) == StairsShape . OUTER_LEFT ;
426
421
}
427
422
}
428
423
}
0 commit comments