From e0ebec1a609281fb8e14d6116eab6386c2cfe8d0 Mon Sep 17 00:00:00 2001 From: AlgorithmX2 Date: Thu, 12 Jun 2014 09:18:39 -0500 Subject: [PATCH] Umm crafting calculation needs some thought... --- crafting/CraftingJob.java | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/crafting/CraftingJob.java b/crafting/CraftingJob.java index 5f8a38d1..f317f382 100644 --- a/crafting/CraftingJob.java +++ b/crafting/CraftingJob.java @@ -100,11 +100,26 @@ public class CraftingJob implements ICraftingParent } } - private void extractItems(IAEItemStack[] requirements, IMEInventory inv, IItemList storage2, IItemList missing) + private void extractItems(IAEItemStack[] requirements, IMEInventory inv, IItemList dest, IItemList missing) { for (IAEItemStack is : requirements) { - inv.extractItems( is, Actionable.MODULATE, jobHost.getActionSrc() ); + IAEItemStack avail = inv.extractItems( is, Actionable.MODULATE, jobHost.getActionSrc() ); + + if ( avail == null ) + { + missing.add( is ); + continue; + } + + if ( avail.getStackSize() != is.getStackSize() ) + { + IAEItemStack ais = avail.copy(); + ais.setStackSize( is.getStackSize() - avail.getStackSize() ); + missing.add( ais ); + } + + dest.add( avail ); } } @@ -114,6 +129,12 @@ public class CraftingJob implements ICraftingParent for (IAEItemStack is : requirements) { IAEItemStack avail = inv.extractItems( is, Actionable.SIMULATE, jobHost.getActionSrc() ); + + if ( avail == null ) + return false; + + if ( avail.getStackSize() != is.getStackSize() ) + return false; } return true;