1515import static net .minecraft .block .enums .BlockHalf .TOP ;
1616
1717public class LightStripBlockEntityRenderer implements BlockEntityRenderer <LightStripBlockEntity > {
18+ protected static RenderFunction renderFunction = LightStripBlockEntityRenderer ::fakeRunnable ;
19+ public static void enableBrightening () {
20+ renderFunction = LightStripBlockEntityRenderer ::renderBrightening ;
21+ }
22+
1823 @ SuppressWarnings ("unused" )
1924 public LightStripBlockEntityRenderer (BlockEntityRendererFactory .Context ctx ) {}
2025
@@ -23,45 +28,31 @@ public void render(LightStripBlockEntity entity, float tickDelta, MatrixStack ma
2328 renderFunction .execute (entity , matrices , vertexConsumers , overlay );
2429 }
2530
26-
27- @ FunctionalInterface
28- protected interface RenderFunction {
29- void execute (LightStripBlockEntity entity , MatrixStack matrices , VertexConsumerProvider vertexConsumers , int overlay );
30- }
31-
32- protected static RenderFunction renderFunction = LightStripBlockEntityRenderer ::fakeRunnable ;
33- public static void enableBrightening () {
34- renderFunction = LightStripBlockEntityRenderer ::renderBrightening ;
35- }
36-
3731 protected static void fakeRunnable (LightStripBlockEntity entity , MatrixStack matrices , VertexConsumerProvider vertexConsumers , int overlay ) {}
3832 protected static void renderBrightening (LightStripBlockEntity entity , MatrixStack matrices , VertexConsumerProvider vertexConsumers , int overlay ) {
3933 World world = entity .getWorld ();
4034 BlockPos pos = entity .getPos ();
41- if (world == null || pos == null ) {
42- return ;
43- }
35+ if (world == null || pos == null ) return ;
4436
4537 BlockState blockState = world .getBlockState (pos );
46- if (blockState == null || !(blockState .getBlock () instanceof LightStripBlock )) {
47- return ;
48- }
38+ if (blockState == null || !(blockState .getBlock () instanceof LightStripBlock )) return ;
4939
5040
5141 matrices .push ();
5242
53- // Scale the rendered block by a configurable factor
43+ // Scale of the brightened model
5444 final float scale = 1.01111f ;
5545
56- // Calculate a pixel shift constant for centering the block
46+ // Calculate a pixel shift constant for centering of the brightened model
5747 final float pixelShift = (1f /32f )*(1 -scale );
5848
59- // Move the block up or down depending on the block's half, and center it
49+ // Move the block up or down depending on the block's half, and centre it
6050 final float deltaY = blockState .get (StairsBlock .HALF ) == TOP ? (1 -scale )-pixelShift : pixelShift ;
6151
6252 // Move the rendered block half of the difference between the original and the scaled size
6353 final float deltaLongAxis = 0.5f *(1 -scale );
6454
55+ // Calculate correct model offsets
6556 float deltaX = 0f ;
6657 float deltaZ = 0f ;
6758 switch (blockState .get (Properties .STAIR_SHAPE )) {
@@ -203,4 +194,9 @@ protected static void renderBrightening(LightStripBlockEntity entity, MatrixStac
203194
204195 matrices .pop ();
205196 }
197+
198+ @ FunctionalInterface
199+ protected interface RenderFunction {
200+ void execute (LightStripBlockEntity entity , MatrixStack matrices , VertexConsumerProvider vertexConsumers , int overlay );
201+ }
206202}
0 commit comments