Buggy code:
public VoxelData getVoxel ( int x , int y , int z ) { } public VoxelData [ ] [ ] [ ] getVoxelData ( ) { } public boolean hasVoxel ( int x , int y , int z ) { } public boolean isGenerationDone ( ) { } public boolean isReadyForRendering ( ) { } public boolean isInitialized ( ) { } public boolean isInitializedAndLightingReady ( ) { } public void loadVoxelData ( ) { } private static long lastUpdateCallId = - 1 ; private static int generationsProcessedThisFrame = - 1 ; public void render ( Camera cam , ShaderProgram shader ) { } public void renderModels ( Camera cam , ModelBatch modelBatch ) { } public void setGenerationDone ( boolean generationDone ) { } private void setInventoryUpdateHandler ( int positionX , int positionY , int positionZ , VoxelData inventoryVoxel ) { } private void setInventoryUpdateHandlerAll ( ) { } public void setVoxel ( int x , int y , int z , VoxelData voxel ) { } public void setVoxelData ( VoxelData [ ] [ ] [ ] voxelData ) { } private void setTileEntityHandlerAll ( ) { } public void simulate ( ) { } public void update ( ) { } private void recalculateLighting ( ) { synchronized ( this . voxelDataLockObject ) { for ( int x = ( VoxelWorld . chunkWidth ) - 1 ; x >= 0 ; x -- ) for ( int y = ( VoxelWorld . chunkHeight ) - 1 ; y >= 0 ; y -- ) for ( int z = ( VoxelWorld . chunkDepth ) - 1 ; z >= 0 ; z -- ) if ( ( this . voxelData [ x ] [ y ] [ z ] ) != null ) { VoxelData v = this . voxelData [ x ] [ y ] [ z ] ; Vector3 absolutePos = this . getAbsoluteBlockPosition ( x , y , z ) ; int absX = ( ( int ) ( absolutePos . x ) ) ; int absY = ( ( int ) ( absolutePos . y ) ) ; int absZ = ( ( int ) ( absolutePos . z ) ) ; if ( ( y == ( ( VoxelWorld . chunkHeight ) - 1 ) ) && ( ( ( v . voxelType ) == null ) || ( v . voxelType . transparent ) ) ) { v . lightLevel = ( ( byte ) ( ( CubicWorldConfiguration . maxLightLevel ) - ( ( this . master . chunksOnYAxis ( ) ) - ( this . chunkY ) ) ) ) ; } else { byte topLightLevel = ( y == ( ( VoxelWorld . chunkHeight ) - 1 ) ) ? this . master . getLightLevel ( absX , ( absY + 1 ) , absZ ) : ( this . voxelData [ x ] [ ( y + 1 ) ] [ z ] ) == null ? CubicWorldConfiguration . maxLightLevel : this . voxelData [ x ] [ ( y + 1 ) ] [ z ] . lightLevel ; if ( ( ( v . voxelType ) == null ) || ( v . voxelType . transparent ) ) v . lightLevel = topLightLevel ; else { byte leftLightLevel = ( x == 0 ) ? this . master . getLightLevel ( ( absX - 1 ) , absY , absZ ) : ( this . voxelData [ ( x - 1 ) ] [ y ] [ z ] ) == null ? CubicWorldConfiguration . maxLightLevel : this . voxelData [ ( x - 1 ) ] [ y ] [ z ] . lightLevel ; byte rightLightLevel = ( x == ( ( VoxelWorld . chunkWidth ) - 1 ) ) ? this . master . getLightLevel ( ( absX + 1 ) , absY , absZ ) : ( this . voxelData [ ( x + 1 ) ] [ y ] [ z ] ) == null ? CubicWorldConfiguration . maxLightLevel : this . voxelData [ ( x + 1 ) ] [ y ] [ z ] . lightLevel ; byte backLightLevel = ( z == 0 ) ? this . master . getLightLevel ( absX , absY , ( absZ - 1 ) ) : ( this . voxelData [ x ] [ y ] [ ( z - 1 ) ] ) == null ? CubicWorldConfiguration . maxLightLevel : this . voxelData [ x ] [ y ] [ ( z - 1 ) ] . lightLevel ; byte frontLightLevel = ( z == ( ( VoxelWorld . chunkDepth ) - 1 ) ) ? this . master . getLightLevel ( absX , absY , ( absZ + 1 ) ) : ( this . voxelData [ x ] [ y ] [ ( z + 1 ) ] ) == null ? CubicWorldConfiguration . maxLightLevel : this . voxelData [ x ] [ y ] [ ( z + 1 ) ] . lightLevel ; byte [ ] adjacentLightLevels = new byte [ ] { topLightLevel , leftLightLevel , rightLightLevel , backLightLevel , frontLightLevel } ; Arrays . sort ( adjacentLightLevels ) ; <START_BUG> byte highestLevel = adjacentLightLevels [ ( ( adjacentLightLevels . length ) - 1 ) ] ; <END_BUG> v . lightLevel = ( ( byte ) ( highestLevel - 1 ) ) ; } } } this . lightingDirty = false ; } } private void WriteSideData ( ArrayList < Vector3 > vertices , ArrayList < Short > indices , ArrayList < Vector2 > uvs , ArrayList < Color > colors , ArrayList < Vector3 > normals , Vector3 [ ] sideVertices , Vector3 [ ] sideNormals , short [ ] sideIndices , short indicesCounter , int x , int y , int z , VoxelData voxelData , VoxelFace face , byte lightLevel ) { } }

Fix:
byte highestLevel = adjacentLightLevels [ 4 ] ;