From eda8bfd0a1887cf42841c46f3f44702301c00c8c Mon Sep 17 00:00:00 2001 From: grimmauld Date: Sun, 4 Oct 2020 14:16:05 +0200 Subject: [PATCH] Fixed crash on pressing alt key on schematic screen --- .../content/schematics/client/SchematicHandler.java | 5 ++--- .../com/simibubi/create/events/ClientEvents.java | 8 ++++---- .../create/foundation/gui/ToolSelectionScreen.java | 13 ++++++++++++- 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/simibubi/create/content/schematics/client/SchematicHandler.java b/src/main/java/com/simibubi/create/content/schematics/client/SchematicHandler.java index 8ac7db3ea..d90c8905e 100644 --- a/src/main/java/com/simibubi/create/content/schematics/client/SchematicHandler.java +++ b/src/main/java/com/simibubi/create/content/schematics/client/SchematicHandler.java @@ -182,7 +182,7 @@ public class SchematicHandler { } - public void renderOverlay(MatrixStack ms, IRenderTypeBuffer buffer, int light, int overlay) { + public void renderOverlay(MatrixStack ms, IRenderTypeBuffer buffer, int light, int overlay, float partialTicks) { if (!active) return; if (activeSchematicItem != null) @@ -190,8 +190,7 @@ public class SchematicHandler { currentTool.getTool() .renderOverlay(ms, buffer); - selectionScreen.renderPassive(ms, Minecraft.getInstance() - .getRenderPartialTicks()); + selectionScreen.renderPassive(ms, partialTicks); } public void onMouseInput(int button, boolean pressed) { diff --git a/src/main/java/com/simibubi/create/events/ClientEvents.java b/src/main/java/com/simibubi/create/events/ClientEvents.java index a212ad594..974a61ccb 100644 --- a/src/main/java/com/simibubi/create/events/ClientEvents.java +++ b/src/main/java/com/simibubi/create/events/ClientEvents.java @@ -129,13 +129,13 @@ public class ClientEvents { if (event.getType() != ElementType.HOTBAR) return; - onRenderHotbar(new MatrixStack(), Minecraft.getInstance() + onRenderHotbar(event.getMatrixStack(), Minecraft.getInstance() .getBufferBuilders() - .getEntityVertexConsumers(), 0xF000F0, OverlayTexture.DEFAULT_UV); + .getEntityVertexConsumers(), 0xF000F0, OverlayTexture.DEFAULT_UV, event.getPartialTicks()); } - public static void onRenderHotbar(MatrixStack ms, IRenderTypeBuffer buffer, int light, int overlay) { - CreateClient.schematicHandler.renderOverlay(ms, buffer, light, overlay); + public static void onRenderHotbar(MatrixStack ms, IRenderTypeBuffer buffer, int light, int overlay, float partialTicks) { + CreateClient.schematicHandler.renderOverlay(ms, buffer, light, overlay, partialTicks); } @SubscribeEvent diff --git a/src/main/java/com/simibubi/create/foundation/gui/ToolSelectionScreen.java b/src/main/java/com/simibubi/create/foundation/gui/ToolSelectionScreen.java index 3ffd47160..48cfd8145 100644 --- a/src/main/java/com/simibubi/create/foundation/gui/ToolSelectionScreen.java +++ b/src/main/java/com/simibubi/create/foundation/gui/ToolSelectionScreen.java @@ -25,6 +25,7 @@ public class ToolSelectionScreen extends Screen { public boolean focused; private float yOffset; protected int selection; + private boolean initialized; protected int w; protected int h; @@ -37,6 +38,7 @@ public class ToolSelectionScreen extends Screen { focused = false; yOffset = 0; selection = 0; + initialized = false; callback.accept(tools.get(selection)); @@ -56,7 +58,11 @@ public class ToolSelectionScreen extends Screen { } private void draw(MatrixStack matrixStack, float partialTicks) { - MainWindow mainWindow = Minecraft.getInstance().getWindow(); + Minecraft mc = Minecraft.getInstance(); + MainWindow mainWindow = mc.getWindow(); + if (!initialized) + init(mc, mainWindow.getScaledWidth(), mainWindow.getScaledHeight()); + int x = (mainWindow.getScaledWidth() - w) / 2 + 15; int y = mainWindow.getScaledHeight() - h - 75; @@ -140,4 +146,9 @@ public class ToolSelectionScreen extends Screen { callback.accept(tools.get(selection)); } + @Override + protected void init() { + super.init(); + initialized = true; + } }