Recursive crafting works.

MA's can accept pushes.
Interfaces no alter pushing behavior depending on ICraftingMachine settings.
Fixed bug where crafting would record items that don't exist as available for the initial pull.
This commit is contained in:
AlgorithmX2
2014-06-20 02:12:39 -05:00
parent fea125a993
commit 6cbc5aa953
6 changed files with 64 additions and 28 deletions
+2 -1
View File
@@ -1,6 +1,7 @@
package appeng.crafting;
import appeng.api.storage.data.IAEItemStack;
import appeng.util.Platform;
public class CraftBranchFailure extends Exception
{
@@ -10,7 +11,7 @@ public class CraftBranchFailure extends Exception
IAEItemStack missing;
public CraftBranchFailure(IAEItemStack what, long howMany) {
super( "this should have been caught!" );
super( "Failed: " + Platform.getItemDisplayName( what ) + " x " + howMany );
missing = what.copy();
missing.setStackSize( howMany );
}
+8 -1
View File
@@ -31,6 +31,7 @@ public class CraftingJob implements Runnable
boolean simulate = false;
final MECraftingInventory original;
final MECraftingInventory availableCheck;
public CraftingTreeNode tree;
private BaseActionSource actionSrc;
@@ -45,6 +46,12 @@ public class CraftingJob implements Runnable
storage = AEApi.instance().storage().createItemList();
prophecies = new HashSet();
original = null;
availableCheck = null;
}
public IAEItemStack checkUse(IAEItemStack available)
{
return availableCheck.extractItems( available, Actionable.MODULATE, this.actionSrc );
}
public CraftingJob(ICraftingHost host, IAEItemStack what, Actionable mode) {
@@ -57,7 +64,7 @@ public class CraftingJob implements Runnable
CraftingCache cc = host.getGrid().getCache( CraftingCache.class );
IStorageGrid sg = host.getGrid().getCache( IStorageGrid.class );
original = new MECraftingInventory( sg.getItemInventory(), false, false, false );
availableCheck = new MECraftingInventory( sg.getItemInventory(), false, false, false );
tree = getCraftingTree( cc, what );
}
+4 -2
View File
@@ -32,6 +32,7 @@ public class CraftingTreeNode
boolean cannotUse = false;
long missing = 0;
CraftingJob job;
IItemList<IAEItemStack> used = AEApi.instance().storage().createItemList();
boolean exhausted = false;
@@ -42,6 +43,7 @@ public class CraftingTreeNode
parent = par;
this.slot = slot;
this.world = job.jobHost.getWorld();
this.job = job;
sim = false;
for (ICraftingPatternDetails details : cc.getCraftingFor( what ))// in order.
@@ -90,7 +92,7 @@ public class CraftingTreeNode
if ( available != null )
{
if ( !exhausted )
used.add( available );
used.add( job.checkUse( available ) );
l -= available.getStackSize();
if ( l == 0 )
@@ -106,7 +108,7 @@ public class CraftingTreeNode
if ( available != null )
{
if ( !exhausted )
used.add( available );
used.add( job.checkUse( available ) );
l -= available.getStackSize();
if ( l == 0 )