Fixed more items being consumed than needed

This commit is contained in:
Robert Seifert 2013-05-25 00:32:24 -04:00
parent 653253ceff
commit a912b4de1b
3 changed files with 20 additions and 29 deletions

View file

@ -354,11 +354,14 @@ public class AutoCraftingManager
{
return null;
}
ItemStack stack = itemStack.copy();
if (stack.getItem() instanceof ItemBucket && stack.itemID != Item.bucketEmpty.itemID)
{
return new ItemStack(Item.bucketEmpty, 1);
}
if (stack.getItem().hasContainerItem())
{
ItemStack containerStack = stack.getItem().getContainerItemStack(stack);
@ -381,6 +384,7 @@ public class AutoCraftingManager
return containerStack;
}
}
System.out.println("ItemGrinder: "+stack.toString());
return this.decrStackSize(stack, amount);
}
@ -389,22 +393,25 @@ public class AutoCraftingManager
*
* @param requiredItems - items that are to be removed
*/
public void consumeItems(final ItemStack... requiredItems)
public void consumeItems(ItemStack... requiredItems)
{
for (ItemStack searchStack : requiredItems)
if (requiredItems != null)
{
if (searchStack != null)
for (ItemStack searchStack : requiredItems)
{
int[] invSlots = ((IAutoCrafter) this.craftingEntity).getCraftingInv();
for (int i = 0; i < invSlots.length; i++)
if (searchStack != null)
{
ItemStack checkStack = this.craftingInv.getStackInSlot(invSlots[i]);
if (checkStack != null)
int[] invSlots = ((IAutoCrafter) this.craftingEntity).getCraftingInv();
for (int i = 0; i < invSlots.length; i++)
{
if (this.areStacksEqual(searchStack, checkStack))
ItemStack checkStack = this.craftingInv.getStackInSlot(invSlots[i]);
if (checkStack != null)
{
this.craftingInv.setInventorySlotContents(invSlots[i], this.consumeItem(searchStack, 1));
break;
if (this.areStacksEqual(searchStack, checkStack))
{
this.craftingInv.setInventorySlotContents(invSlots[i], this.consumeItem(checkStack, 1));
break;
}
}
}
}

View file

@ -116,7 +116,7 @@ public class BlockImprinter extends BlockALMachine
itemStack.stackSize -= var11;
if (i != inventory.imprinterMatrix.length + TileEntityImprinter.IMPRINTER_MATRIX_START - 1)
if (i != inventory.craftingOutputSlot)
{
EntityItem entityItem = new EntityItem(par1World, (x + var8), (y + var9), (z + var10), new ItemStack(itemStack.itemID, var11, itemStack.getItemDamage()));

View file

@ -33,7 +33,7 @@ import com.google.common.io.ByteArrayDataInput;
import dark.library.helpers.Pair;
import dark.library.inv.ISlotPickResult;
public class TileEntityImprinter extends TileEntityAdvanced implements net.minecraftforge.common.ISidedInventory, ISidedInventory, IArmbotUseable, IPacketReceiver, ISlotPickResult, IAutoCrafter
public class TileEntityImprinter extends TileEntityAdvanced implements ISidedInventory, IArmbotUseable, IPacketReceiver, ISlotPickResult, IAutoCrafter
{
public static final int IMPRINTER_MATRIX_START = 9;
public static final int INVENTORY_START = IMPRINTER_MATRIX_START + 3;
@ -377,11 +377,7 @@ public class TileEntityImprinter extends TileEntityAdvanced implements net.minec
if (idealRecipeItem != null)
{
ItemStack[] requiredItems = idealRecipeItem.getValue().clone();
if (requiredItems != null)
{
this.getCraftingManager().consumeItems(requiredItems);
}
this.getCraftingManager().consumeItems(idealRecipeItem.getValue().clone());
}
}
}
@ -562,18 +558,6 @@ public class TileEntityImprinter extends TileEntityAdvanced implements net.minec
return this.isStackValidForSlot(slot, itemstack);
}
@Override
public int getStartInventorySide(ForgeDirection side)
{
return this.craftingMatrix.length + this.imprinterMatrix.length;
}
@Override
public int getSizeInventorySide(ForgeDirection side)
{
return this.containingItems.length - 1;
}
@Override
public int[] getCraftingInv()
{