This commit is contained in:
PrototypeTrousers
2022-03-27 01:39:32 -03:00
parent 234b1c5dc6
commit d054c6ab91
3 changed files with 43 additions and 24 deletions
@@ -145,14 +145,6 @@ public class CraftingTreeNode
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() )
{
Collection<IAEItemStack> itemList = new ArrayList<>();
@@ -170,6 +170,11 @@ public class CraftingTreeProcess
{
final IAEItemStack stack = entry.getKey().request( inv, hasContainerItem ? 1 : entry.getValue(), src );
if( stack.equals( job.getOutput() ) )
{
job.getNeededForLoop().add( stack.copy() );
}
if( stack.getItem().hasContainerItem( stack.getDefinition() ) )
{
final ItemStack is = Platform.getContainerItem( stack.createItemStack() );
@@ -287,17 +287,28 @@ public final class CraftingCPUCluster implements IAECluster, ICraftingCPU
if( this.finalOutput.equals( what ) )
{
IAEItemStack isLoop = neededForLoop.findPrecise( finalOutput );
if( isLoop != null && isLoop.getStackSize() > 0 )
{
isLoop.decStackSize( what.getStackSize() );
return this.inventory.injectItems( what, type, src );
}
IAEItemStack leftover = what;
this.finalOutput.decStackSize( what.getStackSize() );
if( isLoop != null && isLoop.getStackSize() > 0 )
{
if( isLoop.getStackSize() >= what.getStackSize() )
{
leftover = this.inventory.injectItems( what.copy(), type, src );
isLoop.decStackSize( what.getStackSize() );
}
else
{
leftover = this.inventory.injectItems( what.copy().setStackSize( what.getStackSize() - isLoop.getStackSize() ), type, src );
isLoop.decStackSize( what.getStackSize() - isLoop.getStackSize() );
}
if( leftover == null )
{
return null;
}
}
this.finalOutput.decStackSize( leftover.getStackSize() );
if( this.myLastLink != null )
{
@@ -327,17 +338,28 @@ public final class CraftingCPUCluster implements IAECluster, ICraftingCPU
if( this.finalOutput.equals( insert ) )
{
IAEItemStack isLoop = neededForLoop.findPrecise( finalOutput );
if( isLoop != null && isLoop.getStackSize() > 0 )
{
isLoop.decStackSize( insert.getStackSize() );
return this.inventory.injectItems( insert, type, src );
}
IAEItemStack leftover = input;
this.finalOutput.decStackSize( insert.getStackSize() );
if( isLoop != null && isLoop.getStackSize() > 0 )
{
if( isLoop.getStackSize() >= insert.getStackSize() )
{
leftover = this.inventory.injectItems( insert.copy(), type, src );
isLoop.decStackSize( insert.getStackSize() );
}
else
{
leftover = this.inventory.injectItems( insert.copy().setStackSize( insert.getStackSize() - isLoop.getStackSize() ), type, src );
isLoop.decStackSize( insert.getStackSize() - isLoop.getStackSize() );
}
if( leftover == null )
{
return null;
}
}
this.finalOutput.decStackSize( leftover.getStackSize() );
if( this.myLastLink != null )
{