{
if ( parent.details.isValidItemForSlot( slot, fuzz.getItemStack(), world ) )
{
fuzz = fuzz.copy();
fuzz.setStackSize( l );
IAEItemStack available = inv.extractItems( fuzz, Actionable.MODULATE, src );
if ( available != null )
{
if ( !exhausted )
{
IAEItemStack is = job.checkUse( available );
if ( is != null )
{
thingsUsed.add( is.copy() );
used.add( is );
}
}
bytes += available.getStackSize();
l -= available.getStackSize();
if ( l == 0 )
return available;
}
}
}
}
else
{
IAEItemStack available = inv.extractItems( what, Actionable.MODULATE, src );
if ( available != null )
{
if ( !exhausted )
{
IAEItemStack is = job.checkUse( available );
if ( is != null )
{
thingsUsed.add( is.copy() );
used.add( is );
}
}
bytes += available.getStackSize();
l -= available.getStackSize();
if ( l == 0 )
return available;
}
}
if ( canEmit )
{
IAEItemStack wat = what.copy();
wat.setStackSize( l );
howManyEmitted = wat.getStackSize();
bytes += wat.getStackSize();
return wat;
}
exhausted = true;
if ( nodes.size() == 1 )
{
CraftingTreeProcess pro = nodes.get( 0 );
while (pro.possible && l > 0)
{
IAEItemStack madeWhat = pro.getAmountCrafted( what );
pro.request( inv, pro.getTimes( l, madeWhat.getStackSize() ), src );
madeWhat.setStackSize( l );
IAEItemStack available = inv.extractItems( madeWhat, Actionable.MODULATE, src );
if ( available != null )
{
bytes += available.getStackSize();
l -= available.getStackSize();
if ( l <= 0 )
return available;
}
else
pro.possible = false; // ;P
}
}
else if ( nodes.size() > 1 )
{
for (CraftingTreeProcess pro : nodes)
{
try
{
while (pro.possible && l > 0)
{
MECraftingInventory subInv = new MECraftingInventory( inv, true, true, true );
pro.request( subInv, 1, src );
what.setStackSize( l );
IAEItemStack available = subInv.extractItems( what, Actionable.MODULATE, src );
if ( available != null )
{
if ( !subInv.commit( src ) )
throw new CraftBranchFailure( what, l );
bytes += available.getStackSize();
l -= available.getStackSize();
if ( l <= 0 )
return available;
}
else
pro.possible = false; // ;P
}
}
catch (CraftBranchFailure fail)
{
pro.possible = true;
}
}
}
if ( sim )
{
missing += l;
bytes += l;
IAEItemStack rv = what.copy();
rv.setStackSize( l );
return rv;
}
for (IAEItemStack o : thingsUsed)
{