diff options
author | Johannes Gäßler <updrn@student.kit.edu> | 2017-08-06 12:05:08 +0200 |
---|---|---|
committer | Dream-Master <dream-master@gmx.net> | 2017-08-06 12:24:53 +0200 |
commit | 95982ffeec1cfb23ef04a3279ce333f06ad5c49e (patch) | |
tree | 2bb5fabaedf1861af07c4b6d681f484678b9e8fc /src/main/java/gregtech/api | |
parent | f1be666f5f0e71d0dd311d865f6f03ec6459f60a (diff) | |
download | GT5-Unofficial-95982ffeec1cfb23ef04a3279ce333f06ad5c49e.tar.gz GT5-Unofficial-95982ffeec1cfb23ef04a3279ce333f06ad5c49e.tar.bz2 GT5-Unofficial-95982ffeec1cfb23ef04a3279ce333f06ad5c49e.zip |
Fluid can now also be locked via cells, added a chat message
Diffstat (limited to 'src/main/java/gregtech/api')
3 files changed, 30 insertions, 4 deletions
diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicTank.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicTank.java index 6d301ebd22..f4a70b2ee5 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicTank.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicTank.java @@ -145,6 +145,7 @@ public abstract class GT_MetaTileEntity_BasicTank extends GT_MetaTileEntity_Tier if (isFluidInputAllowed(tFluid) && tFluid.amount <= getCapacity()) { if (aBaseMetaTileEntity.addStackToSlot(getOutputSlot(), GT_Utility.getContainerItem(mInventory[getInputSlot()], true), 1)) { setFillableStack(tFluid.copy()); + this.onEmptyingContainerWhenEmpty(); aBaseMetaTileEntity.decrStackSize(getInputSlot(), 1); } } @@ -256,4 +257,8 @@ public abstract class GT_MetaTileEntity_BasicTank extends GT_MetaTileEntity_Tier public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { return aIndex == getInputSlot(); } + + protected void onEmptyingContainerWhenEmpty(){ + //Do nothing + } }
\ No newline at end of file diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Output.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Output.java index 445bd340e8..204be8e373 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Output.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Output.java @@ -11,12 +11,12 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.common.util.ForgeDirection; -import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.IFluidHandler; public class GT_MetaTileEntity_Hatch_Output extends GT_MetaTileEntity_Hatch { private String lockedFluidName = null; + private EntityPlayer playerThatLockedfluid = null; public byte mMode = 0; public GT_MetaTileEntity_Hatch_Output(int aID, String aName, String aNameRegional, int aTier) { @@ -167,30 +167,40 @@ public class GT_MetaTileEntity_Hatch_Output extends GT_MetaTileEntity_Hatch { switch (mMode) { case 0: GT_Utility.sendChatToPlayer(aPlayer, trans("108","Outputs misc. Fluids, Steam and Items")); + this.setLockedFluidName(null); break; case 1: GT_Utility.sendChatToPlayer(aPlayer, trans("109","Outputs Steam and Items")); + this.setLockedFluidName(null); break; case 2: GT_Utility.sendChatToPlayer(aPlayer, trans("110","Outputs Steam and misc. Fluids")); + this.setLockedFluidName(null); break; case 3: GT_Utility.sendChatToPlayer(aPlayer, trans("111","Outputs Steam")); + this.setLockedFluidName(null); break; case 4: GT_Utility.sendChatToPlayer(aPlayer, trans("112","Outputs misc. Fluids and Items")); + this.setLockedFluidName(null); break; case 5: GT_Utility.sendChatToPlayer(aPlayer, trans("113","Outputs only Items")); + this.setLockedFluidName(null); break; case 6: GT_Utility.sendChatToPlayer(aPlayer, trans("114","Outputs only misc. Fluids")); + this.setLockedFluidName(null); break; case 7: GT_Utility.sendChatToPlayer(aPlayer, trans("115","Outputs nothing")); + this.setLockedFluidName(null); break; case 8: + playerThatLockedfluid = aPlayer; if (mFluid == null) { + this.setLockedFluidName(null); inBrackets = trans("115.3","currently none, will be locked to the next that is put in"); } else { this.setLockedFluidName(this.getDrainableStack().getUnlocalizedName()); @@ -199,7 +209,9 @@ public class GT_MetaTileEntity_Hatch_Output extends GT_MetaTileEntity_Hatch { GT_Utility.sendChatToPlayer(aPlayer, String.format("%s (%s)", trans("151.1", "Outputs items and 1 specific Fluid"), inBrackets)); break; case 9: + playerThatLockedfluid = aPlayer; if (mFluid == null) { + this.setLockedFluidName(null); inBrackets = trans("115.3","currently none, will be locked to the next that is put in"); } else { this.setLockedFluidName(this.getDrainableStack().getUnlocalizedName()); @@ -242,4 +254,12 @@ public class GT_MetaTileEntity_Hatch_Output extends GT_MetaTileEntity_Hatch { public int getTankPressure() { return +100; } + + @Override + protected void onEmptyingContainerWhenEmpty() { + if (this.lockedFluidName == null && this.mFluid != null) { + this.setLockedFluidName(this.mFluid.getUnlocalizedName()); + GT_Utility.sendChatToPlayer(playerThatLockedfluid, String.format(trans("151.4","Sucessfully locked Fluid to %s"), mFluid.getLocalizedName())); + } + } } diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java index 582a1a5a62..5afb46e1e4 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java @@ -601,11 +601,12 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity { } int tAmount = tHatch.fill(copiedFluidStack, false); if (tAmount >= copiedFluidStack.amount) { - tHatch.setLockedFluidName(copiedFluidStack.getUnlocalizedName()); - return tHatch.fill(copiedFluidStack, true) >= copiedFluidStack.amount; + boolean filled = tHatch.fill(copiedFluidStack, true) >= copiedFluidStack.amount; + tHatch.onEmptyingContainerWhenEmpty(); + return filled; } else if (tAmount > 0) { - tHatch.setLockedFluidName(copiedFluidStack.getUnlocalizedName()); copiedFluidStack.amount = copiedFluidStack.amount - tHatch.fill(copiedFluidStack, true); + tHatch.onEmptyingContainerWhenEmpty(); } } return false; |