@@ -260,60 +260,61 @@ public boolean renderAttached(@NotNull final BlockModel<? extends BlockLogic> so
260260 final int dirY = element .flip ? -direction .getOffsetY () : direction .getOffsetY ();
261261 final int dirZ = element .flip ? -direction .getOffsetZ () : direction .getOffsetZ ();
262262
263- final int lightmapCoordTopLeft ;
264- final int lightmapCoordBottomLeft ;
265- final int lightmapCoordBottomRight ;
266- final int lightmapCoordTopRight ;
267-
268- if (useAO ) {
269- final int dirX2 ;
270- final int dirY2 ;
271- final int dirZ2 ;
272- if (!isFullCube ) {
273- dirX2 = 0 ;
274- dirY2 = 0 ;
275- dirZ2 = 0 ;
276- } else {
277- dirX2 = dirX ;
278- dirY2 = dirY ;
279- dirZ2 = dirZ ;
280- }
281-
282- final boolean topT = LIGHTING_CACHE .getOpacity (dirX2 + topX , dirY2 + topY , dirZ2 + topZ );
283- final boolean botT = LIGHTING_CACHE .getOpacity (dirX2 - topX , dirY2 - topY , dirZ2 - topZ );
284- final boolean lefT = LIGHTING_CACHE .getOpacity (dirX2 + lefX , dirY2 + lefY , dirZ2 + lefZ );
285- final boolean rigT = LIGHTING_CACHE .getOpacity (dirX2 - lefX , dirY2 - lefY , dirZ2 - lefZ );
286-
287- final boolean topLefT = LIGHTING_CACHE .getOpacity (dirX2 + topX + lefX , dirY2 + topY + lefY , dirZ2 + topZ + lefZ );
288- final boolean topRigT = LIGHTING_CACHE .getOpacity (dirX2 + topX - lefX , dirY2 + topY - lefY , dirZ2 + topZ - lefZ );
289- final boolean botLefT = LIGHTING_CACHE .getOpacity (dirX2 - topX + lefX , dirY2 - topY + lefY , dirZ2 - topZ + lefZ );
290- final boolean botRigT = LIGHTING_CACHE .getOpacity (dirX2 - topX - lefX , dirY2 - topY - lefY , dirZ2 - topZ - lefZ );
291-
292- final int lmcCen = getLightmap (dirX2 , dirY2 , dirZ2 , element .lightEmission );
293-
294- final int lmcTop = topT ? lmcCen : getLightmap (dirX2 + topX , dirY2 + topY , dirZ2 + topZ , element .lightEmission );
295- final int lmcBot = botT ? lmcCen : getLightmap (dirX2 - topX , dirY2 - topY , dirZ2 - topZ , element .lightEmission );
296- final int lmcLef = lefT ? lmcCen : getLightmap (dirX2 + lefX , dirY2 + lefY , dirZ2 + lefZ , element .lightEmission );
297- final int lmcRig = rigT ? lmcCen : getLightmap (dirX2 - lefX , dirY2 - lefY , dirZ2 - lefZ , element .lightEmission );
298-
299- final int lmcTopLef = topT && lefT ? lmcLef : (topLefT ? lmcCen : getLightmap (dirX2 + topX + lefX , dirY2 + topY + lefY , dirZ2 + topZ + lefZ , element .lightEmission ));
300- final int lmcBotLef = botT && lefT ? lmcLef : (botLefT ? lmcCen : getLightmap (dirX2 - topX + lefX , dirY2 - topY + lefY , dirZ2 - topZ + lefZ , element .lightEmission ));
301- final int lmcTopRig = topT && rigT ? lmcRig : (topRigT ? lmcCen : getLightmap (dirX2 + topX - lefX , dirY2 + topY - lefY , dirZ2 + topZ - lefZ , element .lightEmission ));
302- final int lmcBotRig = botT && rigT ? lmcRig : (botRigT ? lmcCen : getLightmap (dirX2 - topX - lefX , dirY2 - topY - lefY , dirZ2 - topZ - lefZ , element .lightEmission ));
303-
304- lightmapCoordTopLeft = LightmapHelper .avg (lmcCen , lmcLef , lmcTop , lmcTopLef );
305- lightmapCoordTopRight = LightmapHelper .avg (lmcCen , lmcRig , lmcTop , lmcTopRig );
306- lightmapCoordBottomLeft = LightmapHelper .avg (lmcCen , lmcLef , lmcBot , lmcBotLef );
307- lightmapCoordBottomRight = LightmapHelper .avg (lmcCen , lmcRig , lmcBot , lmcBotRig );
308- } else {
309- final int lmc ;
310- if (!isFullCube ) {
311- lmc = getLightmap (0 , 0 , 0 , element .lightEmission );
312- } else {
313- lmc = getLightmap (dirX , dirY , dirZ , element .lightEmission );
314- }
315- lightmapCoordTopLeft = lightmapCoordBottomLeft = lightmapCoordBottomRight = lightmapCoordTopRight = lmc ;
316- }
263+ int lightmapCoordTopLeft = 0 ;
264+ int lightmapCoordBottomLeft = 0 ;
265+ int lightmapCoordBottomRight = 0 ;
266+ int lightmapCoordTopRight = 0 ;
267+ if (LightmapHelper .isLightmapEnabled ()) {
268+ if (useAO ) {
269+ final int dirX2 ;
270+ final int dirY2 ;
271+ final int dirZ2 ;
272+ if (!isFullCube ) {
273+ dirX2 = 0 ;
274+ dirY2 = 0 ;
275+ dirZ2 = 0 ;
276+ } else {
277+ dirX2 = dirX ;
278+ dirY2 = dirY ;
279+ dirZ2 = dirZ ;
280+ }
281+
282+ final boolean topT = LIGHTING_CACHE .getOpacity (dirX2 + topX , dirY2 + topY , dirZ2 + topZ );
283+ final boolean botT = LIGHTING_CACHE .getOpacity (dirX2 - topX , dirY2 - topY , dirZ2 - topZ );
284+ final boolean lefT = LIGHTING_CACHE .getOpacity (dirX2 + lefX , dirY2 + lefY , dirZ2 + lefZ );
285+ final boolean rigT = LIGHTING_CACHE .getOpacity (dirX2 - lefX , dirY2 - lefY , dirZ2 - lefZ );
286+
287+ final boolean topLefT = LIGHTING_CACHE .getOpacity (dirX2 + topX + lefX , dirY2 + topY + lefY , dirZ2 + topZ + lefZ );
288+ final boolean topRigT = LIGHTING_CACHE .getOpacity (dirX2 + topX - lefX , dirY2 + topY - lefY , dirZ2 + topZ - lefZ );
289+ final boolean botLefT = LIGHTING_CACHE .getOpacity (dirX2 - topX + lefX , dirY2 - topY + lefY , dirZ2 - topZ + lefZ );
290+ final boolean botRigT = LIGHTING_CACHE .getOpacity (dirX2 - topX - lefX , dirY2 - topY - lefY , dirZ2 - topZ - lefZ );
291+
292+ final int lmcCen = getLightmap (dirX2 , dirY2 , dirZ2 , element .lightEmission );
293+
294+ final int lmcTop = topT ? lmcCen : getLightmap (dirX2 + topX , dirY2 + topY , dirZ2 + topZ , element .lightEmission );
295+ final int lmcBot = botT ? lmcCen : getLightmap (dirX2 - topX , dirY2 - topY , dirZ2 - topZ , element .lightEmission );
296+ final int lmcLef = lefT ? lmcCen : getLightmap (dirX2 + lefX , dirY2 + lefY , dirZ2 + lefZ , element .lightEmission );
297+ final int lmcRig = rigT ? lmcCen : getLightmap (dirX2 - lefX , dirY2 - lefY , dirZ2 - lefZ , element .lightEmission );
298+
299+ final int lmcTopLef = topT && lefT ? lmcLef : (topLefT ? lmcCen : getLightmap (dirX2 + topX + lefX , dirY2 + topY + lefY , dirZ2 + topZ + lefZ , element .lightEmission ));
300+ final int lmcBotLef = botT && lefT ? lmcLef : (botLefT ? lmcCen : getLightmap (dirX2 - topX + lefX , dirY2 - topY + lefY , dirZ2 - topZ + lefZ , element .lightEmission ));
301+ final int lmcTopRig = topT && rigT ? lmcRig : (topRigT ? lmcCen : getLightmap (dirX2 + topX - lefX , dirY2 + topY - lefY , dirZ2 + topZ - lefZ , element .lightEmission ));
302+ final int lmcBotRig = botT && rigT ? lmcRig : (botRigT ? lmcCen : getLightmap (dirX2 - topX - lefX , dirY2 - topY - lefY , dirZ2 - topZ - lefZ , element .lightEmission ));
303+
304+ lightmapCoordTopLeft = LightmapHelper .avg (lmcCen , lmcLef , lmcTop , lmcTopLef );
305+ lightmapCoordTopRight = LightmapHelper .avg (lmcCen , lmcRig , lmcTop , lmcTopRig );
306+ lightmapCoordBottomLeft = LightmapHelper .avg (lmcCen , lmcLef , lmcBot , lmcBotLef );
307+ lightmapCoordBottomRight = LightmapHelper .avg (lmcCen , lmcRig , lmcBot , lmcBotRig );
308+ } else {
309+ final int lmc ;
310+ if (!isFullCube ) {
311+ lmc = getLightmap (0 , 0 , 0 , element .lightEmission );
312+ } else {
313+ lmc = getLightmap (dirX , dirY , dirZ , element .lightEmission );
314+ }
315+ lightmapCoordTopLeft = lightmapCoordBottomLeft = lightmapCoordBottomRight = lightmapCoordTopRight = lmc ;
316+ }
317+ }
317318
318319 float lightTR ;
319320 float lightBR ;
@@ -381,9 +382,9 @@ public boolean renderAttached(@NotNull final BlockModel<? extends BlockLogic> so
381382 if (rotY != 0 ) { norm .rotateY (rotY * org .joml .Math .PI_OVER_2_f ); }
382383 if (rotZ != 0 ) { norm .rotateZ (rotZ * org .joml .Math .PI_OVER_2_f ); }
383384
384- float d1 = Math .max (0 , norm .dot (light1 ));
385- float d2 = Math .max (0 , norm .dot (light2 ));
386- float brightness = 0.5f + 0.5f * (d1 + d2 );
385+ final float d1 = Math .max (0 , norm .dot (light1 ));
386+ final float d2 = Math .max (0 , norm .dot (light2 ));
387+ final float brightness = 0.5f + 0.5f * (d1 + d2 );
387388
388389 r *= brightness ;
389390 g *= brightness ;
@@ -449,7 +450,7 @@ public boolean renderAttached(@NotNull final BlockModel<? extends BlockLogic> so
449450 Vector2fc uvsTL = element .vertexUvs [offset + VERTEX_TOP_LEFT ];
450451 if (uvlock ) uvsTL = rotateUV (uvsTL , rotX , rotY , rotZ , element .directions [face ], new Vector2f ());
451452 tessellator .setColorOpaque_F (colorRedTopLeft , colorGreenTopLeft , colorBlueTopLeft );
452- tessellator .setLightmapCoord (lightmapCoordTopLeft );
453+ if ( LightmapHelper . isLightmapEnabled ()) tessellator .setLightmapCoord (lightmapCoordTopLeft );
453454 tessellator .addVertexWithUV (
454455 posTL .x () + x + xOff ,
455456 posTL .y () + y + yOff ,
@@ -468,7 +469,7 @@ public boolean renderAttached(@NotNull final BlockModel<? extends BlockLogic> so
468469 Vector2fc uvsBL = element .vertexUvs [offset + VERTEX_BOTTOM_LEFT ];
469470 if (uvlock ) uvsBL = rotateUV (uvsBL , rotX , rotY , rotZ , element .directions [face ], new Vector2f ());
470471 tessellator .setColorOpaque_F (colorRedBottomLeft , colorGreenBottomLeft , colorBlueBottomLeft );
471- tessellator .setLightmapCoord (lightmapCoordBottomLeft );
472+ if ( LightmapHelper . isLightmapEnabled ()) tessellator .setLightmapCoord (lightmapCoordBottomLeft );
472473 tessellator .addVertexWithUV (
473474 posBL .x () + x + xOff ,
474475 posBL .y () + y + yOff ,
@@ -487,7 +488,7 @@ public boolean renderAttached(@NotNull final BlockModel<? extends BlockLogic> so
487488 Vector2fc uvsBR = element .vertexUvs [offset + VERTEX_BOTTOM_RIGHT ];
488489 if (uvlock ) uvsBR = rotateUV (uvsBR , rotX , rotY , rotZ , element .directions [face ], new Vector2f ());
489490 tessellator .setColorOpaque_F (colorRedBottomRight , colorGreenBottomRight , colorBlueBottomRight );
490- tessellator .setLightmapCoord (lightmapCoordBottomRight );
491+ if ( LightmapHelper . isLightmapEnabled ()) tessellator .setLightmapCoord (lightmapCoordBottomRight );
491492 tessellator .addVertexWithUV (
492493 posBR .x () + x + xOff ,
493494 posBR .y () + y + yOff ,
@@ -506,7 +507,7 @@ public boolean renderAttached(@NotNull final BlockModel<? extends BlockLogic> so
506507 Vector2fc uvsTR = element .vertexUvs [offset + VERTEX_TOP_RIGHT ];
507508 if (uvlock ) uvsTR = rotateUV (uvsTR , rotX , rotY , rotZ , element .directions [face ], new Vector2f ());
508509 tessellator .setColorOpaque_F (colorRedTopRight , colorGreenTopRight , colorBlueTopRight );
509- tessellator .setLightmapCoord (lightmapCoordTopRight );
510+ if ( LightmapHelper . isLightmapEnabled ()) tessellator .setLightmapCoord (lightmapCoordTopRight );
510511 tessellator .addVertexWithUV (
511512 posTR .x () + x + xOff ,
512513 posTR .y () + y + yOff ,
0 commit comments