diff --git a/src/main/java/dan200/computercraft/client/gui/FixedWidthFontRenderer.java b/src/main/java/dan200/computercraft/client/gui/FixedWidthFontRenderer.java index 48a8b6aed..36868c428 100644 --- a/src/main/java/dan200/computercraft/client/gui/FixedWidthFontRenderer.java +++ b/src/main/java/dan200/computercraft/client/gui/FixedWidthFontRenderer.java @@ -409,7 +409,7 @@ public final class FixedWidthFontRenderer false, false ) ) // blur, minimap .alpha( ONE_TENTH_ALPHA ) - .writeMaskState( DEPTH_MASK ) + .writeMaskState( ALL_MASK ) .lightmap( DISABLE_LIGHTMAP ) .build( false ) ); diff --git a/src/main/java/dan200/computercraft/client/proxy/ComputerCraftProxyClient.java b/src/main/java/dan200/computercraft/client/proxy/ComputerCraftProxyClient.java index d59206009..fa7c0a8f1 100644 --- a/src/main/java/dan200/computercraft/client/proxy/ComputerCraftProxyClient.java +++ b/src/main/java/dan200/computercraft/client/proxy/ComputerCraftProxyClient.java @@ -77,6 +77,10 @@ public final class ComputerCraftProxyClient implements ClientModInitializer BlockRenderLayerMap.INSTANCE.putBlock( ComputerCraftRegistry.ModBlocks.TURTLE_NORMAL, RenderLayer.getTranslucent() ); BlockRenderLayerMap.INSTANCE.putBlock( ComputerCraftRegistry.ModBlocks.TURTLE_ADVANCED, RenderLayer.getTranslucent() ); + // Monitors' textures have transparent fronts and so count as cutouts. + BlockRenderLayerMap.INSTANCE.putBlock( ComputerCraftRegistry.ModBlocks.MONITOR_NORMAL, RenderLayer.getCutout() ); + BlockRenderLayerMap.INSTANCE.putBlock( ComputerCraftRegistry.ModBlocks.MONITOR_ADVANCED, RenderLayer.getCutout() ); + // Setup TESRs BlockEntityRendererRegistry.INSTANCE.register( ComputerCraftRegistry.ModTiles.MONITOR_NORMAL, TileEntityMonitorRenderer::new ); BlockEntityRendererRegistry.INSTANCE.register( ComputerCraftRegistry.ModTiles.MONITOR_ADVANCED, TileEntityMonitorRenderer::new ); diff --git a/src/main/java/dan200/computercraft/client/render/TileEntityMonitorRenderer.java b/src/main/java/dan200/computercraft/client/render/TileEntityMonitorRenderer.java index 6dd81b5a2..2c40576e4 100644 --- a/src/main/java/dan200/computercraft/client/render/TileEntityMonitorRenderer.java +++ b/src/main/java/dan200/computercraft/client/render/TileEntityMonitorRenderer.java @@ -93,10 +93,21 @@ public class TileEntityMonitorRenderer extends BlockEntityRenderer transform.multiply( Vector3f.POSITIVE_X.getDegreesQuaternion( pitch ) ); transform.translate( -0.5 + TileMonitor.RENDER_BORDER + TileMonitor.RENDER_MARGIN, origin.getHeight() - 0.5 - (TileMonitor.RENDER_BORDER + TileMonitor.RENDER_MARGIN) + 0, - 0.501 ); + 0.50 ); double xSize = origin.getWidth() - 2.0 * (TileMonitor.RENDER_MARGIN + TileMonitor.RENDER_BORDER); double ySize = origin.getHeight() - 2.0 * (TileMonitor.RENDER_MARGIN + TileMonitor.RENDER_BORDER); + // Draw the background blocker + FixedWidthFontRenderer.drawBlocker( transform.peek().getModel(), + renderer, + (float) -TileMonitor.RENDER_MARGIN, + (float) TileMonitor.RENDER_MARGIN, + (float) (xSize + 2 * TileMonitor.RENDER_MARGIN), + (float) -(ySize + TileMonitor.RENDER_MARGIN * 2) ); + + // Set the contents slightly off the surface to prevent z-fighting + transform.translate( 0.0, 0.0, 0.001 ); + // Draw the contents Terminal terminal = originTerminal.getTerminal(); if( terminal != null ) @@ -123,6 +134,8 @@ public class TileEntityMonitorRenderer extends BlockEntityRenderer // reasonable. FixedWidthFontRenderer.drawCursor( matrix, buffer, 0, 0, terminal, !originTerminal.isColour() ); + // To go along with sneaky hack above: make sure state changes are undone. I would have thought this would + // happen automatically after these buffers are drawn, but chests will render weird around monitors without this. FixedWidthFontRenderer.TYPE.endDrawing(); transform.pop(); @@ -138,13 +151,6 @@ public class TileEntityMonitorRenderer extends BlockEntityRenderer (float) -(ySize + MARGIN * 2) ); } - // FixedWidthFontRenderer.drawBlocker( transform.peek().getModel(), - // renderer, - // (float) -TileMonitor.RENDER_MARGIN, - // (float) TileMonitor.RENDER_MARGIN, - // (float) (xSize + 2 * TileMonitor.RENDER_MARGIN), - // (float) -(ySize + TileMonitor.RENDER_MARGIN * 2) ); - transform.pop(); }