diff --git a/crafting/CraftingTreeNode.java b/crafting/CraftingTreeNode.java index 84d76491..3cd36bec 100644 --- a/crafting/CraftingTreeNode.java +++ b/crafting/CraftingTreeNode.java @@ -49,7 +49,8 @@ public class CraftingTreeNode this.job = job; sim = false; - for (ICraftingPatternDetails details : cc.getCraftingFor( what ))// in order. + for (ICraftingPatternDetails details : cc.getCraftingFor( what, parent == null ? null : parent.details, slot, world ))// in + // order. { if ( parent == null || parent.notRecurive( details ) ) nodes.add( new CraftingTreeProcess( cc, job, details, this, depth + 1, world ) ); @@ -151,10 +152,12 @@ public class CraftingTreeNode while (pro.possible && l > 0) { - pro.request( inv, pro.getTimes( l, pro.getAmountCrafted( what ).getStackSize() ), src ); + IAEItemStack madeWhat = pro.getAmountCrafted( what ); - what.setStackSize( l ); - IAEItemStack available = inv.extractItems( what, Actionable.MODULATE, src ); + pro.request( inv, pro.getTimes( l, madeWhat.getStackSize() ), src ); + + madeWhat.setStackSize( l ); + IAEItemStack available = inv.extractItems( madeWhat, Actionable.MODULATE, src ); if ( available != null ) { diff --git a/crafting/CraftingTreeProcess.java b/crafting/CraftingTreeProcess.java index 10324473..9b15414a 100644 --- a/crafting/CraftingTreeProcess.java +++ b/crafting/CraftingTreeProcess.java @@ -137,6 +137,17 @@ public class CraftingTreeProcess } } + // more fuzzy! + for (IAEItemStack is : details.getCondencedOutputs()) + { + if ( is.getItem() == what2.getItem() && (is.getItem().isDamageable() || is.getItemDamage() == what2.getItemDamage()) ) + { + what2 = is.copy(); + what2.setStackSize( is.getStackSize() ); + return what2; + } + } + throw new RuntimeException( "Crafting Tree construction failed." ); } diff --git a/me/cache/CraftingGridCache.java b/me/cache/CraftingGridCache.java index 230f9f25..d51b8df5 100644 --- a/me/cache/CraftingGridCache.java +++ b/me/cache/CraftingGridCache.java @@ -448,11 +448,30 @@ public class CraftingGridCache implements ICraftingGrid, ICraftingProviderHelper return 0; } - public ImmutableCollection getCraftingFor(IAEItemStack what) + @Override + public ImmutableCollection getCraftingFor(IAEItemStack whatToCraft, ICraftingPatternDetails details, int slotIndex, World world) { - ImmutableSet res = craftableItems.get( what ); + ImmutableSet res = craftableItems.get( whatToCraft ); + if ( res == null ) + { + if ( details != null && details.isCraftable() ) + { + for (IAEItemStack ais : craftableItems.keySet()) + { + if ( ais.getItem() == whatToCraft.getItem() && (!ais.getItem().getHasSubtypes() || ais.getItemDamage() == whatToCraft.getItemDamage()) ) + { + if ( details.isValidItemForSlot( slotIndex, ais.getItemStack(), world ) ) + { + return craftableItems.get( ais ); + } + } + } + } + return ImmutableSet.of(); + } + return res; } diff --git a/util/Platform.java b/util/Platform.java index c11bf1cb..cbe784c0 100644 --- a/util/Platform.java +++ b/util/Platform.java @@ -1640,7 +1640,9 @@ public class Platform ci.setInventorySlotContents( slot, cp ); if ( r.matches( ci, w ) && Platform.isSameItem( r.getCraftingResult( ci ), output ) ) { - IAEItemStack ex = src.extractItems( AEItemStack.create( cp ), realForFake, mySrc ); + IAEItemStack ax = x.copy(); + ax.setStackSize( 1 ); + IAEItemStack ex = src.extractItems( ax, realForFake, mySrc ); if ( ex != null ) { energySrc.extractAEPower( 1, realForFake, PowerMultiplier.CONFIG );