diff --git a/src/main/java/gregtech/common/covers/redstone/CoverWirelessDoesWorkDetector.java b/src/main/java/gregtech/common/covers/redstone/CoverWirelessDoesWorkDetector.java index 769f578fd12..2518bde5fa3 100644 --- a/src/main/java/gregtech/common/covers/redstone/CoverWirelessDoesWorkDetector.java +++ b/src/main/java/gregtech/common/covers/redstone/CoverWirelessDoesWorkDetector.java @@ -7,9 +7,11 @@ import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.nbt.NBTBase; import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.StatCollector; import net.minecraftforge.common.util.ForgeDirection; import com.google.common.io.ByteArrayDataInput; +import com.gtnewhorizons.modularui.api.math.Alignment; import com.gtnewhorizons.modularui.api.screen.ModularWindow; import com.gtnewhorizons.modularui.common.widget.TextWidget; @@ -76,7 +78,11 @@ public ActivityTransmitterData doCoverThingsImpl(ForgeDirection side, byte aInpu final long hash = hashCoverCoords(aTileEntity, side); setSignalAt(aCoverVariable.getUuid(), aCoverVariable.getFrequency(), hash, signal); - aTileEntity.setOutputRedstoneSignal(side, signal); + if (aCoverVariable.physical) { + aTileEntity.setOutputRedstoneSignal(side, signal); + } else { + aTileEntity.setOutputRedstoneSignal(side, (byte) 0); + } return aCoverVariable; } @@ -114,21 +120,25 @@ public enum ActivityMode { public static class ActivityTransmitterData extends CoverAdvancedRedstoneTransmitterBase.TransmitterData { private ActivityMode mode; + /** Whether the wireless detector cover also sets the tiles sided Redstone output */ + private boolean physical; - public ActivityTransmitterData(int frequency, UUID uuid, boolean invert, ActivityMode mode) { + public ActivityTransmitterData(int frequency, UUID uuid, boolean invert, ActivityMode mode, boolean physical) { super(frequency, uuid, invert); this.mode = mode; + this.physical = physical; } public ActivityTransmitterData() { super(); this.mode = ActivityMode.MACHINE_IDLE; + this.physical = true; } @Nonnull @Override public ISerializableObject copy() { - return new ActivityTransmitterData(frequency, uuid, invert, mode); + return new ActivityTransmitterData(frequency, uuid, invert, mode, physical); } @Nonnull @@ -136,6 +146,7 @@ public ISerializableObject copy() { public NBTBase saveDataToNBT() { NBTTagCompound tag = (NBTTagCompound) super.saveDataToNBT(); tag.setInteger("mode", mode.ordinal()); + tag.setBoolean("physical", physical); return tag; } @@ -144,6 +155,7 @@ public NBTBase saveDataToNBT() { public void writeToByteBuf(ByteBuf aBuf) { super.writeToByteBuf(aBuf); aBuf.writeInt(mode.ordinal()); + aBuf.writeBoolean(physical); } @Override @@ -152,6 +164,11 @@ public void loadDataFromNBT(NBTBase aNBT) { NBTTagCompound tag = (NBTTagCompound) aNBT; mode = ActivityMode.values()[tag.getInteger("mode")]; + if (tag.hasKey("physical")) { + physical = tag.getBoolean("physical"); + } else { + physical = false; + } } @Nonnull @@ -159,6 +176,7 @@ public void loadDataFromNBT(NBTBase aNBT) { public ISerializableObject readFromPacket(ByteArrayDataInput aBuf, EntityPlayerMP aPlayer) { super.readFromPacket(aBuf, aPlayer); mode = ActivityMode.values()[aBuf.readInt()]; + physical = aBuf.readBoolean(); return this; } @@ -177,7 +195,7 @@ public WirelessActivityDetectorUIFactory(CoverUIBuildContext buildContext) { @Override protected int getGUIHeight() { - return 107; + return 123; } @Override @@ -208,7 +226,22 @@ protected void addUIWidgets(ModularWindow.Builder builder) { }) .setSynced(false) .setDefaultColor(COLOR_TEXT_GRAY.get()) - .setPos(startX + spaceX * 3, 4 + startY + spaceY * 2)); + .setPos(startX + spaceX * 3, 4 + startY + spaceY * 2)) + .widget(TextWidget.dynamicString(() -> { + ActivityTransmitterData coverData = getCoverData(); + if (coverData != null) { + return getCoverData().physical + ? StatCollector.translateToLocal("gt.cover.wirelessdetector.redstone.1") + : StatCollector.translateToLocal("gt.cover.wirelessdetector.redstone.0"); + } else { + return ""; + } + }) + .setSynced(false) + .setDefaultColor(COLOR_TEXT_GRAY.get()) + .setTextAlignment(Alignment.CenterLeft) + .setPos(startX + spaceX, 4 + startY + spaceY * 3) + .setSize(spaceX * 10, 12)); } @Override @@ -244,7 +277,17 @@ protected void addUIForDataController(CoverDataControllerWidget widget.setStaticTexture(GTUITextures.OVERLAY_BUTTON_POWER_SWITCH_ON) .addTooltip(GTUtility.trans("271", "Machine enabled")) - .setPos(spaceX * 2, spaceY * 2)); + .setPos(spaceX * 2, spaceY * 2)) + .addFollower( + CoverDataFollowerToggleButtonWidget.ofDisableable(), + coverData -> coverData.physical, + (coverData, state) -> { + coverData.physical = state; + return coverData; + }, + widget -> widget + .addTooltip(StatCollector.translateToLocal("gt.cover.wirelessdetector.redstone.tooltip")) + .setPos(0, 1 + spaceY * 3)); } } diff --git a/src/main/java/gregtech/common/covers/redstone/CoverWirelessFluidDetector.java b/src/main/java/gregtech/common/covers/redstone/CoverWirelessFluidDetector.java index 9c7de19a01f..3a58fd198c0 100644 --- a/src/main/java/gregtech/common/covers/redstone/CoverWirelessFluidDetector.java +++ b/src/main/java/gregtech/common/covers/redstone/CoverWirelessFluidDetector.java @@ -8,11 +8,13 @@ import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.nbt.NBTBase; import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.StatCollector; import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidTankInfo; import net.minecraftforge.fluids.IFluidHandler; import com.google.common.io.ByteArrayDataInput; +import com.gtnewhorizons.modularui.api.math.Alignment; import com.gtnewhorizons.modularui.api.screen.ModularWindow; import com.gtnewhorizons.modularui.common.widget.TextWidget; @@ -24,6 +26,7 @@ import gregtech.common.covers.CoverLiquidMeter; import gregtech.common.gui.modularui.widget.CoverDataControllerWidget; import gregtech.common.gui.modularui.widget.CoverDataFollowerNumericWidget; +import gregtech.common.gui.modularui.widget.CoverDataFollowerToggleButtonWidget; import io.netty.buffer.ByteBuf; public class CoverWirelessFluidDetector @@ -51,7 +54,11 @@ public FluidTransmitterData doCoverThingsImpl(ForgeDirection side, byte aInputRe final long hash = hashCoverCoords(aTileEntity, side); setSignalAt(aCoverVariable.getUuid(), aCoverVariable.getFrequency(), hash, signal); - aTileEntity.setOutputRedstoneSignal(side, signal); + if (aCoverVariable.physical) { + aTileEntity.setOutputRedstoneSignal(side, signal); + } else { + aTileEntity.setOutputRedstoneSignal(side, (byte) 0); + } return aCoverVariable; } @@ -72,21 +79,25 @@ public static class FluidTransmitterData extends CoverAdvancedRedstoneTransmitte /** The special value {@code 0} means threshold check is disabled. */ private int threshold; + /** Whether the wireless detector cover also sets the tiles sided Redstone output */ + private boolean physical; - public FluidTransmitterData(int frequency, UUID uuid, boolean invert, int threshold) { + public FluidTransmitterData(int frequency, UUID uuid, boolean invert, int threshold, boolean physical) { super(frequency, uuid, invert); this.threshold = threshold; + this.physical = physical; } public FluidTransmitterData() { super(); this.threshold = 0; + this.physical = true; } @Nonnull @Override public ISerializableObject copy() { - return new FluidTransmitterData(frequency, uuid, invert, threshold); + return new FluidTransmitterData(frequency, uuid, invert, threshold, physical); } @Nonnull @@ -94,6 +105,7 @@ public ISerializableObject copy() { public NBTBase saveDataToNBT() { NBTTagCompound tag = (NBTTagCompound) super.saveDataToNBT(); tag.setInteger("threshold", threshold); + tag.setBoolean("physical", physical); return tag; } @@ -102,6 +114,7 @@ public NBTBase saveDataToNBT() { public void writeToByteBuf(ByteBuf aBuf) { super.writeToByteBuf(aBuf); aBuf.writeInt(threshold); + aBuf.writeBoolean(physical); } @Override @@ -110,6 +123,11 @@ public void loadDataFromNBT(NBTBase aNBT) { NBTTagCompound tag = (NBTTagCompound) aNBT; threshold = tag.getInteger("threshold"); + if (tag.hasKey("physical")) { + physical = tag.getBoolean("physical"); + } else { + physical = false; + } } @Nonnull @@ -117,6 +135,7 @@ public void loadDataFromNBT(NBTBase aNBT) { public ISerializableObject readFromPacket(ByteArrayDataInput aBuf, EntityPlayerMP aPlayer) { super.readFromPacket(aBuf, aPlayer); threshold = aBuf.readInt(); + physical = aBuf.readBoolean(); return this; } @@ -137,6 +156,11 @@ public WirelessFluidDetectorUIFactory(CoverUIBuildContext buildContext) { super(buildContext); } + @Override + protected int getGUIHeight() { + return 123; + } + @Override protected int getFrequencyRow() { return 0; @@ -151,9 +175,25 @@ protected int getButtonRow() { protected void addUIWidgets(ModularWindow.Builder builder) { setMaxCapacity(); super.addUIWidgets(builder); - builder.widget( - new TextWidget(GTUtility.trans("222", "Fluid threshold")).setDefaultColor(COLOR_TEXT_GRAY.get()) - .setPos(startX + spaceX * 5, 4 + startY + spaceY * 2)); + builder + .widget( + new TextWidget(GTUtility.trans("222", "Fluid threshold")).setDefaultColor(COLOR_TEXT_GRAY.get()) + .setPos(startX + spaceX * 5, 4 + startY + spaceY * 2)) + .widget(TextWidget.dynamicString(() -> { + FluidTransmitterData coverData = getCoverData(); + if (coverData != null) { + return getCoverData().physical + ? StatCollector.translateToLocal("gt.cover.wirelessdetector.redstone.1") + : StatCollector.translateToLocal("gt.cover.wirelessdetector.redstone.0"); + } else { + return ""; + } + }) + .setSynced(false) + .setDefaultColor(COLOR_TEXT_GRAY.get()) + .setTextAlignment(Alignment.CenterLeft) + .setPos(startX + spaceX, 4 + startY + spaceY * 3) + .setSize(spaceX * 10, 12)); } @Override @@ -170,7 +210,17 @@ protected void addUIForDataController(CoverDataControllerWidget coverData.physical, + (coverData, state) -> { + coverData.physical = state; + return coverData; + }, + widget -> widget + .addTooltip(StatCollector.translateToLocal("gt.cover.wirelessdetector.redstone.tooltip")) + .setPos(0, 1 + spaceY * 3)); } private void setMaxCapacity() { diff --git a/src/main/java/gregtech/common/covers/redstone/CoverWirelessItemDetector.java b/src/main/java/gregtech/common/covers/redstone/CoverWirelessItemDetector.java index 72b6d25e736..087e5d58dd9 100644 --- a/src/main/java/gregtech/common/covers/redstone/CoverWirelessItemDetector.java +++ b/src/main/java/gregtech/common/covers/redstone/CoverWirelessItemDetector.java @@ -10,10 +10,12 @@ import net.minecraft.nbt.NBTBase; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.StatCollector; import net.minecraftforge.common.util.ForgeDirection; import com.google.common.io.ByteArrayDataInput; import com.gtnewhorizons.modularui.api.NumberFormatMUI; +import com.gtnewhorizons.modularui.api.math.Alignment; import com.gtnewhorizons.modularui.api.screen.ModularWindow; import com.gtnewhorizons.modularui.common.widget.TextWidget; @@ -26,6 +28,7 @@ import gregtech.common.covers.CoverItemMeter; import gregtech.common.gui.modularui.widget.CoverDataControllerWidget; import gregtech.common.gui.modularui.widget.CoverDataFollowerNumericWidget; +import gregtech.common.gui.modularui.widget.CoverDataFollowerToggleButtonWidget; import gregtech.common.gui.modularui.widget.ItemWatcherSlotWidget; import gregtech.common.tileentities.storage.MTEDigitalChestBase; import io.netty.buffer.ByteBuf; @@ -59,7 +62,11 @@ public ItemTransmitterData doCoverThingsImpl(ForgeDirection side, byte aInputRed final long hash = hashCoverCoords(aTileEntity, side); setSignalAt(aCoverVariable.getUuid(), aCoverVariable.getFrequency(), hash, signal); - aTileEntity.setOutputRedstoneSignal(side, signal); + if (aCoverVariable.physical) { + aTileEntity.setOutputRedstoneSignal(side, signal); + } else { + aTileEntity.setOutputRedstoneSignal(side, (byte) 0); + } return aCoverVariable; } @@ -86,23 +93,28 @@ public static class ItemTransmitterData extends CoverAdvancedRedstoneTransmitter * The special value {@code 0} means threshold check is disabled. */ private int threshold; + /** Whether the wireless detector cover also sets the tiles sided Redstone output */ + private boolean physical; - public ItemTransmitterData(int frequency, UUID uuid, boolean invert, int threshold, int slot) { + public ItemTransmitterData(int frequency, UUID uuid, boolean invert, int threshold, int slot, + boolean physical) { super(frequency, uuid, invert); this.threshold = threshold; this.slot = slot; + this.physical = physical; } public ItemTransmitterData() { super(); this.threshold = 0; this.slot = -1; + this.physical = true; } @Nonnull @Override public ISerializableObject copy() { - return new ItemTransmitterData(frequency, uuid, invert, threshold, slot); + return new ItemTransmitterData(frequency, uuid, invert, threshold, slot, physical); } @Nonnull @@ -111,6 +123,7 @@ public NBTBase saveDataToNBT() { NBTTagCompound tag = (NBTTagCompound) super.saveDataToNBT(); tag.setInteger("threshold", threshold); tag.setInteger("slot", slot); + tag.setBoolean("physical", physical); return tag; } @@ -120,6 +133,7 @@ public void writeToByteBuf(ByteBuf aBuf) { super.writeToByteBuf(aBuf); aBuf.writeInt(threshold); aBuf.writeInt(slot); + aBuf.writeBoolean(physical); } @Override @@ -129,6 +143,12 @@ public void loadDataFromNBT(NBTBase aNBT) { NBTTagCompound tag = (NBTTagCompound) aNBT; threshold = tag.getInteger("threshold"); slot = tag.getInteger("slot"); + + if (tag.hasKey("physical")) { + physical = tag.getBoolean("physical"); + } else { + physical = false; + } } @Nonnull @@ -137,6 +157,7 @@ public ISerializableObject readFromPacket(ByteArrayDataInput aBuf, EntityPlayerM super.readFromPacket(aBuf, aPlayer); threshold = aBuf.readInt(); slot = aBuf.readInt(); + physical = aBuf.readBoolean(); return this; } @@ -172,6 +193,11 @@ public WirelessItemDetectorUIFactory(CoverUIBuildContext buildContext) { super(buildContext); } + @Override + protected int getGUIHeight() { + return 143; + } + @Override protected int getFrequencyRow() { return 0; @@ -195,7 +221,22 @@ protected void addUIWidgets(ModularWindow.Builder builder) { .setPos(startX + spaceX * 5, 4 + startY + spaceY * 2)) .widget( new TextWidget(GTUtility.trans("254", "Detect Slot #")).setDefaultColor(COLOR_TEXT_GRAY.get()) - .setPos(startX + spaceX * 5, 4 + startY + spaceY * 3)); + .setPos(startX + spaceX * 5, 4 + startY + spaceY * 3)) + .widget(TextWidget.dynamicString(() -> { + ItemTransmitterData coverData = getCoverData(); + if (coverData != null) { + return getCoverData().physical + ? StatCollector.translateToLocal("gt.cover.wirelessdetector.redstone.1") + : StatCollector.translateToLocal("gt.cover.wirelessdetector.redstone.0"); + } else { + return ""; + } + }) + .setSynced(false) + .setDefaultColor(COLOR_TEXT_GRAY.get()) + .setTextAlignment(Alignment.CenterLeft) + .setPos(startX + spaceX, 5 + startY + spaceY * 4) + .setSize(spaceX * 10, 12)); } @Override @@ -225,7 +266,17 @@ protected void addUIForDataController(CoverDataControllerWidget coverData.physical, + (coverData, state) -> { + coverData.physical = state; + return coverData; + }, + widget -> widget + .addTooltip(StatCollector.translateToLocal("gt.cover.wirelessdetector.redstone.tooltip")) + .setPos(0, 2 + spaceY * 4)); } private void setMaxSlot() { diff --git a/src/main/java/gregtech/common/covers/redstone/CoverWirelessMaintenanceDetector.java b/src/main/java/gregtech/common/covers/redstone/CoverWirelessMaintenanceDetector.java index a71e597969e..e44e70858ab 100644 --- a/src/main/java/gregtech/common/covers/redstone/CoverWirelessMaintenanceDetector.java +++ b/src/main/java/gregtech/common/covers/redstone/CoverWirelessMaintenanceDetector.java @@ -8,9 +8,11 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTBase; import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.StatCollector; import net.minecraftforge.common.util.ForgeDirection; import com.google.common.io.ByteArrayDataInput; +import com.gtnewhorizons.modularui.api.math.Alignment; import com.gtnewhorizons.modularui.api.screen.ModularWindow; import com.gtnewhorizons.modularui.common.widget.TextWidget; @@ -96,7 +98,11 @@ public MaintenanceTransmitterData doCoverThingsImpl(ForgeDirection side, byte aI final long hash = hashCoverCoords(aTileEntity, side); setSignalAt(aCoverVariable.getUuid(), aCoverVariable.getFrequency(), hash, signal); - aTileEntity.setOutputRedstoneSignal(side, signal); + if (aCoverVariable.physical) { + aTileEntity.setOutputRedstoneSignal(side, signal); + } else { + aTileEntity.setOutputRedstoneSignal(side, (byte) 0); + } return aCoverVariable; } @@ -133,21 +139,26 @@ public enum MaintenanceMode { public static class MaintenanceTransmitterData extends CoverAdvancedRedstoneTransmitterBase.TransmitterData { private MaintenanceMode mode; + /** Whether the wireless detector cover also sets the tiles sided Redstone output */ + private boolean physical; - public MaintenanceTransmitterData(int frequency, UUID uuid, boolean invert, MaintenanceMode mode) { + public MaintenanceTransmitterData(int frequency, UUID uuid, boolean invert, MaintenanceMode mode, + boolean physical) { super(frequency, uuid, invert); this.mode = mode; + this.physical = physical; } public MaintenanceTransmitterData() { super(); this.mode = MaintenanceMode.ONE_ISSUE; + this.physical = true; } @Nonnull @Override public ISerializableObject copy() { - return new MaintenanceTransmitterData(frequency, uuid, invert, mode); + return new MaintenanceTransmitterData(frequency, uuid, invert, mode, physical); } @Nonnull @@ -155,6 +166,7 @@ public ISerializableObject copy() { public NBTBase saveDataToNBT() { NBTTagCompound tag = (NBTTagCompound) super.saveDataToNBT(); tag.setInteger("mode", mode.ordinal()); + tag.setBoolean("physical", physical); return tag; } @@ -163,6 +175,7 @@ public NBTBase saveDataToNBT() { public void writeToByteBuf(ByteBuf aBuf) { super.writeToByteBuf(aBuf); aBuf.writeInt(mode.ordinal()); + aBuf.writeBoolean(physical); } @Override @@ -171,6 +184,11 @@ public void loadDataFromNBT(NBTBase aNBT) { NBTTagCompound tag = (NBTTagCompound) aNBT; mode = MaintenanceMode.values()[tag.getInteger("mode")]; + if (tag.hasKey("physical")) { + physical = tag.getBoolean("physical"); + } else { + physical = false; + } } @Nonnull @@ -178,6 +196,7 @@ public void loadDataFromNBT(NBTBase aNBT) { public ISerializableObject readFromPacket(ByteArrayDataInput aBuf, EntityPlayerMP aPlayer) { super.readFromPacket(aBuf, aPlayer); mode = MaintenanceMode.values()[aBuf.readInt()]; + physical = aBuf.readBoolean(); return this; } @@ -201,7 +220,7 @@ public WirelessMaintenanceDetectorUIFactory(CoverUIBuildContext buildContext) { @Override protected int getGUIHeight() { - return 143; + return 175; } @Override @@ -222,6 +241,21 @@ protected void addUIWidgets(ModularWindow.Builder builder) { new TextWidget(extraTexts[i]).setDefaultColor(COLOR_TEXT_GRAY.get()) .setPos(startX + spaceX * (i % 2 == 0 ? 1 : 7), 4 + startY + spaceY * (2 + i / 2))); } + builder.widget(TextWidget.dynamicString(() -> { + MaintenanceTransmitterData coverData = getCoverData(); + if (coverData != null) { + return getCoverData().physical + ? StatCollector.translateToLocal("gt.cover.wirelessdetector.redstone.1") + : StatCollector.translateToLocal("gt.cover.wirelessdetector.redstone.0"); + } else { + return ""; + } + }) + .setSynced(false) + .setDefaultColor(COLOR_TEXT_GRAY.get()) + .setTextAlignment(Alignment.CenterLeft) + .setPos(startX + spaceX, 4 + startY + spaceY * 6) + .setSize(spaceX * 10, 12)); } @Override @@ -239,6 +273,16 @@ protected void addUIForDataController(CoverDataControllerWidget widget.setToggleTexture(GTUITextures.OVERLAY_BUTTON_CHECKMARK, GTUITextures.TRANSPARENT) .setPos(spaceX * (index % 2 == 0 ? 0 : 6), spaceY * (2 + index / 2))); } + controller.addFollower( + CoverDataFollowerToggleButtonWidget.ofDisableable(), + coverData -> coverData.physical, + (coverData, state) -> { + coverData.physical = state; + return coverData; + }, + widget -> widget + .addTooltip(StatCollector.translateToLocal("gt.cover.wirelessdetector.redstone.tooltip")) + .setPos(0, 1 + spaceY * 6)); } } } diff --git a/src/main/resources/assets/gregtech/lang/en_US.lang b/src/main/resources/assets/gregtech/lang/en_US.lang index e81b5f5cc2f..ee65f5875fb 100644 --- a/src/main/resources/assets/gregtech/lang/en_US.lang +++ b/src/main/resources/assets/gregtech/lang/en_US.lang @@ -1700,6 +1700,9 @@ gt.cover.info.button.tick_rate.2=Left click to increase, right click to decrease gt.cover.info.button.tick_rate.3=Hold Ctrl to adjust by more steps per click gt.cover.info.button.bounds_notification.minimum=§7 (minimum)§r gt.cover.info.button.bounds_notification.maximum=§7 (maximum)§r +gt.cover.wirelessdetector.redstone.tooltip=Changes this covers Redstone output behavior +gt.cover.wirelessdetector.redstone.0=Only a wireless signal +gt.cover.wirelessdetector.redstone.1=Wireless signal & direct Redstone gt.time.tick.singular=tick gt.time.tick.plural=ticks gt.time.second.singular=second