Skip to content

Commit

Permalink
Merge branch 'master' into fix_stocking_dupes
Browse files Browse the repository at this point in the history
  • Loading branch information
Dream-Master authored Jan 5, 2025
2 parents f9592da + 5283554 commit 8a3a33e
Show file tree
Hide file tree
Showing 6 changed files with 215 additions and 24 deletions.
4 changes: 2 additions & 2 deletions dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ dependencies {
compileOnly('com.github.GTNewHorizons:VisualProspecting:1.3.28:dev') { transitive = false }
compileOnly("com.github.GTNewHorizons:Galaxy-Space-GTNH:1.1.106-GTNH:dev") { transitive = false }

compileOnlyApi("com.github.GTNewHorizons:Galacticraft:3.3.0-GTNH:dev") { transitive = false }
implementation("com.github.GTNewHorizons:TinkersConstruct:1.13.2-GTNH:dev")
compileOnlyApi("com.github.GTNewHorizons:Galacticraft:3.3.1-GTNH:dev") { transitive = false }
implementation("com.github.GTNewHorizons:TinkersConstruct:1.13.3-GTNH:dev")

compileOnly("com.github.GTNewHorizons:Chisel:2.16.1-GTNH:dev") { transitive = false }
compileOnly("com.github.GTNewHorizons:Translocators:1.3.0:dev") { transitive = false }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -114,28 +120,33 @@ 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
@Override
public NBTBase saveDataToNBT() {
NBTTagCompound tag = (NBTTagCompound) super.saveDataToNBT();
tag.setInteger("mode", mode.ordinal());
tag.setBoolean("physical", physical);

return tag;
}
Expand All @@ -144,6 +155,7 @@ public NBTBase saveDataToNBT() {
public void writeToByteBuf(ByteBuf aBuf) {
super.writeToByteBuf(aBuf);
aBuf.writeInt(mode.ordinal());
aBuf.writeBoolean(physical);
}

@Override
Expand All @@ -152,13 +164,19 @@ 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
@Override
public ISerializableObject readFromPacket(ByteArrayDataInput aBuf, EntityPlayerMP aPlayer) {
super.readFromPacket(aBuf, aPlayer);
mode = ActivityMode.values()[aBuf.readInt()];
physical = aBuf.readBoolean();

return this;
}
Expand All @@ -177,7 +195,7 @@ public WirelessActivityDetectorUIFactory(CoverUIBuildContext buildContext) {

@Override
protected int getGUIHeight() {
return 107;
return 123;
}

@Override
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -244,7 +277,17 @@ protected void addUIForDataController(CoverDataControllerWidget<ActivityTransmit
},
widget -> 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));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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
Expand Down Expand Up @@ -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;
}
Expand All @@ -72,28 +79,33 @@ 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
@Override
public NBTBase saveDataToNBT() {
NBTTagCompound tag = (NBTTagCompound) super.saveDataToNBT();
tag.setInteger("threshold", threshold);
tag.setBoolean("physical", physical);

return tag;
}
Expand All @@ -102,6 +114,7 @@ public NBTBase saveDataToNBT() {
public void writeToByteBuf(ByteBuf aBuf) {
super.writeToByteBuf(aBuf);
aBuf.writeInt(threshold);
aBuf.writeBoolean(physical);
}

@Override
Expand All @@ -110,13 +123,19 @@ 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
@Override
public ISerializableObject readFromPacket(ByteArrayDataInput aBuf, EntityPlayerMP aPlayer) {
super.readFromPacket(aBuf, aPlayer);
threshold = aBuf.readInt();
physical = aBuf.readBoolean();

return this;
}
Expand All @@ -137,6 +156,11 @@ public WirelessFluidDetectorUIFactory(CoverUIBuildContext buildContext) {
super(buildContext);
}

@Override
protected int getGUIHeight() {
return 123;
}

@Override
protected int getFrequencyRow() {
return 0;
Expand All @@ -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
Expand All @@ -170,7 +210,17 @@ protected void addUIForDataController(CoverDataControllerWidget<FluidTransmitter
.setScrollValues(1000, 144, 100000)
.setFocusOnGuiOpen(true)
.setPos(1, 2 + spaceY * 2)
.setSize(spaceX * 5 - 4, 12));
.setSize(spaceX * 5 - 4, 12))
.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));
}

private void setMaxCapacity() {
Expand Down
Loading

0 comments on commit 8a3a33e

Please sign in to comment.