Puts everywhere brackets

This commit is contained in:
thatsIch
2015-04-29 02:30:53 +02:00
parent 23aa8fd72d
commit 64ed05a1b4
465 changed files with 6726 additions and 14 deletions
@@ -253,7 +253,9 @@ public class CraftingJob implements Runnable, ICraftingJob
}
if( Thread.interrupted() )
{
throw new InterruptedException();
}
}
this.incTime++;
}
@@ -261,7 +263,9 @@ public class CraftingJob implements Runnable, ICraftingJob
public void finish()
{
if( this.callback != null )
{
this.callback.calculationComplete( this );
}
this.availableCheck = null;
@@ -294,7 +298,9 @@ public class CraftingJob implements Runnable, ICraftingJob
public void populatePlan( IItemList<IAEItemStack> plan )
{
if( this.tree != null )
{
this.tree.getPlan( plan );
}
}
@Override
@@ -327,7 +333,9 @@ public class CraftingJob implements Runnable, ICraftingJob
synchronized( this.monitor )
{
if( this.done )
{
return false;
}
this.watch.reset();
this.watch.start();
@@ -47,7 +47,9 @@ public class CraftingLink implements ICraftingLink
this.standalone = data.getBoolean( "standalone" );
if( !data.hasKey( "req" ) || !data.getBoolean( "req" ) )
{
throw new IllegalStateException( "Invalid Crafting Link for Object" );
}
this.req = req;
this.cpu = null;
@@ -61,7 +63,9 @@ public class CraftingLink implements ICraftingLink
this.standalone = data.getBoolean( "standalone" );
if( !data.hasKey( "req" ) || data.getBoolean( "req" ) )
{
throw new IllegalStateException( "Invalid Crafting Link for Object" );
}
this.cpu = cpu;
this.req = null;
@@ -71,13 +75,19 @@ public class CraftingLink implements ICraftingLink
public boolean isCanceled()
{
if( this.canceled )
{
return true;
}
if( this.done )
{
return false;
}
if( this.tie == null )
{
return false;
}
return this.tie.isCanceled();
}
@@ -86,13 +96,19 @@ public class CraftingLink implements ICraftingLink
public boolean isDone()
{
if( this.done )
{
return true;
}
if( this.canceled )
{
return false;
}
if( this.tie == null )
{
return false;
}
return this.tie.isDone();
}
@@ -101,12 +117,16 @@ public class CraftingLink implements ICraftingLink
public void cancel()
{
if( this.done )
{
return;
}
this.canceled = true;
if( this.tie != null )
{
this.tie.cancel();
}
this.tie = null;
}
@@ -136,7 +156,9 @@ public class CraftingLink implements ICraftingLink
public void setNexus( CraftingLinkNexus n )
{
if( this.tie != null )
{
this.tie.remove( this );
}
if( this.canceled && n != null )
{
@@ -148,13 +170,17 @@ public class CraftingLink implements ICraftingLink
this.tie = n;
if( n != null )
{
n.add( this );
}
}
public IAEItemStack injectItems( IAEItemStack input, Actionable mode )
{
if( this.tie == null || this.tie.req == null || this.tie.req.req == null )
{
return input;
}
return this.tie.req.req.injectCraftedItems( this.tie.req, input, mode );
}
@@ -162,6 +188,8 @@ public class CraftingLink implements ICraftingLink
public void markDone()
{
if( this.tie != null )
{
this.tie.markDone();
}
}
}
@@ -42,19 +42,27 @@ public class CraftingLinkNexus
public boolean isDead( IGrid g, CraftingGridCache craftingGridCache )
{
if( this.canceled || this.done )
{
return true;
}
if( this.req == null || this.cpu == null )
{
this.tickOfDeath++;
}
else
{
boolean hasCpu = craftingGridCache.hasCpu( this.cpu.cpu );
boolean hasMachine = this.req.req.getActionableNode().getGrid() == g;
if( hasCpu && hasMachine )
{
this.tickOfDeath = 0;
}
else
{
this.tickOfDeath += 60;
}
}
if( this.tickOfDeath > 60 )
@@ -74,27 +82,39 @@ public class CraftingLinkNexus
{
this.req.canceled = true;
if( this.req.req != null )
{
this.req.req.jobStateChange( this.req );
}
}
if( this.cpu != null )
{
this.cpu.canceled = true;
}
}
public void remove( CraftingLink craftingLink )
{
if( this.req == craftingLink )
{
this.req = null;
}
else if( this.cpu == craftingLink )
{
this.cpu = null;
}
}
public void add( CraftingLink craftingLink )
{
if( craftingLink.cpu != null )
{
this.cpu = craftingLink;
}
else if( craftingLink.req != null )
{
this.req = craftingLink;
}
}
public boolean isCanceled()
@@ -115,11 +135,15 @@ public class CraftingLinkNexus
{
this.req.done = true;
if( this.req.req != null )
{
this.req.req.jobStateChange( this.req );
}
}
if( this.cpu != null )
{
this.cpu.done = true;
}
}
public boolean isMachine( IGridHost machine )
@@ -130,7 +154,9 @@ public class CraftingLinkNexus
public void removeNode()
{
if( this.req != null )
{
this.req.setNexus( null );
}
this.req = null;
this.tickOfDeath = 0;
@@ -70,13 +70,17 @@ public class CraftingTreeNode
this.canEmit = cc.canEmitFor( this.what );
if( this.canEmit )
{
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
// order.
{
if( this.parent == null || this.parent.notRecursive( details ) )
{
this.nodes.add( new CraftingTreeProcess( cc, job, details, this, depth + 1 ) );
}
}
}
@@ -84,16 +88,26 @@ public class CraftingTreeNode
{
IAEItemStack[] o = details.getCondensedOutputs();
for( IAEItemStack i : o )
{
if( i.equals( this.what ) )
{
return false;
}
}
o = details.getCondensedInputs();
for( IAEItemStack i : o )
{
if( i.equals( this.what ) )
{
return false;
}
}
if( this.parent == null )
{
return true;
}
return this.parent.notRecursive( details );
}
@@ -131,7 +145,9 @@ public class CraftingTreeNode
l -= available.getStackSize();
if( l == 0 )
{
return available;
}
}
}
}
@@ -156,7 +172,9 @@ public class CraftingTreeNode
l -= available.getStackSize();
if( l == 0 )
{
return available;
}
}
}
@@ -192,10 +210,14 @@ public class CraftingTreeNode
l -= available.getStackSize();
if( l <= 0 )
{
return available;
}
}
else
{
pro.possible = false; // ;P
}
}
}
else if( this.nodes.size() > 1 )
@@ -215,16 +237,22 @@ public class CraftingTreeNode
if( available != null )
{
if( !subInv.commit( src ) )
{
throw new CraftBranchFailure( this.what, l );
}
this.bytes += available.getStackSize();
l -= available.getStackSize();
if( l <= 0 )
{
return available;
}
}
else
{
pro.possible = false; // ;P
}
}
}
catch( CraftBranchFailure fail )
@@ -256,13 +284,17 @@ public class CraftingTreeNode
public void dive( CraftingJob job )
{
if( this.missing > 0 )
{
job.addMissing( this.getStack( this.missing ) );
}
// missing = 0;
job.addBytes( 8 + this.bytes );
for( CraftingTreeProcess pro : this.nodes )
{
pro.dive( job );
}
}
public IAEItemStack getStack( long size )
@@ -281,7 +313,9 @@ public class CraftingTreeNode
this.exhausted = false;
for( CraftingTreeProcess pro : this.nodes )
{
pro.setSimulate();
}
}
public void setJob( MECraftingInventory storage, CraftingCPUCluster craftingCPUCluster, BaseActionSource src ) throws CraftBranchFailure
@@ -291,7 +325,9 @@ public class CraftingTreeNode
IAEItemStack ex = storage.extractItems( i, Actionable.MODULATE, src );
if( ex == null || ex.getStackSize() != i.getStackSize() )
{
throw new CraftBranchFailure( i, i.getStackSize() );
}
craftingCPUCluster.addStorage( ex );
}
@@ -304,7 +340,9 @@ public class CraftingTreeNode
}
for( CraftingTreeProcess pro : this.nodes )
{
pro.setJob( storage, craftingCPUCluster, src );
}
}
public void getPlan( IItemList<IAEItemStack> plan )
@@ -324,9 +362,13 @@ public class CraftingTreeNode
}
for( IAEItemStack i : this.used )
{
plan.add( i.copy() );
}
for( CraftingTreeProcess pro : this.nodes )
{
pro.getPlan( plan );
}
}
}
@@ -73,7 +73,9 @@ public class CraftingTreeProcess
InventoryCrafting ic = new InventoryCrafting( new ContainerNull(), 3, 3 );
IAEItemStack[] is = details.getInputs();
for( int x = 0; x < ic.getSizeInventory(); x++ )
{
ic.setInventorySlotContents( x, is[x] == null ? null : is[x].getItemStack() );
}
FMLCommonHandler.instance().firePlayerCraftingEvent( Platform.getPlayer( (WorldServer) world ), details.getOutput( ic, world ), ic );
@@ -81,7 +83,9 @@ public class CraftingTreeProcess
{
ItemStack g = ic.getStackInSlot( x );
if( g != null && g.stackSize > 1 )
{
this.fullSimulation = true;
}
}
for( IAEItemStack part : details.getCondensedInputs() )
@@ -92,14 +96,20 @@ public class CraftingTreeProcess
for( IAEItemStack a : details.getCondensedOutputs() )
{
if( g != null && a != null && a.equals( g ) )
{
isAnInput = true;
}
}
if( isAnInput )
{
this.limitQty = true;
}
if( g.getItem().hasContainerItem( g ) )
{
this.limitQty = this.containerItems = true;
}
}
boolean complicated = false;
@@ -110,7 +120,9 @@ public class CraftingTreeProcess
{
IAEItemStack part = list[x];
if( part != null )
{
this.nodes.put( new CraftingTreeNode( cc, job, part.copy(), this, x, depth + 1 ), part.getStackSize() );
}
}
}
else
@@ -141,11 +153,15 @@ public class CraftingTreeProcess
for( IAEItemStack a : details.getCondensedOutputs() )
{
if( g != null && a != null && a.equals( g ) )
{
isAnInput = true;
}
}
if( isAnInput )
{
this.limitQty = true;
}
}
for( IAEItemStack part : details.getCondensedInputs() )
@@ -163,7 +179,9 @@ public class CraftingTreeProcess
long getTimes( long remaining, long stackSize )
{
if( this.limitQty || this.fullSimulation )
{
return 1;
}
return ( remaining / stackSize ) + ( remaining % stackSize != 0 ? 1 : 0 );
}
@@ -236,7 +254,9 @@ public class CraftingTreeProcess
{
job.addTask( this.getAmountCrafted( this.parent.getStack( 1 ) ), this.crafts, this.details, this.depth );
for( CraftingTreeNode pro : this.nodes.keySet() )
{
pro.dive( job );
}
job.addBytes( 8 + this.crafts + this.bytes );
}
@@ -273,7 +293,9 @@ public class CraftingTreeProcess
this.bytes = 0;
for( CraftingTreeNode pro : this.nodes.keySet() )
{
pro.setSimulate();
}
}
public void setJob( MECraftingInventory storage, CraftingCPUCluster craftingCPUCluster, BaseActionSource src ) throws CraftBranchFailure
@@ -281,7 +303,9 @@ public class CraftingTreeProcess
craftingCPUCluster.addCrafting( this.details, this.crafts );
for( CraftingTreeNode pro : this.nodes.keySet() )
{
pro.setJob( storage, craftingCPUCluster, src );
}
}
public void getPlan( IItemList<IAEItemStack> plan )
@@ -294,6 +318,8 @@ public class CraftingTreeProcess
}
for( CraftingTreeNode pro : this.nodes.keySet() )
{
pro.getPlan( plan );
}
}
}
@@ -90,7 +90,9 @@ public class CraftingWatcher implements ICraftingWatcher
public boolean add( IAEStack e )
{
if( this.myInterests.contains( e ) )
{
return false;
}
return this.myInterests.add( e.copy() ) && this.gsc.interestManager.put( e, this );
}
@@ -113,7 +115,9 @@ public class CraftingWatcher implements ICraftingWatcher
boolean didChange = false;
for( IAEStack o : c )
{
didChange = this.add( o ) || didChange;
}
return didChange;
}
@@ -123,7 +127,9 @@ public class CraftingWatcher implements ICraftingWatcher
{
boolean didSomething = false;
for( Object o : c )
{
didSomething = this.remove( o ) || didSomething;
}
return didSomething;
}
@@ -67,19 +67,31 @@ public class MECraftingInventory implements IMEInventory<IAEItemStack>
this.logMissing = parent.logMissing;
if( this.logMissing )
{
this.missingCache = AEApi.instance().storage().createItemList();
}
else
{
this.missingCache = null;
}
if( this.logExtracted )
{
this.extractedCache = AEApi.instance().storage().createItemList();
}
else
{
this.extractedCache = null;
}
if( this.logInjections )
{
this.injectedCache = AEApi.instance().storage().createItemList();
}
else
{
this.injectedCache = null;
}
this.localCache = this.target.getAvailableItems( AEApi.instance().storage().createItemList() );
@@ -94,23 +106,37 @@ public class MECraftingInventory implements IMEInventory<IAEItemStack>
this.logMissing = logMissing;
if( logMissing )
{
this.missingCache = AEApi.instance().storage().createItemList();
}
else
{
this.missingCache = null;
}
if( logExtracted )
{
this.extractedCache = AEApi.instance().storage().createItemList();
}
else
{
this.extractedCache = null;
}
if( logInjections )
{
this.injectedCache = AEApi.instance().storage().createItemList();
}
else
{
this.injectedCache = null;
}
this.localCache = AEApi.instance().storage().createItemList();
for( IAEItemStack is : target.getStorageList() )
{
this.localCache.add( target.extractItems( is, Actionable.SIMULATE, src ) );
}
this.par = null;
}
@@ -123,19 +149,31 @@ public class MECraftingInventory implements IMEInventory<IAEItemStack>
this.logMissing = logMissing;
if( logMissing )
{
this.missingCache = AEApi.instance().storage().createItemList();
}
else
{
this.missingCache = null;
}
if( logExtracted )
{
this.extractedCache = AEApi.instance().storage().createItemList();
}
else
{
this.extractedCache = null;
}
if( logInjections )
{
this.injectedCache = AEApi.instance().storage().createItemList();
}
else
{
this.injectedCache = null;
}
this.localCache = target.getAvailableItems( AEApi.instance().storage().createItemList() );
this.par = null;
@@ -145,12 +183,16 @@ public class MECraftingInventory implements IMEInventory<IAEItemStack>
public IAEItemStack injectItems( IAEItemStack input, Actionable mode, BaseActionSource src )
{
if( input == null )
{
return null;
}
if( mode == Actionable.MODULATE )
{
if( this.logInjections )
{
this.injectedCache.add( input );
}
this.localCache.add( input );
}
@@ -161,11 +203,15 @@ public class MECraftingInventory implements IMEInventory<IAEItemStack>
public IAEItemStack extractItems( IAEItemStack request, Actionable mode, BaseActionSource src )
{
if( request == null )
{
return null;
}
IAEItemStack list = this.localCache.findPrecise( request );
if( list == null || list.getStackSize() == 0 )
{
return null;
}
if( list.getStackSize() >= request.getStackSize() )
{
@@ -173,7 +219,9 @@ public class MECraftingInventory implements IMEInventory<IAEItemStack>
{
list.decStackSize( request.getStackSize() );
if( this.logExtracted )
{
this.extractedCache.add( request );
}
}
return request;
@@ -186,7 +234,9 @@ public class MECraftingInventory implements IMEInventory<IAEItemStack>
{
list.reset();
if( this.logExtracted )
{
this.extractedCache.add( ret );
}
}
return ret;
@@ -196,7 +246,9 @@ public class MECraftingInventory implements IMEInventory<IAEItemStack>
public IItemList<IAEItemStack> getAvailableItems( IItemList<IAEItemStack> out )
{
for( IAEItemStack is : this.localCache )
{
out.add( is );
}
return out;
}
@@ -236,7 +288,9 @@ public class MECraftingInventory implements IMEInventory<IAEItemStack>
if( failed )
{
for( IAEItemStack is : added )
{
this.target.extractItems( is, Actionable.MODULATE, src );
}
return false;
}
@@ -259,10 +313,14 @@ public class MECraftingInventory implements IMEInventory<IAEItemStack>
if( failed )
{
for( IAEItemStack is : added )
{
this.target.extractItems( is, Actionable.MODULATE, src );
}
for( IAEItemStack is : pulled )
{
this.target.injectItems( is, Actionable.MODULATE, src );
}
return false;
}
@@ -270,7 +328,9 @@ public class MECraftingInventory implements IMEInventory<IAEItemStack>
if( this.logMissing && this.par != null )
{
for( IAEItemStack extra : this.missingCache )
{
this.par.addMissing( extra );
}
}
return true;
@@ -285,6 +345,8 @@ public class MECraftingInventory implements IMEInventory<IAEItemStack>
{
IAEItemStack list = this.localCache.findPrecise( what );
if( list != null )
{
list.setStackSize( 0 );
}
}
}