From 118c6d3a4c32e817da73ce1cf2b861afbc79fa82 Mon Sep 17 00:00:00 2001 From: bukowski912 Date: Fri, 27 Dec 2024 10:34:51 +1100 Subject: [PATCH] Properly blend the slot-holder warning overlay & fixup GuiSlotHolder --- .../client/gui/element/GuiInsetElement.java | 15 ++++++++++----- .../client/gui/element/GuiSideHolder.java | 6 +++--- 2 files changed, 13 insertions(+), 8 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..bca78dbc95e 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; @@ -76,7 +76,12 @@ protected ResourceLocation getOverlay() { protected void draw(@NotNull GuiGraphics guiGraphics) { boolean warning = warningSupplier != null && warningSupplier.getAsBoolean(); if (warning) { - innerDraw(guiGraphics, left ? WARNING_LEFT : WARNING_RIGHT); + drawUncolored(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); } diff --git a/src/main/java/mekanism/client/gui/element/GuiSideHolder.java b/src/main/java/mekanism/client/gui/element/GuiSideHolder.java index 1017542c848..7d0baaa693b 100644 --- a/src/main/java/mekanism/client/gui/element/GuiSideHolder.java +++ b/src/main/java/mekanism/client/gui/element/GuiSideHolder.java @@ -65,11 +65,11 @@ public void drawBackground(@NotNull GuiGraphics guiGraphics, int mouseX, int mou protected void draw(@NotNull GuiGraphics guiGraphics) { colorTab(guiGraphics); - innerDraw(guiGraphics, getResource()); + drawUncolored(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 drawUncolored(@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