final variables and parameters
This commit is contained in:
+59
-59
@@ -92,7 +92,7 @@ public class CraftingGridCache implements ICraftingGrid, ICraftingProviderHelper
|
||||
static final Comparator<ICraftingPatternDetails> COMPARATOR = new Comparator<ICraftingPatternDetails>()
|
||||
{
|
||||
@Override
|
||||
public int compare( ICraftingPatternDetails firstDetail, ICraftingPatternDetails nextDetail )
|
||||
public int compare( final ICraftingPatternDetails firstDetail, final ICraftingPatternDetails nextDetail )
|
||||
{
|
||||
return nextDetail.getPriority() - firstDetail.getPriority();
|
||||
}
|
||||
@@ -100,11 +100,11 @@ public class CraftingGridCache implements ICraftingGrid, ICraftingProviderHelper
|
||||
|
||||
static
|
||||
{
|
||||
ThreadFactory factory = new ThreadFactory()
|
||||
final ThreadFactory factory = new ThreadFactory()
|
||||
{
|
||||
|
||||
@Override
|
||||
public Thread newThread( Runnable ar )
|
||||
public Thread newThread( final Runnable ar )
|
||||
{
|
||||
return new Thread( ar, "AE Crafting Calculator" );
|
||||
}
|
||||
@@ -127,13 +127,13 @@ public class CraftingGridCache implements ICraftingGrid, ICraftingProviderHelper
|
||||
private IEnergyGrid energyGrid;
|
||||
private boolean updateList = false;
|
||||
|
||||
public CraftingGridCache( IGrid grid )
|
||||
public CraftingGridCache( final IGrid grid )
|
||||
{
|
||||
this.grid = grid;
|
||||
}
|
||||
|
||||
@MENetworkEventSubscribe
|
||||
public void afterCacheConstruction( MENetworkPostCacheConstruction cacheConstruction )
|
||||
public void afterCacheConstruction( final MENetworkPostCacheConstruction cacheConstruction )
|
||||
{
|
||||
this.storageGrid = this.grid.getCache( IStorageGrid.class );
|
||||
this.energyGrid = this.grid.getCache( IEnergyGrid.class );
|
||||
@@ -150,7 +150,7 @@ public class CraftingGridCache implements ICraftingGrid, ICraftingProviderHelper
|
||||
this.updateCPUClusters();
|
||||
}
|
||||
|
||||
Iterator<CraftingLinkNexus> craftingLinkIterator = this.craftingLinks.values().iterator();
|
||||
final Iterator<CraftingLinkNexus> craftingLinkIterator = this.craftingLinks.values().iterator();
|
||||
while( craftingLinkIterator.hasNext() )
|
||||
{
|
||||
if( craftingLinkIterator.next().isDead( this.grid, this ) )
|
||||
@@ -159,18 +159,18 @@ public class CraftingGridCache implements ICraftingGrid, ICraftingProviderHelper
|
||||
}
|
||||
}
|
||||
|
||||
for( CraftingCPUCluster cpu : this.craftingCPUClusters )
|
||||
for( final CraftingCPUCluster cpu : this.craftingCPUClusters )
|
||||
{
|
||||
cpu.updateCraftingLogic( this.grid, this.energyGrid, this );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeNode( IGridNode gridNode, IGridHost machine )
|
||||
public void removeNode( final IGridNode gridNode, final IGridHost machine )
|
||||
{
|
||||
if( machine instanceof ICraftingWatcherHost )
|
||||
{
|
||||
ICraftingWatcher craftingWatcher = this.craftingWatchers.get( machine );
|
||||
final ICraftingWatcher craftingWatcher = this.craftingWatchers.get( machine );
|
||||
if( craftingWatcher != null )
|
||||
{
|
||||
craftingWatcher.clear();
|
||||
@@ -180,7 +180,7 @@ public class CraftingGridCache implements ICraftingGrid, ICraftingProviderHelper
|
||||
|
||||
if( machine instanceof ICraftingRequester )
|
||||
{
|
||||
for( CraftingLinkNexus link : this.craftingLinks.values() )
|
||||
for( final CraftingLinkNexus link : this.craftingLinks.values() )
|
||||
{
|
||||
if( link.isMachine( machine ) )
|
||||
{
|
||||
@@ -202,19 +202,19 @@ public class CraftingGridCache implements ICraftingGrid, ICraftingProviderHelper
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addNode( IGridNode gridNode, IGridHost machine )
|
||||
public void addNode( final IGridNode gridNode, final IGridHost machine )
|
||||
{
|
||||
if( machine instanceof ICraftingWatcherHost )
|
||||
{
|
||||
ICraftingWatcherHost watcherHost = (ICraftingWatcherHost) machine;
|
||||
CraftingWatcher watcher = new CraftingWatcher( this, watcherHost );
|
||||
final ICraftingWatcherHost watcherHost = (ICraftingWatcherHost) machine;
|
||||
final CraftingWatcher watcher = new CraftingWatcher( this, watcherHost );
|
||||
this.craftingWatchers.put( gridNode, watcher );
|
||||
watcherHost.updateWatcher( watcher );
|
||||
}
|
||||
|
||||
if( machine instanceof ICraftingRequester )
|
||||
{
|
||||
for( ICraftingLink link : ( (ICraftingRequester) machine ).getRequestedJobs() )
|
||||
for( final ICraftingLink link : ( (ICraftingRequester) machine ).getRequestedJobs() )
|
||||
{
|
||||
if( link instanceof CraftingLink )
|
||||
{
|
||||
@@ -236,25 +236,25 @@ public class CraftingGridCache implements ICraftingGrid, ICraftingProviderHelper
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSplit( IGridStorage destinationStorage )
|
||||
public void onSplit( final IGridStorage destinationStorage )
|
||||
{ // nothing!
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onJoin( IGridStorage sourceStorage )
|
||||
public void onJoin( final IGridStorage sourceStorage )
|
||||
{
|
||||
// nothing!
|
||||
}
|
||||
|
||||
@Override
|
||||
public void populateGridStorage( IGridStorage destinationStorage )
|
||||
public void populateGridStorage( final IGridStorage destinationStorage )
|
||||
{
|
||||
// nothing!
|
||||
}
|
||||
|
||||
private void updatePatterns()
|
||||
{
|
||||
Map<IAEItemStack, ImmutableList<ICraftingPatternDetails>> oldItems = this.craftableItems;
|
||||
final Map<IAEItemStack, ImmutableList<ICraftingPatternDetails>> oldItems = this.craftableItems;
|
||||
|
||||
// erase list.
|
||||
this.craftingMethods.clear();
|
||||
@@ -265,15 +265,15 @@ public class CraftingGridCache implements ICraftingGrid, ICraftingProviderHelper
|
||||
this.storageGrid.postAlterationOfStoredItems( StorageChannel.ITEMS, oldItems.keySet(), new BaseActionSource() );
|
||||
|
||||
// re-create list..
|
||||
for( ICraftingProvider provider : this.craftingProviders )
|
||||
for( final ICraftingProvider provider : this.craftingProviders )
|
||||
{
|
||||
provider.provideCrafting( this );
|
||||
}
|
||||
|
||||
Map<IAEItemStack, Set<ICraftingPatternDetails>> tmpCraft = new HashMap<IAEItemStack, Set<ICraftingPatternDetails>>();
|
||||
final Map<IAEItemStack, Set<ICraftingPatternDetails>> tmpCraft = new HashMap<IAEItemStack, Set<ICraftingPatternDetails>>();
|
||||
|
||||
// new craftables!
|
||||
for( ICraftingPatternDetails details : this.craftingMethods.keySet() )
|
||||
for( final ICraftingPatternDetails details : this.craftingMethods.keySet() )
|
||||
{
|
||||
for( IAEItemStack out : details.getOutputs() )
|
||||
{
|
||||
@@ -293,7 +293,7 @@ public class CraftingGridCache implements ICraftingGrid, ICraftingProviderHelper
|
||||
}
|
||||
|
||||
// make them immutable
|
||||
for( Entry<IAEItemStack, Set<ICraftingPatternDetails>> e : tmpCraft.entrySet() )
|
||||
for( final Entry<IAEItemStack, Set<ICraftingPatternDetails>> e : tmpCraft.entrySet() )
|
||||
{
|
||||
this.craftableItems.put( e.getKey(), ImmutableList.copyOf( e.getValue() ) );
|
||||
}
|
||||
@@ -305,10 +305,10 @@ public class CraftingGridCache implements ICraftingGrid, ICraftingProviderHelper
|
||||
{
|
||||
this.craftingCPUClusters.clear();
|
||||
|
||||
for( IGridNode cst : this.grid.getMachines( TileCraftingStorageTile.class ) )
|
||||
for( final IGridNode cst : this.grid.getMachines( TileCraftingStorageTile.class ) )
|
||||
{
|
||||
TileCraftingStorageTile tile = (TileCraftingStorageTile) cst.getMachine();
|
||||
CraftingCPUCluster cluster = (CraftingCPUCluster) tile.getCluster();
|
||||
final TileCraftingStorageTile tile = (TileCraftingStorageTile) cst.getMachine();
|
||||
final CraftingCPUCluster cluster = (CraftingCPUCluster) tile.getCluster();
|
||||
if( cluster != null )
|
||||
{
|
||||
this.craftingCPUClusters.add( cluster );
|
||||
@@ -321,7 +321,7 @@ public class CraftingGridCache implements ICraftingGrid, ICraftingProviderHelper
|
||||
}
|
||||
}
|
||||
|
||||
public void addLink( CraftingLink link )
|
||||
public void addLink( final CraftingLink link )
|
||||
{
|
||||
if( link.isStandalone() )
|
||||
{
|
||||
@@ -338,19 +338,19 @@ public class CraftingGridCache implements ICraftingGrid, ICraftingProviderHelper
|
||||
}
|
||||
|
||||
@MENetworkEventSubscribe
|
||||
public void updateCPUClusters( MENetworkCraftingCpuChange c )
|
||||
public void updateCPUClusters( final MENetworkCraftingCpuChange c )
|
||||
{
|
||||
this.updateList = true;
|
||||
}
|
||||
|
||||
@MENetworkEventSubscribe
|
||||
public void updateCPUClusters( MENetworkCraftingPatternChange c )
|
||||
public void updateCPUClusters( final MENetworkCraftingPatternChange c )
|
||||
{
|
||||
this.updatePatterns();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCraftingOption( ICraftingMedium medium, ICraftingPatternDetails api )
|
||||
public void addCraftingOption( final ICraftingMedium medium, final ICraftingPatternDetails api )
|
||||
{
|
||||
List<ICraftingMedium> details = this.craftingMethods.get( api );
|
||||
if( details == null )
|
||||
@@ -366,15 +366,15 @@ public class CraftingGridCache implements ICraftingGrid, ICraftingProviderHelper
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEmitable( IAEItemStack someItem )
|
||||
public void setEmitable( final IAEItemStack someItem )
|
||||
{
|
||||
this.emitableItems.add( someItem.copy() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<IMEInventoryHandler> getCellArray( StorageChannel channel )
|
||||
public List<IMEInventoryHandler> getCellArray( final StorageChannel channel )
|
||||
{
|
||||
List<IMEInventoryHandler> list = new ArrayList<IMEInventoryHandler>( 1 );
|
||||
final List<IMEInventoryHandler> list = new ArrayList<IMEInventoryHandler>( 1 );
|
||||
|
||||
if( channel == StorageChannel.ITEMS )
|
||||
{
|
||||
@@ -397,15 +397,15 @@ public class CraftingGridCache implements ICraftingGrid, ICraftingProviderHelper
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPrioritized( IAEStack input )
|
||||
public boolean isPrioritized( final IAEStack input )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canAccept( IAEStack input )
|
||||
public boolean canAccept( final IAEStack input )
|
||||
{
|
||||
for( CraftingCPUCluster cpu : this.craftingCPUClusters )
|
||||
for( final CraftingCPUCluster cpu : this.craftingCPUClusters )
|
||||
{
|
||||
if( cpu.canAccept( input ) )
|
||||
{
|
||||
@@ -423,15 +423,15 @@ public class CraftingGridCache implements ICraftingGrid, ICraftingProviderHelper
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean validForPass( int i )
|
||||
public boolean validForPass( final int i )
|
||||
{
|
||||
return i == 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAEStack injectItems( IAEStack input, Actionable type, BaseActionSource src )
|
||||
public IAEStack injectItems( IAEStack input, final Actionable type, final BaseActionSource src )
|
||||
{
|
||||
for( CraftingCPUCluster cpu : this.craftingCPUClusters )
|
||||
for( final CraftingCPUCluster cpu : this.craftingCPUClusters )
|
||||
{
|
||||
input = cpu.injectItems( input, type, src );
|
||||
}
|
||||
@@ -440,21 +440,21 @@ public class CraftingGridCache implements ICraftingGrid, ICraftingProviderHelper
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAEStack extractItems( IAEStack request, Actionable mode, BaseActionSource src )
|
||||
public IAEStack extractItems( final IAEStack request, final Actionable mode, final BaseActionSource src )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemList<IAEStack> getAvailableItems( IItemList<IAEStack> out )
|
||||
public IItemList<IAEStack> getAvailableItems( final IItemList<IAEStack> out )
|
||||
{
|
||||
// add craftable items!
|
||||
for( IAEItemStack stack : this.craftableItems.keySet() )
|
||||
for( final IAEItemStack stack : this.craftableItems.keySet() )
|
||||
{
|
||||
out.addCrafting( stack );
|
||||
}
|
||||
|
||||
for( IAEItemStack st : this.emitableItems )
|
||||
for( final IAEItemStack st : this.emitableItems )
|
||||
{
|
||||
out.addCrafting( st );
|
||||
}
|
||||
@@ -469,15 +469,15 @@ public class CraftingGridCache implements ICraftingGrid, ICraftingProviderHelper
|
||||
}
|
||||
|
||||
@Override
|
||||
public ImmutableCollection<ICraftingPatternDetails> getCraftingFor( IAEItemStack whatToCraft, ICraftingPatternDetails details, int slotIndex, World world )
|
||||
public ImmutableCollection<ICraftingPatternDetails> getCraftingFor( final IAEItemStack whatToCraft, final ICraftingPatternDetails details, final int slotIndex, final World world )
|
||||
{
|
||||
ImmutableList<ICraftingPatternDetails> res = this.craftableItems.get( whatToCraft );
|
||||
final ImmutableList<ICraftingPatternDetails> res = this.craftableItems.get( whatToCraft );
|
||||
|
||||
if( res == null )
|
||||
{
|
||||
if( details != null && details.isCraftable() )
|
||||
{
|
||||
for( IAEItemStack ais : this.craftableItems.keySet() )
|
||||
for( final IAEItemStack ais : this.craftableItems.keySet() )
|
||||
{
|
||||
if( ais.getItem() == whatToCraft.getItem() && ( !ais.getItem().getHasSubtypes() || ais.getItemDamage() == whatToCraft.getItemDamage() ) )
|
||||
{
|
||||
@@ -496,20 +496,20 @@ public class CraftingGridCache implements ICraftingGrid, ICraftingProviderHelper
|
||||
}
|
||||
|
||||
@Override
|
||||
public Future<ICraftingJob> beginCraftingJob( World world, IGrid grid, BaseActionSource actionSrc, IAEItemStack slotItem, ICraftingCallback cb )
|
||||
public Future<ICraftingJob> beginCraftingJob( final World world, final IGrid grid, final BaseActionSource actionSrc, final IAEItemStack slotItem, final ICraftingCallback cb )
|
||||
{
|
||||
if( world == null || grid == null || actionSrc == null || slotItem == null )
|
||||
{
|
||||
throw new IllegalArgumentException( "Invalid Crafting Job Request" );
|
||||
}
|
||||
|
||||
CraftingJob job = new CraftingJob( world, grid, actionSrc, slotItem, cb );
|
||||
final CraftingJob job = new CraftingJob( world, grid, actionSrc, slotItem, cb );
|
||||
|
||||
return CRAFTING_POOL.submit( job, (ICraftingJob) job );
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICraftingLink submitJob( ICraftingJob job, ICraftingRequester requestingMachine, ICraftingCPU target, final boolean prioritizePower, BaseActionSource src )
|
||||
public ICraftingLink submitJob( final ICraftingJob job, final ICraftingRequester requestingMachine, final ICraftingCPU target, final boolean prioritizePower, final BaseActionSource src )
|
||||
{
|
||||
if( job.isSimulation() )
|
||||
{
|
||||
@@ -525,8 +525,8 @@ public class CraftingGridCache implements ICraftingGrid, ICraftingProviderHelper
|
||||
|
||||
if( target == null )
|
||||
{
|
||||
List<CraftingCPUCluster> validCpusClusters = new ArrayList<CraftingCPUCluster>();
|
||||
for( CraftingCPUCluster cpu : this.craftingCPUClusters )
|
||||
final List<CraftingCPUCluster> validCpusClusters = new ArrayList<CraftingCPUCluster>();
|
||||
for( final CraftingCPUCluster cpu : this.craftingCPUClusters )
|
||||
{
|
||||
if( cpu.isActive() && !cpu.isBusy() && cpu.getAvailableStorage() >= job.getByteTotal() )
|
||||
{
|
||||
@@ -537,11 +537,11 @@ public class CraftingGridCache implements ICraftingGrid, ICraftingProviderHelper
|
||||
Collections.sort( validCpusClusters, new Comparator<CraftingCPUCluster>()
|
||||
{
|
||||
@Override
|
||||
public int compare( CraftingCPUCluster firstCluster, CraftingCPUCluster nextCluster )
|
||||
public int compare( final CraftingCPUCluster firstCluster, final CraftingCPUCluster nextCluster )
|
||||
{
|
||||
if( prioritizePower )
|
||||
{
|
||||
int comparison = ItemSorters.compareLong( nextCluster.getCoProcessors(), firstCluster.getCoProcessors() );
|
||||
final int comparison = ItemSorters.compareLong( nextCluster.getCoProcessors(), firstCluster.getCoProcessors() );
|
||||
if( comparison != 0 )
|
||||
{
|
||||
return comparison;
|
||||
@@ -549,7 +549,7 @@ public class CraftingGridCache implements ICraftingGrid, ICraftingProviderHelper
|
||||
return ItemSorters.compareLong( nextCluster.getAvailableStorage(), firstCluster.getAvailableStorage() );
|
||||
}
|
||||
|
||||
int comparison = ItemSorters.compareLong( firstCluster.getCoProcessors(), nextCluster.getCoProcessors() );
|
||||
final int comparison = ItemSorters.compareLong( firstCluster.getCoProcessors(), nextCluster.getCoProcessors() );
|
||||
if( comparison != 0 )
|
||||
{
|
||||
return comparison;
|
||||
@@ -579,15 +579,15 @@ public class CraftingGridCache implements ICraftingGrid, ICraftingProviderHelper
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canEmitFor( IAEItemStack someItem )
|
||||
public boolean canEmitFor( final IAEItemStack someItem )
|
||||
{
|
||||
return this.emitableItems.contains( someItem );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRequesting( IAEItemStack what )
|
||||
public boolean isRequesting( final IAEItemStack what )
|
||||
{
|
||||
for( CraftingCPUCluster cluster : this.craftingCPUClusters )
|
||||
for( final CraftingCPUCluster cluster : this.craftingCPUClusters )
|
||||
{
|
||||
if( cluster.isMaking( what ) )
|
||||
{
|
||||
@@ -598,7 +598,7 @@ public class CraftingGridCache implements ICraftingGrid, ICraftingProviderHelper
|
||||
return false;
|
||||
}
|
||||
|
||||
public List<ICraftingMedium> getMediums( ICraftingPatternDetails key )
|
||||
public List<ICraftingMedium> getMediums( final ICraftingPatternDetails key )
|
||||
{
|
||||
List<ICraftingMedium> mediums = this.craftingMethods.get( key );
|
||||
|
||||
@@ -610,7 +610,7 @@ public class CraftingGridCache implements ICraftingGrid, ICraftingProviderHelper
|
||||
return mediums;
|
||||
}
|
||||
|
||||
public boolean hasCpu( ICraftingCPU cpu )
|
||||
public boolean hasCpu( final ICraftingCPU cpu )
|
||||
{
|
||||
return this.craftingCPUClusters.contains( cpu );
|
||||
}
|
||||
@@ -621,7 +621,7 @@ public class CraftingGridCache implements ICraftingGrid, ICraftingProviderHelper
|
||||
private final Iterator<CraftingCPUCluster> iterator;
|
||||
private CraftingCPUCluster cpuCluster;
|
||||
|
||||
public ActiveCpuIterator( Collection<CraftingCPUCluster> o )
|
||||
public ActiveCpuIterator( final Collection<CraftingCPUCluster> o )
|
||||
{
|
||||
this.iterator = o.iterator();
|
||||
this.cpuCluster = null;
|
||||
|
||||
+62
-62
@@ -95,33 +95,33 @@ public class EnergyGridCache implements IEnergyGrid
|
||||
PathGridCache pgc;
|
||||
double lastStoredPower = -1;
|
||||
|
||||
public EnergyGridCache( IGrid g )
|
||||
public EnergyGridCache( final IGrid g )
|
||||
{
|
||||
this.myGrid = g;
|
||||
}
|
||||
|
||||
@MENetworkEventSubscribe
|
||||
public void postInit( MENetworkPostCacheConstruction pcc )
|
||||
public void postInit( final MENetworkPostCacheConstruction pcc )
|
||||
{
|
||||
this.pgc = this.myGrid.getCache( IPathingGrid.class );
|
||||
}
|
||||
|
||||
@MENetworkEventSubscribe
|
||||
public void EnergyNodeChanges( MENetworkPowerIdleChange ev )
|
||||
public void EnergyNodeChanges( final MENetworkPowerIdleChange ev )
|
||||
{
|
||||
// update power usage based on event.
|
||||
GridNode node = (GridNode) ev.node;
|
||||
IGridBlock gb = node.getGridBlock();
|
||||
final GridNode node = (GridNode) ev.node;
|
||||
final IGridBlock gb = node.getGridBlock();
|
||||
|
||||
double newDraw = gb.getIdlePowerUsage();
|
||||
double diffDraw = newDraw - node.previousDraw;
|
||||
final double newDraw = gb.getIdlePowerUsage();
|
||||
final double diffDraw = newDraw - node.previousDraw;
|
||||
node.previousDraw = newDraw;
|
||||
|
||||
this.drainPerTick += diffDraw;
|
||||
}
|
||||
|
||||
@MENetworkEventSubscribe
|
||||
public void EnergyNodeChanges( MENetworkPowerStorage ev )
|
||||
public void EnergyNodeChanges( final MENetworkPowerStorage ev )
|
||||
{
|
||||
if( ev.storage.isAEPublicPowerStorage() )
|
||||
{
|
||||
@@ -152,12 +152,12 @@ public class EnergyGridCache implements IEnergyGrid
|
||||
{
|
||||
if( !this.interests.isEmpty() )
|
||||
{
|
||||
double oldPower = this.lastStoredPower;
|
||||
final double oldPower = this.lastStoredPower;
|
||||
this.lastStoredPower = this.getStoredPower();
|
||||
|
||||
EnergyThreshold low = new EnergyThreshold( Math.min( oldPower, this.lastStoredPower ), null );
|
||||
EnergyThreshold high = new EnergyThreshold( Math.max( oldPower, this.lastStoredPower ), null );
|
||||
for( EnergyThreshold th : this.interests.subSet( low, true, high, true ) )
|
||||
final EnergyThreshold low = new EnergyThreshold( Math.min( oldPower, this.lastStoredPower ), null );
|
||||
final EnergyThreshold high = new EnergyThreshold( Math.max( oldPower, this.lastStoredPower ), null );
|
||||
for( final EnergyThreshold th : this.interests.subSet( low, true, high, true ) )
|
||||
{
|
||||
( (EnergyWatcher) th.watcher ).post( this );
|
||||
}
|
||||
@@ -177,7 +177,7 @@ public class EnergyGridCache implements IEnergyGrid
|
||||
|
||||
if( this.drainPerTick > 0.0001 )
|
||||
{
|
||||
double drained = this.extractAEPower( this.getIdlePowerUsage(), Actionable.MODULATE, PowerMultiplier.CONFIG );
|
||||
final double drained = this.extractAEPower( this.getIdlePowerUsage(), Actionable.MODULATE, PowerMultiplier.CONFIG );
|
||||
currentlyHasPower = drained >= this.drainPerTick - 0.001;
|
||||
}
|
||||
else
|
||||
@@ -212,7 +212,7 @@ public class EnergyGridCache implements IEnergyGrid
|
||||
}
|
||||
|
||||
@Override
|
||||
public double extractAEPower( double amt, Actionable mode, PowerMultiplier pm )
|
||||
public double extractAEPower( final double amt, final Actionable mode, final PowerMultiplier pm )
|
||||
{
|
||||
this.localSeen.clear();
|
||||
return pm.divide( this.extractAEPower( pm.multiply( amt ), mode, this.localSeen ) );
|
||||
@@ -224,7 +224,7 @@ public class EnergyGridCache implements IEnergyGrid
|
||||
return this.drainPerTick + this.pgc.channelPowerUsage;
|
||||
}
|
||||
|
||||
private void publicPowerState( boolean newState, IGrid grid )
|
||||
private void publicPowerState( final boolean newState, final IGrid grid )
|
||||
{
|
||||
if( this.publicHasPower == newState )
|
||||
{
|
||||
@@ -243,14 +243,14 @@ public class EnergyGridCache implements IEnergyGrid
|
||||
{
|
||||
this.availableTicksSinceUpdate = 0;
|
||||
this.globalAvailablePower = 0;
|
||||
for( IAEPowerStorage p : this.providers )
|
||||
for( final IAEPowerStorage p : this.providers )
|
||||
{
|
||||
this.globalAvailablePower += p.getAECurrentPower();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public double extractAEPower( double amt, Actionable mode, Set<IEnergyGrid> seen )
|
||||
public double extractAEPower( final double amt, final Actionable mode, final Set<IEnergyGrid> seen )
|
||||
{
|
||||
if( !seen.add( this ) )
|
||||
{
|
||||
@@ -265,7 +265,7 @@ public class EnergyGridCache implements IEnergyGrid
|
||||
|
||||
if( extractedPower < amt )
|
||||
{
|
||||
Iterator<IEnergyGridProvider> i = this.energyGridProviders.iterator();
|
||||
final Iterator<IEnergyGridProvider> i = this.energyGridProviders.iterator();
|
||||
while( extractedPower < amt && i.hasNext() )
|
||||
{
|
||||
extractedPower += i.next().extractAEPower( amt - extractedPower, mode, seen );
|
||||
@@ -292,7 +292,7 @@ public class EnergyGridCache implements IEnergyGrid
|
||||
|
||||
if( extractedPower < amt )
|
||||
{
|
||||
Iterator<IEnergyGridProvider> i = this.energyGridProviders.iterator();
|
||||
final Iterator<IEnergyGridProvider> i = this.energyGridProviders.iterator();
|
||||
while( extractedPower < amt && i.hasNext() )
|
||||
{
|
||||
extractedPower += i.next().extractAEPower( amt - extractedPower, mode, seen );
|
||||
@@ -306,26 +306,26 @@ public class EnergyGridCache implements IEnergyGrid
|
||||
}
|
||||
|
||||
@Override
|
||||
public double injectAEPower( double amt, Actionable mode, Set<IEnergyGrid> seen )
|
||||
public double injectAEPower( double amt, final Actionable mode, final Set<IEnergyGrid> seen )
|
||||
{
|
||||
if( !seen.add( this ) )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
double ignore = this.extra;
|
||||
final double ignore = this.extra;
|
||||
amt += this.extra;
|
||||
|
||||
if( mode == Actionable.SIMULATE )
|
||||
{
|
||||
Iterator<IAEPowerStorage> it = this.requesters.iterator();
|
||||
final Iterator<IAEPowerStorage> it = this.requesters.iterator();
|
||||
while( amt > 0 && it.hasNext() )
|
||||
{
|
||||
IAEPowerStorage node = it.next();
|
||||
final IAEPowerStorage node = it.next();
|
||||
amt = node.injectAEPower( amt, Actionable.SIMULATE );
|
||||
}
|
||||
|
||||
Iterator<IEnergyGridProvider> i = this.energyGridProviders.iterator();
|
||||
final Iterator<IEnergyGridProvider> i = this.energyGridProviders.iterator();
|
||||
while( amt > 0 && i.hasNext() )
|
||||
{
|
||||
amt = i.next().injectAEPower( amt, mode, seen );
|
||||
@@ -338,7 +338,7 @@ public class EnergyGridCache implements IEnergyGrid
|
||||
|
||||
while( amt > 0 && !this.requesters.isEmpty() )
|
||||
{
|
||||
IAEPowerStorage node = this.getFirstRequester();
|
||||
final IAEPowerStorage node = this.getFirstRequester();
|
||||
|
||||
amt = node.injectAEPower( amt, Actionable.MODULATE );
|
||||
if( amt > 0 )
|
||||
@@ -348,14 +348,14 @@ public class EnergyGridCache implements IEnergyGrid
|
||||
}
|
||||
}
|
||||
|
||||
Iterator<IEnergyGridProvider> i = this.energyGridProviders.iterator();
|
||||
final Iterator<IEnergyGridProvider> i = this.energyGridProviders.iterator();
|
||||
while( amt > 0 && i.hasNext() )
|
||||
{
|
||||
IEnergyGridProvider what = i.next();
|
||||
Set<IEnergyGrid> listCopy = new HashSet<IEnergyGrid>();
|
||||
final IEnergyGridProvider what = i.next();
|
||||
final Set<IEnergyGrid> listCopy = new HashSet<IEnergyGrid>();
|
||||
listCopy.addAll( seen );
|
||||
|
||||
double cannotHold = what.injectAEPower( amt, Actionable.SIMULATE, listCopy );
|
||||
final double cannotHold = what.injectAEPower( amt, Actionable.SIMULATE, listCopy );
|
||||
what.injectAEPower( amt - cannotHold, mode, seen );
|
||||
|
||||
amt = cannotHold;
|
||||
@@ -368,7 +368,7 @@ public class EnergyGridCache implements IEnergyGrid
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getEnergyDemand( double maxRequired, Set<IEnergyGrid> seen )
|
||||
public double getEnergyDemand( final double maxRequired, final Set<IEnergyGrid> seen )
|
||||
{
|
||||
if( !seen.add( this ) )
|
||||
{
|
||||
@@ -377,50 +377,50 @@ public class EnergyGridCache implements IEnergyGrid
|
||||
|
||||
double required = this.buffer() - this.extra;
|
||||
|
||||
Iterator<IAEPowerStorage> it = this.requesters.iterator();
|
||||
final Iterator<IAEPowerStorage> it = this.requesters.iterator();
|
||||
while( required < maxRequired && it.hasNext() )
|
||||
{
|
||||
IAEPowerStorage node = it.next();
|
||||
final IAEPowerStorage node = it.next();
|
||||
if( node.getPowerFlow() != AccessRestriction.READ )
|
||||
{
|
||||
required += Math.max( 0.0, node.getAEMaxPower() - node.getAECurrentPower() );
|
||||
}
|
||||
}
|
||||
|
||||
Iterator<IEnergyGridProvider> ix = this.energyGridProviders.iterator();
|
||||
final Iterator<IEnergyGridProvider> ix = this.energyGridProviders.iterator();
|
||||
while( required < maxRequired && ix.hasNext() )
|
||||
{
|
||||
IEnergyGridProvider node = ix.next();
|
||||
final IEnergyGridProvider node = ix.next();
|
||||
required += node.getEnergyDemand( maxRequired - required, seen );
|
||||
}
|
||||
|
||||
return required;
|
||||
}
|
||||
|
||||
private double simulateExtract( double extractedPower, double amt )
|
||||
private double simulateExtract( double extractedPower, final double amt )
|
||||
{
|
||||
Iterator<IAEPowerStorage> it = this.providers.iterator();
|
||||
final Iterator<IAEPowerStorage> it = this.providers.iterator();
|
||||
|
||||
while( extractedPower < amt && it.hasNext() )
|
||||
{
|
||||
IAEPowerStorage node = it.next();
|
||||
final IAEPowerStorage node = it.next();
|
||||
|
||||
double req = amt - extractedPower;
|
||||
double newPower = node.extractAEPower( req, Actionable.SIMULATE, PowerMultiplier.ONE );
|
||||
final double req = amt - extractedPower;
|
||||
final double newPower = node.extractAEPower( req, Actionable.SIMULATE, PowerMultiplier.ONE );
|
||||
extractedPower += newPower;
|
||||
}
|
||||
|
||||
return extractedPower;
|
||||
}
|
||||
|
||||
private double doExtract( double extractedPower, double amt )
|
||||
private double doExtract( double extractedPower, final double amt )
|
||||
{
|
||||
while( extractedPower < amt && !this.providers.isEmpty() )
|
||||
{
|
||||
IAEPowerStorage node = this.getFirstProvider();
|
||||
final IAEPowerStorage node = this.getFirstProvider();
|
||||
|
||||
double req = amt - extractedPower;
|
||||
double newPower = node.extractAEPower( req, Actionable.MODULATE, PowerMultiplier.ONE );
|
||||
final double req = amt - extractedPower;
|
||||
final double newPower = node.extractAEPower( req, Actionable.MODULATE, PowerMultiplier.ONE );
|
||||
extractedPower += newPower;
|
||||
|
||||
if( newPower < req )
|
||||
@@ -438,7 +438,7 @@ public class EnergyGridCache implements IEnergyGrid
|
||||
{
|
||||
if( this.lastProvider == null )
|
||||
{
|
||||
Iterator<IAEPowerStorage> i = this.providers.iterator();
|
||||
final Iterator<IAEPowerStorage> i = this.providers.iterator();
|
||||
this.lastProvider = i.hasNext() ? i.next() : null;
|
||||
}
|
||||
|
||||
@@ -464,7 +464,7 @@ public class EnergyGridCache implements IEnergyGrid
|
||||
}
|
||||
|
||||
@Override
|
||||
public double injectPower( double amt, Actionable mode )
|
||||
public double injectPower( final double amt, final Actionable mode )
|
||||
{
|
||||
this.localSeen.clear();
|
||||
return this.injectAEPower( amt, mode, this.localSeen );
|
||||
@@ -474,7 +474,7 @@ public class EnergyGridCache implements IEnergyGrid
|
||||
{
|
||||
if( this.lastRequester == null )
|
||||
{
|
||||
Iterator<IAEPowerStorage> i = this.requesters.iterator();
|
||||
final Iterator<IAEPowerStorage> i = this.requesters.iterator();
|
||||
this.lastRequester = i.hasNext() ? i.next() : null;
|
||||
}
|
||||
|
||||
@@ -504,14 +504,14 @@ public class EnergyGridCache implements IEnergyGrid
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getEnergyDemand( double maxRequired )
|
||||
public double getEnergyDemand( final double maxRequired )
|
||||
{
|
||||
this.localSeen.clear();
|
||||
return this.getEnergyDemand( maxRequired, this.localSeen );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeNode( IGridNode node, IGridHost machine )
|
||||
public void removeNode( final IGridNode node, final IGridHost machine )
|
||||
{
|
||||
if( machine instanceof IEnergyGridProvider )
|
||||
{
|
||||
@@ -519,13 +519,13 @@ public class EnergyGridCache implements IEnergyGrid
|
||||
}
|
||||
|
||||
// idle draw.
|
||||
GridNode gridNode = (GridNode) node;
|
||||
final GridNode gridNode = (GridNode) node;
|
||||
this.drainPerTick -= gridNode.previousDraw;
|
||||
|
||||
// power storage.
|
||||
if( machine instanceof IAEPowerStorage )
|
||||
{
|
||||
IAEPowerStorage ps = (IAEPowerStorage) machine;
|
||||
final IAEPowerStorage ps = (IAEPowerStorage) machine;
|
||||
if( ps.isAEPublicPowerStorage() )
|
||||
{
|
||||
if( ps.getPowerFlow() != AccessRestriction.WRITE )
|
||||
@@ -551,7 +551,7 @@ public class EnergyGridCache implements IEnergyGrid
|
||||
|
||||
if( machine instanceof IStackWatcherHost )
|
||||
{
|
||||
IEnergyWatcher myWatcher = this.watchers.get( machine );
|
||||
final IEnergyWatcher myWatcher = this.watchers.get( machine );
|
||||
if( myWatcher != null )
|
||||
{
|
||||
myWatcher.clear();
|
||||
@@ -561,7 +561,7 @@ public class EnergyGridCache implements IEnergyGrid
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addNode( IGridNode node, IGridHost machine )
|
||||
public void addNode( final IGridNode node, final IGridHost machine )
|
||||
{
|
||||
if( machine instanceof IEnergyGridProvider )
|
||||
{
|
||||
@@ -569,19 +569,19 @@ public class EnergyGridCache implements IEnergyGrid
|
||||
}
|
||||
|
||||
// idle draw...
|
||||
GridNode gridNode = (GridNode) node;
|
||||
IGridBlock gb = gridNode.getGridBlock();
|
||||
final GridNode gridNode = (GridNode) node;
|
||||
final IGridBlock gb = gridNode.getGridBlock();
|
||||
gridNode.previousDraw = gb.getIdlePowerUsage();
|
||||
this.drainPerTick += gridNode.previousDraw;
|
||||
|
||||
// power storage
|
||||
if( machine instanceof IAEPowerStorage )
|
||||
{
|
||||
IAEPowerStorage ps = (IAEPowerStorage) machine;
|
||||
final IAEPowerStorage ps = (IAEPowerStorage) machine;
|
||||
if( ps.isAEPublicPowerStorage() )
|
||||
{
|
||||
double max = ps.getAEMaxPower();
|
||||
double current = ps.getAECurrentPower();
|
||||
final double max = ps.getAEMaxPower();
|
||||
final double current = ps.getAECurrentPower();
|
||||
|
||||
if( ps.getPowerFlow() != AccessRestriction.WRITE )
|
||||
{
|
||||
@@ -603,8 +603,8 @@ public class EnergyGridCache implements IEnergyGrid
|
||||
|
||||
if( machine instanceof IEnergyWatcherHost )
|
||||
{
|
||||
IEnergyWatcherHost swh = (IEnergyWatcherHost) machine;
|
||||
EnergyWatcher iw = new EnergyWatcher( this, swh );
|
||||
final IEnergyWatcherHost swh = (IEnergyWatcherHost) machine;
|
||||
final EnergyWatcher iw = new EnergyWatcher( this, swh );
|
||||
this.watchers.put( node, iw );
|
||||
swh.updateWatcher( iw );
|
||||
}
|
||||
@@ -613,20 +613,20 @@ public class EnergyGridCache implements IEnergyGrid
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSplit( IGridStorage storageB )
|
||||
public void onSplit( final IGridStorage storageB )
|
||||
{
|
||||
this.extra /= 2;
|
||||
storageB.dataObject().setDouble( "extraEnergy", this.extra );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onJoin( IGridStorage storageB )
|
||||
public void onJoin( final IGridStorage storageB )
|
||||
{
|
||||
this.extra += storageB.dataObject().getDouble( "extraEnergy" );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void populateGridStorage( IGridStorage storage )
|
||||
public void populateGridStorage( final IGridStorage storage )
|
||||
{
|
||||
storage.dataObject().setDouble( "extraEnergy", this.extra );
|
||||
}
|
||||
|
||||
+35
-35
@@ -69,7 +69,7 @@ public class GridStorageCache implements IStorageGrid
|
||||
private NetworkInventoryHandler<IAEItemStack> myItemNetwork;
|
||||
private NetworkInventoryHandler<IAEFluidStack> myFluidNetwork;
|
||||
|
||||
public GridStorageCache( IGrid g )
|
||||
public GridStorageCache( final IGrid g )
|
||||
{
|
||||
this.myGrid = g;
|
||||
}
|
||||
@@ -82,11 +82,11 @@ public class GridStorageCache implements IStorageGrid
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeNode( IGridNode node, IGridHost machine )
|
||||
public void removeNode( final IGridNode node, final IGridHost machine )
|
||||
{
|
||||
if( machine instanceof ICellContainer )
|
||||
{
|
||||
ICellContainer cc = (ICellContainer) machine;
|
||||
final ICellContainer cc = (ICellContainer) machine;
|
||||
|
||||
this.myGrid.postEvent( new MENetworkCellArrayUpdate() );
|
||||
this.removeCellProvider( cc, new CellChangeTracker() ).applyChanges();
|
||||
@@ -95,7 +95,7 @@ public class GridStorageCache implements IStorageGrid
|
||||
|
||||
if( machine instanceof IStackWatcherHost )
|
||||
{
|
||||
IStackWatcher myWatcher = this.watchers.get( machine );
|
||||
final IStackWatcher myWatcher = this.watchers.get( machine );
|
||||
if( myWatcher != null )
|
||||
{
|
||||
myWatcher.clear();
|
||||
@@ -105,11 +105,11 @@ public class GridStorageCache implements IStorageGrid
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addNode( IGridNode node, IGridHost machine )
|
||||
public void addNode( final IGridNode node, final IGridHost machine )
|
||||
{
|
||||
if( machine instanceof ICellContainer )
|
||||
{
|
||||
ICellContainer cc = (ICellContainer) machine;
|
||||
final ICellContainer cc = (ICellContainer) machine;
|
||||
this.inactiveCellProviders.add( cc );
|
||||
|
||||
this.myGrid.postEvent( new MENetworkCellArrayUpdate() );
|
||||
@@ -121,32 +121,32 @@ public class GridStorageCache implements IStorageGrid
|
||||
|
||||
if( machine instanceof IStackWatcherHost )
|
||||
{
|
||||
IStackWatcherHost swh = (IStackWatcherHost) machine;
|
||||
ItemWatcher iw = new ItemWatcher( this, swh );
|
||||
final IStackWatcherHost swh = (IStackWatcherHost) machine;
|
||||
final ItemWatcher iw = new ItemWatcher( this, swh );
|
||||
this.watchers.put( node, iw );
|
||||
swh.updateWatcher( iw );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSplit( IGridStorage storageB )
|
||||
public void onSplit( final IGridStorage storageB )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onJoin( IGridStorage storageB )
|
||||
public void onJoin( final IGridStorage storageB )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void populateGridStorage( IGridStorage storage )
|
||||
public void populateGridStorage( final IGridStorage storage )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public CellChangeTracker addCellProvider( ICellProvider cc, CellChangeTracker tracker )
|
||||
public CellChangeTracker addCellProvider( final ICellProvider cc, final CellChangeTracker tracker )
|
||||
{
|
||||
if( this.inactiveCellProviders.contains( cc ) )
|
||||
{
|
||||
@@ -159,12 +159,12 @@ public class GridStorageCache implements IStorageGrid
|
||||
actionSrc = new MachineSource( (IActionHost) cc );
|
||||
}
|
||||
|
||||
for( IMEInventoryHandler<IAEItemStack> h : cc.getCellArray( StorageChannel.ITEMS ) )
|
||||
for( final IMEInventoryHandler<IAEItemStack> h : cc.getCellArray( StorageChannel.ITEMS ) )
|
||||
{
|
||||
tracker.postChanges( StorageChannel.ITEMS, 1, h, actionSrc );
|
||||
}
|
||||
|
||||
for( IMEInventoryHandler<IAEFluidStack> h : cc.getCellArray( StorageChannel.FLUIDS ) )
|
||||
for( final IMEInventoryHandler<IAEFluidStack> h : cc.getCellArray( StorageChannel.FLUIDS ) )
|
||||
{
|
||||
tracker.postChanges( StorageChannel.FLUIDS, 1, h, actionSrc );
|
||||
}
|
||||
@@ -173,7 +173,7 @@ public class GridStorageCache implements IStorageGrid
|
||||
return tracker;
|
||||
}
|
||||
|
||||
public CellChangeTracker removeCellProvider( ICellProvider cc, CellChangeTracker tracker )
|
||||
public CellChangeTracker removeCellProvider( final ICellProvider cc, final CellChangeTracker tracker )
|
||||
{
|
||||
if( this.activeCellProviders.contains( cc ) )
|
||||
{
|
||||
@@ -186,12 +186,12 @@ public class GridStorageCache implements IStorageGrid
|
||||
actionSrc = new MachineSource( (IActionHost) cc );
|
||||
}
|
||||
|
||||
for( IMEInventoryHandler<IAEItemStack> h : cc.getCellArray( StorageChannel.ITEMS ) )
|
||||
for( final IMEInventoryHandler<IAEItemStack> h : cc.getCellArray( StorageChannel.ITEMS ) )
|
||||
{
|
||||
tracker.postChanges( StorageChannel.ITEMS, -1, h, actionSrc );
|
||||
}
|
||||
|
||||
for( IMEInventoryHandler<IAEFluidStack> h : cc.getCellArray( StorageChannel.FLUIDS ) )
|
||||
for( final IMEInventoryHandler<IAEFluidStack> h : cc.getCellArray( StorageChannel.FLUIDS ) )
|
||||
{
|
||||
tracker.postChanges( StorageChannel.FLUIDS, -1, h, actionSrc );
|
||||
}
|
||||
@@ -201,24 +201,24 @@ public class GridStorageCache implements IStorageGrid
|
||||
}
|
||||
|
||||
@MENetworkEventSubscribe
|
||||
public void cellUpdate( MENetworkCellArrayUpdate ev )
|
||||
public void cellUpdate( final MENetworkCellArrayUpdate ev )
|
||||
{
|
||||
this.myItemNetwork = null;
|
||||
this.myFluidNetwork = null;
|
||||
|
||||
LinkedList<ICellProvider> ll = new LinkedList();
|
||||
final LinkedList<ICellProvider> ll = new LinkedList();
|
||||
ll.addAll( this.inactiveCellProviders );
|
||||
ll.addAll( this.activeCellProviders );
|
||||
|
||||
CellChangeTracker tracker = new CellChangeTracker();
|
||||
final CellChangeTracker tracker = new CellChangeTracker();
|
||||
|
||||
for( ICellProvider cc : ll )
|
||||
for( final ICellProvider cc : ll )
|
||||
{
|
||||
boolean Active = true;
|
||||
|
||||
if( cc instanceof IActionHost )
|
||||
{
|
||||
IGridNode node = ( (IActionHost) cc ).getActionableNode();
|
||||
final IGridNode node = ( (IActionHost) cc ).getActionableNode();
|
||||
if( node != null && node.isActive() )
|
||||
{
|
||||
Active = true;
|
||||
@@ -245,7 +245,7 @@ public class GridStorageCache implements IStorageGrid
|
||||
tracker.applyChanges();
|
||||
}
|
||||
|
||||
private void postChangesToNetwork( StorageChannel chan, int upOrDown, IItemList availableItems, BaseActionSource src )
|
||||
private void postChangesToNetwork( final StorageChannel chan, final int upOrDown, final IItemList availableItems, final BaseActionSource src )
|
||||
{
|
||||
switch( chan )
|
||||
{
|
||||
@@ -268,17 +268,17 @@ public class GridStorageCache implements IStorageGrid
|
||||
return this.myItemNetwork;
|
||||
}
|
||||
|
||||
private void buildNetworkStorage( StorageChannel chan )
|
||||
private void buildNetworkStorage( final StorageChannel chan )
|
||||
{
|
||||
SecurityCache security = this.myGrid.getCache( ISecurityGrid.class );
|
||||
final SecurityCache security = this.myGrid.getCache( ISecurityGrid.class );
|
||||
|
||||
switch( chan )
|
||||
{
|
||||
case FLUIDS:
|
||||
this.myFluidNetwork = new NetworkInventoryHandler<IAEFluidStack>( StorageChannel.FLUIDS, security );
|
||||
for( ICellProvider cc : this.activeCellProviders )
|
||||
for( final ICellProvider cc : this.activeCellProviders )
|
||||
{
|
||||
for( IMEInventoryHandler<IAEFluidStack> h : cc.getCellArray( chan ) )
|
||||
for( final IMEInventoryHandler<IAEFluidStack> h : cc.getCellArray( chan ) )
|
||||
{
|
||||
this.myFluidNetwork.addNewStorage( h );
|
||||
}
|
||||
@@ -286,9 +286,9 @@ public class GridStorageCache implements IStorageGrid
|
||||
break;
|
||||
case ITEMS:
|
||||
this.myItemNetwork = new NetworkInventoryHandler<IAEItemStack>( StorageChannel.ITEMS, security );
|
||||
for( ICellProvider cc : this.activeCellProviders )
|
||||
for( final ICellProvider cc : this.activeCellProviders )
|
||||
{
|
||||
for( IMEInventoryHandler<IAEItemStack> h : cc.getCellArray( chan ) )
|
||||
for( final IMEInventoryHandler<IAEItemStack> h : cc.getCellArray( chan ) )
|
||||
{
|
||||
this.myItemNetwork.addNewStorage( h );
|
||||
}
|
||||
@@ -308,7 +308,7 @@ public class GridStorageCache implements IStorageGrid
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postAlterationOfStoredItems( StorageChannel chan, Iterable<? extends IAEStack> input, BaseActionSource src )
|
||||
public void postAlterationOfStoredItems( final StorageChannel chan, final Iterable<? extends IAEStack> input, final BaseActionSource src )
|
||||
{
|
||||
if( chan == StorageChannel.ITEMS )
|
||||
{
|
||||
@@ -321,14 +321,14 @@ public class GridStorageCache implements IStorageGrid
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerCellProvider( ICellProvider provider )
|
||||
public void registerCellProvider( final ICellProvider provider )
|
||||
{
|
||||
this.inactiveCellProviders.add( provider );
|
||||
this.addCellProvider( provider, new CellChangeTracker() ).applyChanges();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unregisterCellProvider( ICellProvider provider )
|
||||
public void unregisterCellProvider( final ICellProvider provider )
|
||||
{
|
||||
this.removeCellProvider( provider, new CellChangeTracker() ).applyChanges();
|
||||
this.inactiveCellProviders.remove( provider );
|
||||
@@ -354,7 +354,7 @@ public class GridStorageCache implements IStorageGrid
|
||||
final IItemList list;
|
||||
final BaseActionSource src;
|
||||
|
||||
public CellChangeTrackerRecord( StorageChannel channel, int i, IMEInventoryHandler<? extends IAEStack> h, BaseActionSource actionSrc )
|
||||
public CellChangeTrackerRecord( final StorageChannel channel, final int i, final IMEInventoryHandler<? extends IAEStack> h, final BaseActionSource actionSrc )
|
||||
{
|
||||
this.channel = channel;
|
||||
this.up_or_down = i;
|
||||
@@ -386,14 +386,14 @@ public class GridStorageCache implements IStorageGrid
|
||||
|
||||
final List<CellChangeTrackerRecord> data = new LinkedList<CellChangeTrackerRecord>();
|
||||
|
||||
public void postChanges( StorageChannel channel, int i, IMEInventoryHandler<? extends IAEStack> h, BaseActionSource actionSrc )
|
||||
public void postChanges( final StorageChannel channel, final int i, final IMEInventoryHandler<? extends IAEStack> h, final BaseActionSource actionSrc )
|
||||
{
|
||||
this.data.add( new CellChangeTrackerRecord( channel, i, h, actionSrc ) );
|
||||
}
|
||||
|
||||
public void applyChanges()
|
||||
{
|
||||
for( CellChangeTrackerRecord rec : this.data )
|
||||
for( final CellChangeTrackerRecord rec : this.data )
|
||||
{
|
||||
rec.applyChanges();
|
||||
}
|
||||
|
||||
+10
-10
@@ -44,7 +44,7 @@ public class NetworkMonitor<T extends IAEStack<T>> extends MEMonitorHandler<T>
|
||||
private final StorageChannel myChannel;
|
||||
boolean sendEvent = false;
|
||||
|
||||
public NetworkMonitor( GridStorageCache cache, StorageChannel chan )
|
||||
public NetworkMonitor( final GridStorageCache cache, final StorageChannel chan )
|
||||
{
|
||||
super( null, chan );
|
||||
this.myGridCache = cache;
|
||||
@@ -55,11 +55,11 @@ public class NetworkMonitor<T extends IAEStack<T>> extends MEMonitorHandler<T>
|
||||
{
|
||||
this.hasChanged = true;
|
||||
|
||||
Iterator<Entry<IMEMonitorHandlerReceiver<T>, Object>> i = this.getListeners();
|
||||
final Iterator<Entry<IMEMonitorHandlerReceiver<T>, Object>> i = this.getListeners();
|
||||
while( i.hasNext() )
|
||||
{
|
||||
Entry<IMEMonitorHandlerReceiver<T>, Object> o = i.next();
|
||||
IMEMonitorHandlerReceiver<T> receiver = o.getKey();
|
||||
final Entry<IMEMonitorHandlerReceiver<T>, Object> o = i.next();
|
||||
final IMEMonitorHandlerReceiver<T> receiver = o.getKey();
|
||||
|
||||
if( receiver.isValid( o.getValue() ) )
|
||||
{
|
||||
@@ -96,12 +96,12 @@ public class NetworkMonitor<T extends IAEStack<T>> extends MEMonitorHandler<T>
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void postChangesToListeners( Iterable<T> changes, BaseActionSource src )
|
||||
protected void postChangesToListeners( final Iterable<T> changes, final BaseActionSource src )
|
||||
{
|
||||
this.postChange( true, changes, src );
|
||||
}
|
||||
|
||||
protected void postChange( boolean add, Iterable<T> changes, BaseActionSource src )
|
||||
protected void postChange( final boolean add, final Iterable<T> changes, final BaseActionSource src )
|
||||
{
|
||||
if( DEPTH.contains( this ) )
|
||||
{
|
||||
@@ -113,9 +113,9 @@ public class NetworkMonitor<T extends IAEStack<T>> extends MEMonitorHandler<T>
|
||||
this.sendEvent = true;
|
||||
this.notifyListenersOfChange( changes, src );
|
||||
|
||||
IItemList<T> myStorageList = this.getStorageList();
|
||||
final IItemList<T> myStorageList = this.getStorageList();
|
||||
|
||||
for( T changedItem : changes )
|
||||
for( final T changedItem : changes )
|
||||
{
|
||||
T difference = changedItem;
|
||||
|
||||
@@ -126,7 +126,7 @@ public class NetworkMonitor<T extends IAEStack<T>> extends MEMonitorHandler<T>
|
||||
|
||||
if( this.myGridCache.interestManager.containsKey( changedItem ) )
|
||||
{
|
||||
Collection<ItemWatcher> list = this.myGridCache.interestManager.get( changedItem );
|
||||
final Collection<ItemWatcher> list = this.myGridCache.interestManager.get( changedItem );
|
||||
if( !list.isEmpty() )
|
||||
{
|
||||
IAEStack fullStack = myStorageList.findPrecise( changedItem );
|
||||
@@ -138,7 +138,7 @@ public class NetworkMonitor<T extends IAEStack<T>> extends MEMonitorHandler<T>
|
||||
|
||||
this.myGridCache.interestManager.enableTransactions();
|
||||
|
||||
for( ItemWatcher iw : list )
|
||||
for( final ItemWatcher iw : list )
|
||||
{
|
||||
iw.getHost().onStackChange( myStorageList, fullStack, difference, src, this.getChannel() );
|
||||
}
|
||||
|
||||
+22
-22
@@ -47,16 +47,16 @@ public class P2PCache implements IGridCache
|
||||
private final Multimap<Long, PartP2PTunnel> outputs = LinkedHashMultimap.create();
|
||||
private final TunnelCollection NullColl = new TunnelCollection<PartP2PTunnel>( null, null );
|
||||
|
||||
public P2PCache( IGrid g )
|
||||
public P2PCache( final IGrid g )
|
||||
{
|
||||
this.myGrid = g;
|
||||
}
|
||||
|
||||
@MENetworkEventSubscribe
|
||||
public void bootComplete( MENetworkBootingStatusChange bootStatus )
|
||||
public void bootComplete( final MENetworkBootingStatusChange bootStatus )
|
||||
{
|
||||
ITickManager tm = this.myGrid.getCache( ITickManager.class );
|
||||
for( PartP2PTunnel me : this.inputs.values() )
|
||||
final ITickManager tm = this.myGrid.getCache( ITickManager.class );
|
||||
for( final PartP2PTunnel me : this.inputs.values() )
|
||||
{
|
||||
if( me instanceof PartP2PTunnelME )
|
||||
{
|
||||
@@ -66,10 +66,10 @@ public class P2PCache implements IGridCache
|
||||
}
|
||||
|
||||
@MENetworkEventSubscribe
|
||||
public void bootComplete( MENetworkPowerStatusChange power )
|
||||
public void bootComplete( final MENetworkPowerStatusChange power )
|
||||
{
|
||||
ITickManager tm = this.myGrid.getCache( ITickManager.class );
|
||||
for( PartP2PTunnel me : this.inputs.values() )
|
||||
final ITickManager tm = this.myGrid.getCache( ITickManager.class );
|
||||
for( final PartP2PTunnel me : this.inputs.values() )
|
||||
{
|
||||
if( me instanceof PartP2PTunnelME )
|
||||
{
|
||||
@@ -85,7 +85,7 @@ public class P2PCache implements IGridCache
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeNode( IGridNode node, IGridHost machine )
|
||||
public void removeNode( final IGridNode node, final IGridHost machine )
|
||||
{
|
||||
if( machine instanceof PartP2PTunnel )
|
||||
{
|
||||
@@ -97,7 +97,7 @@ public class P2PCache implements IGridCache
|
||||
}
|
||||
}
|
||||
|
||||
PartP2PTunnel t = (PartP2PTunnel) machine;
|
||||
final PartP2PTunnel t = (PartP2PTunnel) machine;
|
||||
// AELog.info( "rmv-" + (t.output ? "output: " : "input: ") + t.freq
|
||||
// );
|
||||
|
||||
@@ -115,7 +115,7 @@ public class P2PCache implements IGridCache
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addNode( IGridNode node, IGridHost machine )
|
||||
public void addNode( final IGridNode node, final IGridHost machine )
|
||||
{
|
||||
if( machine instanceof PartP2PTunnel )
|
||||
{
|
||||
@@ -127,7 +127,7 @@ public class P2PCache implements IGridCache
|
||||
}
|
||||
}
|
||||
|
||||
PartP2PTunnel t = (PartP2PTunnel) machine;
|
||||
final PartP2PTunnel t = (PartP2PTunnel) machine;
|
||||
// AELog.info( "add-" + (t.output ? "output: " : "input: ") + t.freq
|
||||
// );
|
||||
|
||||
@@ -145,26 +145,26 @@ public class P2PCache implements IGridCache
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSplit( IGridStorage storageB )
|
||||
public void onSplit( final IGridStorage storageB )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onJoin( IGridStorage storageB )
|
||||
public void onJoin( final IGridStorage storageB )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void populateGridStorage( IGridStorage storage )
|
||||
public void populateGridStorage( final IGridStorage storage )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void updateTunnel( long freq, boolean updateOutputs, boolean configChange )
|
||||
private void updateTunnel( final long freq, final boolean updateOutputs, final boolean configChange )
|
||||
{
|
||||
for( PartP2PTunnel p : this.outputs.get( freq ) )
|
||||
for( final PartP2PTunnel p : this.outputs.get( freq ) )
|
||||
{
|
||||
if( configChange )
|
||||
{
|
||||
@@ -173,7 +173,7 @@ public class P2PCache implements IGridCache
|
||||
p.onTunnelNetworkChange();
|
||||
}
|
||||
|
||||
PartP2PTunnel in = this.inputs.get( freq );
|
||||
final PartP2PTunnel in = this.inputs.get( freq );
|
||||
if( in != null )
|
||||
{
|
||||
if( configChange )
|
||||
@@ -184,7 +184,7 @@ public class P2PCache implements IGridCache
|
||||
}
|
||||
}
|
||||
|
||||
public void updateFreq( PartP2PTunnel t, long newFrequency )
|
||||
public void updateFreq( final PartP2PTunnel t, final long newFrequency )
|
||||
{
|
||||
if( this.outputs.containsValue( t ) )
|
||||
{
|
||||
@@ -213,15 +213,15 @@ public class P2PCache implements IGridCache
|
||||
this.updateTunnel( t.freq, !t.output, true );
|
||||
}
|
||||
|
||||
public TunnelCollection<PartP2PTunnel> getOutputs( long freq, Class<? extends PartP2PTunnel> c )
|
||||
public TunnelCollection<PartP2PTunnel> getOutputs( final long freq, final Class<? extends PartP2PTunnel> c )
|
||||
{
|
||||
PartP2PTunnel in = this.inputs.get( freq );
|
||||
final PartP2PTunnel in = this.inputs.get( freq );
|
||||
if( in == null )
|
||||
{
|
||||
return this.NullColl;
|
||||
}
|
||||
|
||||
TunnelCollection<PartP2PTunnel> out = this.inputs.get( freq ).getCollection( this.outputs.get( freq ), c );
|
||||
final TunnelCollection<PartP2PTunnel> out = this.inputs.get( freq ).getCollection( this.outputs.get( freq ), c );
|
||||
if( out == null )
|
||||
{
|
||||
return this.NullColl;
|
||||
@@ -230,7 +230,7 @@ public class P2PCache implements IGridCache
|
||||
return out;
|
||||
}
|
||||
|
||||
public PartP2PTunnel getInput( long freq )
|
||||
public PartP2PTunnel getInput( final long freq )
|
||||
{
|
||||
return this.inputs.get( freq );
|
||||
}
|
||||
|
||||
+37
-37
@@ -76,7 +76,7 @@ public class PathGridCache implements IPathingGrid
|
||||
int lastChannels = 0;
|
||||
private HashSet<IPathItem> semiOpen = new HashSet<IPathItem>();
|
||||
|
||||
public PathGridCache( IGrid g )
|
||||
public PathGridCache( final IGrid g )
|
||||
{
|
||||
this.myGrid = g;
|
||||
}
|
||||
@@ -103,9 +103,9 @@ public class PathGridCache implements IPathingGrid
|
||||
|
||||
if( !AEConfig.instance.isFeatureEnabled( AEFeature.Channels ) )
|
||||
{
|
||||
int used = this.calculateRequiredChannels();
|
||||
final int used = this.calculateRequiredChannels();
|
||||
|
||||
int nodes = this.myGrid.getNodes().size();
|
||||
final int nodes = this.myGrid.getNodes().size();
|
||||
this.ticksUntilReady = 20 + Math.max( 0, nodes / 100 - 20 );
|
||||
this.channelsByBlocks = nodes * used;
|
||||
this.channelPowerUsage = this.channelsByBlocks / 128.0;
|
||||
@@ -114,14 +114,14 @@ public class PathGridCache implements IPathingGrid
|
||||
}
|
||||
else if( this.controllerState == ControllerState.NO_CONTROLLER )
|
||||
{
|
||||
int requiredChannels = this.calculateRequiredChannels();
|
||||
final int requiredChannels = this.calculateRequiredChannels();
|
||||
int used = requiredChannels;
|
||||
if( requiredChannels > 8 )
|
||||
{
|
||||
used = 0;
|
||||
}
|
||||
|
||||
int nodes = this.myGrid.getNodes().size();
|
||||
final int nodes = this.myGrid.getNodes().size();
|
||||
this.channelsInUse = used;
|
||||
|
||||
this.ticksUntilReady = 20 + Math.max( 0, nodes / 100 - 20 );
|
||||
@@ -137,22 +137,22 @@ public class PathGridCache implements IPathingGrid
|
||||
}
|
||||
else
|
||||
{
|
||||
int nodes = this.myGrid.getNodes().size();
|
||||
final int nodes = this.myGrid.getNodes().size();
|
||||
this.ticksUntilReady = 20 + Math.max( 0, nodes / 100 - 20 );
|
||||
HashSet<IPathItem> closedList = new HashSet<IPathItem>();
|
||||
final HashSet<IPathItem> closedList = new HashSet<IPathItem>();
|
||||
this.semiOpen = new HashSet<IPathItem>();
|
||||
|
||||
// myGrid.getPivot().beginVisit( new AdHocChannelUpdater( 0 )
|
||||
// );
|
||||
for( IGridNode node : this.myGrid.getMachines( TileController.class ) )
|
||||
for( final IGridNode node : this.myGrid.getMachines( TileController.class ) )
|
||||
{
|
||||
closedList.add( (IPathItem) node );
|
||||
for( IGridConnection gcc : node.getConnections() )
|
||||
for( final IGridConnection gcc : node.getConnections() )
|
||||
{
|
||||
GridConnection gc = (GridConnection) gcc;
|
||||
final GridConnection gc = (GridConnection) gcc;
|
||||
if( !( gc.getOtherSide( node ).getMachine() instanceof TileController ) )
|
||||
{
|
||||
List<IPathItem> open = new LinkedList<IPathItem>();
|
||||
final List<IPathItem> open = new LinkedList<IPathItem>();
|
||||
closedList.add( gc );
|
||||
open.add( gc );
|
||||
gc.setControllerRoute( (GridNode) node, true );
|
||||
@@ -165,10 +165,10 @@ public class PathGridCache implements IPathingGrid
|
||||
|
||||
if( !this.active.isEmpty() || this.ticksUntilReady > 0 )
|
||||
{
|
||||
Iterator<PathSegment> i = this.active.iterator();
|
||||
final Iterator<PathSegment> i = this.active.iterator();
|
||||
while( i.hasNext() )
|
||||
{
|
||||
PathSegment pat = i.next();
|
||||
final PathSegment pat = i.next();
|
||||
if( pat.step() )
|
||||
{
|
||||
pat.isDead = true;
|
||||
@@ -201,7 +201,7 @@ public class PathGridCache implements IPathingGrid
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeNode( IGridNode gridNode, IGridHost machine )
|
||||
public void removeNode( final IGridNode gridNode, final IGridHost machine )
|
||||
{
|
||||
if( machine instanceof TileController )
|
||||
{
|
||||
@@ -209,7 +209,7 @@ public class PathGridCache implements IPathingGrid
|
||||
this.recalculateControllerNextTick = true;
|
||||
}
|
||||
|
||||
EnumSet<GridFlags> flags = gridNode.getGridBlock().getFlags();
|
||||
final EnumSet<GridFlags> flags = gridNode.getGridBlock().getFlags();
|
||||
|
||||
if( flags.contains( GridFlags.REQUIRE_CHANNEL ) )
|
||||
{
|
||||
@@ -225,7 +225,7 @@ public class PathGridCache implements IPathingGrid
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addNode( IGridNode gridNode, IGridHost machine )
|
||||
public void addNode( final IGridNode gridNode, final IGridHost machine )
|
||||
{
|
||||
if( machine instanceof TileController )
|
||||
{
|
||||
@@ -233,7 +233,7 @@ public class PathGridCache implements IPathingGrid
|
||||
this.recalculateControllerNextTick = true;
|
||||
}
|
||||
|
||||
EnumSet<GridFlags> flags = gridNode.getGridBlock().getFlags();
|
||||
final EnumSet<GridFlags> flags = gridNode.getGridBlock().getFlags();
|
||||
|
||||
if( flags.contains( GridFlags.REQUIRE_CHANNEL ) )
|
||||
{
|
||||
@@ -249,19 +249,19 @@ public class PathGridCache implements IPathingGrid
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSplit( IGridStorage storageB )
|
||||
public void onSplit( final IGridStorage storageB )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onJoin( IGridStorage storageB )
|
||||
public void onJoin( final IGridStorage storageB )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void populateGridStorage( IGridStorage storage )
|
||||
public void populateGridStorage( final IGridStorage storage )
|
||||
{
|
||||
|
||||
}
|
||||
@@ -269,7 +269,7 @@ public class PathGridCache implements IPathingGrid
|
||||
private void recalcController()
|
||||
{
|
||||
this.recalculateControllerNextTick = false;
|
||||
ControllerState old = this.controllerState;
|
||||
final ControllerState old = this.controllerState;
|
||||
|
||||
if( this.controllers.isEmpty() )
|
||||
{
|
||||
@@ -277,15 +277,15 @@ public class PathGridCache implements IPathingGrid
|
||||
}
|
||||
else
|
||||
{
|
||||
IGridNode startingNode = this.controllers.iterator().next().getGridNode( AEPartLocation.INTERNAL );
|
||||
final IGridNode startingNode = this.controllers.iterator().next().getGridNode( AEPartLocation.INTERNAL );
|
||||
if( startingNode == null )
|
||||
{
|
||||
this.controllerState = ControllerState.CONTROLLER_CONFLICT;
|
||||
return;
|
||||
}
|
||||
|
||||
DimensionalCoord dc = startingNode.getGridBlock().getLocation();
|
||||
ControllerValidator cv = new ControllerValidator( dc.x, dc.y, dc.z );
|
||||
final DimensionalCoord dc = startingNode.getGridBlock().getLocation();
|
||||
final ControllerValidator cv = new ControllerValidator( dc.x, dc.y, dc.z );
|
||||
|
||||
startingNode.beginVisit( cv );
|
||||
|
||||
@@ -310,12 +310,12 @@ public class PathGridCache implements IPathingGrid
|
||||
this.semiOpen.clear();
|
||||
|
||||
int depth = 0;
|
||||
for( IGridNode nodes : this.requireChannels )
|
||||
for( final IGridNode nodes : this.requireChannels )
|
||||
{
|
||||
if( !this.semiOpen.contains( nodes ) )
|
||||
{
|
||||
IGridBlock gb = nodes.getGridBlock();
|
||||
EnumSet<GridFlags> flags = gb.getFlags();
|
||||
final IGridBlock gb = nodes.getGridBlock();
|
||||
final EnumSet<GridFlags> flags = gb.getFlags();
|
||||
|
||||
if( flags.contains( GridFlags.COMPRESSED_CHANNEL ) && !this.blockDense.isEmpty() )
|
||||
{
|
||||
@@ -326,8 +326,8 @@ public class PathGridCache implements IPathingGrid
|
||||
|
||||
if( flags.contains( GridFlags.MULTIBLOCK ) )
|
||||
{
|
||||
IGridMultiblock gmb = (IGridMultiblock) gb;
|
||||
Iterator<IGridNode> i = gmb.getMultiblockNodes();
|
||||
final IGridMultiblock gmb = (IGridMultiblock) gb;
|
||||
final Iterator<IGridNode> i = gmb.getMultiblockNodes();
|
||||
while( i.hasNext() )
|
||||
{
|
||||
this.semiOpen.add( (IPathItem) i.next() );
|
||||
@@ -343,17 +343,17 @@ public class PathGridCache implements IPathingGrid
|
||||
{
|
||||
if( this.lastChannels != this.channelsInUse && AEConfig.instance.isFeatureEnabled( AEFeature.Channels ) )
|
||||
{
|
||||
Achievements currentBracket = this.getAchievementBracket( this.channelsInUse );
|
||||
Achievements lastBracket = this.getAchievementBracket( this.lastChannels );
|
||||
final Achievements currentBracket = this.getAchievementBracket( this.channelsInUse );
|
||||
final Achievements lastBracket = this.getAchievementBracket( this.lastChannels );
|
||||
if( currentBracket != lastBracket && currentBracket != null )
|
||||
{
|
||||
Set<Integer> players = new HashSet<Integer>();
|
||||
for( IGridNode n : this.requireChannels )
|
||||
final Set<Integer> players = new HashSet<Integer>();
|
||||
for( final IGridNode n : this.requireChannels )
|
||||
{
|
||||
players.add( n.getPlayerID() );
|
||||
}
|
||||
|
||||
for( int id : players )
|
||||
for( final int id : players )
|
||||
{
|
||||
Platform.addStat( id, currentBracket.getAchievement() );
|
||||
}
|
||||
@@ -362,7 +362,7 @@ public class PathGridCache implements IPathingGrid
|
||||
this.lastChannels = this.channelsInUse;
|
||||
}
|
||||
|
||||
private Achievements getAchievementBracket( int ch )
|
||||
private Achievements getAchievementBracket( final int ch )
|
||||
{
|
||||
if( ch < 8 )
|
||||
{
|
||||
@@ -383,9 +383,9 @@ public class PathGridCache implements IPathingGrid
|
||||
}
|
||||
|
||||
@MENetworkEventSubscribe
|
||||
void updateNodReq( MENetworkChannelChanged ev )
|
||||
void updateNodReq( final MENetworkChannelChanged ev )
|
||||
{
|
||||
IGridNode gridNode = ev.node;
|
||||
final IGridNode gridNode = ev.node;
|
||||
|
||||
if( gridNode.getGridBlock().getFlags().contains( GridFlags.REQUIRE_CHANNEL ) )
|
||||
{
|
||||
|
||||
+12
-12
@@ -49,13 +49,13 @@ public class SecurityCache implements ISecurityGrid
|
||||
private final HashMap<Integer, EnumSet<SecurityPermissions>> playerPerms = new HashMap<Integer, EnumSet<SecurityPermissions>>();
|
||||
private long securityKey = -1;
|
||||
|
||||
public SecurityCache( IGrid g )
|
||||
public SecurityCache( final IGrid g )
|
||||
{
|
||||
this.myGrid = g;
|
||||
}
|
||||
|
||||
@MENetworkEventSubscribe
|
||||
public void updatePermissions( MENetworkSecurityChange ev )
|
||||
public void updatePermissions( final MENetworkSecurityChange ev )
|
||||
{
|
||||
this.playerPerms.clear();
|
||||
if( this.securityProvider.isEmpty() )
|
||||
@@ -78,7 +78,7 @@ public class SecurityCache implements ISecurityGrid
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeNode( IGridNode gridNode, IGridHost machine )
|
||||
public void removeNode( final IGridNode gridNode, final IGridHost machine )
|
||||
{
|
||||
if( machine instanceof ISecurityProvider )
|
||||
{
|
||||
@@ -89,7 +89,7 @@ public class SecurityCache implements ISecurityGrid
|
||||
|
||||
private void updateSecurityKey()
|
||||
{
|
||||
long lastCode = this.securityKey;
|
||||
final long lastCode = this.securityKey;
|
||||
|
||||
if( this.securityProvider.size() == 1 )
|
||||
{
|
||||
@@ -103,7 +103,7 @@ public class SecurityCache implements ISecurityGrid
|
||||
if( lastCode != this.securityKey )
|
||||
{
|
||||
this.myGrid.postEvent( new MENetworkSecurityChange() );
|
||||
for( IGridNode n : this.myGrid.getNodes() )
|
||||
for( final IGridNode n : this.myGrid.getNodes() )
|
||||
{
|
||||
( (GridNode) n ).lastSecurityKey = this.securityKey;
|
||||
}
|
||||
@@ -111,7 +111,7 @@ public class SecurityCache implements ISecurityGrid
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addNode( IGridNode gridNode, IGridHost machine )
|
||||
public void addNode( final IGridNode gridNode, final IGridHost machine )
|
||||
{
|
||||
if( machine instanceof ISecurityProvider )
|
||||
{
|
||||
@@ -125,19 +125,19 @@ public class SecurityCache implements ISecurityGrid
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSplit( IGridStorage destinationStorage )
|
||||
public void onSplit( final IGridStorage destinationStorage )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onJoin( IGridStorage sourceStorage )
|
||||
public void onJoin( final IGridStorage sourceStorage )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void populateGridStorage( IGridStorage destinationStorage )
|
||||
public void populateGridStorage( final IGridStorage destinationStorage )
|
||||
{
|
||||
|
||||
} @Override
|
||||
@@ -149,7 +149,7 @@ public class SecurityCache implements ISecurityGrid
|
||||
|
||||
|
||||
@Override
|
||||
public boolean hasPermission( EntityPlayer player, SecurityPermissions perm )
|
||||
public boolean hasPermission( final EntityPlayer player, final SecurityPermissions perm )
|
||||
{
|
||||
Preconditions.checkNotNull( player );
|
||||
Preconditions.checkNotNull( perm );
|
||||
@@ -161,11 +161,11 @@ public class SecurityCache implements ISecurityGrid
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPermission( int playerID, SecurityPermissions perm )
|
||||
public boolean hasPermission( final int playerID, final SecurityPermissions perm )
|
||||
{
|
||||
if( this.isAvailable() )
|
||||
{
|
||||
EnumSet<SecurityPermissions> perms = this.playerPerms.get( playerID );
|
||||
final EnumSet<SecurityPermissions> perms = this.playerPerms.get( playerID );
|
||||
|
||||
if( perms == null )
|
||||
{
|
||||
|
||||
+21
-21
@@ -51,34 +51,34 @@ public class SpatialPylonCache implements ISpatialCache
|
||||
HashMap<SpatialPylonCluster, SpatialPylonCluster> clusters = new HashMap<SpatialPylonCluster, SpatialPylonCluster>();
|
||||
boolean needsUpdate = false;
|
||||
|
||||
public SpatialPylonCache( IGrid g )
|
||||
public SpatialPylonCache( final IGrid g )
|
||||
{
|
||||
this.myGrid = g;
|
||||
}
|
||||
|
||||
@MENetworkEventSubscribe
|
||||
public void bootingRender( MENetworkBootingStatusChange c )
|
||||
public void bootingRender( final MENetworkBootingStatusChange c )
|
||||
{
|
||||
this.reset( this.myGrid );
|
||||
}
|
||||
|
||||
public void reset( IGrid grid )
|
||||
public void reset( final IGrid grid )
|
||||
{
|
||||
|
||||
this.clusters = new HashMap<SpatialPylonCluster, SpatialPylonCluster>();
|
||||
this.ioPorts = new LinkedList<TileSpatialIOPort>();
|
||||
|
||||
for( IGridNode gm : grid.getMachines( TileSpatialIOPort.class ) )
|
||||
for( final IGridNode gm : grid.getMachines( TileSpatialIOPort.class ) )
|
||||
{
|
||||
this.ioPorts.add( (TileSpatialIOPort) gm.getMachine() );
|
||||
}
|
||||
|
||||
IReadOnlyCollection<IGridNode> set = grid.getMachines( TileSpatialPylon.class );
|
||||
for( IGridNode gm : set )
|
||||
final IReadOnlyCollection<IGridNode> set = grid.getMachines( TileSpatialPylon.class );
|
||||
for( final IGridNode gm : set )
|
||||
{
|
||||
if( gm.meetsChannelRequirements() )
|
||||
{
|
||||
SpatialPylonCluster c = ( (TileSpatialPylon) gm.getMachine() ).getCluster();
|
||||
final SpatialPylonCluster c = ( (TileSpatialPylon) gm.getMachine() ).getCluster();
|
||||
if( c != null )
|
||||
{
|
||||
this.clusters.put( c, c );
|
||||
@@ -91,7 +91,7 @@ public class SpatialPylonCache implements ISpatialCache
|
||||
this.isValid = true;
|
||||
|
||||
int pylonBlocks = 0;
|
||||
for( SpatialPylonCluster cl : this.clusters.values() )
|
||||
for( final SpatialPylonCluster cl : this.clusters.values() )
|
||||
{
|
||||
if( this.captureMax == null )
|
||||
{
|
||||
@@ -119,7 +119,7 @@ public class SpatialPylonCache implements ISpatialCache
|
||||
{
|
||||
this.isValid = this.captureMax.x - this.captureMin.x > 1 && this.captureMax.y - this.captureMin.y > 1 && this.captureMax.z - this.captureMin.z > 1;
|
||||
|
||||
for( SpatialPylonCluster cl : this.clusters.values() )
|
||||
for( final SpatialPylonCluster cl : this.clusters.values() )
|
||||
{
|
||||
switch( cl.currentAxis )
|
||||
{
|
||||
@@ -144,10 +144,10 @@ public class SpatialPylonCache implements ISpatialCache
|
||||
}
|
||||
}
|
||||
|
||||
int reqX = this.captureMax.x - this.captureMin.x;
|
||||
int reqY = this.captureMax.y - this.captureMin.y;
|
||||
int reqZ = this.captureMax.z - this.captureMin.z;
|
||||
int requirePylonBlocks = Math.max( 6, ( ( reqX * reqZ + reqX * reqY + reqY * reqZ ) * 3 ) / 8 );
|
||||
final int reqX = this.captureMax.x - this.captureMin.x;
|
||||
final int reqY = this.captureMax.y - this.captureMin.y;
|
||||
final int reqZ = this.captureMax.z - this.captureMin.z;
|
||||
final int requirePylonBlocks = Math.max( 6, ( ( reqX * reqZ + reqX * reqY + reqY * reqZ ) * 3 ) / 8 );
|
||||
|
||||
this.efficiency = (double) pylonBlocks / (double) requirePylonBlocks;
|
||||
|
||||
@@ -164,12 +164,12 @@ public class SpatialPylonCache implements ISpatialCache
|
||||
maxPower = Math.pow( minPower, AEConfig.instance.spatialPowerExponent );
|
||||
}
|
||||
|
||||
double affective_efficiency = Math.pow( this.efficiency, 0.25 );
|
||||
final double affective_efficiency = Math.pow( this.efficiency, 0.25 );
|
||||
this.powerRequired = (long) ( affective_efficiency * minPower + ( 1.0 - affective_efficiency ) * maxPower );
|
||||
|
||||
for( SpatialPylonCluster cl : this.clusters.values() )
|
||||
for( final SpatialPylonCluster cl : this.clusters.values() )
|
||||
{
|
||||
boolean myWasValid = cl.isValid;
|
||||
final boolean myWasValid = cl.isValid;
|
||||
cl.isValid = this.isValid;
|
||||
if( myWasValid != this.isValid )
|
||||
{
|
||||
@@ -220,31 +220,31 @@ public class SpatialPylonCache implements ISpatialCache
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeNode( IGridNode node, IGridHost machine )
|
||||
public void removeNode( final IGridNode node, final IGridHost machine )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addNode( IGridNode node, IGridHost machine )
|
||||
public void addNode( final IGridNode node, final IGridHost machine )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSplit( IGridStorage storageB )
|
||||
public void onSplit( final IGridStorage storageB )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onJoin( IGridStorage storageB )
|
||||
public void onJoin( final IGridStorage storageB )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void populateGridStorage( IGridStorage storage )
|
||||
public void populateGridStorage( final IGridStorage storage )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
+21
-21
@@ -46,7 +46,7 @@ public class TickManagerCache implements ITickManager
|
||||
final PriorityQueue<TickTracker> upcomingTicks = new PriorityQueue<TickTracker>();
|
||||
private long currentTick = 0;
|
||||
|
||||
public TickManagerCache( IGrid g )
|
||||
public TickManagerCache( final IGrid g )
|
||||
{
|
||||
this.myGrid = g;
|
||||
}
|
||||
@@ -56,7 +56,7 @@ public class TickManagerCache implements ITickManager
|
||||
return this.currentTick;
|
||||
}
|
||||
|
||||
public long getAvgNanoTime( IGridNode node )
|
||||
public long getAvgNanoTime( final IGridNode node )
|
||||
{
|
||||
TickTracker tt = this.awake.get( node );
|
||||
|
||||
@@ -83,12 +83,12 @@ public class TickManagerCache implements ITickManager
|
||||
while( !this.upcomingTicks.isEmpty() )
|
||||
{
|
||||
tt = this.upcomingTicks.peek();
|
||||
int diff = (int) ( this.currentTick - tt.lastTick );
|
||||
final int diff = (int) ( this.currentTick - tt.lastTick );
|
||||
if( diff >= tt.current_rate )
|
||||
{
|
||||
// remove tt..
|
||||
this.upcomingTicks.poll();
|
||||
TickRateModulation mod = tt.gt.tickingRequest( tt.node, diff );
|
||||
final TickRateModulation mod = tt.gt.tickingRequest( tt.node, diff );
|
||||
|
||||
switch( mod )
|
||||
{
|
||||
@@ -124,23 +124,23 @@ public class TickManagerCache implements ITickManager
|
||||
}
|
||||
}
|
||||
}
|
||||
catch( Throwable t )
|
||||
catch( final Throwable t )
|
||||
{
|
||||
CrashReport crashreport = CrashReport.makeCrashReport( t, "Ticking GridNode" );
|
||||
CrashReportCategory crashreportcategory = crashreport.makeCategory( tt.gt.getClass().getSimpleName() + " being ticked." );
|
||||
final CrashReport crashreport = CrashReport.makeCrashReport( t, "Ticking GridNode" );
|
||||
final CrashReportCategory crashreportcategory = crashreport.makeCategory( tt.gt.getClass().getSimpleName() + " being ticked." );
|
||||
tt.addEntityCrashInfo( crashreportcategory );
|
||||
throw new ReportedException( crashreport );
|
||||
}
|
||||
}
|
||||
|
||||
private void addToQueue( TickTracker tt )
|
||||
private void addToQueue( final TickTracker tt )
|
||||
{
|
||||
tt.lastTick = this.currentTick;
|
||||
this.upcomingTicks.add( tt );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeNode( IGridNode gridNode, IGridHost machine )
|
||||
public void removeNode( final IGridNode gridNode, final IGridHost machine )
|
||||
{
|
||||
if( machine instanceof IGridTickable )
|
||||
{
|
||||
@@ -151,14 +151,14 @@ public class TickManagerCache implements ITickManager
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addNode( IGridNode gridNode, IGridHost machine )
|
||||
public void addNode( final IGridNode gridNode, final IGridHost machine )
|
||||
{
|
||||
if( machine instanceof IGridTickable )
|
||||
{
|
||||
TickingRequest tr = ( (IGridTickable) machine ).getTickingRequest( gridNode );
|
||||
final TickingRequest tr = ( (IGridTickable) machine ).getTickingRequest( gridNode );
|
||||
if( tr != null )
|
||||
{
|
||||
TickTracker tt = new TickTracker( tr, gridNode, (IGridTickable) machine, this.currentTick, this );
|
||||
final TickTracker tt = new TickTracker( tr, gridNode, (IGridTickable) machine, this.currentTick, this );
|
||||
|
||||
if( tr.canBeAlerted )
|
||||
{
|
||||
@@ -179,27 +179,27 @@ public class TickManagerCache implements ITickManager
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSplit( IGridStorage storageB )
|
||||
public void onSplit( final IGridStorage storageB )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onJoin( IGridStorage storageB )
|
||||
public void onJoin( final IGridStorage storageB )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void populateGridStorage( IGridStorage storage )
|
||||
public void populateGridStorage( final IGridStorage storage )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean alertDevice( IGridNode node )
|
||||
public boolean alertDevice( final IGridNode node )
|
||||
{
|
||||
TickTracker tt = this.alertable.get( node );
|
||||
final TickTracker tt = this.alertable.get( node );
|
||||
if( tt == null )
|
||||
{
|
||||
return false;
|
||||
@@ -223,11 +223,11 @@ public class TickManagerCache implements ITickManager
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean sleepDevice( IGridNode node )
|
||||
public boolean sleepDevice( final IGridNode node )
|
||||
{
|
||||
if( this.awake.containsKey( node ) )
|
||||
{
|
||||
TickTracker gt = this.awake.get( node );
|
||||
final TickTracker gt = this.awake.get( node );
|
||||
this.awake.remove( node );
|
||||
this.sleeping.put( node, gt );
|
||||
|
||||
@@ -238,11 +238,11 @@ public class TickManagerCache implements ITickManager
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean wakeDevice( IGridNode node )
|
||||
public boolean wakeDevice( final IGridNode node )
|
||||
{
|
||||
if( this.sleeping.containsKey( node ) )
|
||||
{
|
||||
TickTracker gt = this.sleeping.get( node );
|
||||
final TickTracker gt = this.sleeping.get( node );
|
||||
this.sleeping.remove( node );
|
||||
this.awake.put( node, gt );
|
||||
this.addToQueue( gt );
|
||||
|
||||
@@ -27,7 +27,7 @@ public class ConnectionWrapper
|
||||
|
||||
public IGridConnection connection;
|
||||
|
||||
public ConnectionWrapper( IGridConnection gc )
|
||||
public ConnectionWrapper( final IGridConnection gc )
|
||||
{
|
||||
this.connection = gc;
|
||||
}
|
||||
|
||||
+2
-2
@@ -36,13 +36,13 @@ public class Connections implements IWorldCallable<Void>
|
||||
public boolean create = false;
|
||||
public boolean destroy = false;
|
||||
|
||||
public Connections( PartP2PTunnelME o )
|
||||
public Connections( final PartP2PTunnelME o )
|
||||
{
|
||||
this.me = o;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void call( World world ) throws Exception
|
||||
public Void call( final World world ) throws Exception
|
||||
{
|
||||
this.me.updateConnections( this );
|
||||
|
||||
|
||||
+8
-8
@@ -43,7 +43,7 @@ public class TickTracker implements Comparable<TickTracker>
|
||||
public long lastTick;
|
||||
public int current_rate;
|
||||
|
||||
public TickTracker( TickingRequest req, IGridNode node, IGridTickable gt, long currentTick, TickManagerCache tickManagerCache )
|
||||
public TickTracker( final TickingRequest req, final IGridNode node, final IGridTickable gt, final long currentTick, final TickManagerCache tickManagerCache )
|
||||
{
|
||||
this.request = req;
|
||||
this.gt = gt;
|
||||
@@ -58,7 +58,7 @@ public class TickTracker implements Comparable<TickTracker>
|
||||
return ( this.LastFiveTicksTime / 5 );
|
||||
}
|
||||
|
||||
public void setRate( int rate )
|
||||
public void setRate( final int rate )
|
||||
{
|
||||
this.current_rate = rate;
|
||||
|
||||
@@ -74,18 +74,18 @@ public class TickTracker implements Comparable<TickTracker>
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo( @Nonnull TickTracker t )
|
||||
public int compareTo( @Nonnull final TickTracker t )
|
||||
{
|
||||
int nextTick = (int) ( ( this.lastTick - this.host.getCurrentTick() ) + this.current_rate );
|
||||
int ts_nextTick = (int) ( ( t.lastTick - this.host.getCurrentTick() ) + t.current_rate );
|
||||
final int nextTick = (int) ( ( this.lastTick - this.host.getCurrentTick() ) + this.current_rate );
|
||||
final int ts_nextTick = (int) ( ( t.lastTick - this.host.getCurrentTick() ) + t.current_rate );
|
||||
return nextTick - ts_nextTick;
|
||||
}
|
||||
|
||||
public void addEntityCrashInfo( CrashReportCategory crashreportcategory )
|
||||
public void addEntityCrashInfo( final CrashReportCategory crashreportcategory )
|
||||
{
|
||||
if( this.gt instanceof AEBasePart )
|
||||
{
|
||||
AEBasePart part = (AEBasePart) this.gt;
|
||||
final AEBasePart part = (AEBasePart) this.gt;
|
||||
part.addEntityCrashInfo( crashreportcategory );
|
||||
}
|
||||
|
||||
@@ -96,7 +96,7 @@ public class TickTracker implements Comparable<TickTracker>
|
||||
crashreportcategory.addCrashSection( "GridBlockType", this.node.getGridBlock().getClass().getName() );
|
||||
crashreportcategory.addCrashSection( "ConnectedSides", this.node.getConnectedSides() );
|
||||
|
||||
DimensionalCoord dc = this.node.getGridBlock().getLocation();
|
||||
final DimensionalCoord dc = this.node.getGridBlock().getLocation();
|
||||
if( dc != null )
|
||||
{
|
||||
crashreportcategory.addCrashSection( "Location", dc );
|
||||
|
||||
@@ -32,13 +32,13 @@ public class TunnelCollection<T extends PartP2PTunnel> implements Iterable<T>
|
||||
final Class clz;
|
||||
Collection<T> tunnelSources;
|
||||
|
||||
public TunnelCollection( Collection<T> src, Class c )
|
||||
public TunnelCollection( final Collection<T> src, final Class c )
|
||||
{
|
||||
this.tunnelSources = src;
|
||||
this.clz = c;
|
||||
}
|
||||
|
||||
public void setSource( Collection<T> c )
|
||||
public void setSource( final Collection<T> c )
|
||||
{
|
||||
this.tunnelSources = c;
|
||||
}
|
||||
@@ -58,7 +58,7 @@ public class TunnelCollection<T extends PartP2PTunnel> implements Iterable<T>
|
||||
return new TunnelIterator<T>( this.tunnelSources, this.clz );
|
||||
}
|
||||
|
||||
public boolean matches( Class<? extends PartP2PTunnel> c )
|
||||
public boolean matches( final Class<? extends PartP2PTunnel> c )
|
||||
{
|
||||
return this.clz == c;
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ public class TunnelConnection
|
||||
public final PartP2PTunnelME tunnel;
|
||||
public final IGridConnection c;
|
||||
|
||||
public TunnelConnection( PartP2PTunnelME t, IGridConnection con )
|
||||
public TunnelConnection( final PartP2PTunnelME t, final IGridConnection con )
|
||||
{
|
||||
this.tunnel = t;
|
||||
this.c = con;
|
||||
|
||||
@@ -32,7 +32,7 @@ public class TunnelIterator<T extends PartP2PTunnel> implements Iterator<T>
|
||||
final Class targetType;
|
||||
T Next;
|
||||
|
||||
public TunnelIterator( Collection<T> tunnelSources, Class clz )
|
||||
public TunnelIterator( final Collection<T> tunnelSources, final Class clz )
|
||||
{
|
||||
this.wrapped = tunnelSources.iterator();
|
||||
this.targetType = clz;
|
||||
@@ -61,7 +61,7 @@ public class TunnelIterator<T extends PartP2PTunnel> implements Iterator<T>
|
||||
@Override
|
||||
public T next()
|
||||
{
|
||||
T tmp = this.Next;
|
||||
final T tmp = this.Next;
|
||||
this.Next = null;
|
||||
return tmp;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user