From ca4c644d20d7871366b5491b1d0252aeb5c5e9bc Mon Sep 17 00:00:00 2001 From: Sanduhr32 <25187502+Sanduhr32@users.noreply.github.com> Date: Sun, 8 Dec 2024 16:03:49 +0100 Subject: [PATCH 1/7] include toggle logic for detector covers --- .../redstone/CoverWirelessDoesWorkDetector.java | 17 ++++++++++++++--- .../redstone/CoverWirelessFluidDetector.java | 16 +++++++++++++--- .../redstone/CoverWirelessItemDetector.java | 17 ++++++++++++++--- .../CoverWirelessMaintenanceDetector.java | 11 +++++++++-- 4 files changed, 50 insertions(+), 11 deletions(-) diff --git a/src/main/java/gregtech/common/covers/redstone/CoverWirelessDoesWorkDetector.java b/src/main/java/gregtech/common/covers/redstone/CoverWirelessDoesWorkDetector.java index 1d5f89ee902..e84bff7abe3 100644 --- a/src/main/java/gregtech/common/covers/redstone/CoverWirelessDoesWorkDetector.java +++ b/src/main/java/gregtech/common/covers/redstone/CoverWirelessDoesWorkDetector.java @@ -76,7 +76,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; } @@ -108,21 +112,24 @@ public enum ActivityMode { public static class ActivityTransmitterData extends CoverAdvancedRedstoneTransmitterBase.TransmitterData { private ActivityMode mode; + 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 @@ -130,6 +137,7 @@ public ISerializableObject copy() { public NBTBase saveDataToNBT() { NBTTagCompound tag = (NBTTagCompound) super.saveDataToNBT(); tag.setInteger("mode", mode.ordinal()); + tag.setBoolean("physical", physical); return tag; } @@ -138,6 +146,7 @@ public NBTBase saveDataToNBT() { public void writeToByteBuf(ByteBuf aBuf) { super.writeToByteBuf(aBuf); aBuf.writeInt(mode.ordinal()); + aBuf.writeBoolean(physical); } @Override @@ -146,6 +155,7 @@ public void loadDataFromNBT(NBTBase aNBT) { NBTTagCompound tag = (NBTTagCompound) aNBT; mode = ActivityMode.values()[tag.getInteger("mode")]; + physical = tag.getBoolean("physical"); } @Nonnull @@ -153,6 +163,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; } diff --git a/src/main/java/gregtech/common/covers/redstone/CoverWirelessFluidDetector.java b/src/main/java/gregtech/common/covers/redstone/CoverWirelessFluidDetector.java index 9c7de19a01f..cda43662403 100644 --- a/src/main/java/gregtech/common/covers/redstone/CoverWirelessFluidDetector.java +++ b/src/main/java/gregtech/common/covers/redstone/CoverWirelessFluidDetector.java @@ -51,7 +51,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,10 +76,12 @@ public static class FluidTransmitterData extends CoverAdvancedRedstoneTransmitte /** The special value {@code 0} means threshold check is disabled. */ private int threshold; + 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() { @@ -86,7 +92,7 @@ public FluidTransmitterData() { @Nonnull @Override public ISerializableObject copy() { - return new FluidTransmitterData(frequency, uuid, invert, threshold); + return new FluidTransmitterData(frequency, uuid, invert, threshold, physical); } @Nonnull @@ -94,6 +100,7 @@ public ISerializableObject copy() { public NBTBase saveDataToNBT() { NBTTagCompound tag = (NBTTagCompound) super.saveDataToNBT(); tag.setInteger("threshold", threshold); + tag.setBoolean("physical", physical); return tag; } @@ -102,6 +109,7 @@ public NBTBase saveDataToNBT() { public void writeToByteBuf(ByteBuf aBuf) { super.writeToByteBuf(aBuf); aBuf.writeInt(threshold); + aBuf.writeBoolean(physical); } @Override @@ -110,6 +118,7 @@ public void loadDataFromNBT(NBTBase aNBT) { NBTTagCompound tag = (NBTTagCompound) aNBT; threshold = tag.getInteger("threshold"); + physical = tag.getBoolean("physical"); } @Nonnull @@ -117,6 +126,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; } diff --git a/src/main/java/gregtech/common/covers/redstone/CoverWirelessItemDetector.java b/src/main/java/gregtech/common/covers/redstone/CoverWirelessItemDetector.java index 72b6d25e736..343fb5e8982 100644 --- a/src/main/java/gregtech/common/covers/redstone/CoverWirelessItemDetector.java +++ b/src/main/java/gregtech/common/covers/redstone/CoverWirelessItemDetector.java @@ -59,7 +59,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 +90,26 @@ public static class ItemTransmitterData extends CoverAdvancedRedstoneTransmitter * The special value {@code 0} means threshold check is disabled. */ private int threshold; + 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 +118,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 +128,7 @@ public void writeToByteBuf(ByteBuf aBuf) { super.writeToByteBuf(aBuf); aBuf.writeInt(threshold); aBuf.writeInt(slot); + aBuf.writeBoolean(physical); } @Override @@ -129,6 +138,7 @@ public void loadDataFromNBT(NBTBase aNBT) { NBTTagCompound tag = (NBTTagCompound) aNBT; threshold = tag.getInteger("threshold"); slot = tag.getInteger("slot"); + physical = tag.getBoolean("physical"); } @Nonnull @@ -137,6 +147,7 @@ public ISerializableObject readFromPacket(ByteArrayDataInput aBuf, EntityPlayerM super.readFromPacket(aBuf, aPlayer); threshold = aBuf.readInt(); slot = aBuf.readInt(); + physical = aBuf.readBoolean(); return this; } diff --git a/src/main/java/gregtech/common/covers/redstone/CoverWirelessMaintenanceDetector.java b/src/main/java/gregtech/common/covers/redstone/CoverWirelessMaintenanceDetector.java index a71e597969e..f4fdd6b0d38 100644 --- a/src/main/java/gregtech/common/covers/redstone/CoverWirelessMaintenanceDetector.java +++ b/src/main/java/gregtech/common/covers/redstone/CoverWirelessMaintenanceDetector.java @@ -133,21 +133,24 @@ public enum MaintenanceMode { public static class MaintenanceTransmitterData extends CoverAdvancedRedstoneTransmitterBase.TransmitterData { private MaintenanceMode mode; + 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 = false; } @Nonnull @Override public ISerializableObject copy() { - return new MaintenanceTransmitterData(frequency, uuid, invert, mode); + return new MaintenanceTransmitterData(frequency, uuid, invert, mode, physical); } @Nonnull @@ -155,6 +158,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 +167,7 @@ public NBTBase saveDataToNBT() { public void writeToByteBuf(ByteBuf aBuf) { super.writeToByteBuf(aBuf); aBuf.writeInt(mode.ordinal()); + aBuf.writeBoolean(physical); } @Override @@ -171,6 +176,7 @@ public void loadDataFromNBT(NBTBase aNBT) { NBTTagCompound tag = (NBTTagCompound) aNBT; mode = MaintenanceMode.values()[tag.getInteger("mode")]; + physical = tag.getBoolean("physical"); } @Nonnull @@ -178,6 +184,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; } From 6c733e13493a2486fc0ad023b2183ea8d227fc8b Mon Sep 17 00:00:00 2001 From: Sanduhr32 <25187502+Sanduhr32@users.noreply.github.com> Date: Sun, 8 Dec 2024 20:37:54 +0100 Subject: [PATCH 2/7] include gui button & hint for toggling behavior --- .../CoverWirelessDoesWorkDetector.java | 34 ++++++++++++++-- .../redstone/CoverWirelessFluidDetector.java | 40 ++++++++++++++++++- .../redstone/CoverWirelessItemDetector.java | 40 +++++++++++++++++-- .../CoverWirelessMaintenanceDetector.java | 38 +++++++++++++++++- .../resources/assets/gregtech/lang/en_US.lang | 3 ++ 5 files changed, 145 insertions(+), 10 deletions(-) diff --git a/src/main/java/gregtech/common/covers/redstone/CoverWirelessDoesWorkDetector.java b/src/main/java/gregtech/common/covers/redstone/CoverWirelessDoesWorkDetector.java index e84bff7abe3..d613beeb6a6 100644 --- a/src/main/java/gregtech/common/covers/redstone/CoverWirelessDoesWorkDetector.java +++ b/src/main/java/gregtech/common/covers/redstone/CoverWirelessDoesWorkDetector.java @@ -4,9 +4,11 @@ import javax.annotation.Nonnull; +import com.gtnewhorizons.modularui.api.math.Alignment; 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; @@ -182,7 +184,7 @@ public WirelessActivityDetectorUIFactory(CoverUIBuildContext buildContext) { @Override protected int getGUIHeight() { - return 107; + return 123; } @Override @@ -213,7 +215,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 @@ -249,7 +266,18 @@ 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.ofRedstone(), + 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 cda43662403..7f8d44323e9 100644 --- a/src/main/java/gregtech/common/covers/redstone/CoverWirelessFluidDetector.java +++ b/src/main/java/gregtech/common/covers/redstone/CoverWirelessFluidDetector.java @@ -5,9 +5,13 @@ import javax.annotation.Nonnull; +import com.gtnewhorizons.modularui.api.drawable.Text; +import com.gtnewhorizons.modularui.api.math.Alignment; +import gregtech.common.gui.modularui.widget.CoverDataFollowerToggleButtonWidget; 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; @@ -147,6 +151,11 @@ public WirelessFluidDetectorUIFactory(CoverUIBuildContext buildContext) { super(buildContext); } + @Override + protected int getGUIHeight() { + return 123; + } + @Override protected int getFrequencyRow() { return 0; @@ -163,7 +172,23 @@ protected void addUIWidgets(ModularWindow.Builder builder) { 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)); + .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 @@ -180,7 +205,18 @@ 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 343fb5e8982..f5f2fcd27ff 100644 --- a/src/main/java/gregtech/common/covers/redstone/CoverWirelessItemDetector.java +++ b/src/main/java/gregtech/common/covers/redstone/CoverWirelessItemDetector.java @@ -5,11 +5,14 @@ import javax.annotation.Nonnull; +import com.gtnewhorizons.modularui.api.math.Alignment; +import gregtech.common.gui.modularui.widget.CoverDataFollowerToggleButtonWidget; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.item.ItemStack; 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; @@ -103,7 +106,7 @@ public ItemTransmitterData() { super(); this.threshold = 0; this.slot = -1; - this.physical = true; + this.physical = false; } @Nonnull @@ -183,6 +186,11 @@ public WirelessItemDetectorUIFactory(CoverUIBuildContext buildContext) { super(buildContext); } + @Override + protected int getGUIHeight() { + return 143; + } + @Override protected int getFrequencyRow() { return 0; @@ -206,7 +214,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 @@ -236,7 +259,18 @@ 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 f4fdd6b0d38..a26c5802b3e 100644 --- a/src/main/java/gregtech/common/covers/redstone/CoverWirelessMaintenanceDetector.java +++ b/src/main/java/gregtech/common/covers/redstone/CoverWirelessMaintenanceDetector.java @@ -4,10 +4,12 @@ import javax.annotation.Nonnull; +import com.gtnewhorizons.modularui.api.math.Alignment; import net.minecraft.entity.player.EntityPlayerMP; 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; @@ -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; } @@ -208,7 +214,7 @@ public WirelessMaintenanceDetectorUIFactory(CoverUIBuildContext buildContext) { @Override protected int getGUIHeight() { - return 143; + return 175; } @Override @@ -229,6 +235,23 @@ 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 @@ -246,6 +269,17 @@ 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.ofRedstone(), + 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 0ed55b6ee28..4af37dc22d0 100644 --- a/src/main/resources/assets/gregtech/lang/en_US.lang +++ b/src/main/resources/assets/gregtech/lang/en_US.lang @@ -1655,6 +1655,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 From 09a7e0645700319df7fb7b606936af3c1cec1f70 Mon Sep 17 00:00:00 2001 From: Sanduhr32 <25187502+Sanduhr32@users.noreply.github.com> Date: Sun, 8 Dec 2024 20:45:27 +0100 Subject: [PATCH 3/7] document meaning & behavior of variable named "physical" --- .../common/covers/redstone/CoverWirelessDoesWorkDetector.java | 1 + .../common/covers/redstone/CoverWirelessFluidDetector.java | 1 + .../common/covers/redstone/CoverWirelessItemDetector.java | 1 + .../common/covers/redstone/CoverWirelessMaintenanceDetector.java | 1 + 4 files changed, 4 insertions(+) diff --git a/src/main/java/gregtech/common/covers/redstone/CoverWirelessDoesWorkDetector.java b/src/main/java/gregtech/common/covers/redstone/CoverWirelessDoesWorkDetector.java index d613beeb6a6..a4d5d761f92 100644 --- a/src/main/java/gregtech/common/covers/redstone/CoverWirelessDoesWorkDetector.java +++ b/src/main/java/gregtech/common/covers/redstone/CoverWirelessDoesWorkDetector.java @@ -114,6 +114,7 @@ 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, boolean physical) { diff --git a/src/main/java/gregtech/common/covers/redstone/CoverWirelessFluidDetector.java b/src/main/java/gregtech/common/covers/redstone/CoverWirelessFluidDetector.java index 7f8d44323e9..cb4a1d979c5 100644 --- a/src/main/java/gregtech/common/covers/redstone/CoverWirelessFluidDetector.java +++ b/src/main/java/gregtech/common/covers/redstone/CoverWirelessFluidDetector.java @@ -80,6 +80,7 @@ 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, boolean physical) { diff --git a/src/main/java/gregtech/common/covers/redstone/CoverWirelessItemDetector.java b/src/main/java/gregtech/common/covers/redstone/CoverWirelessItemDetector.java index f5f2fcd27ff..a9ec4386261 100644 --- a/src/main/java/gregtech/common/covers/redstone/CoverWirelessItemDetector.java +++ b/src/main/java/gregtech/common/covers/redstone/CoverWirelessItemDetector.java @@ -93,6 +93,7 @@ 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, boolean physical) { diff --git a/src/main/java/gregtech/common/covers/redstone/CoverWirelessMaintenanceDetector.java b/src/main/java/gregtech/common/covers/redstone/CoverWirelessMaintenanceDetector.java index a26c5802b3e..ed3e74ecc9e 100644 --- a/src/main/java/gregtech/common/covers/redstone/CoverWirelessMaintenanceDetector.java +++ b/src/main/java/gregtech/common/covers/redstone/CoverWirelessMaintenanceDetector.java @@ -139,6 +139,7 @@ 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, boolean physical) { From 9e9664818779bd8e1ad8e030c4001adea5ef2346 Mon Sep 17 00:00:00 2001 From: Sanduhr32 <25187502+Sanduhr32@users.noreply.github.com> Date: Sun, 8 Dec 2024 21:00:20 +0100 Subject: [PATCH 4/7] adjust gui to use "checkmark" button --- .../common/covers/redstone/CoverWirelessDoesWorkDetector.java | 2 +- .../common/covers/redstone/CoverWirelessFluidDetector.java | 2 +- .../common/covers/redstone/CoverWirelessItemDetector.java | 2 +- .../covers/redstone/CoverWirelessMaintenanceDetector.java | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/gregtech/common/covers/redstone/CoverWirelessDoesWorkDetector.java b/src/main/java/gregtech/common/covers/redstone/CoverWirelessDoesWorkDetector.java index a4d5d761f92..0faf20fbad8 100644 --- a/src/main/java/gregtech/common/covers/redstone/CoverWirelessDoesWorkDetector.java +++ b/src/main/java/gregtech/common/covers/redstone/CoverWirelessDoesWorkDetector.java @@ -269,7 +269,7 @@ protected void addUIForDataController(CoverDataControllerWidget coverData.physical, (coverData, state) -> { coverData.physical = state; diff --git a/src/main/java/gregtech/common/covers/redstone/CoverWirelessFluidDetector.java b/src/main/java/gregtech/common/covers/redstone/CoverWirelessFluidDetector.java index cb4a1d979c5..fc1ff742875 100644 --- a/src/main/java/gregtech/common/covers/redstone/CoverWirelessFluidDetector.java +++ b/src/main/java/gregtech/common/covers/redstone/CoverWirelessFluidDetector.java @@ -208,7 +208,7 @@ protected void addUIForDataController(CoverDataControllerWidget coverData.physical, (coverData, state) -> { coverData.physical = state; diff --git a/src/main/java/gregtech/common/covers/redstone/CoverWirelessItemDetector.java b/src/main/java/gregtech/common/covers/redstone/CoverWirelessItemDetector.java index a9ec4386261..0587efc5f5c 100644 --- a/src/main/java/gregtech/common/covers/redstone/CoverWirelessItemDetector.java +++ b/src/main/java/gregtech/common/covers/redstone/CoverWirelessItemDetector.java @@ -262,7 +262,7 @@ protected void addUIForDataController(CoverDataControllerWidget coverData.physical, (coverData, state) -> { coverData.physical = state; diff --git a/src/main/java/gregtech/common/covers/redstone/CoverWirelessMaintenanceDetector.java b/src/main/java/gregtech/common/covers/redstone/CoverWirelessMaintenanceDetector.java index ed3e74ecc9e..c8fb6ca66de 100644 --- a/src/main/java/gregtech/common/covers/redstone/CoverWirelessMaintenanceDetector.java +++ b/src/main/java/gregtech/common/covers/redstone/CoverWirelessMaintenanceDetector.java @@ -271,7 +271,7 @@ protected void addUIForDataController(CoverDataControllerWidget coverData.physical, (coverData, state) -> { coverData.physical = state; From d692de052b1ed29761a5a4e55a766119365868b1 Mon Sep 17 00:00:00 2001 From: Sanduhr32 <25187502+Sanduhr32@users.noreply.github.com> Date: Sun, 8 Dec 2024 21:18:36 +0100 Subject: [PATCH 5/7] apply spotless java guidelines --- .../CoverWirelessDoesWorkDetector.java | 21 ++++----- .../redstone/CoverWirelessFluidDetector.java | 46 +++++++++---------- .../redstone/CoverWirelessItemDetector.java | 38 +++++++-------- .../CoverWirelessMaintenanceDetector.java | 40 ++++++++-------- 4 files changed, 70 insertions(+), 75 deletions(-) diff --git a/src/main/java/gregtech/common/covers/redstone/CoverWirelessDoesWorkDetector.java b/src/main/java/gregtech/common/covers/redstone/CoverWirelessDoesWorkDetector.java index 0faf20fbad8..dd56eda1e57 100644 --- a/src/main/java/gregtech/common/covers/redstone/CoverWirelessDoesWorkDetector.java +++ b/src/main/java/gregtech/common/covers/redstone/CoverWirelessDoesWorkDetector.java @@ -4,7 +4,6 @@ import javax.annotation.Nonnull; -import com.gtnewhorizons.modularui.api.math.Alignment; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.nbt.NBTBase; import net.minecraft.nbt.NBTTagCompound; @@ -12,6 +11,7 @@ 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; @@ -217,21 +217,21 @@ protected void addUIWidgets(ModularWindow.Builder builder) { .setSynced(false) .setDefaultColor(COLOR_TEXT_GRAY.get()) .setPos(startX + spaceX * 3, 4 + startY + spaceY * 2)) - .widget(TextWidget.dynamicString(() -> { + .widget(TextWidget.dynamicString(() -> { ActivityTransmitterData coverData = getCoverData(); if (coverData != null) { - return getCoverData().physical ? StatCollector.translateToLocal("gt.cover.wirelessdetector.redstone.1") + 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) - ); + .setSynced(false) + .setDefaultColor(COLOR_TEXT_GRAY.get()) + .setTextAlignment(Alignment.CenterLeft) + .setPos(startX + spaceX, 4 + startY + spaceY * 3) + .setSize(spaceX * 10, 12)); } @Override @@ -277,8 +277,7 @@ protected void addUIForDataController(CoverDataControllerWidget widget .addTooltip(StatCollector.translateToLocal("gt.cover.wirelessdetector.redstone.tooltip")) - .setPos(0, 1 + spaceY * 3) - ); + .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 fc1ff742875..c4fca27fef5 100644 --- a/src/main/java/gregtech/common/covers/redstone/CoverWirelessFluidDetector.java +++ b/src/main/java/gregtech/common/covers/redstone/CoverWirelessFluidDetector.java @@ -5,9 +5,6 @@ import javax.annotation.Nonnull; -import com.gtnewhorizons.modularui.api.drawable.Text; -import com.gtnewhorizons.modularui.api.math.Alignment; -import gregtech.common.gui.modularui.widget.CoverDataFollowerToggleButtonWidget; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.nbt.NBTBase; import net.minecraft.nbt.NBTTagCompound; @@ -17,6 +14,7 @@ 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; @@ -28,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 @@ -171,25 +170,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)) - .widget( - TextWidget.dynamicString(() -> { + 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") + 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) - ); + .setSynced(false) + .setDefaultColor(COLOR_TEXT_GRAY.get()) + .setTextAlignment(Alignment.CenterLeft) + .setPos(startX + spaceX, 4 + startY + spaceY * 3) + .setSize(spaceX * 10, 12)); } @Override @@ -207,17 +206,16 @@ protected void addUIForDataController(CoverDataControllerWidget coverData.physical, - (coverData, state) -> { - coverData.physical = state; - return coverData; - }, + .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) - ); + .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 0587efc5f5c..a3ab8aab76b 100644 --- a/src/main/java/gregtech/common/covers/redstone/CoverWirelessItemDetector.java +++ b/src/main/java/gregtech/common/covers/redstone/CoverWirelessItemDetector.java @@ -5,8 +5,6 @@ import javax.annotation.Nonnull; -import com.gtnewhorizons.modularui.api.math.Alignment; -import gregtech.common.gui.modularui.widget.CoverDataFollowerToggleButtonWidget; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTBase; @@ -17,6 +15,7 @@ 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; @@ -29,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; @@ -96,7 +96,8 @@ public static class ItemTransmitterData extends CoverAdvancedRedstoneTransmitter /** 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, boolean physical) { + public ItemTransmitterData(int frequency, UUID uuid, boolean invert, int threshold, int slot, + boolean physical) { super(frequency, uuid, invert); this.threshold = threshold; this.slot = slot; @@ -217,20 +218,20 @@ protected void addUIWidgets(ModularWindow.Builder builder) { new TextWidget(GTUtility.trans("254", "Detect Slot #")).setDefaultColor(COLOR_TEXT_GRAY.get()) .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) - ); + 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 @@ -270,8 +271,7 @@ protected void addUIForDataController(CoverDataControllerWidget widget .addTooltip(StatCollector.translateToLocal("gt.cover.wirelessdetector.redstone.tooltip")) - .setPos(0, 2 + spaceY * 4) - ); + .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 c8fb6ca66de..f40461b65e8 100644 --- a/src/main/java/gregtech/common/covers/redstone/CoverWirelessMaintenanceDetector.java +++ b/src/main/java/gregtech/common/covers/redstone/CoverWirelessMaintenanceDetector.java @@ -4,7 +4,6 @@ import javax.annotation.Nonnull; -import com.gtnewhorizons.modularui.api.math.Alignment; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTBase; @@ -13,6 +12,7 @@ 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; @@ -142,7 +142,8 @@ public static class MaintenanceTransmitterData extends CoverAdvancedRedstoneTran /** 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, boolean physical) { + public MaintenanceTransmitterData(int frequency, UUID uuid, boolean invert, MaintenanceMode mode, + boolean physical) { super(frequency, uuid, invert); this.mode = mode; this.physical = physical; @@ -236,23 +237,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) - ); + 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 @@ -279,8 +278,7 @@ protected void addUIForDataController(CoverDataControllerWidget widget .addTooltip(StatCollector.translateToLocal("gt.cover.wirelessdetector.redstone.tooltip")) - .setPos(0, 1 + spaceY * 6) - ); + .setPos(0, 1 + spaceY * 6)); } } } From d57d542c7506d22d6a0328f0734d0eaaf0ecc9cb Mon Sep 17 00:00:00 2001 From: Sanduhr32 <25187502+Sanduhr32@users.noreply.github.com> Date: Thu, 19 Dec 2024 17:36:44 +0100 Subject: [PATCH 6/7] make physical mode true by default --- .../common/covers/redstone/CoverWirelessFluidDetector.java | 1 + .../common/covers/redstone/CoverWirelessItemDetector.java | 2 +- .../covers/redstone/CoverWirelessMaintenanceDetector.java | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/gregtech/common/covers/redstone/CoverWirelessFluidDetector.java b/src/main/java/gregtech/common/covers/redstone/CoverWirelessFluidDetector.java index c4fca27fef5..6fe52b3e003 100644 --- a/src/main/java/gregtech/common/covers/redstone/CoverWirelessFluidDetector.java +++ b/src/main/java/gregtech/common/covers/redstone/CoverWirelessFluidDetector.java @@ -91,6 +91,7 @@ public FluidTransmitterData(int frequency, UUID uuid, boolean invert, int thresh public FluidTransmitterData() { super(); this.threshold = 0; + this.physical = true; } @Nonnull diff --git a/src/main/java/gregtech/common/covers/redstone/CoverWirelessItemDetector.java b/src/main/java/gregtech/common/covers/redstone/CoverWirelessItemDetector.java index a3ab8aab76b..39122850f4a 100644 --- a/src/main/java/gregtech/common/covers/redstone/CoverWirelessItemDetector.java +++ b/src/main/java/gregtech/common/covers/redstone/CoverWirelessItemDetector.java @@ -108,7 +108,7 @@ public ItemTransmitterData() { super(); this.threshold = 0; this.slot = -1; - this.physical = false; + this.physical = true; } @Nonnull diff --git a/src/main/java/gregtech/common/covers/redstone/CoverWirelessMaintenanceDetector.java b/src/main/java/gregtech/common/covers/redstone/CoverWirelessMaintenanceDetector.java index f40461b65e8..c59bb44864a 100644 --- a/src/main/java/gregtech/common/covers/redstone/CoverWirelessMaintenanceDetector.java +++ b/src/main/java/gregtech/common/covers/redstone/CoverWirelessMaintenanceDetector.java @@ -152,7 +152,7 @@ public MaintenanceTransmitterData(int frequency, UUID uuid, boolean invert, Main public MaintenanceTransmitterData() { super(); this.mode = MaintenanceMode.ONE_ISSUE; - this.physical = false; + this.physical = true; } @Nonnull From cc0b453b42a5aa4bb1e604db919cdf6b09b62de2 Mon Sep 17 00:00:00 2001 From: Sanduhr32 <25187502+Sanduhr32@users.noreply.github.com> Date: Thu, 19 Dec 2024 17:39:21 +0100 Subject: [PATCH 7/7] add explicit `false` for missing physical nbt tags --- .../covers/redstone/CoverWirelessDoesWorkDetector.java | 6 +++++- .../common/covers/redstone/CoverWirelessFluidDetector.java | 6 +++++- .../common/covers/redstone/CoverWirelessItemDetector.java | 7 ++++++- .../covers/redstone/CoverWirelessMaintenanceDetector.java | 6 +++++- 4 files changed, 21 insertions(+), 4 deletions(-) diff --git a/src/main/java/gregtech/common/covers/redstone/CoverWirelessDoesWorkDetector.java b/src/main/java/gregtech/common/covers/redstone/CoverWirelessDoesWorkDetector.java index dd56eda1e57..fcc9b6b414c 100644 --- a/src/main/java/gregtech/common/covers/redstone/CoverWirelessDoesWorkDetector.java +++ b/src/main/java/gregtech/common/covers/redstone/CoverWirelessDoesWorkDetector.java @@ -158,7 +158,11 @@ public void loadDataFromNBT(NBTBase aNBT) { NBTTagCompound tag = (NBTTagCompound) aNBT; mode = ActivityMode.values()[tag.getInteger("mode")]; - physical = tag.getBoolean("physical"); + if (tag.hasKey("physical")) { + physical = tag.getBoolean("physical"); + } else { + physical = false; + } } @Nonnull diff --git a/src/main/java/gregtech/common/covers/redstone/CoverWirelessFluidDetector.java b/src/main/java/gregtech/common/covers/redstone/CoverWirelessFluidDetector.java index 6fe52b3e003..3a58fd198c0 100644 --- a/src/main/java/gregtech/common/covers/redstone/CoverWirelessFluidDetector.java +++ b/src/main/java/gregtech/common/covers/redstone/CoverWirelessFluidDetector.java @@ -123,7 +123,11 @@ public void loadDataFromNBT(NBTBase aNBT) { NBTTagCompound tag = (NBTTagCompound) aNBT; threshold = tag.getInteger("threshold"); - physical = tag.getBoolean("physical"); + if (tag.hasKey("physical")) { + physical = tag.getBoolean("physical"); + } else { + physical = false; + } } @Nonnull diff --git a/src/main/java/gregtech/common/covers/redstone/CoverWirelessItemDetector.java b/src/main/java/gregtech/common/covers/redstone/CoverWirelessItemDetector.java index 39122850f4a..087e5d58dd9 100644 --- a/src/main/java/gregtech/common/covers/redstone/CoverWirelessItemDetector.java +++ b/src/main/java/gregtech/common/covers/redstone/CoverWirelessItemDetector.java @@ -143,7 +143,12 @@ public void loadDataFromNBT(NBTBase aNBT) { NBTTagCompound tag = (NBTTagCompound) aNBT; threshold = tag.getInteger("threshold"); slot = tag.getInteger("slot"); - physical = tag.getBoolean("physical"); + + if (tag.hasKey("physical")) { + physical = tag.getBoolean("physical"); + } else { + physical = false; + } } @Nonnull diff --git a/src/main/java/gregtech/common/covers/redstone/CoverWirelessMaintenanceDetector.java b/src/main/java/gregtech/common/covers/redstone/CoverWirelessMaintenanceDetector.java index c59bb44864a..e44e70858ab 100644 --- a/src/main/java/gregtech/common/covers/redstone/CoverWirelessMaintenanceDetector.java +++ b/src/main/java/gregtech/common/covers/redstone/CoverWirelessMaintenanceDetector.java @@ -184,7 +184,11 @@ public void loadDataFromNBT(NBTBase aNBT) { NBTTagCompound tag = (NBTTagCompound) aNBT; mode = MaintenanceMode.values()[tag.getInteger("mode")]; - physical = tag.getBoolean("physical"); + if (tag.hasKey("physical")) { + physical = tag.getBoolean("physical"); + } else { + physical = false; + } } @Nonnull