aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/gregtech/api
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/gregtech/api')
-rw-r--r--src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Item.java2
-rw-r--r--src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine.java16
-rw-r--r--src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Buffer.java4
-rw-r--r--src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_OutputBus.java11
-rw-r--r--src/main/java/gregtech/api/util/GT_Multiblock_Tooltip_Builder.java348
-rw-r--r--src/main/java/gregtech/api/util/GT_Utility.java104
6 files changed, 473 insertions, 12 deletions
diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Item.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Item.java
index 650e9a031e..c73e95e95b 100644
--- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Item.java
+++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Item.java
@@ -270,7 +270,7 @@ public class GT_MetaPipeEntity_Item extends MetaPipeEntity implements IMetaTileE
TileEntity tInventory = getBaseMetaTileEntity().getTileEntityAtSide(aSide);
if (tInventory != null && !(tInventory instanceof BaseMetaPipeEntity)) {
if ((!(tInventory instanceof TileEntityHopper) && !(tInventory instanceof TileEntityDispenser)) || getBaseMetaTileEntity().getMetaIDAtSide(aSide) != GT_Utility.getOppositeSide(aSide)) {
- return GT_Utility.moveOneItemStack(aSender, tInventory, (byte) 6, GT_Utility.getOppositeSide(aSide), null, false, (byte) 64, (byte) 1, (byte) 64, (byte) 1) > 0;
+ return GT_Utility.moveMultipleItemStacks(aSender, tInventory, (byte) 6, GT_Utility.getOppositeSide(aSide), null, false, (byte) 64, (byte) 1, (byte) 64, (byte) 1,1) > 0;
}
}
}
diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine.java
index 97daa6fc71..2c632c596b 100644
--- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine.java
+++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine.java
@@ -32,6 +32,7 @@ import java.util.Arrays;
import static gregtech.api.enums.GT_Values.V;
import static gregtech.api.enums.GT_Values.debugCleanroom;
+import static gregtech.api.util.GT_Utility.moveMultipleItemStacks;
/**
* NEVER INCLUDE THIS FILE IN YOUR MOD!!!
@@ -510,10 +511,17 @@ public abstract class GT_MetaTileEntity_BasicMachine extends GT_MetaTileEntity_B
if (doesAutoOutput() && !isOutputEmpty() && aBaseMetaTileEntity.getFrontFacing() != mMainFacing && (tSucceeded || mOutputBlocked % 300 == 1 || aBaseMetaTileEntity.hasInventoryBeenModified() || aTick % 600 == 0)) {
TileEntity tTileEntity2 = aBaseMetaTileEntity.getTileEntityAtSide(aBaseMetaTileEntity.getFrontFacing());
- for (int i = 0, tCosts = 1; i < mOutputItems.length && tCosts > 0 && aBaseMetaTileEntity.isUniversalEnergyStored(128); i++) {
- tCosts = GT_Utility.moveOneItemStack(aBaseMetaTileEntity, tTileEntity2, aBaseMetaTileEntity.getFrontFacing(), aBaseMetaTileEntity.getBackFacing(), null, false, (byte) 64, (byte) 1, (byte) 64, (byte) 1);
- if (tCosts > 0) aBaseMetaTileEntity.decreaseStoredEnergyUnits(tCosts, true);
- }
+ long tStoredEnergy = aBaseMetaTileEntity.getUniversalEnergyStored();
+ int tMaxStacks = (int)(tStoredEnergy/64l);
+ if (tMaxStacks > mOutputItems.length)
+ tMaxStacks = mOutputItems.length;
+
+ int tCost = moveMultipleItemStacks(aBaseMetaTileEntity, tTileEntity2, aBaseMetaTileEntity.getFrontFacing(), aBaseMetaTileEntity.getBackFacing(), null, false, (byte) 64, (byte) 1, (byte) 64, (byte) 1,tMaxStacks);
+ aBaseMetaTileEntity.decreaseStoredEnergyUnits(tCost, true);
+// for (int i = 0, tCosts = 1; i < mOutputItems.length && tCosts > 0 && aBaseMetaTileEntity.isUniversalEnergyStored(128); i++) {
+// tCosts = GT_Utility.moveOneItemStack(aBaseMetaTileEntity, tTileEntity2, aBaseMetaTileEntity.getFrontFacing(), aBaseMetaTileEntity.getBackFacing(), null, false, (byte) 64, (byte) 1, (byte) 64, (byte) 1);
+// if (tCosts > 0) aBaseMetaTileEntity.decreaseStoredEnergyUnits(tCosts, true);
+// }
}
if (mOutputBlocked != 0) if (isOutputEmpty()) mOutputBlocked = 0;
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 645836a801..7284cd3c01 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
@@ -259,9 +259,9 @@ public abstract class GT_MetaTileEntity_Buffer extends GT_MetaTileEntity_TieredM
protected void moveItems(IGregTechTileEntity aBaseMetaTileEntity, long aTimer) {
int tCost;
if( bStockingMode )
- 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);
+ tCost = GT_Utility.moveMultipleItemStacks(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,1);
else
- 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);
+ tCost = GT_Utility.moveMultipleItemStacks(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,1);
if (tCost > 0 || aBaseMetaTileEntity.hasInventoryBeenModified()) {
mSuccess = 50;
diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_OutputBus.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_OutputBus.java
index 6c56ac6a74..1dafbcce5a 100644
--- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_OutputBus.java
+++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_OutputBus.java
@@ -12,6 +12,8 @@ import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
+import static gregtech.api.util.GT_Utility.*;
+
public class GT_MetaTileEntity_Hatch_OutputBus extends GT_MetaTileEntity_Hatch {
public GT_MetaTileEntity_Hatch_OutputBus(int aID, String aName, String aNameRegional, int aTier) {
super(aID, aName, aNameRegional, aTier, getSlots(aTier), new String[]{"Item Output for Multiblocks",
@@ -112,10 +114,11 @@ public class GT_MetaTileEntity_Hatch_OutputBus extends GT_MetaTileEntity_Hatch {
if (aBaseMetaTileEntity.isServerSide() && aBaseMetaTileEntity.isAllowedToWork() && (aTick&0x7)==0) {
IInventory tTileEntity =aBaseMetaTileEntity.getIInventoryAtSide(aBaseMetaTileEntity.getFrontFacing());
if(tTileEntity!=null){
- for (ItemStack aMInventory : mInventory)
- GT_Utility.moveOneItemStack(aBaseMetaTileEntity, tTileEntity,
- aBaseMetaTileEntity.getFrontFacing(), aBaseMetaTileEntity.getBackFacing(),
- null, false, (byte) 64, (byte) 1, (byte) 64, (byte) 1);
+ moveMultipleItemStacks(aBaseMetaTileEntity,tTileEntity,aBaseMetaTileEntity.getFrontFacing(),aBaseMetaTileEntity.getBackFacing(),null,false,(byte)64,(byte)1,(byte)64,(byte)1,mInventory.length);
+
+// GT_Utility.moveOneItemStack(aBaseMetaTileEntity, tTileEntity,
+// aBaseMetaTileEntity.getFrontFacing(), aBaseMetaTileEntity.getBackFacing(),
+// null, false, (byte) 64, (byte) 1, (byte)( 64 * aBaseMetaTileEntity.getSizeInventory()), (byte) 1);
}
}
}
diff --git a/src/main/java/gregtech/api/util/GT_Multiblock_Tooltip_Builder.java b/src/main/java/gregtech/api/util/GT_Multiblock_Tooltip_Builder.java
new file mode 100644
index 0000000000..e30fe5d606
--- /dev/null
+++ b/src/main/java/gregtech/api/util/GT_Multiblock_Tooltip_Builder.java
@@ -0,0 +1,348 @@
+package gregtech.api.util;
+
+import java.util.LinkedList;
+import java.util.List;
+
+import net.minecraft.util.EnumChatFormatting;
+import net.minecraft.util.StatCollector;
+
+/**
+ * This makes it easier to build multi tooltips, with a standardized format. <br>
+ * Info section order should be:<br>
+ * addMachineType<br>
+ * addInfo, for what it does, special notes, etc.<br>
+ * addSeparator, if you need it<br>
+ * addPollutionAmount<br>
+ * <br>
+ * Structure order should be:<br>
+ * beginStructureBlock<br>
+ * addController<br>
+ * addCasingInfo<br>
+ * addOtherStructurePart, for secondary structure block info (pipes, coils, etc)<br>
+ * addEnergyHatch/addDynamoHatch<br>
+ * addMaintenanceHatch<br>
+ * addMufflerHatch<br>
+ * addInputBus/addInputHatch/addOutputBus/addOutputHatch, in that order<br>
+ * Use addStructureInfo for any comments on nonstandard structure info wherever needed
+ * <br>
+ * toolTipFinisher goes at the very end<br>
+ * <br>
+ * Originally created by kekzdealer
+ */
+public class GT_Multiblock_Tooltip_Builder {
+ private static final String TAB = " ";
+ private static final String COLON = ": ";
+
+ private final List<String> iLines;
+ private final List<String> sLines;
+
+ private String[] iArray;
+ private String[] sArray;
+
+ //Localized tooltips
+ private static final String TT_machineType = StatCollector.translateToLocal("GT5U.MBTT.MachineType");
+ private static final String TT_dimensions = StatCollector.translateToLocal("GT5U.MBTT.Dimensions");
+ private static final String TT_hollow = StatCollector.translateToLocal("GT5U.MBTT.Hollow");
+ private static final String TT_structure = StatCollector.translateToLocal("GT5U.MBTT.Structure");
+ private static final String TT_controller = StatCollector.translateToLocal("GT5U.MBTT.Controller");
+ private static final String TT_minimum = StatCollector.translateToLocal("GT5U.MBTT.Minimum");
+ private static final String TT_maintenancehatch = StatCollector.translateToLocal("GT5U.MBTT.MaintenanceHatch");
+ private static final String TT_energyhatch = StatCollector.translateToLocal("GT5U.MBTT.EnergyHatch");
+ private static final String TT_dynamohatch = StatCollector.translateToLocal("GT5U.MBTT.DynamoHatch");
+ private static final String TT_mufflerhatch = StatCollector.translateToLocal("GT5U.MBTT.MufflerHatch");
+ private static final String TT_inputbus = StatCollector.translateToLocal("GT5U.MBTT.InputBus");
+ private static final String TT_inputhatch = StatCollector.translateToLocal("GT5U.MBTT.InputHatch");
+ private static final String TT_outputbus = StatCollector.translateToLocal("GT5U.MBTT.OutputBus");
+ private static final String TT_outputhatch = StatCollector.translateToLocal("GT5U.MBTT.OutputHatch");
+ private static final String TT_causes = StatCollector.translateToLocal("GT5U.MBTT.Causes");
+ private static final String TT_pps = StatCollector.translateToLocal("GT5U.MBTT.PPS");
+ private static final String TT_hold = StatCollector.translateToLocal("GT5U.MBTT.Hold");
+ private static final String TT_todisplay = StatCollector.translateToLocal("GT5U.MBTT.Display");
+ private static final String TT_mod = StatCollector.translateToLocal("GT5U.MBTT.Mod");
+
+ public GT_Multiblock_Tooltip_Builder() {
+ iLines = new LinkedList<>();
+ sLines = new LinkedList<>();
+ }
+
+ /**
+ * Add a line telling you what the machine type is. Usually, this will be the name of a SB version.<br>
+ * Machine Type: machine
+ *
+ * @param machine
+ * Name of the machine type
+ *
+ * @return Instance this method was called on.
+ */
+ public GT_Multiblock_Tooltip_Builder addMachineType(String machine) {
+ iLines.add(TT_machineType + COLON + EnumChatFormatting.YELLOW + machine + EnumChatFormatting.RESET);
+ return this;
+ }
+
+ /**
+ * Add a basic line of information about this structure
+ *
+ * @param info
+ * The line to be added.
+ * @return Instance this method was called on.
+ */
+ public GT_Multiblock_Tooltip_Builder addInfo(String info) {
+ iLines.add(info);
+ return this;
+ }
+
+ /**
+ * Add a separator line like this:<br>
+ * -----------------------------------------
+ *
+ * @return Instance this method was called on.
+ */
+ public GT_Multiblock_Tooltip_Builder addSeparator() {
+ iLines.add("-----------------------------------------");
+ return this;
+ }
+
+ /**
+ * Add a line telling you what the machine type is. Usually, this will be the name of a SB version.<br>
+ * Machine Type: machine
+ *
+ * @param machine
+ * Name of the machine type
+ *
+ * @return Instance this method was called on.
+ */
+ public GT_Multiblock_Tooltip_Builder addPollutionAmount(int pollution) {
+ iLines.add(TT_causes + COLON + EnumChatFormatting.DARK_PURPLE + pollution + " " + EnumChatFormatting.GRAY + TT_pps);
+ return this;
+ }
+
+ /**
+ * Begin adding structural information by adding a line about the structure's dimensions
+ * and then inserting a "Structure:" line.
+ *
+ * @param w
+ * Structure width.
+ * @param h
+ * Structure height.
+ * @param l
+ * Structure depth/length.
+ * @param hollow
+ * T/F, adds a (hollow) comment if true
+ * @return Instance this method was called on.
+ */
+ public GT_Multiblock_Tooltip_Builder beginStructureBlock(int w, int h, int l, boolean hollow) {
+ if (hollow) {
+ sLines.add(TT_dimensions + COLON + w + "x" + h + "x" + l + " (WxHxL) " + TT_hollow);
+ }
+ else {
+ sLines.add(TT_dimensions + COLON + w + "x" + h + "x" + l + " (WxHxL)");
+ }
+ sLines.add(TT_structure + COLON);
+ return this;
+ }
+
+ /**
+ * Begin adding structural information by adding a line about the structure's dimensions<br>
+ * and then inserting a "Structure:" line. Variable version displays min and max
+ *
+ * @param wmin
+ * Structure min width.
+ * @param wmax
+ * Structure max width.
+ * @param hmin
+ * Structure min height.
+ * @param hmax
+ * Structure max height.
+ * @param lmin
+ * Structure min depth/length.
+ * @param lmax
+ * Structure max depth/length.
+ * @param hollow
+ * T/F, adds a (hollow) comment if true
+ * @return Instance this method was called on.
+ */
+ public GT_Multiblock_Tooltip_Builder beginVariableStructureBlock(int wmin, int wmax, int hmin, int hmax, int lmin, int lmax, boolean hollow) {
+ if (hollow) {
+ sLines.add(TT_dimensions + COLON + wmin + "-" + wmax + "x" + hmin + "-" + hmax + "x" + lmin + "-" + lmax + " (WxHxL) " + TT_hollow);
+ }
+ else {
+ sLines.add(TT_dimensions + COLON + wmin + "-" + wmax + "x" + hmin + "-" + hmax + "x" + lmin + "-" + lmax + " (WxHxL)");
+ }
+ sLines.add(TT_structure + COLON);
+ return this;
+ }
+
+ /**
+ * Add a line of information about the structure:<br>
+ * (indent)Controller: info
+ * @param info
+ * Positional information.
+ * @return Instance this method was called on.
+ */
+ public GT_Multiblock_Tooltip_Builder addController(String info) {
+ sLines.add(TAB + TT_controller + COLON + info);
+ return this;
+ }
+
+ /**
+ * Add a line of information about the structure:<br>
+ * (indent)minCountx casingName (minimum)
+ * @param casingName
+ * Name of the Casing.
+ * @param minCount
+ * Minimum needed for valid structure check.
+ * @return Instance this method was called on.
+ */
+ public GT_Multiblock_Tooltip_Builder addCasingInfo(String casingName, int minCount) {
+ sLines.add(TAB + minCount +"x " + casingName + " " + TT_minimum);
+ return this;
+ }
+
+ /**
+ * Use this method to add a structural part that isn't covered by the other methods.<br>
+ * (indent)name: info
+ * @param name
+ * Name of the hatch or other component.
+ * @param info
+ * Positional information.
+ * @return Instance this method was called on.
+ */
+ public GT_Multiblock_Tooltip_Builder addOtherStructurePart(String name, String info) {
+ sLines.add(TAB + name + COLON + info);
+ return this;
+ }
+
+ /**
+ * Add a line of information about the structure:<br>
+ * (indent)Maintenance Hatch: info
+ * @param info
+ * Positional information.
+ * @return Instance this method was called on.
+ */
+ public GT_Multiblock_Tooltip_Builder addMaintenanceHatch(String info) {
+ sLines.add(TAB + TT_maintenancehatch + COLON + info);
+ return this;
+ }
+
+ /**
+ * Add a line of information about the structure:<br>
+ * (indent)Muffler Hatch: info
+ * @param info
+ * Location where the hatch goes
+ * @return Instance this method was called on.
+ */
+ public GT_Multiblock_Tooltip_Builder addMufflerHatch(String info) {
+ sLines.add(TAB + TT_mufflerhatch + COLON + info);
+ return this;
+ }
+
+ /**
+ * Add a line of information about the structure:<br>
+ * (indent)Energy Hatch: info
+ * @param info
+ * Positional information.
+ * @return Instance this method was called on.
+ */
+ public GT_Multiblock_Tooltip_Builder addEnergyHatch(String info) {
+ sLines.add(TAB + TT_energyhatch + COLON + info);
+ return this;
+ }
+
+ /**
+ * Add a line of information about the structure:<br>
+ * (indent)Dynamo Hatch: info
+ * @param info
+ * Positional information.
+ * @return Instance this method was called on.
+ */
+ public GT_Multiblock_Tooltip_Builder addDynamoHatch(String info) {
+ sLines.add(TAB + TT_dynamohatch + COLON + info);
+ return this;
+ }
+
+ /**
+ * Add a line of information about the structure:<br>
+ * (indent)Input Bus: info
+ * @param info
+ * Location where the bus goes
+ * @return Instance this method was called on.
+ */
+ public GT_Multiblock_Tooltip_Builder addInputBus(String info) {
+ sLines.add(TAB + TT_inputbus + COLON + info);
+ return this;
+ }
+
+ /**
+ * Add a line of information about the structure:<br>
+ * (indent)Input Hatch: info
+ * @param info
+ * Location where the hatch goes
+ * @return Instance this method was called on.
+ */
+ public GT_Multiblock_Tooltip_Builder addInputHatch(String info) {
+ sLines.add(TAB + TT_inputhatch + COLON + info);
+ return this;
+ }
+
+ /**
+ * Add a line of information about the structure:<br>
+ * (indent)Output Bus: info
+ * @param info
+ * Location where the bus goes
+ * @return Instance this method was called on.
+ */
+ public GT_Multiblock_Tooltip_Builder addOutputBus(String info) {
+ sLines.add(TAB + TT_outputbus + COLON + info);
+ return this;
+ }
+
+ /**
+ * Add a line of information about the structure:<br>
+ * (indent)Output Hatch: info
+ * @param info
+ * Location where the bus goes
+ * @return Instance this method was called on.
+ */
+ public GT_Multiblock_Tooltip_Builder addOutputHatch(String info) {
+ sLines.add(TAB + TT_outputhatch + COLON + info);
+ return this;
+ }
+
+ /**
+ * Use this method to add non-standard structural info.<br>
+ * (indent)info
+ * @param info
+ * The line to be added.
+ * @return Instance this method was called on.
+ */
+ public GT_Multiblock_Tooltip_Builder addStructureInfo(String info) {
+ sLines.add(TAB + info);
+ return this;
+ }
+
+ /**
+ * Call at the very end.<br>
+ * Adds a final line with the mod name and information on how to display the structure guidelines.<br>
+ * Ends the building process.
+ *
+ * @param mod
+ * Name of the mod that adds this multiblock machine
+ */
+ public void toolTipFinisher(String mod) {
+ iLines.add(TT_hold + " " + EnumChatFormatting.BOLD + "[LSHIFT]" + EnumChatFormatting.RESET + EnumChatFormatting.GRAY + " " + TT_todisplay);
+ iLines.add(TT_mod + COLON + EnumChatFormatting.GREEN + mod + EnumChatFormatting.GRAY);
+ iArray = new String[iLines.size()];
+ sArray = new String[sLines.size()];
+ iLines.toArray(iArray);
+ sLines.toArray(sArray);
+ }
+
+ public String[] getInformation() {
+ return iArray;
+ }
+
+ public String[] getStructureInformation() {
+ return sArray;
+ }
+
+}
diff --git a/src/main/java/gregtech/api/util/GT_Utility.java b/src/main/java/gregtech/api/util/GT_Utility.java
index cf7b86fe94..b06cc1d82a 100644
--- a/src/main/java/gregtech/api/util/GT_Utility.java
+++ b/src/main/java/gregtech/api/util/GT_Utility.java
@@ -523,6 +523,108 @@ public class GT_Utility {
}
/**
+ * moves multiple stacks from Inv-Side to Inv-Side
+ *
+ * @return the Amount of moved Items
+ */
+
+ public static int moveMultipleItemStacks(Object aTileEntity1, Object aTileEntity2, byte aGrabFrom, byte aPutTo, List<ItemStack> aFilter, boolean aInvertFilter, byte aMaxTargetStackSize, byte aMinTargetStackSize, byte aMaxMoveAtOnce, byte aMinMoveAtOnce,int aStackAmount) {
+ if (aTileEntity1 instanceof IInventory)
+ return moveMultipleItemStacks((IInventory) aTileEntity1, aTileEntity2, aGrabFrom, aPutTo, aFilter, aInvertFilter, aMaxTargetStackSize, aMinTargetStackSize, aMaxMoveAtOnce, aMinMoveAtOnce,aStackAmount, true);
+ return 0;
+ }
+
+ public static int moveMultipleItemStacks(IInventory aTileEntity1, Object aTileEntity2, byte aGrabFrom, byte aPutTo, List<ItemStack> aFilter, boolean aInvertFilter, byte aMaxTargetStackSize, byte aMinTargetStackSize, byte aMaxMoveAtOnce, byte aMinMoveAtOnce,int aMaxStackTransfer, boolean aDoCheckChests) {
+ if (aTileEntity1 == null || aMaxTargetStackSize <= 0 || aMinTargetStackSize <= 0 || aMaxMoveAtOnce <= 0 || aMinTargetStackSize > aMaxTargetStackSize || aMinMoveAtOnce > aMaxMoveAtOnce || aMaxStackTransfer == 0)
+ return 0;
+ int tGrabInventorySize = aTileEntity1.getSizeInventory();
+ if (aTileEntity2 instanceof IInventory)
+ {
+ IInventory tPutInventory = (IInventory) aTileEntity2;
+ int tPutInventorySize = tPutInventory.getSizeInventory();
+ int tFirstsValidSlot = 0,tStacksMoved = 0,tTotalItemsMoved = 0;
+ for (int tGrabSlot = 0;tGrabSlot<tGrabInventorySize;tGrabSlot++)
+ {
+ //ItemStack tInventoryStack : mInventory
+ int tMovedItems = 0;
+ do {
+ ItemStack tGrabStack = aTileEntity1.getStackInSlot(tGrabSlot);
+ if (listContainsItem(aFilter, tGrabStack, true, aInvertFilter) &&
+ (tGrabStack.stackSize >= aMinMoveAtOnce && isAllowedToTakeFromSlot(aTileEntity1, tGrabSlot, aGrabFrom, tGrabStack))) {
+ int tStackSize = tGrabStack.stackSize;
+ tMovedItems = 0;
+ for (int tPutSlot = tFirstsValidSlot; tPutSlot < tPutInventorySize; tPutSlot++) {
+ if (isAllowedToPutIntoSlot(tPutInventory, tPutSlot, aPutTo, tGrabStack, (byte) 64)) {
+ int tMoved = moveStackFromSlotAToSlotB(aTileEntity1, tPutInventory, tGrabSlot, tPutSlot, aMaxTargetStackSize, aMinTargetStackSize, (byte) (aMaxMoveAtOnce - tMovedItems), aMinMoveAtOnce);
+ tTotalItemsMoved += tMoved;
+ tMovedItems += tMoved;
+ if (tMovedItems == tStackSize)
+ break;
+ }
+ }
+ if (tMovedItems > 0) {
+ if (++tStacksMoved >= aMaxStackTransfer)
+ return tTotalItemsMoved;
+ }
+ }
+ } while (tGrabInventorySize == 2 && tMovedItems > 0); //to suport draweres and barrels
+ }
+ if (aDoCheckChests && aTileEntity1 instanceof TileEntityChest) {
+ TileEntityChest tTileEntity1 = (TileEntityChest) aTileEntity1;
+ int tAmount = 0;
+ int maxStackTransfer = aMaxStackTransfer - tStacksMoved;
+ if (tTileEntity1.adjacentChestXNeg != null) {
+ tAmount = moveMultipleItemStacks(tTileEntity1.adjacentChestXNeg, aTileEntity2, aGrabFrom, aPutTo, aFilter, aInvertFilter, aMaxTargetStackSize, aMinTargetStackSize, aMaxMoveAtOnce, aMinMoveAtOnce,maxStackTransfer, false);
+ } else if (tTileEntity1.adjacentChestZNeg != null) {
+ tAmount = moveMultipleItemStacks(tTileEntity1.adjacentChestZNeg, aTileEntity2, aGrabFrom, aPutTo, aFilter, aInvertFilter, aMaxTargetStackSize, aMinTargetStackSize, aMaxMoveAtOnce, aMinMoveAtOnce,maxStackTransfer, false);
+ } else if (tTileEntity1.adjacentChestXPos != null) {
+ tAmount = moveMultipleItemStacks(tTileEntity1.adjacentChestXPos, aTileEntity2, aGrabFrom, aPutTo, aFilter, aInvertFilter, aMaxTargetStackSize, aMinTargetStackSize, aMaxMoveAtOnce, aMinMoveAtOnce,maxStackTransfer, false);
+ } else if (tTileEntity1.adjacentChestZPos != null) {
+ tAmount = moveMultipleItemStacks(tTileEntity1.adjacentChestZPos, aTileEntity2, aGrabFrom, aPutTo, aFilter, aInvertFilter, aMaxTargetStackSize, aMinTargetStackSize, aMaxMoveAtOnce, aMinMoveAtOnce,maxStackTransfer, false);
+ }
+ if (tAmount != 0) return tAmount+tTotalItemsMoved;
+ }
+
+ if (aDoCheckChests && aTileEntity2 instanceof TileEntityChest) {
+ TileEntityChest tTileEntity2 = (TileEntityChest) aTileEntity2;
+ if (tTileEntity2.adjacentChestChecked) {
+ int tAmount = 0;
+ int maxStackTransfer = aMaxStackTransfer - tStacksMoved;
+ if (tTileEntity2.adjacentChestXNeg != null) {
+ tAmount = moveMultipleItemStacks(aTileEntity1, tTileEntity2.adjacentChestXNeg, aGrabFrom, aPutTo, aFilter, aInvertFilter, aMaxTargetStackSize, aMinTargetStackSize, aMaxMoveAtOnce, aMinMoveAtOnce,maxStackTransfer, false);
+ } else if (tTileEntity2.adjacentChestZNeg != null) {
+ tAmount = moveMultipleItemStacks(aTileEntity1, tTileEntity2.adjacentChestZNeg, aGrabFrom, aPutTo, aFilter, aInvertFilter, aMaxTargetStackSize, aMinTargetStackSize, aMaxMoveAtOnce, aMinMoveAtOnce,maxStackTransfer, false);
+ } else if (tTileEntity2.adjacentChestXPos != null) {
+ tAmount = moveMultipleItemStacks(aTileEntity1, tTileEntity2.adjacentChestXPos, aGrabFrom, aPutTo, aFilter, aInvertFilter, aMaxTargetStackSize, aMinTargetStackSize, aMaxMoveAtOnce, aMinMoveAtOnce,maxStackTransfer, false);
+ } else if (tTileEntity2.adjacentChestZPos != null) {
+ tAmount = moveMultipleItemStacks(aTileEntity1, tTileEntity2.adjacentChestZPos, aGrabFrom, aPutTo, aFilter, aInvertFilter, aMaxTargetStackSize, aMinTargetStackSize, aMaxMoveAtOnce, aMinMoveAtOnce,maxStackTransfer, false);
+ }
+ if (tAmount != 0) return tAmount+tTotalItemsMoved;
+ }
+ }
+
+ return tTotalItemsMoved;
+
+ }
+ //there should be a function to transfer more then 1 stack in a pipe
+ //ut i dont see any ways to improve it too much work for what it is worth
+ int[] tGrabSlots = new int[tGrabInventorySize];
+ for (int i = 0; i < tGrabInventorySize; i++) {
+ tGrabSlots[i] = i;
+ }
+ int tTotalItemsMoved = 0;
+ for (int i = 0; i < tGrabInventorySize; i++) {
+ int tMoved = moveStackIntoPipe(aTileEntity1, aTileEntity2, tGrabSlots, aGrabFrom, aPutTo, aFilter, aInvertFilter, aMaxTargetStackSize, aMinTargetStackSize, aMaxMoveAtOnce, aMinMoveAtOnce, aDoCheckChests);
+ if (tMoved == 0)
+ return tTotalItemsMoved;
+ else
+ tTotalItemsMoved += tMoved;
+ }
+ return 0;
+ }
+
+
+ /**
* Moves Stack from Inv-Side to Inv-Side.
*
* @return the Amount of moved Items
@@ -539,7 +641,7 @@ public class GT_Utility {
private static byte moveOneItemStack(IInventory aTileEntity1, Object aTileEntity2, byte aGrabFrom, byte aPutTo, List<ItemStack> aFilter, boolean aInvertFilter, byte aMaxTargetStackSize, byte aMinTargetStackSize, byte aMaxMoveAtOnce, byte aMinMoveAtOnce, boolean aDoCheckChests) {
if (aTileEntity1 == null || aMaxTargetStackSize <= 0 || aMinTargetStackSize <= 0 || aMaxMoveAtOnce <= 0 || aMinTargetStackSize > aMaxTargetStackSize || aMinMoveAtOnce > aMaxMoveAtOnce)
return 0;
-
+
int[] tGrabSlots = null;
if (aTileEntity1 instanceof ISidedInventory)
tGrabSlots = ((ISidedInventory) aTileEntity1).getAccessibleSlotsFromSide(aGrabFrom);