diff --git a/src/main/java/dan200/computercraft/client/render/ComputerBorderRenderer.java b/src/main/java/dan200/computercraft/client/render/ComputerBorderRenderer.java index 31450a69d..8efd22185 100644 --- a/src/main/java/dan200/computercraft/client/render/ComputerBorderRenderer.java +++ b/src/main/java/dan200/computercraft/client/render/ComputerBorderRenderer.java @@ -38,7 +38,10 @@ public class ComputerBorderRenderer { private static final int CORNER_LEFT_X = BORDER; private static final int CORNER_RIGHT_X = CORNER_LEFT_X + BORDER; private static final int BORDER_RIGHT_X = 36; - private static final int GAP = 4; + private static final int LIGHT_BORDER_Y = 56; + private static final int LIGHT_CORNER_Y = 80; + + public static final int LIGHT_HEIGHT = 8; private static final float TEX_SCALE = 1 / 256.0f; static { @@ -89,15 +92,16 @@ public class ComputerBorderRenderer { } public static void render(Matrix4f transform, VertexConsumer buffer, int x, int y, int z, int width, int height, float r, float g, float b) { - render(transform, buffer, x, y, z, width, height, 0, r, g, b); + render( transform, buffer, x, y, z, width, height, false, r, g, b ); } - public static void render(Matrix4f transform, VertexConsumer buffer, int x, int y, int z, int width, int height, int borderHeight, float r, float g, - float b) { - new ComputerBorderRenderer(transform, buffer, z, r, g, b).doRender(x, y, width, height, borderHeight); + public static void render( Matrix4f transform, VertexConsumer buffer, int x, int y, int z, int width, int height, boolean withLight, float r, float g, float b ) + { + new ComputerBorderRenderer( transform, buffer, z, r, g, b ).doRender( x, y, width, height, withLight ); } - public void doRender(int x, int y, int width, int height, int bottomHeight) { + public void doRender( int x, int y, int width, int height, boolean withLight ) + { int endX = x + width; int endY = y + height; @@ -112,24 +116,17 @@ public class ComputerBorderRenderer { // Bottom bar. We allow for drawing a stretched version, which allows for additional elements (such as the // pocket computer's lights). - if (bottomHeight <= 0) { + if( withLight ) + { + renderTexture( x, endY, 0, LIGHT_BORDER_Y, endX - x, BORDER + LIGHT_HEIGHT, BORDER, BORDER + LIGHT_HEIGHT ); + renderTexture( x - BORDER, endY, CORNER_LEFT_X, LIGHT_CORNER_Y, BORDER, BORDER + LIGHT_HEIGHT ); + renderTexture( endX, endY, CORNER_RIGHT_X, LIGHT_CORNER_Y, BORDER, BORDER + LIGHT_HEIGHT ); + } + else + { this.renderLine(x, endY, 0, BORDER, endX - x, BORDER); this.renderCorner(x - BORDER, endY, CORNER_LEFT_X, CORNER_BOTTOM_Y); this.renderCorner(endX, endY, CORNER_RIGHT_X, CORNER_BOTTOM_Y); - } else { - // Bottom left, middle, right. We do this in three portions: the top inner corners, an extended region for - // lights, and then the bottom outer corners. - this.renderTexture(x - BORDER, endY, CORNER_LEFT_X, CORNER_BOTTOM_Y, BORDER, BORDER / 2); - this.renderTexture(x, endY, 0, BORDER, width, BORDER / 2, BORDER, BORDER / 2); - this.renderTexture(endX, endY, CORNER_RIGHT_X, CORNER_BOTTOM_Y, BORDER, BORDER / 2); - - this.renderTexture(x - BORDER, endY + BORDER / 2, CORNER_LEFT_X, CORNER_BOTTOM_Y + GAP, BORDER, bottomHeight, BORDER, GAP); - this.renderTexture(x, endY + BORDER / 2, 0, BORDER + GAP, width, bottomHeight, BORDER, GAP); - this.renderTexture(endX, endY + BORDER / 2, CORNER_RIGHT_X, CORNER_BOTTOM_Y + GAP, BORDER, bottomHeight, BORDER, GAP); - - this.renderTexture(x - BORDER, endY + bottomHeight + BORDER / 2, CORNER_LEFT_X, CORNER_BOTTOM_Y + BORDER / 2, BORDER, BORDER / 2); - this.renderTexture(x, endY + bottomHeight + BORDER / 2, 0, BORDER + BORDER / 2, width, BORDER / 2); - this.renderTexture(endX, endY + bottomHeight + BORDER / 2, CORNER_RIGHT_X, CORNER_BOTTOM_Y + BORDER / 2, BORDER, BORDER / 2); } } diff --git a/src/main/java/dan200/computercraft/client/render/ItemPocketRenderer.java b/src/main/java/dan200/computercraft/client/render/ItemPocketRenderer.java index c3c310431..754f9684f 100644 --- a/src/main/java/dan200/computercraft/client/render/ItemPocketRenderer.java +++ b/src/main/java/dan200/computercraft/client/render/ItemPocketRenderer.java @@ -6,6 +6,7 @@ package dan200.computercraft.client.render; +import static dan200.computercraft.client.render.ComputerBorderRenderer.*; import static dan200.computercraft.client.gui.FixedWidthFontRenderer.FONT_HEIGHT; import static dan200.computercraft.client.gui.FixedWidthFontRenderer.FONT_WIDTH; import static dan200.computercraft.client.render.ComputerBorderRenderer.BORDER; @@ -31,12 +32,13 @@ import net.minecraft.client.util.math.Vector3f; import net.minecraft.item.ItemStack; import net.minecraft.util.math.Matrix4f; +import static dan200.computercraft.client.render.ComputerBorderRenderer.*; + /** * Emulates map rendering for pocket computers. */ public final class ItemPocketRenderer extends ItemMapLikeRenderer { public static final ItemPocketRenderer INSTANCE = new ItemPocketRenderer(); - private static final int LIGHT_HEIGHT = 8; private ItemPocketRenderer() { } @@ -108,7 +110,7 @@ public final class ItemPocketRenderer extends ItemMapLikeRenderer { BufferBuilder buffer = tessellator.getBuffer(); buffer.begin(GL11.GL_QUADS, VertexFormats.POSITION_COLOR_TEXTURE); - ComputerBorderRenderer.render(transform, buffer, 0, 0, 0, width, height, LIGHT_HEIGHT, r, g, b); + ComputerBorderRenderer.render(transform, buffer, 0, 0, 0, width, height, true, r, g, b); tessellator.draw(); } diff --git a/src/main/resources/assets/computercraft/textures/gui/corners_advanced.png b/src/main/resources/assets/computercraft/textures/gui/corners_advanced.png index 81fc8da05..f4e8032a1 100644 Binary files a/src/main/resources/assets/computercraft/textures/gui/corners_advanced.png and b/src/main/resources/assets/computercraft/textures/gui/corners_advanced.png differ diff --git a/src/main/resources/assets/computercraft/textures/gui/corners_colour.png b/src/main/resources/assets/computercraft/textures/gui/corners_colour.png index 23507a186..ab658e686 100644 Binary files a/src/main/resources/assets/computercraft/textures/gui/corners_colour.png and b/src/main/resources/assets/computercraft/textures/gui/corners_colour.png differ diff --git a/src/main/resources/assets/computercraft/textures/gui/corners_normal.png b/src/main/resources/assets/computercraft/textures/gui/corners_normal.png index be4cd974b..8b1e9f676 100644 Binary files a/src/main/resources/assets/computercraft/textures/gui/corners_normal.png and b/src/main/resources/assets/computercraft/textures/gui/corners_normal.png differ