diff --git a/src/datagen/generated/mekanism/.cache/c10fcd8abbb6a520fc3ac2cf14b627d36958dd55 b/src/datagen/generated/mekanism/.cache/c10fcd8abbb6a520fc3ac2cf14b627d36958dd55 index 00b567bbc28..f3a5d8e79c5 100644 --- a/src/datagen/generated/mekanism/.cache/c10fcd8abbb6a520fc3ac2cf14b627d36958dd55 +++ b/src/datagen/generated/mekanism/.cache/c10fcd8abbb6a520fc3ac2cf14b627d36958dd55 @@ -1,5 +1,5 @@ -// 1.21.1 2024-09-28T11:00:15.3042814 Languages: en_us for mod: mekanism +// 1.21.1 2024-11-23T20:13:21.6073479 Languages: en_us for mod: mekanism 8d915354d84b3a4d60c65f9280fdd7ceca016c35 assets/mekanism/lang/en_au.json 8d915354d84b3a4d60c65f9280fdd7ceca016c35 assets/mekanism/lang/en_gb.json -2cd403d1dc72293441a4c86b1b1ddc05978130e8 assets/mekanism/lang/en_ud.json -525157cafd0048a56223755ff5b66a357d3008b4 assets/mekanism/lang/en_us.json +7e84d49fa4f68936a43bca5f7a4dfb071e735e27 assets/mekanism/lang/en_ud.json +85cdcefae92079d12d07e68a3561964f4d4d9552 assets/mekanism/lang/en_us.json diff --git a/src/datagen/generated/mekanism/assets/mekanism/lang/en_ud.json b/src/datagen/generated/mekanism/assets/mekanism/lang/en_ud.json index 0d8f56e1208..9d000521a90 100644 --- a/src/datagen/generated/mekanism/assets/mekanism/lang/en_ud.json +++ b/src/datagen/generated/mekanism/assets/mekanism/lang/en_ud.json @@ -2294,6 +2294,7 @@ "gui.mekanism.issues.no_recipe": "ʇnduᴉ ɥᵷnouǝ ʇou ɹo ǝdᴉɔǝɹ ᵷuᴉɥɔʇɐɯ oN - ", "gui.mekanism.issues.no_space": "ʇndʇno uᴉ ɯooɹ ɥᵷnouǝ ʇoN - ", "gui.mekanism.issues.no_space.overflow": "ɹǝɟɟnq ꞁɐuɹǝʇuᴉ uᴉ pǝɹoʇs ʍoꞁɟɹǝʌo 'ʇndʇno uᴉ ɯooɹ ɥᵷnouǝ ʇoN - ", + "gui.mekanism.issues.redstone_prevents_activation": "ʇǝɯ ʇou suoᴉʇᴉpuoɔ ǝuoʇspǝᴚ - ", "gui.mekanism.jitter": "%%%s :ɹǝʇʇᴉՐ", "gui.mekanism.liquid": "%s :pᴉnbᴉꞀ", "gui.mekanism.max": "%s :xɐW", diff --git a/src/datagen/generated/mekanism/assets/mekanism/lang/en_us.json b/src/datagen/generated/mekanism/assets/mekanism/lang/en_us.json index d78477a49c4..3629b1f0937 100644 --- a/src/datagen/generated/mekanism/assets/mekanism/lang/en_us.json +++ b/src/datagen/generated/mekanism/assets/mekanism/lang/en_us.json @@ -2297,6 +2297,7 @@ "gui.mekanism.issues.no_recipe": " - No matching recipe or not enough input", "gui.mekanism.issues.no_space": " - Not enough room in output", "gui.mekanism.issues.no_space.overflow": " - Not enough room in output, overflow stored in internal buffer", + "gui.mekanism.issues.redstone_prevents_activation": " - Redstone conditions not met", "gui.mekanism.jitter": "Jitter: %1$s%%", "gui.mekanism.liquid": "Liquid: %1$s", "gui.mekanism.max": "Max: %1$s", diff --git a/src/datagen/main/java/mekanism/client/lang/MekanismLangProvider.java b/src/datagen/main/java/mekanism/client/lang/MekanismLangProvider.java index 4cec72f0704..61732f0df8b 100644 --- a/src/datagen/main/java/mekanism/client/lang/MekanismLangProvider.java +++ b/src/datagen/main/java/mekanism/client/lang/MekanismLangProvider.java @@ -1182,6 +1182,7 @@ private void addMisc() { add(MekanismLang.ISSUE_INPUT_DOESNT_PRODUCE_OUTPUT, " - Input does not produce output"); add(MekanismLang.ISSUE_INVALID_OREDICTIONIFICATOR_FILTER, " - Filter is no longer valid or supported"); add(MekanismLang.ISSUE_FILTER_HAS_BLACKLISTED_ELEMENT, " - Filter contains at least one element that is blacklisted"); + add(MekanismLang.ISSUE_REDSTONE_PREVENTS_ACTIVATION, " - Redstone conditions not met"); //Laser Amplifier add(MekanismLang.ENTITY_DETECTION, "Entity Detection"); add(MekanismLang.ENERGY_CONTENTS, "Energy Contents"); diff --git a/src/main/java/mekanism/client/gui/GuiMekanismTile.java b/src/main/java/mekanism/client/gui/GuiMekanismTile.java index 5a5dbd877e5..0696e892d33 100644 --- a/src/main/java/mekanism/client/gui/GuiMekanismTile.java +++ b/src/main/java/mekanism/client/gui/GuiMekanismTile.java @@ -5,6 +5,7 @@ import mekanism.client.gui.element.tab.GuiSecurityTab; import mekanism.client.gui.element.tab.window.GuiUpgradeWindowTab; import mekanism.common.inventory.container.tile.MekanismTileContainer; +import mekanism.common.inventory.warning.WarningTracker.WarningType; import mekanism.common.tile.base.TileEntityMekanism; import net.minecraft.network.chat.Component; import net.minecraft.world.entity.player.Inventory; @@ -39,7 +40,7 @@ protected void addGenericTabs() { upgradeWindowTab = addRenderableWidget(new GuiUpgradeWindowTab(this, tile, () -> upgradeWindowTab)); } if (tile.supportsRedstone()) { - addRenderableWidget(new GuiRedstoneControlTab(this, tile)); + addRenderableWidget(new GuiRedstoneControlTab(this, tile).warning(WarningType.REDSTONE_PREVENTS_ACTIVATION, () -> !tile.isRedstoneActivated())); } //Note: We check if the capability is present rather than calling hasSecurity so that we don't add the tab to the security desk if (tile.getLevel() != null && IBlockSecurityUtils.INSTANCE.securityCapability(tile.getLevel(), tile.getBlockPos(), tile) != null) { diff --git a/src/main/java/mekanism/client/gui/element/GuiInsetElement.java b/src/main/java/mekanism/client/gui/element/GuiInsetElement.java index cdec5578438..9ced4c3f60f 100644 --- a/src/main/java/mekanism/client/gui/element/GuiInsetElement.java +++ b/src/main/java/mekanism/client/gui/element/GuiInsetElement.java @@ -1,11 +1,19 @@ 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 net.minecraft.client.gui.GuiGraphics; import net.minecraft.resources.ResourceLocation; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; -public abstract class GuiInsetElement extends GuiSideHolder { +public abstract class GuiInsetElement extends GuiSideHolder implements ISupportsWarning> { protected final int border; protected final int innerWidth; @@ -13,6 +21,9 @@ public abstract class GuiInsetElement extends GuiSideHolder { protected final DATA_SOURCE dataSource; protected final ResourceLocation overlay; + @Nullable + protected BooleanSupplier warningSupplier; + public GuiInsetElement(ResourceLocation overlay, IGuiWrapper gui, DATA_SOURCE dataSource, int x, int y, int height, int innerSize, boolean left) { super(gui, x, y, height, left, false); this.overlay = overlay; @@ -25,6 +36,12 @@ public GuiInsetElement(ResourceLocation overlay, IGuiWrapper gui, DATA_SOURCE da active = true; } + @Override + public GuiInsetElement warning(@NotNull WarningType type, @NotNull BooleanSupplier warningSupplier) { + this.warningSupplier = ISupportsWarning.compound(this.warningSupplier, gui().trackWarning(type, warningSupplier)); + return this; + } + @Override public boolean isMouseOver(double xAxis, double yAxis) { //TODO: override isHovered @@ -55,6 +72,21 @@ protected ResourceLocation getOverlay() { return overlay; } + @Override + protected void drawHolder(@NotNull GuiGraphics guiGraphics) { + boolean warning = warningSupplier != null && warningSupplier.getAsBoolean(); + if (warning) { + 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.drawHolder(guiGraphics); + } + } + @Override public void drawBackground(@NotNull GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTicks) { super.drawBackground(guiGraphics, mouseX, mouseY, partialTicks); diff --git a/src/main/java/mekanism/client/gui/element/GuiSideHolder.java b/src/main/java/mekanism/client/gui/element/GuiSideHolder.java index 9427f278ad7..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,13 +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); } } - private void draw(@NotNull GuiGraphics guiGraphics) { + protected void drawHolder(@NotNull GuiGraphics guiGraphics) { colorTab(guiGraphics); - GuiUtils.blitNineSlicedSized(guiGraphics, getResource(), relativeX, relativeY, width, height, 4, TEXTURE_WIDTH, TEXTURE_HEIGHT, 0, 0, TEXTURE_WIDTH, TEXTURE_HEIGHT); + drawHolderUncolored(guiGraphics); MekanismRenderer.resetColor(guiGraphics); } + + 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 diff --git a/src/main/java/mekanism/common/MekanismLang.java b/src/main/java/mekanism/common/MekanismLang.java index 63018a6699a..f9703b3792b 100644 --- a/src/main/java/mekanism/common/MekanismLang.java +++ b/src/main/java/mekanism/common/MekanismLang.java @@ -294,6 +294,7 @@ public enum MekanismLang implements ILangEntry { ISSUE_INPUT_DOESNT_PRODUCE_OUTPUT("gui", "issues.input_doesnt_produce_output"), ISSUE_INVALID_OREDICTIONIFICATOR_FILTER("gui", "issues.invalid_oredictionificator_filter"), ISSUE_FILTER_HAS_BLACKLISTED_ELEMENT("gui", "issues.filter_has_blacklisted_element"), + ISSUE_REDSTONE_PREVENTS_ACTIVATION("gui", "issues.redstone_prevents_activation"), //Laser Amplifier ENTITY_DETECTION("laser_amplifier", "entity_detection"), ENERGY_CONTENTS("laser_amplifier", "energy_contents"), diff --git a/src/main/java/mekanism/common/inventory/warning/WarningTracker.java b/src/main/java/mekanism/common/inventory/warning/WarningTracker.java index 0b985d60063..2dd3c9ab43f 100644 --- a/src/main/java/mekanism/common/inventory/warning/WarningTracker.java +++ b/src/main/java/mekanism/common/inventory/warning/WarningTracker.java @@ -75,6 +75,7 @@ public enum WarningType { NOT_ENOUGH_ENERGY_REDUCED_RATE(MekanismLang.ISSUE_NOT_ENOUGH_ENERGY_REDUCED_RATE), INVALID_OREDICTIONIFICATOR_FILTER(MekanismLang.ISSUE_INVALID_OREDICTIONIFICATOR_FILTER, 4), FILTER_HAS_BLACKLISTED_ELEMENT(MekanismLang.ISSUE_FILTER_HAS_BLACKLISTED_ELEMENT, 5), + REDSTONE_PREVENTS_ACTIVATION(MekanismLang.ISSUE_REDSTONE_PREVENTS_ACTIVATION), ; private final ILangEntry langEntry; diff --git a/src/main/java/mekanism/common/tile/base/TileEntityMekanism.java b/src/main/java/mekanism/common/tile/base/TileEntityMekanism.java index 009c2de6d44..3c53e969c75 100644 --- a/src/main/java/mekanism/common/tile/base/TileEntityMekanism.java +++ b/src/main/java/mekanism/common/tile/base/TileEntityMekanism.java @@ -82,6 +82,7 @@ import mekanism.common.integration.computer.annotation.ComputerMethod; import mekanism.common.inventory.container.ITrackableContainer; import mekanism.common.inventory.container.MekanismContainer; +import mekanism.common.inventory.container.sync.SyncableBoolean; import mekanism.common.inventory.container.sync.SyncableDouble; import mekanism.common.inventory.container.sync.SyncableEnum; import mekanism.common.inventory.container.sync.SyncableFluidStack; @@ -901,6 +902,7 @@ public void addContainerTrackers(MekanismContainer container) { } if (supportsRedstone()) { container.track(SyncableEnum.create(RedstoneControl.BY_ID, RedstoneControl.DISABLED, () -> controlType, value -> controlType = value)); + container.track(SyncableBoolean.create(this::isPowered, value -> redstone = value)); } boolean isClient = isRemote(); if (canHandleChemicals() && syncs(ContainerType.CHEMICAL)) { @@ -1087,16 +1089,18 @@ public final void updatePower() { } } - public boolean canFunction() { - if (supportsRedstone()) { - return switch (controlType) { + public final boolean isRedstoneActivated() { + return !supportsRedstone() || + switch (controlType) { case DISABLED -> true; case HIGH -> isPowered(); case LOW -> !isPowered(); case PULSE -> isPowered() && !redstoneLastTick; }; - } - return true; + } + + public boolean canFunction() { + return isRedstoneActivated(); } //End methods ITileRedstone diff --git a/src/main/resources/assets/mekanism/gui/warning_left.png b/src/main/resources/assets/mekanism/gui/warning_left.png new file mode 100644 index 00000000000..b62c6f42289 Binary files /dev/null and b/src/main/resources/assets/mekanism/gui/warning_left.png differ diff --git a/src/main/resources/assets/mekanism/gui/warning_right.png b/src/main/resources/assets/mekanism/gui/warning_right.png new file mode 100644 index 00000000000..86da5c5b032 Binary files /dev/null and b/src/main/resources/assets/mekanism/gui/warning_right.png differ