From 7f8bbffef73c269e316ed2cc04e533e3416efb81 Mon Sep 17 00:00:00 2001 From: bukowski912 Date: Mon, 2 Dec 2024 10:24:51 +1100 Subject: [PATCH] Properly blend the slot-holder warning overlay & fixup GuiSlotHolder --- .../client/gui/element/GuiInsetElement.java | 19 ++++++++++++------- .../client/gui/element/GuiSideHolder.java | 12 ++++++------ 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/src/main/java/mekanism/client/gui/element/GuiInsetElement.java b/src/main/java/mekanism/client/gui/element/GuiInsetElement.java index 96c44da9662..9ced4c3f60f 100644 --- a/src/main/java/mekanism/client/gui/element/GuiInsetElement.java +++ b/src/main/java/mekanism/client/gui/element/GuiInsetElement.java @@ -1,10 +1,13 @@ package mekanism.client.gui.element; import java.util.function.BooleanSupplier; + +import com.mojang.blaze3d.platform.GlStateManager.DestFactor; +import com.mojang.blaze3d.platform.GlStateManager.SourceFactor; +import com.mojang.blaze3d.systems.RenderSystem; import mekanism.client.gui.IGuiWrapper; import mekanism.common.inventory.warning.ISupportsWarning; import mekanism.common.inventory.warning.WarningTracker.WarningType; -import mekanism.common.util.MekanismUtils; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.resources.ResourceLocation; import org.jetbrains.annotations.NotNull; @@ -12,9 +15,6 @@ public abstract class GuiInsetElement extends GuiSideHolder implements ISupportsWarning> { - private static final ResourceLocation WARNING_LEFT = MekanismUtils.getResource(MekanismUtils.ResourceType.GUI, "warning_left.png"); - private static final ResourceLocation WARNING_RIGHT = MekanismUtils.getResource(MekanismUtils.ResourceType.GUI, "warning_right.png"); - protected final int border; protected final int innerWidth; protected final int innerHeight; @@ -73,12 +73,17 @@ protected ResourceLocation getOverlay() { } @Override - protected void draw(@NotNull GuiGraphics guiGraphics) { + protected void drawHolder(@NotNull GuiGraphics guiGraphics) { boolean warning = warningSupplier != null && warningSupplier.getAsBoolean(); if (warning) { - innerDraw(guiGraphics, left ? WARNING_LEFT : WARNING_RIGHT); + drawHolderUncolored(guiGraphics); + //Draw the warning overlay (multiply-blended) + RenderSystem.enableBlend(); + RenderSystem.blendFunc(SourceFactor.DST_COLOR, DestFactor.ZERO); + guiGraphics.blit(WARNING_TEXTURE, relativeX, relativeY, 0, 0, width, height, 256, 256); + RenderSystem.disableBlend(); } else { - super.draw(guiGraphics); + super.drawHolder(guiGraphics); } } diff --git a/src/main/java/mekanism/client/gui/element/GuiSideHolder.java b/src/main/java/mekanism/client/gui/element/GuiSideHolder.java index 1017542c848..a2458269473 100644 --- a/src/main/java/mekanism/client/gui/element/GuiSideHolder.java +++ b/src/main/java/mekanism/client/gui/element/GuiSideHolder.java @@ -51,7 +51,7 @@ public void renderWidget(@NotNull GuiGraphics guiGraphics, int mouseX, int mouse super.renderWidget(guiGraphics, mouseX, mouseY, partialTicks); if (this.slotHolder) { //Slot holders need to draw here to render behind the slots instead of in front of them - draw(guiGraphics); + drawHolder(guiGraphics); } } @@ -59,17 +59,17 @@ public void renderWidget(@NotNull GuiGraphics guiGraphics, int mouseX, int mouse public void drawBackground(@NotNull GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTicks) { super.drawBackground(guiGraphics, mouseX, mouseY, partialTicks); if (!this.slotHolder) { - draw(guiGraphics); + drawHolder(guiGraphics); } } - protected void draw(@NotNull GuiGraphics guiGraphics) { + protected void drawHolder(@NotNull GuiGraphics guiGraphics) { colorTab(guiGraphics); - innerDraw(guiGraphics, getResource()); + drawHolderUncolored(guiGraphics); MekanismRenderer.resetColor(guiGraphics); } - protected void innerDraw(@NotNull GuiGraphics guiGraphics, ResourceLocation texture) { - GuiUtils.blitNineSlicedSized(guiGraphics, texture, relativeX, relativeY, width, height, 4, TEXTURE_WIDTH, TEXTURE_HEIGHT, 0, 0, TEXTURE_WIDTH, TEXTURE_HEIGHT); + protected void drawHolderUncolored(@NotNull GuiGraphics guiGraphics) { + GuiUtils.blitNineSlicedSized(guiGraphics, getResource(), relativeX, relativeY, width, height, 4, TEXTURE_WIDTH, TEXTURE_HEIGHT, 0, 0, TEXTURE_WIDTH, TEXTURE_HEIGHT); } } \ No newline at end of file