final variables and parameters

This commit is contained in:
thatsIch
2015-09-30 14:24:40 +02:00
parent 059523f543
commit 8b3a954f73
732 changed files with 9253 additions and 9256 deletions
@@ -29,7 +29,7 @@ public class CraftBranchFailure extends Exception
final IAEItemStack missing;
public CraftBranchFailure( IAEItemStack what, long howMany )
public CraftBranchFailure( final IAEItemStack what, final long howMany )
{
super( "Failed: " + what.getItem().getUnlocalizedName() + " x " + howMany );
this.missing = what.copy();
@@ -29,7 +29,7 @@ public class CraftingCalculationFailure extends RuntimeException
final IAEItemStack missing;
public CraftingCalculationFailure( IAEItemStack what, long howMany )
public CraftingCalculationFailure( final IAEItemStack what, final long howMany )
{
super( "this should have been caught!" );
this.missing = what.copy();
+30 -30
View File
@@ -67,7 +67,7 @@ public class CraftingJob implements Runnable, ICraftingJob
private int time = 5;
private int incTime = Integer.MAX_VALUE;
public CraftingJob( World w, NBTTagCompound data )
public CraftingJob( final World w, final NBTTagCompound data )
{
this.world = this.wrapWorld( w );
this.storage = AEApi.instance().storage().createItemList();
@@ -76,12 +76,12 @@ public class CraftingJob implements Runnable, ICraftingJob
this.availableCheck = null;
}
private World wrapWorld( World w )
private World wrapWorld( final World w )
{
return w;
}
public CraftingJob( World w, IGrid grid, BaseActionSource actionSrc, IAEItemStack what, ICraftingCallback callback )
public CraftingJob( final World w, final IGrid grid, final BaseActionSource actionSrc, final IAEItemStack what, final ICraftingCallback callback )
{
this.world = this.wrapWorld( w );
this.output = what.copy();
@@ -90,35 +90,35 @@ public class CraftingJob implements Runnable, ICraftingJob
this.actionSrc = actionSrc;
this.callback = callback;
ICraftingGrid cc = grid.getCache( ICraftingGrid.class );
IStorageGrid sg = grid.getCache( IStorageGrid.class );
final ICraftingGrid cc = grid.getCache( ICraftingGrid.class );
final IStorageGrid sg = grid.getCache( IStorageGrid.class );
this.original = new MECraftingInventory( sg.getItemInventory(), actionSrc, false, false, false );
this.tree = this.getCraftingTree( cc, what );
this.availableCheck = null;
}
private CraftingTreeNode getCraftingTree( ICraftingGrid cc, IAEItemStack what )
private CraftingTreeNode getCraftingTree( final ICraftingGrid cc, final IAEItemStack what )
{
return new CraftingTreeNode( cc, this, what, null, -1, 0 );
}
public void refund( IAEItemStack o )
public void refund( final IAEItemStack o )
{
this.availableCheck.injectItems( o, Actionable.MODULATE, this.actionSrc );
}
public IAEItemStack checkUse( IAEItemStack available )
public IAEItemStack checkUse( final IAEItemStack available )
{
return this.availableCheck.extractItems( available, Actionable.MODULATE, this.actionSrc );
}
public void writeToNBT( NBTTagCompound out )
public void writeToNBT( final NBTTagCompound out )
{
}
public void addTask( IAEItemStack what, long crafts, ICraftingPatternDetails details, int depth )
public void addTask( IAEItemStack what, final long crafts, final ICraftingPatternDetails details, final int depth )
{
if( crafts > 0 )
{
@@ -144,18 +144,18 @@ public class CraftingJob implements Runnable, ICraftingJob
TickHandler.INSTANCE.registerCraftingSimulation( this.world, this );
this.handlePausing();
Stopwatch timer = Stopwatch.createStarted();
final Stopwatch timer = Stopwatch.createStarted();
MECraftingInventory craftingInventory = new MECraftingInventory( this.original, true, false, true );
final MECraftingInventory craftingInventory = new MECraftingInventory( this.original, true, false, true );
craftingInventory.ignore( this.output );
this.availableCheck = new MECraftingInventory( this.original, false, false, false );
this.tree.request( craftingInventory, this.output.getStackSize(), this.actionSrc );
this.tree.dive( this );
for( String s : this.opsAndMultiplier.keySet() )
for( final String s : this.opsAndMultiplier.keySet() )
{
TwoIntegers ti = this.opsAndMultiplier.get( s );
final TwoIntegers ti = this.opsAndMultiplier.get( s );
AELog.crafting( s + " * " + ti.times + " = " + ( ti.perOp * ti.times ) );
}
@@ -163,14 +163,14 @@ public class CraftingJob implements Runnable, ICraftingJob
// if ( mode == Actionable.MODULATE )
// craftingInventory.moveItemsToStorage( storage );
}
catch( CraftBranchFailure e )
catch( final CraftBranchFailure e )
{
this.simulate = true;
try
{
Stopwatch timer = Stopwatch.createStarted();
MECraftingInventory craftingInventory = new MECraftingInventory( this.original, true, false, true );
final Stopwatch timer = Stopwatch.createStarted();
final MECraftingInventory craftingInventory = new MECraftingInventory( this.original, true, false, true );
craftingInventory.ignore( this.output );
this.availableCheck = new MECraftingInventory( this.original, false, false, false );
@@ -179,34 +179,34 @@ public class CraftingJob implements Runnable, ICraftingJob
this.tree.request( craftingInventory, this.output.getStackSize(), this.actionSrc );
this.tree.dive( this );
for( String s : this.opsAndMultiplier.keySet() )
for( final String s : this.opsAndMultiplier.keySet() )
{
TwoIntegers ti = this.opsAndMultiplier.get( s );
final TwoIntegers ti = this.opsAndMultiplier.get( s );
AELog.crafting( s + " * " + ti.times + " = " + ( ti.perOp * ti.times ) );
}
AELog.crafting( "------------- " + this.bytes + "b simulate" + timer.elapsed( TimeUnit.MILLISECONDS ) + "ms" );
}
catch( CraftBranchFailure e1 )
catch( final CraftBranchFailure e1 )
{
AELog.error( e1 );
}
catch( CraftingCalculationFailure f )
catch( final CraftingCalculationFailure f )
{
AELog.error( f );
}
catch( InterruptedException e1 )
catch( final InterruptedException e1 )
{
AELog.crafting( "Crafting calculation canceled." );
this.finish();
return;
}
}
catch( CraftingCalculationFailure f )
catch( final CraftingCalculationFailure f )
{
AELog.error( f );
}
catch( InterruptedException e1 )
catch( final InterruptedException e1 )
{
AELog.crafting( "Crafting calculation canceled." );
this.finish();
@@ -215,7 +215,7 @@ public class CraftingJob implements Runnable, ICraftingJob
this.log( "crafting job now done" );
}
catch( Throwable t )
catch( final Throwable t )
{
this.finish();
throw new IllegalStateException( t );
@@ -277,7 +277,7 @@ public class CraftingJob implements Runnable, ICraftingJob
}
}
private void log( String string )
private void log( final String string )
{
// AELog.crafting( string );
}
@@ -295,7 +295,7 @@ public class CraftingJob implements Runnable, ICraftingJob
}
@Override
public void populatePlan( IItemList<IAEItemStack> plan )
public void populatePlan( final IItemList<IAEItemStack> plan )
{
if( this.tree != null )
{
@@ -326,7 +326,7 @@ public class CraftingJob implements Runnable, ICraftingJob
*
* @return true if this needs more simulation
*/
public boolean simulateFor( int milli )
public boolean simulateFor( final int milli )
{
this.time = milli;
@@ -351,7 +351,7 @@ public class CraftingJob implements Runnable, ICraftingJob
{
this.monitor.wait();
}
catch( InterruptedException ignored )
catch( final InterruptedException ignored )
{
}
}
@@ -362,7 +362,7 @@ public class CraftingJob implements Runnable, ICraftingJob
return true;
}
public void addBytes( long crafts )
public void addBytes( final long crafts )
{
this.bytes += crafts;
}
@@ -38,7 +38,7 @@ public class CraftingLink implements ICraftingLink
boolean done = false;
CraftingLinkNexus tie;
public CraftingLink( NBTTagCompound data, ICraftingRequester req )
public CraftingLink( final NBTTagCompound data, final ICraftingRequester req )
{
this.CraftID = data.getString( "CraftID" );
this.canceled = data.getBoolean( "canceled" );
@@ -54,7 +54,7 @@ public class CraftingLink implements ICraftingLink
this.cpu = null;
}
public CraftingLink( NBTTagCompound data, ICraftingCPU cpu )
public CraftingLink( final NBTTagCompound data, final ICraftingCPU cpu )
{
this.CraftID = data.getString( "CraftID" );
this.canceled = data.getBoolean( "canceled" );
@@ -137,7 +137,7 @@ public class CraftingLink implements ICraftingLink
}
@Override
public void writeToNBT( NBTTagCompound tag )
public void writeToNBT( final NBTTagCompound tag )
{
tag.setString( "CraftID", this.CraftID );
tag.setBoolean( "canceled", this.canceled );
@@ -152,7 +152,7 @@ public class CraftingLink implements ICraftingLink
return this.CraftID;
}
public void setNexus( CraftingLinkNexus n )
public void setNexus( final CraftingLinkNexus n )
{
if( this.tie != null )
{
@@ -174,7 +174,7 @@ public class CraftingLink implements ICraftingLink
}
}
public IAEItemStack injectItems( IAEItemStack input, Actionable mode )
public IAEItemStack injectItems( final IAEItemStack input, final Actionable mode )
{
if( this.tie == null || this.tie.req == null || this.tie.req.req == null )
{
@@ -34,12 +34,12 @@ public class CraftingLinkNexus
CraftingLink req;
CraftingLink cpu;
public CraftingLinkNexus( String craftID )
public CraftingLinkNexus( final String craftID )
{
this.CraftID = craftID;
}
public boolean isDead( IGrid g, CraftingGridCache craftingGridCache )
public boolean isDead( final IGrid g, final CraftingGridCache craftingGridCache )
{
if( this.canceled || this.done )
{
@@ -52,8 +52,8 @@ public class CraftingLinkNexus
}
else
{
boolean hasCpu = craftingGridCache.hasCpu( this.cpu.cpu );
boolean hasMachine = this.req.req.getActionableNode().getGrid() == g;
final boolean hasCpu = craftingGridCache.hasCpu( this.cpu.cpu );
final boolean hasMachine = this.req.req.getActionableNode().getGrid() == g;
if( hasCpu && hasMachine )
{
@@ -93,7 +93,7 @@ public class CraftingLinkNexus
}
}
public void remove( CraftingLink craftingLink )
public void remove( final CraftingLink craftingLink )
{
if( this.req == craftingLink )
{
@@ -105,7 +105,7 @@ public class CraftingLinkNexus
}
}
public void add( CraftingLink craftingLink )
public void add( final CraftingLink craftingLink )
{
if( craftingLink.cpu != null )
{
@@ -146,7 +146,7 @@ public class CraftingLinkNexus
}
}
public boolean isMachine( IGridHost machine )
public boolean isMachine( final IGridHost machine )
{
return this.req == machine;
}
@@ -58,7 +58,7 @@ public class CraftingTreeNode
boolean sim;
public CraftingTreeNode( ICraftingGrid cc, CraftingJob job, IAEItemStack wat, CraftingTreeProcess par, int slot, int depth )
public CraftingTreeNode( final ICraftingGrid cc, final CraftingJob job, final IAEItemStack wat, final CraftingTreeProcess par, final int slot, final int depth )
{
this.what = wat;
this.parent = par;
@@ -73,7 +73,7 @@ public class CraftingTreeNode
return; // if you can emit for something, you can't make it with patterns.
}
for( ICraftingPatternDetails details : cc.getCraftingFor( this.what, this.parent == null ? null : this.parent.details, slot, this.world ) )// in
for( final ICraftingPatternDetails details : cc.getCraftingFor( this.what, this.parent == null ? null : this.parent.details, slot, this.world ) )// in
// order.
{
if( this.parent == null || this.parent.notRecursive( details ) )
@@ -83,10 +83,10 @@ public class CraftingTreeNode
}
}
boolean notRecursive( ICraftingPatternDetails details )
boolean notRecursive( final ICraftingPatternDetails details )
{
IAEItemStack[] o = details.getCondensedOutputs();
for( IAEItemStack i : o )
for( final IAEItemStack i : o )
{
if( i.equals( this.what ) )
{
@@ -95,7 +95,7 @@ public class CraftingTreeNode
}
o = details.getCondensedInputs();
for( IAEItemStack i : o )
for( final IAEItemStack i : o )
{
if( i.equals( this.what ) )
{
@@ -111,11 +111,11 @@ public class CraftingTreeNode
return this.parent.notRecursive( details );
}
public IAEItemStack request( MECraftingInventory inv, long l, BaseActionSource src ) throws CraftBranchFailure, InterruptedException
public IAEItemStack request( final MECraftingInventory inv, long l, final BaseActionSource src ) throws CraftBranchFailure, InterruptedException
{
this.job.handlePausing();
List<IAEItemStack> thingsUsed = new LinkedList<IAEItemStack>();
final List<IAEItemStack> thingsUsed = new LinkedList<IAEItemStack>();
this.what.setStackSize( l );
if( this.slot >= 0 && this.parent != null && this.parent.details.isCraftable() )
@@ -126,13 +126,13 @@ public class CraftingTreeNode
{
fuzz = fuzz.copy();
fuzz.setStackSize( l );
IAEItemStack available = inv.extractItems( fuzz, Actionable.MODULATE, src );
final IAEItemStack available = inv.extractItems( fuzz, Actionable.MODULATE, src );
if( available != null )
{
if( !this.exhausted )
{
IAEItemStack is = this.job.checkUse( available );
final IAEItemStack is = this.job.checkUse( available );
if( is != null )
{
thingsUsed.add( is.copy() );
@@ -153,13 +153,13 @@ public class CraftingTreeNode
}
else
{
IAEItemStack available = inv.extractItems( this.what, Actionable.MODULATE, src );
final IAEItemStack available = inv.extractItems( this.what, Actionable.MODULATE, src );
if( available != null )
{
if( !this.exhausted )
{
IAEItemStack is = this.job.checkUse( available );
final IAEItemStack is = this.job.checkUse( available );
if( is != null )
{
thingsUsed.add( is.copy() );
@@ -179,7 +179,7 @@ public class CraftingTreeNode
if( this.canEmit )
{
IAEItemStack wat = this.what.copy();
final IAEItemStack wat = this.what.copy();
wat.setStackSize( l );
this.howManyEmitted = wat.getStackSize();
@@ -192,16 +192,16 @@ public class CraftingTreeNode
if( this.nodes.size() == 1 )
{
CraftingTreeProcess pro = this.nodes.get( 0 );
final CraftingTreeProcess pro = this.nodes.get( 0 );
while( pro.possible && l > 0 )
{
IAEItemStack madeWhat = pro.getAmountCrafted( this.what );
final IAEItemStack madeWhat = pro.getAmountCrafted( this.what );
pro.request( inv, pro.getTimes( l, madeWhat.getStackSize() ), src );
madeWhat.setStackSize( l );
IAEItemStack available = inv.extractItems( madeWhat, Actionable.MODULATE, src );
final IAEItemStack available = inv.extractItems( madeWhat, Actionable.MODULATE, src );
if( available != null )
{
@@ -221,17 +221,17 @@ public class CraftingTreeNode
}
else if( this.nodes.size() > 1 )
{
for( CraftingTreeProcess pro : this.nodes )
for( final CraftingTreeProcess pro : this.nodes )
{
try
{
while( pro.possible && l > 0 )
{
MECraftingInventory subInv = new MECraftingInventory( inv, true, true, true );
final MECraftingInventory subInv = new MECraftingInventory( inv, true, true, true );
pro.request( subInv, 1, src );
this.what.setStackSize( l );
IAEItemStack available = subInv.extractItems( this.what, Actionable.MODULATE, src );
final IAEItemStack available = subInv.extractItems( this.what, Actionable.MODULATE, src );
if( available != null )
{
@@ -254,7 +254,7 @@ public class CraftingTreeNode
}
}
}
catch( CraftBranchFailure fail )
catch( final CraftBranchFailure fail )
{
pro.possible = true;
}
@@ -265,12 +265,12 @@ public class CraftingTreeNode
{
this.missing += l;
this.bytes += l;
IAEItemStack rv = this.what.copy();
final IAEItemStack rv = this.what.copy();
rv.setStackSize( l );
return rv;
}
for( IAEItemStack o : thingsUsed )
for( final IAEItemStack o : thingsUsed )
{
this.job.refund( o.copy() );
o.setStackSize( -o.getStackSize() );
@@ -280,7 +280,7 @@ public class CraftingTreeNode
throw new CraftBranchFailure( this.what, l );
}
public void dive( CraftingJob job )
public void dive( final CraftingJob job )
{
if( this.missing > 0 )
{
@@ -290,15 +290,15 @@ public class CraftingTreeNode
job.addBytes( 8 + this.bytes );
for( CraftingTreeProcess pro : this.nodes )
for( final CraftingTreeProcess pro : this.nodes )
{
pro.dive( job );
}
}
public IAEItemStack getStack( long size )
public IAEItemStack getStack( final long size )
{
IAEItemStack is = this.what.copy();
final IAEItemStack is = this.what.copy();
is.setStackSize( size );
return is;
}
@@ -311,17 +311,17 @@ public class CraftingTreeNode
this.used.resetStatus();
this.exhausted = false;
for( CraftingTreeProcess pro : this.nodes )
for( final CraftingTreeProcess pro : this.nodes )
{
pro.setSimulate();
}
}
public void setJob( MECraftingInventory storage, CraftingCPUCluster craftingCPUCluster, BaseActionSource src ) throws CraftBranchFailure
public void setJob( final MECraftingInventory storage, final CraftingCPUCluster craftingCPUCluster, final BaseActionSource src ) throws CraftBranchFailure
{
for( IAEItemStack i : this.used )
for( final IAEItemStack i : this.used )
{
IAEItemStack ex = storage.extractItems( i, Actionable.MODULATE, src );
final IAEItemStack ex = storage.extractItems( i, Actionable.MODULATE, src );
if( ex == null || ex.getStackSize() != i.getStackSize() )
{
@@ -333,39 +333,39 @@ public class CraftingTreeNode
if( this.howManyEmitted > 0 )
{
IAEItemStack i = this.what.copy();
final IAEItemStack i = this.what.copy();
i.setStackSize( this.howManyEmitted );
craftingCPUCluster.addEmitable( i );
}
for( CraftingTreeProcess pro : this.nodes )
for( final CraftingTreeProcess pro : this.nodes )
{
pro.setJob( storage, craftingCPUCluster, src );
}
}
public void getPlan( IItemList<IAEItemStack> plan )
public void getPlan( final IItemList<IAEItemStack> plan )
{
if( this.missing > 0 )
{
IAEItemStack o = this.what.copy();
final IAEItemStack o = this.what.copy();
o.setStackSize( this.missing );
plan.add( o );
}
if( this.howManyEmitted > 0 )
{
IAEItemStack i = this.what.copy();
final IAEItemStack i = this.what.copy();
i.setCountRequestable( this.howManyEmitted );
plan.addRequestable( i );
}
for( IAEItemStack i : this.used )
for( final IAEItemStack i : this.used )
{
plan.add( i.copy() );
}
for( CraftingTreeProcess pro : this.nodes )
for( final CraftingTreeProcess pro : this.nodes )
{
pro.getPlan( plan );
}
@@ -56,20 +56,20 @@ public class CraftingTreeProcess
boolean fullSimulation;
private long bytes = 0;
public CraftingTreeProcess( ICraftingGrid cc, CraftingJob job, ICraftingPatternDetails details, CraftingTreeNode craftingTreeNode, int depth )
public CraftingTreeProcess( final ICraftingGrid cc, final CraftingJob job, final ICraftingPatternDetails details, final CraftingTreeNode craftingTreeNode, final int depth )
{
this.parent = craftingTreeNode;
this.details = details;
this.job = job;
this.depth = depth;
World world = job.getWorld();
final World world = job.getWorld();
if( details.isCraftable() )
{
IAEItemStack[] list = details.getInputs();
final IAEItemStack[] list = details.getInputs();
InventoryCrafting ic = new InventoryCrafting( new ContainerNull(), 3, 3 );
IAEItemStack[] is = details.getInputs();
final InventoryCrafting ic = new InventoryCrafting( new ContainerNull(), 3, 3 );
final IAEItemStack[] is = details.getInputs();
for( int x = 0; x < ic.getSizeInventory(); x++ )
{
ic.setInventorySlotContents( x, is[x] == null ? null : is[x].getItemStack() );
@@ -79,19 +79,19 @@ public class CraftingTreeProcess
for( int x = 0; x < ic.getSizeInventory(); x++ )
{
ItemStack g = ic.getStackInSlot( x );
final ItemStack g = ic.getStackInSlot( x );
if( g != null && g.stackSize > 1 )
{
this.fullSimulation = true;
}
}
for( IAEItemStack part : details.getCondensedInputs() )
for( final IAEItemStack part : details.getCondensedInputs() )
{
ItemStack g = part.getItemStack();
final ItemStack g = part.getItemStack();
boolean isAnInput = false;
for( IAEItemStack a : details.getCondensedOutputs() )
for( final IAEItemStack a : details.getCondensedOutputs() )
{
if( g != null && a != null && a.equals( g ) )
{
@@ -110,13 +110,13 @@ public class CraftingTreeProcess
}
}
boolean complicated = false;
final boolean complicated = false;
if( this.containerItems || complicated )
{
for( int x = 0; x < list.length; x++ )
{
IAEItemStack part = list[x];
final IAEItemStack part = list[x];
if( part != null )
{
this.nodes.put( new CraftingTreeNode( cc, job, part.copy(), this, x, depth + 1 ), part.getStackSize() );
@@ -126,11 +126,11 @@ public class CraftingTreeProcess
else
{
// this is minor different then below, this slot uses the pattern, but kinda fudges it.
for( IAEItemStack part : details.getCondensedInputs() )
for( final IAEItemStack part : details.getCondensedInputs() )
{
for( int x = 0; x < list.length; x++ )
{
IAEItemStack comparePart = list[x];
final IAEItemStack comparePart = list[x];
if( part != null && part.equals( comparePart ) )
{
// use the first slot...
@@ -143,12 +143,12 @@ public class CraftingTreeProcess
}
else
{
for( IAEItemStack part : details.getCondensedInputs() )
for( final IAEItemStack part : details.getCondensedInputs() )
{
ItemStack g = part.getItemStack();
final ItemStack g = part.getItemStack();
boolean isAnInput = false;
for( IAEItemStack a : details.getCondensedOutputs() )
for( final IAEItemStack a : details.getCondensedOutputs() )
{
if( g != null && a != null && a.equals( g ) )
{
@@ -162,19 +162,19 @@ public class CraftingTreeProcess
}
}
for( IAEItemStack part : details.getCondensedInputs() )
for( final IAEItemStack part : details.getCondensedInputs() )
{
this.nodes.put( new CraftingTreeNode( cc, job, part.copy(), this, -1, depth + 1 ), part.getStackSize() );
}
}
}
public boolean notRecursive( ICraftingPatternDetails details )
public boolean notRecursive( final ICraftingPatternDetails details )
{
return this.parent == null || this.parent.notRecursive( details );
}
long getTimes( long remaining, long stackSize )
long getTimes( final long remaining, final long stackSize )
{
if( this.limitQty || this.fullSimulation )
{
@@ -183,18 +183,18 @@ public class CraftingTreeProcess
return ( remaining / stackSize ) + ( remaining % stackSize != 0 ? 1 : 0 );
}
public void request( MECraftingInventory inv, long i, BaseActionSource src ) throws CraftBranchFailure, InterruptedException
public void request( final MECraftingInventory inv, final long i, final BaseActionSource src ) throws CraftBranchFailure, InterruptedException
{
this.job.handlePausing();
if( this.fullSimulation )
{
InventoryCrafting ic = new InventoryCrafting( new ContainerNull(), 3, 3 );
final InventoryCrafting ic = new InventoryCrafting( new ContainerNull(), 3, 3 );
for( Entry<CraftingTreeNode, Long> entry : this.nodes.entrySet() )
for( final Entry<CraftingTreeNode, Long> entry : this.nodes.entrySet() )
{
IAEItemStack item = entry.getKey().getStack( entry.getValue() );
IAEItemStack stack = entry.getKey().request( inv, item.getStackSize(), src );
final IAEItemStack item = entry.getKey().getStack( entry.getValue() );
final IAEItemStack stack = entry.getKey().request( inv, item.getStackSize(), src );
ic.setInventorySlotContents( entry.getKey().slot, stack.getItemStack() );
}
@@ -206,7 +206,7 @@ public class CraftingTreeProcess
ItemStack is = ic.getStackInSlot( x );
is = Platform.getContainerItem( is );
IAEItemStack o = AEApi.instance().storage().createItemStack( is );
final IAEItemStack o = AEApi.instance().storage().createItemStack( is );
if( o != null )
{
this.bytes++;
@@ -217,15 +217,15 @@ public class CraftingTreeProcess
else
{
// request and remove inputs...
for( Entry<CraftingTreeNode, Long> entry : this.nodes.entrySet() )
for( final Entry<CraftingTreeNode, Long> entry : this.nodes.entrySet() )
{
IAEItemStack item = entry.getKey().getStack( entry.getValue() );
IAEItemStack stack = entry.getKey().request( inv, item.getStackSize() * i, src );
final IAEItemStack item = entry.getKey().getStack( entry.getValue() );
final IAEItemStack stack = entry.getKey().request( inv, item.getStackSize() * i, src );
if( this.containerItems )
{
ItemStack is = Platform.getContainerItem( stack.getItemStack() );
IAEItemStack o = AEApi.instance().storage().createItemStack( is );
final ItemStack is = Platform.getContainerItem( stack.getItemStack() );
final IAEItemStack o = AEApi.instance().storage().createItemStack( is );
if( o != null )
{
this.bytes++;
@@ -238,9 +238,9 @@ public class CraftingTreeProcess
// assume its possible.
// add crafting results..
for( IAEItemStack out : this.details.getCondensedOutputs() )
for( final IAEItemStack out : this.details.getCondensedOutputs() )
{
IAEItemStack o = out.copy();
final IAEItemStack o = out.copy();
o.setStackSize( o.getStackSize() * i );
inv.injectItems( o, Actionable.MODULATE, src );
}
@@ -248,10 +248,10 @@ public class CraftingTreeProcess
this.crafts += i;
}
public void dive( CraftingJob job )
public void dive( final CraftingJob job )
{
job.addTask( this.getAmountCrafted( this.parent.getStack( 1 ) ), this.crafts, this.details, this.depth );
for( CraftingTreeNode pro : this.nodes.keySet() )
for( final CraftingTreeNode pro : this.nodes.keySet() )
{
pro.dive( job );
}
@@ -261,7 +261,7 @@ public class CraftingTreeProcess
IAEItemStack getAmountCrafted( IAEItemStack what2 )
{
for( IAEItemStack is : this.details.getCondensedOutputs() )
for( final IAEItemStack is : this.details.getCondensedOutputs() )
{
if( is.equals( what2 ) )
{
@@ -272,7 +272,7 @@ public class CraftingTreeProcess
}
// more fuzzy!
for( IAEItemStack is : this.details.getCondensedOutputs() )
for( final IAEItemStack is : this.details.getCondensedOutputs() )
{
if( is.getItem() == what2.getItem() && ( is.getItem().isDamageable() || is.getItemDamage() == what2.getItemDamage() ) )
{
@@ -290,23 +290,23 @@ public class CraftingTreeProcess
this.crafts = 0;
this.bytes = 0;
for( CraftingTreeNode pro : this.nodes.keySet() )
for( final CraftingTreeNode pro : this.nodes.keySet() )
{
pro.setSimulate();
}
}
public void setJob( MECraftingInventory storage, CraftingCPUCluster craftingCPUCluster, BaseActionSource src ) throws CraftBranchFailure
public void setJob( final MECraftingInventory storage, final CraftingCPUCluster craftingCPUCluster, final BaseActionSource src ) throws CraftBranchFailure
{
craftingCPUCluster.addCrafting( this.details, this.crafts );
for( CraftingTreeNode pro : this.nodes.keySet() )
for( final CraftingTreeNode pro : this.nodes.keySet() )
{
pro.setJob( storage, craftingCPUCluster, src );
}
}
public void getPlan( IItemList<IAEItemStack> plan )
public void getPlan( final IItemList<IAEItemStack> plan )
{
for( IAEItemStack i : this.details.getOutputs() )
{
@@ -315,7 +315,7 @@ public class CraftingTreeProcess
plan.addRequestable( i );
}
for( CraftingTreeNode pro : this.nodes.keySet() )
for( final CraftingTreeNode pro : this.nodes.keySet() )
{
pro.getPlan( plan );
}
@@ -41,7 +41,7 @@ public class CraftingWatcher implements ICraftingWatcher
final ICraftingWatcherHost host;
final HashSet<IAEStack> myInterests = new HashSet<IAEStack>();
public CraftingWatcher( CraftingGridCache cache, ICraftingWatcherHost host )
public CraftingWatcher( final CraftingGridCache cache, final ICraftingWatcherHost host )
{
this.gsc = cache;
this.host = host;
@@ -65,7 +65,7 @@ public class CraftingWatcher implements ICraftingWatcher
}
@Override
public boolean contains( Object o )
public boolean contains( final Object o )
{
return this.myInterests.contains( o );
}
@@ -86,13 +86,13 @@ public class CraftingWatcher implements ICraftingWatcher
@Nonnull
@Override
public <T> T[] toArray( @Nonnull T[] a )
public <T> T[] toArray( @Nonnull final T[] a )
{
return this.myInterests.toArray( a );
}
@Override
public boolean add( IAEStack e )
public boolean add( final IAEStack e )
{
if( this.myInterests.contains( e ) )
{
@@ -103,23 +103,23 @@ public class CraftingWatcher implements ICraftingWatcher
}
@Override
public boolean remove( Object o )
public boolean remove( final Object o )
{
return this.myInterests.remove( o ) && this.gsc.interestManager.remove( (IAEStack) o, this );
}
@Override
public boolean containsAll( @Nonnull Collection<?> c )
public boolean containsAll( @Nonnull final Collection<?> c )
{
return this.myInterests.containsAll( c );
}
@Override
public boolean addAll( @Nonnull Collection<? extends IAEStack> c )
public boolean addAll( @Nonnull final Collection<? extends IAEStack> c )
{
boolean didChange = false;
for( IAEStack o : c )
for( final IAEStack o : c )
{
didChange = this.add( o ) || didChange;
}
@@ -128,10 +128,10 @@ public class CraftingWatcher implements ICraftingWatcher
}
@Override
public boolean removeAll( @Nonnull Collection<?> c )
public boolean removeAll( @Nonnull final Collection<?> c )
{
boolean didSomething = false;
for( Object o : c )
for( final Object o : c )
{
didSomething = this.remove( o ) || didSomething;
}
@@ -139,10 +139,10 @@ public class CraftingWatcher implements ICraftingWatcher
}
@Override
public boolean retainAll( @Nonnull Collection<?> c )
public boolean retainAll( @Nonnull final Collection<?> c )
{
boolean changed = false;
Iterator<IAEStack> i = this.iterator();
final Iterator<IAEStack> i = this.iterator();
while( i.hasNext() )
{
@@ -159,7 +159,7 @@ public class CraftingWatcher implements ICraftingWatcher
@Override
public void clear()
{
Iterator<IAEStack> i = this.myInterests.iterator();
final Iterator<IAEStack> i = this.myInterests.iterator();
while( i.hasNext() )
{
this.gsc.interestManager.remove( i.next(), this );
@@ -174,7 +174,7 @@ public class CraftingWatcher implements ICraftingWatcher
final Iterator<IAEStack> interestIterator;
IAEStack myLast;
public ItemWatcherIterator( CraftingWatcher parent, Iterator<IAEStack> i )
public ItemWatcherIterator( final CraftingWatcher parent, final Iterator<IAEStack> i )
{
this.watcher = parent;
this.interestIterator = i;
@@ -59,7 +59,7 @@ public class MECraftingInventory implements IMEInventory<IAEItemStack>
this.par = null;
}
public MECraftingInventory( MECraftingInventory parent )
public MECraftingInventory( final MECraftingInventory parent )
{
this.target = parent;
this.logExtracted = parent.logExtracted;
@@ -98,7 +98,7 @@ public class MECraftingInventory implements IMEInventory<IAEItemStack>
this.par = parent;
}
public MECraftingInventory( IMEMonitor<IAEItemStack> target, BaseActionSource src, boolean logExtracted, boolean logInjections, boolean logMissing )
public MECraftingInventory( final IMEMonitor<IAEItemStack> target, final BaseActionSource src, final boolean logExtracted, final boolean logInjections, final boolean logMissing )
{
this.target = target;
this.logExtracted = logExtracted;
@@ -133,7 +133,7 @@ public class MECraftingInventory implements IMEInventory<IAEItemStack>
}
this.localCache = AEApi.instance().storage().createItemList();
for( IAEItemStack is : target.getStorageList() )
for( final IAEItemStack is : target.getStorageList() )
{
this.localCache.add( target.extractItems( is, Actionable.SIMULATE, src ) );
}
@@ -141,7 +141,7 @@ public class MECraftingInventory implements IMEInventory<IAEItemStack>
this.par = null;
}
public MECraftingInventory( IMEInventory<IAEItemStack> target, boolean logExtracted, boolean logInjections, boolean logMissing )
public MECraftingInventory( final IMEInventory<IAEItemStack> target, final boolean logExtracted, final boolean logInjections, final boolean logMissing )
{
this.target = target;
this.logExtracted = logExtracted;
@@ -180,7 +180,7 @@ public class MECraftingInventory implements IMEInventory<IAEItemStack>
}
@Override
public IAEItemStack injectItems( IAEItemStack input, Actionable mode, BaseActionSource src )
public IAEItemStack injectItems( final IAEItemStack input, final Actionable mode, final BaseActionSource src )
{
if( input == null )
{
@@ -200,14 +200,14 @@ public class MECraftingInventory implements IMEInventory<IAEItemStack>
}
@Override
public IAEItemStack extractItems( IAEItemStack request, Actionable mode, BaseActionSource src )
public IAEItemStack extractItems( final IAEItemStack request, final Actionable mode, final BaseActionSource src )
{
if( request == null )
{
return null;
}
IAEItemStack list = this.localCache.findPrecise( request );
final IAEItemStack list = this.localCache.findPrecise( request );
if( list == null || list.getStackSize() == 0 )
{
return null;
@@ -227,7 +227,7 @@ public class MECraftingInventory implements IMEInventory<IAEItemStack>
return request;
}
IAEItemStack ret = request.copy();
final IAEItemStack ret = request.copy();
ret.setStackSize( list.getStackSize() );
if( mode == Actionable.MODULATE )
@@ -243,9 +243,9 @@ public class MECraftingInventory implements IMEInventory<IAEItemStack>
}
@Override
public IItemList<IAEItemStack> getAvailableItems( IItemList<IAEItemStack> out )
public IItemList<IAEItemStack> getAvailableItems( final IItemList<IAEItemStack> out )
{
for( IAEItemStack is : this.localCache )
for( final IAEItemStack is : this.localCache )
{
out.add( is );
}
@@ -264,15 +264,15 @@ public class MECraftingInventory implements IMEInventory<IAEItemStack>
return this.localCache;
}
public boolean commit( BaseActionSource src )
public boolean commit( final BaseActionSource src )
{
IItemList<IAEItemStack> added = AEApi.instance().storage().createItemList();
IItemList<IAEItemStack> pulled = AEApi.instance().storage().createItemList();
final IItemList<IAEItemStack> added = AEApi.instance().storage().createItemList();
final IItemList<IAEItemStack> pulled = AEApi.instance().storage().createItemList();
boolean failed = false;
if( this.logInjections )
{
for( IAEItemStack inject : this.injectedCache )
for( final IAEItemStack inject : this.injectedCache )
{
IAEItemStack result = null;
added.add( result = this.target.injectItems( inject, Actionable.MODULATE, src ) );
@@ -287,7 +287,7 @@ public class MECraftingInventory implements IMEInventory<IAEItemStack>
if( failed )
{
for( IAEItemStack is : added )
for( final IAEItemStack is : added )
{
this.target.extractItems( is, Actionable.MODULATE, src );
}
@@ -297,7 +297,7 @@ public class MECraftingInventory implements IMEInventory<IAEItemStack>
if( this.logExtracted )
{
for( IAEItemStack extra : this.extractedCache )
for( final IAEItemStack extra : this.extractedCache )
{
IAEItemStack result = null;
pulled.add( result = this.target.extractItems( extra, Actionable.MODULATE, src ) );
@@ -312,12 +312,12 @@ public class MECraftingInventory implements IMEInventory<IAEItemStack>
if( failed )
{
for( IAEItemStack is : added )
for( final IAEItemStack is : added )
{
this.target.extractItems( is, Actionable.MODULATE, src );
}
for( IAEItemStack is : pulled )
for( final IAEItemStack is : pulled )
{
this.target.injectItems( is, Actionable.MODULATE, src );
}
@@ -327,7 +327,7 @@ public class MECraftingInventory implements IMEInventory<IAEItemStack>
if( this.logMissing && this.par != null )
{
for( IAEItemStack extra : this.missingCache )
for( final IAEItemStack extra : this.missingCache )
{
this.par.addMissing( extra );
}
@@ -336,14 +336,14 @@ public class MECraftingInventory implements IMEInventory<IAEItemStack>
return true;
}
public void addMissing( IAEItemStack extra )
public void addMissing( final IAEItemStack extra )
{
this.missingCache.add( extra );
}
public void ignore( IAEItemStack what )
public void ignore( final IAEItemStack what )
{
IAEItemStack list = this.localCache.findPrecise( what );
final IAEItemStack list = this.localCache.findPrecise( what );
if( list != null )
{
list.setStackSize( 0 );