meh. crafting gets stuck if the output loops
This commit is contained in:
@@ -129,7 +129,7 @@ public class CraftingJob implements Runnable, ICraftingJob
|
|||||||
|
|
||||||
public void reserve( CraftingTreeNode node, IAEItemStack stack )
|
public void reserve( CraftingTreeNode node, IAEItemStack stack )
|
||||||
{
|
{
|
||||||
checkUse( stack );
|
this.checkUse( stack );
|
||||||
reserved.put( node, stack );
|
reserved.put( node, stack );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -156,6 +156,8 @@ public class CraftingJob implements Runnable, ICraftingJob
|
|||||||
final MECraftingInventory craftingInventory = new MECraftingInventory( this.original, true, false, true );
|
final MECraftingInventory craftingInventory = new MECraftingInventory( this.original, true, false, true );
|
||||||
|
|
||||||
this.availableCheck = new MECraftingInventory( this.original, false, false, false );
|
this.availableCheck = new MECraftingInventory( this.original, false, false, false );
|
||||||
|
this.reserved.values().forEach( availableCheck::reserve );
|
||||||
|
|
||||||
craftingTreeWatch.start();
|
craftingTreeWatch.start();
|
||||||
this.getTree().request( craftingInventory, this.output.getStackSize(), this.actionSrc );
|
this.getTree().request( craftingInventory, this.output.getStackSize(), this.actionSrc );
|
||||||
craftingTreeWatch.stop();
|
craftingTreeWatch.stop();
|
||||||
@@ -185,9 +187,11 @@ public class CraftingJob implements Runnable, ICraftingJob
|
|||||||
if( actionSrc.player().isPresent() )
|
if( actionSrc.player().isPresent() )
|
||||||
{
|
{
|
||||||
final MECraftingInventory craftingInventory = new MECraftingInventory( this.original, true, false, true );
|
final MECraftingInventory craftingInventory = new MECraftingInventory( this.original, true, false, true );
|
||||||
|
|
||||||
this.getTree().setSimulate();
|
this.getTree().setSimulate();
|
||||||
|
|
||||||
this.availableCheck = new MECraftingInventory( this.original, false, false, false );
|
this.availableCheck = new MECraftingInventory( this.original, false, false, false );
|
||||||
|
this.reserved.values().forEach( availableCheck::reserve );
|
||||||
|
|
||||||
craftingTreeWatch.reset().start();
|
craftingTreeWatch.reset().start();
|
||||||
this.getTree().request( craftingInventory, this.output.getStackSize(), this.actionSrc );
|
this.getTree().request( craftingInventory, this.output.getStackSize(), this.actionSrc );
|
||||||
craftingTreeWatch.stop();
|
craftingTreeWatch.stop();
|
||||||
|
|||||||
@@ -56,6 +56,7 @@ public class CraftingTreeNode
|
|||||||
private final ArrayList<CraftingTreeProcess> nodes = new ArrayList<>();
|
private final ArrayList<CraftingTreeProcess> nodes = new ArrayList<>();
|
||||||
private final boolean canEmit;
|
private final boolean canEmit;
|
||||||
private CraftingTreeNode loopHead;
|
private CraftingTreeNode loopHead;
|
||||||
|
private int times;
|
||||||
private int bytes = 0;
|
private int bytes = 0;
|
||||||
private long missing = 0;
|
private long missing = 0;
|
||||||
private long howManyEmitted = 0;
|
private long howManyEmitted = 0;
|
||||||
@@ -88,14 +89,6 @@ public class CraftingTreeNode
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for( IAEItemStack i : details.getCondensedInputs() )
|
|
||||||
{
|
|
||||||
if( i.equals( job.getOutput() ) )
|
|
||||||
{
|
|
||||||
job.getNeededForLoop().add( i.copy().setStackSize( i.getStackSize() * times ) );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if( this.parent == null )
|
if( this.parent == null )
|
||||||
{
|
{
|
||||||
this.nodes.add( new CraftingTreeProcess( cc, job, details, times, this ) );
|
this.nodes.add( new CraftingTreeProcess( cc, job, details, times, this ) );
|
||||||
@@ -115,7 +108,7 @@ public class CraftingTreeNode
|
|||||||
|
|
||||||
void reserveForNode()
|
void reserveForNode()
|
||||||
{
|
{
|
||||||
if( loopHead == this )
|
if( this.equals( loopHead ) )
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -152,6 +145,14 @@ public class CraftingTreeNode
|
|||||||
|
|
||||||
this.what.setStackSize( l );
|
this.what.setStackSize( l );
|
||||||
|
|
||||||
|
if( parent != null )
|
||||||
|
{
|
||||||
|
if( this.what.equals( job.getOutput() ) )
|
||||||
|
{
|
||||||
|
job.getNeededForLoop().add( this.what.copy() );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if( this.getSlot() >= 0 && this.parent != null && this.parent.details.isCraftable() )
|
if( this.getSlot() >= 0 && this.parent != null && this.parent.details.isCraftable() )
|
||||||
{
|
{
|
||||||
Collection<IAEItemStack> itemList = new ArrayList<>();
|
Collection<IAEItemStack> itemList = new ArrayList<>();
|
||||||
@@ -203,7 +204,16 @@ public class CraftingTreeNode
|
|||||||
fuzz = fuzz.copy();
|
fuzz = fuzz.copy();
|
||||||
fuzz.setStackSize( l );
|
fuzz.setStackSize( l );
|
||||||
|
|
||||||
final IAEItemStack available = inv.extractItems( fuzz, Actionable.MODULATE, src );
|
final IAEItemStack available;
|
||||||
|
|
||||||
|
if( reserved != null )
|
||||||
|
{
|
||||||
|
available = reserved;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
available = inv.extractItems( fuzz, Actionable.MODULATE, src );
|
||||||
|
}
|
||||||
|
|
||||||
if( available != null )
|
if( available != null )
|
||||||
{
|
{
|
||||||
@@ -216,6 +226,11 @@ public class CraftingTreeNode
|
|||||||
thingsUsed.add( is.copy() );
|
thingsUsed.add( is.copy() );
|
||||||
this.used.add( is );
|
this.used.add( is );
|
||||||
}
|
}
|
||||||
|
else if( reserved != null )
|
||||||
|
{
|
||||||
|
thingsUsed.add( reserved.copy() );
|
||||||
|
this.used.add( reserved );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.bytes += available.getStackSize();
|
this.bytes += available.getStackSize();
|
||||||
@@ -231,28 +246,37 @@ public class CraftingTreeNode
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
final IAEItemStack available = inv.extractItems( this.what, Actionable.MODULATE, src );
|
final IAEItemStack available;
|
||||||
|
|
||||||
|
if( parent == null && this.what.equals( job.getOutput() ) )
|
||||||
|
{
|
||||||
|
available = null;
|
||||||
|
}
|
||||||
|
else if( reserved != null )
|
||||||
|
{
|
||||||
|
available = reserved;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
available = inv.extractItems( this.what, Actionable.MODULATE, src );
|
||||||
|
}
|
||||||
|
|
||||||
if( available != null )
|
if( available != null )
|
||||||
{
|
{
|
||||||
if( !this.exhausted )
|
if( !this.exhausted )
|
||||||
{
|
{
|
||||||
IAEItemStack is;
|
final IAEItemStack is = this.job.checkUse( available );
|
||||||
|
|
||||||
if( reserved != null )
|
|
||||||
{
|
|
||||||
is = reserved;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
is = this.job.checkUse( available );
|
|
||||||
}
|
|
||||||
|
|
||||||
if( is != null )
|
if( is != null )
|
||||||
{
|
{
|
||||||
thingsUsed.add( is.copy() );
|
thingsUsed.add( is.copy() );
|
||||||
this.used.add( is );
|
this.used.add( is );
|
||||||
}
|
}
|
||||||
|
else if( reserved != null )
|
||||||
|
{
|
||||||
|
thingsUsed.add( reserved.copy() );
|
||||||
|
this.used.add( reserved );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.bytes += available.getStackSize();
|
this.bytes += available.getStackSize();
|
||||||
|
|||||||
@@ -349,6 +349,24 @@ public class MECraftingInventory implements IMEInventory<IAEItemStack>
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ignore( final IAEItemStack what )
|
||||||
|
{
|
||||||
|
final IAEItemStack list = this.localCache.findPrecise( what );
|
||||||
|
if( list != null )
|
||||||
|
{
|
||||||
|
list.setStackSize( 0 );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void reserve( final IAEItemStack what )
|
||||||
|
{
|
||||||
|
final IAEItemStack list = this.localCache.findPrecise( what );
|
||||||
|
if( list != null )
|
||||||
|
{
|
||||||
|
list.decStackSize( what.getStackSize() );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void addMissing( final IAEItemStack extra )
|
private void addMissing( final IAEItemStack extra )
|
||||||
{
|
{
|
||||||
this.missingCache.add( extra );
|
this.missingCache.add( extra );
|
||||||
|
|||||||
@@ -283,16 +283,15 @@ public class AEItemStack extends AEStack<IAEItemStack> implements IAEItemStack
|
|||||||
{
|
{
|
||||||
if( this.cachedItemStack != null )
|
if( this.cachedItemStack != null )
|
||||||
{
|
{
|
||||||
ItemStack currentCached = this.cachedItemStack;
|
if( Platform.itemComparisons().isSameItem( this.getDefinition(), this.cachedItemStack ) )
|
||||||
this.cachedItemStack = null;
|
{
|
||||||
currentCached.setCount( Ints.saturatedCast( stackSize ) );
|
ItemStack currentCached = this.cachedItemStack;
|
||||||
return currentCached;
|
this.cachedItemStack = null;
|
||||||
|
currentCached.setCount( Ints.saturatedCast( stackSize ) );
|
||||||
|
return currentCached;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
return ItemHandlerHelper.copyStackWithSize( this.getDefinition(), Ints.saturatedCast( stackSize ) );
|
||||||
ItemStack itemStack = this.createItemStack();
|
|
||||||
itemStack.setCount( Ints.saturatedCast( stackSize ) );
|
|
||||||
|
|
||||||
return itemStack;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user