From 788a00efdf7c2916980291382e4105cc5c9d1281 Mon Sep 17 00:00:00 2001 From: simibubi <31564874+simibubi@users.noreply.github.com> Date: Wed, 16 Jun 2021 17:17:55 +0200 Subject: [PATCH] Breaks in every port - Fixed the schematic hotbar overlay - Goggles overlay is no longer its own eventhandler --- .../goggles/GoggleOverlayRenderer.java | 19 +++++-------------- .../schematics/client/SchematicHandler.java | 3 +-- .../client/SchematicHotbarSlotOverlay.java | 5 ++--- .../simibubi/create/events/ClientEvents.java | 2 ++ .../foundation/gui/ToolSelectionScreen.java | 1 + 5 files changed, 11 insertions(+), 19 deletions(-) diff --git a/src/main/java/com/simibubi/create/content/contraptions/goggles/GoggleOverlayRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/goggles/GoggleOverlayRenderer.java index 3bd7cebd9..2acd72a7a 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/goggles/GoggleOverlayRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/goggles/GoggleOverlayRenderer.java @@ -22,6 +22,7 @@ import com.simibubi.create.foundation.utility.outliner.Outliner.OutlineEntry; import net.minecraft.block.BlockState; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.screen.Screen; +import net.minecraft.client.renderer.IRenderTypeBuffer; import net.minecraft.client.world.ClientWorld; import net.minecraft.inventory.EquipmentSlotType; import net.minecraft.item.ItemStack; @@ -33,24 +34,15 @@ import net.minecraft.util.math.RayTraceResult; import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.ITextProperties; import net.minecraft.util.text.StringTextComponent; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.client.event.RenderGameOverlayEvent; -import net.minecraftforge.client.event.RenderGameOverlayEvent.ElementType; -import net.minecraftforge.eventbus.api.SubscribeEvent; -import net.minecraftforge.fml.common.Mod.EventBusSubscriber; -@EventBusSubscriber(value = Dist.CLIENT) public class GoggleOverlayRenderer { private static final Map outlines = CreateClient.OUTLINER.getOutlines(); - @SubscribeEvent - public static void lookingAtBlocksThroughGogglesShowsTooltip(RenderGameOverlayEvent.Post event) { - MatrixStack ms = event.getMatrixStack(); - if (event.getType() != ElementType.HOTBAR) - return; - + public static void renderOverlay(MatrixStack ms, IRenderTypeBuffer buffer, int light, int overlay, + float partialTicks) { RayTraceResult objectMouseOver = Minecraft.getInstance().objectMouseOver; + if (!(objectMouseOver instanceof BlockRayTraceResult)) return; @@ -58,9 +50,8 @@ public class GoggleOverlayRenderer { if (!entry.isAlive()) continue; Outline outline = entry.getOutline(); - if (outline instanceof ValueBox && !((ValueBox) outline).isPassive) { + if (outline instanceof ValueBox && !((ValueBox) outline).isPassive) return; - } } BlockRayTraceResult result = (BlockRayTraceResult) objectMouseOver; 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 d2eaa4595..9bea80f55 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 @@ -191,12 +191,11 @@ public class SchematicHandler { return; if (activeSchematicItem != null) this.overlay.renderOn(ms, activeHotbarSlot); - currentTool.getTool() .renderOverlay(ms, buffer); selectionScreen.renderPassive(ms, partialTicks); } - + public void onMouseInput(int button, boolean pressed) { if (!active) return; diff --git a/src/main/java/com/simibubi/create/content/schematics/client/SchematicHotbarSlotOverlay.java b/src/main/java/com/simibubi/create/content/schematics/client/SchematicHotbarSlotOverlay.java index 8b765eca9..33f531cbe 100644 --- a/src/main/java/com/simibubi/create/content/schematics/client/SchematicHotbarSlotOverlay.java +++ b/src/main/java/com/simibubi/create/content/schematics/client/SchematicHotbarSlotOverlay.java @@ -14,11 +14,10 @@ public class SchematicHotbarSlotOverlay extends AbstractGui { MainWindow mainWindow = Minecraft.getInstance().getWindow(); int x = mainWindow.getScaledWidth() / 2 - 88; int y = mainWindow.getScaledHeight() - 19; - RenderSystem.enableAlphaTest(); RenderSystem.enableDepthTest(); - RenderSystem.enableBlend(); + matrixStack.push(); AllGuiTextures.SCHEMATIC_SLOT.draw(matrixStack, this, x + 20 * slot, y); - RenderSystem.disableAlphaTest(); + matrixStack.pop(); } } diff --git a/src/main/java/com/simibubi/create/events/ClientEvents.java b/src/main/java/com/simibubi/create/events/ClientEvents.java index ee0c5d676..32ff48000 100644 --- a/src/main/java/com/simibubi/create/events/ClientEvents.java +++ b/src/main/java/com/simibubi/create/events/ClientEvents.java @@ -21,6 +21,7 @@ import com.simibubi.create.content.contraptions.components.structureMovement.tra import com.simibubi.create.content.contraptions.components.structureMovement.train.CouplingRenderer; import com.simibubi.create.content.contraptions.components.structureMovement.train.capability.CapabilityMinecartController; import com.simibubi.create.content.contraptions.components.turntable.TurntableHandler; +import com.simibubi.create.content.contraptions.goggles.GoggleOverlayRenderer; import com.simibubi.create.content.contraptions.goggles.IHaveGoggleInformation; import com.simibubi.create.content.contraptions.relays.belt.item.BeltConnectorHandler; import com.simibubi.create.content.curiosities.armor.CopperBacktankArmorLayer; @@ -228,6 +229,7 @@ public class ClientEvents { CreateClient.SCHEMATIC_HANDLER.renderOverlay(ms, buffer, light, overlay, partialTicks); LinkedControllerClientHandler.renderOverlay(ms, buffer, light, overlay, partialTicks); BlueprintOverlayRenderer.renderOverlay(ms, buffer, light, overlay, partialTicks); + GoggleOverlayRenderer.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 5efe5c936..cb77c8b7d 100644 --- a/src/main/java/com/simibubi/create/foundation/gui/ToolSelectionScreen.java +++ b/src/main/java/com/simibubi/create/foundation/gui/ToolSelectionScreen.java @@ -136,6 +136,7 @@ public class ToolSelectionScreen extends Screen { matrixStack.pop(); } + RenderSystem.enableBlend(); matrixStack.pop(); }