Removed StackUtil from TileAutoWorkbench.java.

This commit is contained in:
SirSengir 2012-09-08 17:40:38 +02:00
parent d30717b271
commit 1e40b70649
2 changed files with 24 additions and 13 deletions

View file

@ -51,6 +51,16 @@ public class Utils {
public static final float pipeMaxPos = 0.75F;
public static float pipeNormalSpeed = 0.01F;
/**
* Tries to add the passed stack to any valid inventories around the given coordinates.
* @param stack
* @param world
* @param x
* @param y
* @param z
* @param from
* @return ItemStack representing what was added.
*/
public static ItemStack addToRandomInventory(ItemStack stack, World world, int x, int y, int z, Orientations from) {
LinkedList<ITransactor> possibleInventories = new LinkedList<ITransactor>();

View file

@ -14,7 +14,8 @@ import java.util.LinkedList;
import buildcraft.api.core.Orientations;
import buildcraft.api.core.Position;
import buildcraft.api.inventory.ISpecialInventory;
import buildcraft.core.utils.StackUtil;
import buildcraft.core.inventory.ITransactor;
import buildcraft.core.inventory.TransactorSimple;
import buildcraft.core.utils.Utils;
import net.minecraft.src.Container;
@ -283,7 +284,8 @@ public class TileAutoWorkbench extends TileEntity implements ISpecialInventory {
/* ISPECIALINVENTORY */
@Override
public int addItem(ItemStack stack, boolean doAdd, Orientations from) {
StackUtil stackUtils = new StackUtil(stack);
ITransactor transactor = new TransactorSimple(this);
int minSimilar = Integer.MAX_VALUE;
int minSlot = -1;
@ -299,18 +301,17 @@ public class TileAutoWorkbench extends TileEntity implements ISpecialInventory {
}
if (minSlot != -1) {
if (stackUtils.tryAdding(this, minSlot, doAdd, false)) {
if (doAdd && stack.stackSize != 0) {
addItem(stack, doAdd, from);
}
ItemStack added = transactor.add(stack, from, doAdd);
ItemStack remaining = stack.copy();
remaining.stackSize -= added.stackSize;
return stackUtils.itemsAdded;
} else {
return stackUtils.itemsAdded;
}
} else {
if(doAdd && remaining.stackSize >= 0)
added.stackSize += addItem(remaining, doAdd, from);
return added.stackSize;
} else
return 0;
}
}
@Override