aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
authorくぁーりぃ <39122497+Quarri6343@users.noreply.github.com>2022-08-30 05:04:31 +0900
committerGitHub <noreply@github.com>2022-08-29 22:04:31 +0200
commit4927a8885381ca48479be71e7cdb37aae9cbf5fd (patch)
tree7664056ac3ec23574942e9a265e6ca37067b8963 /src/main/java
parentce1bd5b2138093a61e9b17989ffea7c126a00c12 (diff)
downloadGT5-Unofficial-4927a8885381ca48479be71e7cdb37aae9cbf5fd.tar.gz
GT5-Unofficial-4927a8885381ca48479be71e7cdb37aae9cbf5fd.tar.bz2
GT5-Unofficial-4927a8885381ca48479be71e7cdb37aae9cbf5fd.zip
Digitalize Super Tank (#1318)
* add new GUI * make gui interactable * make later three buttons actually function * add auto output feature * do localization * apply spotless * spotless pt.2
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/gregtech/api/gui/GT_Container.java1
-rw-r--r--src/main/java/gregtech/api/gui/GT_Container_BasicTank.java9
-rw-r--r--src/main/java/gregtech/api/gui/GT_Container_DigitalTank.java135
-rw-r--r--src/main/java/gregtech/api/gui/GT_GUIContainer_DigitalTank.java91
-rw-r--r--src/main/java/gregtech/api/util/GT_Utility.java4
-rw-r--r--src/main/java/gregtech/common/tileentities/storage/GT_MetaTileEntity_DigitalTankBase.java146
6 files changed, 357 insertions, 29 deletions
diff --git a/src/main/java/gregtech/api/gui/GT_Container.java b/src/main/java/gregtech/api/gui/GT_Container.java
index b5aebf87f2..083634f030 100644
--- a/src/main/java/gregtech/api/gui/GT_Container.java
+++ b/src/main/java/gregtech/api/gui/GT_Container.java
@@ -670,7 +670,6 @@ public class GT_Container extends Container {
}
replaceCursorItemStack(aPlayer, tFilledContainer);
}
- if (tTankStack.amount <= 0) aFluidAccess.set(null);
return tFilledContainer;
}
diff --git a/src/main/java/gregtech/api/gui/GT_Container_BasicTank.java b/src/main/java/gregtech/api/gui/GT_Container_BasicTank.java
index 23769ab0cc..6e4f5b8920 100644
--- a/src/main/java/gregtech/api/gui/GT_Container_BasicTank.java
+++ b/src/main/java/gregtech/api/gui/GT_Container_BasicTank.java
@@ -22,7 +22,7 @@ import net.minecraftforge.fluids.FluidStack;
public class GT_Container_BasicTank extends GT_ContainerMetaTile_Machine {
public int mContent = 0;
- private int oContent = 0;
+ protected int oContent = 0;
public GT_Container_BasicTank(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) {
super(aInventoryPlayer, aTileEntity);
@@ -68,6 +68,11 @@ public class GT_Container_BasicTank extends GT_ContainerMetaTile_Machine {
if (((GT_MetaTileEntity_BasicTank) mTileEntity.getMetaTileEntity()).mFluid != null)
mContent = ((GT_MetaTileEntity_BasicTank) mTileEntity.getMetaTileEntity()).mFluid.amount;
else mContent = 0;
+ sendProgressBar();
+ oContent = mContent;
+ }
+
+ public void sendProgressBar() {
for (Object crafter : this.crafters) {
ICrafting player = (ICrafting) crafter;
if (mTimer % 500 == 0 || oContent != mContent) {
@@ -75,8 +80,6 @@ public class GT_Container_BasicTank extends GT_ContainerMetaTile_Machine {
player.sendProgressBarUpdate(this, 101, mContent >>> 16);
}
}
-
- oContent = mContent;
}
@Override
diff --git a/src/main/java/gregtech/api/gui/GT_Container_DigitalTank.java b/src/main/java/gregtech/api/gui/GT_Container_DigitalTank.java
new file mode 100644
index 0000000000..ae67dfd59f
--- /dev/null
+++ b/src/main/java/gregtech/api/gui/GT_Container_DigitalTank.java
@@ -0,0 +1,135 @@
+package gregtech.api.gui;
+
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
+import gregtech.api.util.GT_Utility;
+import gregtech.common.tileentities.storage.GT_MetaTileEntity_DigitalTankBase;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.entity.player.InventoryPlayer;
+import net.minecraft.inventory.ICrafting;
+import net.minecraft.inventory.Slot;
+import net.minecraft.item.ItemStack;
+
+public class GT_Container_DigitalTank extends GT_Container_BasicTank {
+ public boolean outputFluid = false, mLockFluid = false, mVoidFluidPart = false, mVoidFluidFull = false;
+
+ public GT_Container_DigitalTank(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) {
+ super(aInventoryPlayer, aTileEntity);
+ }
+
+ @Override
+ public void addSlots(InventoryPlayer aInventoryPlayer) {
+ addSlotToContainer(new Slot(mTileEntity, 0, 81, 17));
+ addSlotToContainer(new GT_Slot_Output(mTileEntity, 1, 81, 44));
+ addSlotToContainer(new GT_Slot_Render(mTileEntity, 2, 59, 42));
+ addSlotToContainer(new GT_Slot_Holo(mTileEntity, 3, 8, 64, false, true, 1));
+ addSlotToContainer(new GT_Slot_Holo(mTileEntity, 4, 26, 64, false, true, 1));
+ addSlotToContainer(new GT_Slot_Holo(mTileEntity, 5, 44, 64, false, true, 1));
+ addSlotToContainer(new GT_Slot_Holo(mTileEntity, 6, 62, 64, false, true, 1));
+ }
+
+ @Override
+ public ItemStack slotClick(int aSlotIndex, int aMouseclick, int aShifthold, EntityPlayer aPlayer) {
+
+ GT_MetaTileEntity_DigitalTankBase mte = ((GT_MetaTileEntity_DigitalTankBase) mTileEntity.getMetaTileEntity());
+
+ if (aSlotIndex == 3) {
+ mte.mOutputFluid = !mte.mOutputFluid;
+ if (!mte.mOutputFluid) {
+ GT_Utility.sendChatToPlayer(aPlayer, GT_Utility.trans("225", "Fluid Auto Output Disabled"));
+ } else {
+ GT_Utility.sendChatToPlayer(aPlayer, GT_Utility.trans("226", "Fluid Auto Output Enabled"));
+ }
+ return null;
+ }
+ if (aSlotIndex == 4) {
+ String inBrackets;
+ mte.mLockFluid = !mte.mLockFluid;
+ if (mte.mLockFluid) {
+ if (mte.mFluid == null) {
+ mte.lockedFluidName = null;
+ inBrackets = GT_Utility.trans("227", "currently none, will be locked to the next that is put in");
+ } else {
+ mte.lockedFluidName = mte.getDrainableStack().getUnlocalizedName();
+ inBrackets = mte.getDrainableStack().getLocalizedName();
+ }
+ GT_Utility.sendChatToPlayer(
+ aPlayer, String.format("%s (%s)", GT_Utility.trans("228", "1 specific Fluid"), inBrackets));
+ } else {
+ GT_Utility.sendChatToPlayer(aPlayer, GT_Utility.trans("229", "Lock Fluid Mode Disabled"));
+ }
+ return null;
+ }
+ if (aSlotIndex == 5) {
+ mte.mVoidFluidPart = !mte.mVoidFluidPart;
+ if (!mte.mVoidFluidPart) {
+ GT_Utility.sendChatToPlayer(aPlayer, GT_Utility.trans("230", "Overflow Voiding Mode Disabled"));
+ } else {
+ GT_Utility.sendChatToPlayer(aPlayer, GT_Utility.trans("231", "Overflow Voiding Mode Enabled"));
+ }
+ return null;
+ }
+ if (aSlotIndex == 6) {
+ mte.mVoidFluidFull = !mte.mVoidFluidFull;
+ if (!mte.mVoidFluidFull) {
+ GT_Utility.sendChatToPlayer(aPlayer, GT_Utility.trans("232", "Void Full Mode Disabled"));
+ } else {
+ GT_Utility.sendChatToPlayer(aPlayer, GT_Utility.trans("233", "Void Full Mode Enabled"));
+ }
+ return null;
+ }
+
+ return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer);
+ }
+
+ @Override
+ public void sendProgressBar() {
+ GT_MetaTileEntity_DigitalTankBase mte = ((GT_MetaTileEntity_DigitalTankBase) mTileEntity.getMetaTileEntity());
+
+ for (Object crafter : this.crafters) {
+ ICrafting player = (ICrafting) crafter;
+ if (mContent != oContent) {
+ player.sendProgressBarUpdate(this, 100, mContent & 65535);
+ player.sendProgressBarUpdate(this, 101, mContent >>> 16);
+ }
+ if (outputFluid != mte.mOutputFluid) {
+ player.sendProgressBarUpdate(this, 103, mte.mOutputFluid ? 1 : 0);
+ }
+ if (mLockFluid != mte.mLockFluid) {
+ player.sendProgressBarUpdate(this, 104, mte.mLockFluid ? 1 : 0);
+ }
+ if (mVoidFluidPart != mte.mVoidFluidPart) {
+ player.sendProgressBarUpdate(this, 105, mte.mVoidFluidPart ? 1 : 0);
+ }
+ if (mVoidFluidFull != mte.mVoidFluidFull) {
+ player.sendProgressBarUpdate(this, 106, mte.mVoidFluidFull ? 1 : 0);
+ }
+ }
+
+ outputFluid = mte.mOutputFluid;
+ mLockFluid = mte.mLockFluid;
+ mVoidFluidPart = mte.mVoidFluidPart;
+ mVoidFluidFull = mte.mVoidFluidFull;
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public void updateProgressBar(int id, int value) {
+ super.updateProgressBar(id, value);
+ switch (id) {
+ case 103:
+ outputFluid = (value != 0);
+ break;
+ case 104:
+ mLockFluid = (value != 0);
+ break;
+ case 105:
+ mVoidFluidPart = (value != 0);
+ break;
+ case 106:
+ mVoidFluidFull = (value != 0);
+ break;
+ }
+ }
+}
diff --git a/src/main/java/gregtech/api/gui/GT_GUIContainer_DigitalTank.java b/src/main/java/gregtech/api/gui/GT_GUIContainer_DigitalTank.java
new file mode 100644
index 0000000000..c0655ced94
--- /dev/null
+++ b/src/main/java/gregtech/api/gui/GT_GUIContainer_DigitalTank.java
@@ -0,0 +1,91 @@
+package gregtech.api.gui;
+
+import static gregtech.api.enums.GT_Values.RES_PATH_GUI;
+
+import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
+import gregtech.api.util.GT_Utility;
+import java.util.ArrayList;
+import java.util.List;
+import net.minecraft.entity.player.InventoryPlayer;
+import net.minecraft.util.StatCollector;
+
+public class GT_GUIContainer_DigitalTank extends GT_GUIContainerMetaTile_Machine {
+
+ private final String mName;
+ private final int textColor = this.getTextColorOrDefault("text", 0xFAFAFF),
+ textColorTitle = this.getTextColorOrDefault("title", 0x404040),
+ textColorValue = this.getTextColorOrDefault("value", 0xFAFAFF);
+
+ public GT_GUIContainer_DigitalTank(
+ InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity, String aName) {
+ super(new GT_Container_DigitalTank(aInventoryPlayer, aTileEntity), RES_PATH_GUI + "DigitalTank.png");
+ mName = aName;
+ }
+
+ @Override
+ public void drawScreen(int par1, int par2, float par3) {
+ super.drawScreen(par1, par2, par3);
+ drawTooltip(par1, par2);
+ }
+
+ private void drawTooltip(int x2, int y2) {
+ int xStart = (width - xSize) / 2;
+ int yStart = (height - ySize) / 2;
+ int x = x2 - xStart;
+ int y = y2 - yStart + 5;
+ List<String> list = new ArrayList<>();
+ if (y >= 68 && y <= 84) {
+ if (x >= 8 && x <= 24) {
+ list.add(StatCollector.translateToLocal("GT5U.machines.digitaltank.autooutput.name"));
+ } else if (x >= 26 && x <= 42) {
+ list.add(StatCollector.translateToLocal("GT5U.machines.digitaltank.lockfluid.name"));
+ list.add(StatCollector.translateToLocal("GT5U.machines.digitaltank.lockfluid.tooltip"));
+ list.add(StatCollector.translateToLocal("GT5U.machines.digitaltank.lockfluid.tooltip1"));
+ }
+ if (x >= 44 && x <= 60) {
+ list.add(StatCollector.translateToLocal("GT5U.machines.digitaltank.voidoverflow.name"));
+ list.add(StatCollector.translateToLocal("GT5U.machines.digitaltank.voidoverflow.tooltip"));
+ }
+ if (x >= 62 && x <= 78) {
+ list.add(StatCollector.translateToLocal("GT5U.machines.digitaltank.voidfull.name"));
+ list.add(StatCollector.translateToLocal("GT5U.machines.digitaltank.voidfull.tooltip"));
+ }
+ }
+ if (!list.isEmpty()) drawHoveringText(list, x2, y2, fontRendererObj);
+ }
+
+ @Override
+ protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
+ fontRendererObj.drawString(mName, 8, 6, textColorTitle);
+ if (mContainer != null) {
+ fontRendererObj.drawString("Liquid Amount", 10, 20, textColor);
+ fontRendererObj.drawString(
+ GT_Utility.parseNumberToString(((GT_Container_DigitalTank) mContainer).mContent),
+ 10,
+ 30,
+ textColorValue);
+ }
+ }
+
+ @Override
+ protected void drawGuiContainerBackgroundLayer(float parTicks, int mouseX, int mouseY) {
+ super.drawGuiContainerBackgroundLayer(parTicks, mouseX, mouseY);
+ int x = (width - xSize) / 2;
+ int y = (height - ySize) / 2;
+ drawTexturedModalRect(x, y, 0, 0, xSize, ySize);
+ if (mContainer != null) {
+ if (((GT_Container_DigitalTank) mContainer).mLockFluid) {
+ drawTexturedModalRect(x + 25, y + 63, 176, 0, 18, 18);
+ }
+ if (((GT_Container_DigitalTank) mContainer).outputFluid) {
+ drawTexturedModalRect(x + 7, y + 63, 176, 18, 18, 18);
+ }
+ if (((GT_Container_DigitalTank) mContainer).mVoidFluidPart) {
+ drawTexturedModalRect(x + 43, y + 63, 176, 36, 18, 18);
+ }
+ if (((GT_Container_DigitalTank) mContainer).mVoidFluidFull) {
+ drawTexturedModalRect(x + 61, y + 63, 176, 54, 18, 18);
+ }
+ }
+ }
+}
diff --git a/src/main/java/gregtech/api/util/GT_Utility.java b/src/main/java/gregtech/api/util/GT_Utility.java
index dc192a7d57..50106795eb 100644
--- a/src/main/java/gregtech/api/util/GT_Utility.java
+++ b/src/main/java/gregtech/api/util/GT_Utility.java
@@ -3469,6 +3469,10 @@ public class GT_Utility {
return GT_LanguageManager.addStringLocalization("Interaction_DESCRIPTION_Index_" + aKey, aEnglish, false);
}
+ public static String getTrans(String aKey) {
+ return GT_LanguageManager.getTranslation("Interaction_DESCRIPTION_Index_" + aKey);
+ }
+
/**
* @return an Array containing the X and the Y Coordinate of the clicked Point, with the top left Corner as Origin, like on the Texture Sheet. return values should always be between [0.0F and 0.99F].
*/
diff --git a/src/main/java/gregtech/common/tileentities/storage/GT_MetaTileEntity_DigitalTankBase.java b/src/main/java/gregtech/common/tileentities/storage/GT_MetaTileEntity_DigitalTankBase.java
index 6b2a9caf4b..7ccd1e62c3 100644
--- a/src/main/java/gregtech/common/tileentities/storage/GT_MetaTileEntity_DigitalTankBase.java
+++ b/src/main/java/gregtech/common/tileentities/storage/GT_MetaTileEntity_DigitalTankBase.java
@@ -1,33 +1,36 @@
package gregtech.common.tileentities.storage;
-import static gregtech.api.enums.Textures.BlockIcons.MACHINE_CASINGS;
-import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_QTANK;
-import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_QTANK_GLOW;
+import static gregtech.api.enums.Textures.BlockIcons.*;
+import gregtech.api.gui.GT_Container_DigitalTank;
+import gregtech.api.gui.GT_GUIContainer_DigitalTank;
import gregtech.api.interfaces.ITexture;
import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicTank;
import gregtech.api.render.TextureFactory;
import gregtech.api.util.GT_Utility;
import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.StatCollector;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidTankInfo;
+import net.minecraftforge.fluids.IFluidHandler;
public abstract class GT_MetaTileEntity_DigitalTankBase extends GT_MetaTileEntity_BasicTank {
- protected boolean mVoidOverflow = false;
+ public boolean mOutputFluid = false, mVoidFluidPart = false, mVoidFluidFull = false, mLockFluid = false;
+ public String lockedFluidName = null;
private boolean voidBreak;
+ public boolean mAllowInputFromOutputSide = false;
public GT_MetaTileEntity_DigitalTankBase(int aID, String aName, String aNameRegional, int aTier) {
super(aID, aName, aNameRegional, aTier, 3, new String[] {
- "Stores " + GT_Utility.formatNumbers(commonSizeCompute(aTier)) + "L of fluid",
- "Use a screwdriver to enable",
- "voiding fluid on overflow",
- "Can keep its contents when harvested",
- "Sneak when harvesting to void its contents"
+ StatCollector.translateToLocalFormatted(
+ "GT5U.machines.digitaltank.tooltip", GT_Utility.formatNumbers(commonSizeCompute(aTier))),
+ StatCollector.translateToLocal("GT5U.machines.digitaltank.tooltip1"),
+ StatCollector.translateToLocal("GT5U.machines.digitaltank.tooltip2")
});
}
@@ -77,7 +80,13 @@ public abstract class GT_MetaTileEntity_DigitalTankBase extends GT_MetaTileEntit
if (mFluid != null && mFluid.amount > 0) {
aNBT.setTag("mFluid", mFluid.writeToNBT(new NBTTagCompound()));
}
- aNBT.setBoolean("mVoidOverflow", mVoidOverflow);
+ aNBT.setBoolean("mOutputFluid", this.mOutputFluid);
+ aNBT.setBoolean("mVoidOverflow", this.mVoidFluidPart);
+ aNBT.setBoolean("mVoidFluidFull", this.mVoidFluidFull);
+ aNBT.setBoolean("mLockFluid", mLockFluid);
+ if (lockedFluidName != null && lockedFluidName.length() != 0)
+ aNBT.setString("lockedFluidName", lockedFluidName);
+ else aNBT.removeTag("lockedFluidName");
}
super.setItemNBT(aNBT);
}
@@ -85,13 +94,43 @@ public abstract class GT_MetaTileEntity_DigitalTankBase extends GT_MetaTileEntit
@Override
public void saveNBTData(NBTTagCompound aNBT) {
super.saveNBTData(aNBT);
- aNBT.setBoolean("mVoidOverflow", mVoidOverflow);
+ aNBT.setBoolean("mOutputFluid", this.mOutputFluid);
+ aNBT.setBoolean("mVoidOverflow", this.mVoidFluidPart);
+ aNBT.setBoolean("mVoidFluidFull", this.mVoidFluidFull);
+ aNBT.setBoolean("mLockFluid", mLockFluid);
+ if (lockedFluidName != null && lockedFluidName.length() != 0)
+ aNBT.setString("lockedFluidName", lockedFluidName);
+ else aNBT.removeTag("lockedFluidName");
+ aNBT.setBoolean("mAllowInputFromOutputSide", mAllowInputFromOutputSide);
}
@Override
public void loadNBTData(NBTTagCompound aNBT) {
super.loadNBTData(aNBT);
- mVoidOverflow = aNBT.getBoolean("mVoidOverflow");
+ mOutputFluid = aNBT.getBoolean("mOutputFluid");
+ mVoidFluidPart = aNBT.getBoolean("mVoidOverflow");
+ mVoidFluidFull = aNBT.getBoolean("mVoidFluidFull");
+ mLockFluid = aNBT.getBoolean("mLockFluid");
+ lockedFluidName = aNBT.getString("lockedFluidName");
+ lockedFluidName = lockedFluidName.length() == 0 ? null : lockedFluidName;
+ mAllowInputFromOutputSide = aNBT.getBoolean("mAllowInputFromOutputSide");
+ }
+
+ @Override
+ public boolean isFluidInputAllowed(FluidStack aFluid) {
+ return !mLockFluid || lockedFluidName == null || lockedFluidName.equals(aFluid.getUnlocalizedName());
+ }
+
+ @Override
+ public boolean isFluidChangingAllowed() {
+ return !mLockFluid || lockedFluidName == null;
+ }
+
+ @Override
+ public void onEmptyingContainerWhenEmpty() {
+ if (this.lockedFluidName == null && this.mFluid != null) {
+ this.lockedFluidName = this.mFluid.getUnlocalizedName();
+ }
}
@Override
@@ -137,7 +176,11 @@ public abstract class GT_MetaTileEntity_DigitalTankBase extends GT_MetaTileEntit
byte aColorIndex,
boolean aActive,
boolean aRedstone) {
- if (aSide != ForgeDirection.UP.ordinal()) return new ITexture[] {MACHINE_CASINGS[mTier][aColorIndex + 1]};
+ if (aSide != ForgeDirection.UP.ordinal()) {
+ if (aSide == aBaseMetaTileEntity.getFrontFacing()) {
+ return new ITexture[] {MACHINE_CASINGS[mTier][aColorIndex + 1], TextureFactory.of(OVERLAY_PIPE)};
+ } else return new ITexture[] {MACHINE_CASINGS[mTier][aColorIndex + 1]};
+ }
return new ITexture[] {
MACHINE_CASINGS[mTier][aColorIndex + 1],
TextureFactory.of(OVERLAY_QTANK),
@@ -159,11 +202,11 @@ public abstract class GT_MetaTileEntity_DigitalTankBase extends GT_MetaTileEntit
@Override
public final void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) {
- mVoidOverflow = !mVoidOverflow;
- GT_Utility.sendChatToPlayer(
- aPlayer,
- StatCollector.translateToLocal(
- mVoidOverflow ? "GT5U.machines.voidoveflow.enabled" : "GT5U.machines.voidoveflow.disabled"));
+ if (aSide == getBaseMetaTileEntity().getFrontFacing()) {
+ mAllowInputFromOutputSide = !mAllowInputFromOutputSide;
+ GT_Utility.sendChatToPlayer(
+ aPlayer, mAllowInputFromOutputSide ? GT_Utility.getTrans("095") : GT_Utility.getTrans("096"));
+ }
}
@Override
@@ -185,11 +228,27 @@ public abstract class GT_MetaTileEntity_DigitalTankBase extends GT_MetaTileEntit
}
@Override
+ public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) {
+ return new GT_Container_DigitalTank(aPlayerInventory, aBaseMetaTileEntity);
+ }
+
+ @Override
+ public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) {
+ return new GT_GUIContainer_DigitalTank(aPlayerInventory, aBaseMetaTileEntity, getLocalName());
+ }
+
+ @Override
public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) {
if (aBaseMetaTileEntity.isServerSide()) {
if (isFluidChangingAllowed() && getFillableStack() != null && getFillableStack().amount <= 0)
setFillableStack(null);
+ if (mVoidFluidFull && getFillableStack() != null) {
+ mVoidFluidPart = false;
+ mLockFluid = false;
+ setFillableStack(null);
+ }
+
if (mOpenerCount > 0) updateFluidDisplayItem();
if (doesEmptyContainers()) {
@@ -197,9 +256,8 @@ public abstract class GT_MetaTileEntity_DigitalTankBase extends GT_MetaTileEntit
if (tFluid != null && isFluidInputAllowed(tFluid)) {
if (getFillableStack() == null) {
if (isFluidInputAllowed(tFluid)) {
- if ((tFluid.amount <= getRealCapacity()) || mVoidOverflow) {
+ if ((tFluid.amount <= getRealCapacity()) || mVoidFluidPart) {
tFluid = tFluid.copy();
- tFluid.amount = Math.min(tFluid.amount, getRealCapacity());
if (aBaseMetaTileEntity.addStackToSlot(
getOutputSlot(),
GT_Utility.getContainerForFilledItem(mInventory[getInputSlot()], true),
@@ -213,7 +271,8 @@ public abstract class GT_MetaTileEntity_DigitalTankBase extends GT_MetaTileEntit
} else {
if (tFluid.isFluidEqual(getFillableStack())) {
if ((((long) tFluid.amount + getFillableStack().amount) <= (long) getRealCapacity())
- || mVoidOverflow) {
+ || mVoidFluidPart
+ || mVoidFluidFull) {
if (aBaseMetaTileEntity.addStackToSlot(
getOutputSlot(),
GT_Utility.getContainerForFilledItem(mInventory[getInputSlot()], true),
@@ -264,12 +323,29 @@ public abstract class GT_MetaTileEntity_DigitalTankBase extends GT_MetaTileEntit
if (getFillableStack() == null) setFillableStack(fillableStack);
getBaseMetaTileEntity().markDirty();
}
- return mVoidOverflow ? aFluid.amount : amount;
+ return (mVoidFluidPart || mVoidFluidFull) ? aFluid.amount : amount;
}
@Override
- public final byte getUpdateData() {
- return 0x00;
+ public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) {
+ super.onPostTick(aBaseMetaTileEntity, aTick);
+ if (aBaseMetaTileEntity.isServerSide()) {
+ if (mOutputFluid && getDrainableStack() != null && (aTick % 20 == 0)) {
+ IFluidHandler tTank = aBaseMetaTileEntity.getITankContainerAtSide(aBaseMetaTileEntity.getFrontFacing());
+ if (tTank != null) {
+ FluidStack tDrained = drain(commonSizeCompute(mTier) / 100, false);
+ if (tDrained != null) {
+ int tFilledAmount = tTank.fill(
+ ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()), tDrained, false);
+ if (tFilledAmount > 0)
+ tTank.fill(
+ ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()),
+ drain(tFilledAmount, true),
+ true);
+ }
+ }
+ }
+ }
}
@Override
@@ -278,6 +354,26 @@ public abstract class GT_MetaTileEntity_DigitalTankBase extends GT_MetaTileEntit
}
@Override
+ public boolean isInputFacing(byte aSide) {
+ return mAllowInputFromOutputSide || aSide != getBaseMetaTileEntity().getFrontFacing();
+ }
+
+ @Override
+ public boolean isOutputFacing(byte aSide) {
+ return false;
+ }
+
+ @Override
+ public boolean isLiquidInput(byte aSide) {
+ return mAllowInputFromOutputSide || aSide != getBaseMetaTileEntity().getFrontFacing();
+ }
+
+ @Override
+ public boolean isLiquidOutput(byte aSide) {
+ return aSide != getBaseMetaTileEntity().getFrontFacing();
+ }
+
+ @Override
public boolean isAccessAllowed(EntityPlayer aPlayer) {
return true;
}
@@ -289,7 +385,7 @@ public abstract class GT_MetaTileEntity_DigitalTankBase extends GT_MetaTileEntit
@Override
public int getCapacity() {
- return mVoidOverflow ? Integer.MAX_VALUE : getRealCapacity();
+ return (mVoidFluidPart || mVoidFluidFull) ? Integer.MAX_VALUE : getRealCapacity();
}
public int getRealCapacity() {