From d4625eb0284863725f4d978283ad8296ef89b502 Mon Sep 17 00:00:00 2001 From: Richard Hendricks Date: Wed, 20 Jun 2018 02:12:04 -0500 Subject: New feature for chestbuffers/superbuffers:Transfer size mode. Instead of matching the output inventory, this mode will only transfer fixed sizes to output invetory. Useful for input hatches to Amazon Packager or PA filled with packagers. --- .../implementations/GT_MetaTileEntity_Buffer.java | 22 ++++++++++++++++----- .../java/gregtech/api/util/GT_LanguageManager.java | 4 +++- .../common/gui/GT_Container_ChestBuffer.java | 10 ++++++++++ .../common/gui/GT_Container_SuperBuffer.java | 10 ++++++++++ .../assets/gregtech/textures/gui/ChestBuffer.png | Bin 4084 -> 4515 bytes .../assets/gregtech/textures/gui/SuperBuffer.png | Bin 6053 -> 7635 bytes 6 files changed, 40 insertions(+), 6 deletions(-) diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Buffer.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Buffer.java index e0f7037cdf..73ab28822a 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Buffer.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Buffer.java @@ -12,7 +12,7 @@ import net.minecraft.nbt.NBTTagCompound; import static gregtech.api.enums.GT_Values.V; public abstract class GT_MetaTileEntity_Buffer extends GT_MetaTileEntity_TieredMachineBlock { - public boolean bOutput = false, bRedstoneIfFull = false, bInvert = false; + public boolean bOutput = false, bRedstoneIfFull = false, bInvert = false, bStockingMode = true; public int mSuccess = 0, mTargetStackSize = 0; public GT_MetaTileEntity_Buffer(int aID, String aName, String aNameRegional, int aTier, int aInvSlotCount, String aDescription) { @@ -192,6 +192,7 @@ public abstract class GT_MetaTileEntity_Buffer extends GT_MetaTileEntity_TieredM aNBT.setBoolean("bInvert", bInvert); aNBT.setBoolean("bOutput", bOutput); aNBT.setBoolean("bRedstoneIfFull", bRedstoneIfFull); + aNBT.setBoolean("bStockingMode", bStockingMode); aNBT.setInteger("mTargetStackSize", mTargetStackSize); } @@ -200,6 +201,9 @@ public abstract class GT_MetaTileEntity_Buffer extends GT_MetaTileEntity_TieredM bInvert = aNBT.getBoolean("bInvert"); bOutput = aNBT.getBoolean("bOutput"); bRedstoneIfFull = aNBT.getBoolean("bRedstoneIfFull"); + if (aNBT.hasKey("bStockingMode")) { // Adding new key to existing NBT, need to protect if it is not there. + bStockingMode = aNBT.getBoolean("bStockingMode"); + } mTargetStackSize = aNBT.getInteger("mTargetStackSize"); } @@ -253,10 +257,18 @@ public abstract class GT_MetaTileEntity_Buffer extends GT_MetaTileEntity_TieredM } protected void moveItems(IGregTechTileEntity aBaseMetaTileEntity, long aTimer) { - int tCost = GT_Utility.moveOneItemStack(aBaseMetaTileEntity, aBaseMetaTileEntity.getTileEntityAtSide(aBaseMetaTileEntity.getBackFacing()), aBaseMetaTileEntity.getBackFacing(), aBaseMetaTileEntity.getFrontFacing(), null, false, mTargetStackSize == 0 ? 64 : (byte) mTargetStackSize, mTargetStackSize == 0 ? 1 : (byte) mTargetStackSize, (byte) 64, (byte) 1); - if (tCost > 0 || aBaseMetaTileEntity.hasInventoryBeenModified()) { - mSuccess = 50; - aBaseMetaTileEntity.decreaseStoredEnergyUnits(Math.abs(tCost), true); + if( bStockingMode ) { + int tCost = GT_Utility.moveOneItemStack(aBaseMetaTileEntity, aBaseMetaTileEntity.getTileEntityAtSide(aBaseMetaTileEntity.getBackFacing()), aBaseMetaTileEntity.getBackFacing(), aBaseMetaTileEntity.getFrontFacing(), null, false, mTargetStackSize == 0 ? 64 : (byte) mTargetStackSize, mTargetStackSize == 0 ? 1 : (byte) mTargetStackSize, (byte) 64, (byte) 1); + if (tCost > 0 || aBaseMetaTileEntity.hasInventoryBeenModified()) { + mSuccess = 50; + aBaseMetaTileEntity.decreaseStoredEnergyUnits(Math.abs(tCost), true); + } + } else { + int tCost = GT_Utility.moveOneItemStack(aBaseMetaTileEntity, aBaseMetaTileEntity.getTileEntityAtSide(aBaseMetaTileEntity.getBackFacing()), aBaseMetaTileEntity.getBackFacing(), aBaseMetaTileEntity.getFrontFacing(), null, false, (byte) 64, (byte) 1, mTargetStackSize == 0 ? 64 : (byte) mTargetStackSize, mTargetStackSize == 0 ? 1 : (byte) mTargetStackSize); + if (tCost > 0 || aBaseMetaTileEntity.hasInventoryBeenModified()) { + mSuccess = 50; + aBaseMetaTileEntity.decreaseStoredEnergyUnits(Math.abs(tCost), true); + } } } diff --git a/src/main/java/gregtech/api/util/GT_LanguageManager.java b/src/main/java/gregtech/api/util/GT_LanguageManager.java index 08b1ec6a2a..96877deb26 100644 --- a/src/main/java/gregtech/api/util/GT_LanguageManager.java +++ b/src/main/java/gregtech/api/util/GT_LanguageManager.java @@ -323,6 +323,8 @@ public class GT_LanguageManager { addStringLocalization("Interaction_DESCRIPTION_Index_214", "Connected"); addStringLocalization("Interaction_DESCRIPTION_Index_215", "Disconnected"); addStringLocalization("Interaction_DESCRIPTION_Index_216", "Deprecated Recipe"); + addStringLocalization("Interaction_DESCRIPTION_Index_217", "Stocking mode. Keeps this many items in destination input slots."); + addStringLocalization("Interaction_DESCRIPTION_Index_218", "Transfer size mode. Add exactly this many items in destination input slots as long as there is room."); addStringLocalization("Interaction_DESCRIPTION_Index_500", "Fitting: Loose - More Flow"); addStringLocalization("Interaction_DESCRIPTION_Index_501", "Fitting: Tight - More Efficiency"); @@ -349,4 +351,4 @@ public class GT_LanguageManager { addStringLocalization("Item_DESCRIPTION_Index_501", "Optimal Steam flow (Loose): %s L/t"); } -} \ No newline at end of file +} diff --git a/src/main/java/gregtech/common/gui/GT_Container_ChestBuffer.java b/src/main/java/gregtech/common/gui/GT_Container_ChestBuffer.java index 4ea3fed295..016d0889f7 100644 --- a/src/main/java/gregtech/common/gui/GT_Container_ChestBuffer.java +++ b/src/main/java/gregtech/common/gui/GT_Container_ChestBuffer.java @@ -25,6 +25,7 @@ public class GT_Container_ChestBuffer addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 27, 8, 63, false, true, 1)); addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 27, 26, 63, false, true, 1)); addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 27, 44, 63, false, true, 1)); + addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 27, 62, 63, false, true, 1)); } public ItemStack slotClick(int aSlotIndex, int aMouseclick, int aShifthold, EntityPlayer aPlayer) { @@ -63,6 +64,15 @@ public class GT_Container_ChestBuffer } return null; } + if (aSlotIndex == 30) { + ((GT_MetaTileEntity_ChestBuffer) this.mTileEntity.getMetaTileEntity()).bStockingMode = (!((GT_MetaTileEntity_ChestBuffer) this.mTileEntity.getMetaTileEntity()).bStockingMode); + if (((GT_MetaTileEntity_ChestBuffer) this.mTileEntity.getMetaTileEntity()).bStockingMode) { + GT_Utility.sendChatToPlayer(aPlayer, trans("217","Stocking mode. Keeps this many items in destination input slots.")); + } else { + GT_Utility.sendChatToPlayer(aPlayer, trans("218", "Transfer size mode. Add exactly this many items in destination input slots as long as there is room.")); + } + return null; + } } return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); } diff --git a/src/main/java/gregtech/common/gui/GT_Container_SuperBuffer.java b/src/main/java/gregtech/common/gui/GT_Container_SuperBuffer.java index 3a0bd80bf3..5a59cb5aa9 100644 --- a/src/main/java/gregtech/common/gui/GT_Container_SuperBuffer.java +++ b/src/main/java/gregtech/common/gui/GT_Container_SuperBuffer.java @@ -20,6 +20,7 @@ public class GT_Container_SuperBuffer addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 256, 8, 63, false, true, 1)); addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 256, 26, 63, false, true, 1)); addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 256, 44, 63, false, true, 1)); + addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 256, 62, 63, false, true, 1)); } public ItemStack slotClick(int aSlotIndex, int aMouseclick, int aShifthold, EntityPlayer aPlayer) { @@ -58,6 +59,15 @@ public class GT_Container_SuperBuffer } return null; } + if (aSlotIndex == 3) { + ((GT_MetaTileEntity_ChestBuffer) this.mTileEntity.getMetaTileEntity()).bStockingMode = (!((GT_MetaTileEntity_ChestBuffer) this.mTileEntity.getMetaTileEntity()).bStockingMode); + if (((GT_MetaTileEntity_ChestBuffer) this.mTileEntity.getMetaTileEntity()).bStockingMode) { + GT_Utility.sendChatToPlayer(aPlayer, trans("217","Stocking mode. Keeps this many items in destination input slots.")); + } else { + GT_Utility.sendChatToPlayer(aPlayer, trans("218", "Transfer size mode. Add exactly this many items in destination input slots as long as there is room.")); + } + return null; + } } return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); } diff --git a/src/main/resources/assets/gregtech/textures/gui/ChestBuffer.png b/src/main/resources/assets/gregtech/textures/gui/ChestBuffer.png index bb66203449..448f09f4b7 100644 Binary files a/src/main/resources/assets/gregtech/textures/gui/ChestBuffer.png and b/src/main/resources/assets/gregtech/textures/gui/ChestBuffer.png differ diff --git a/src/main/resources/assets/gregtech/textures/gui/SuperBuffer.png b/src/main/resources/assets/gregtech/textures/gui/SuperBuffer.png index 6d133e13fb..d6bcef70b6 100644 Binary files a/src/main/resources/assets/gregtech/textures/gui/SuperBuffer.png and b/src/main/resources/assets/gregtech/textures/gui/SuperBuffer.png differ -- cgit