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
+16
View File
@@ -95,7 +95,9 @@ public class Grid implements IGrid
{
int out = 0;
for( Collection<?> x : this.machines.values() )
{
out += x.size();
}
return out;
}
@@ -110,7 +112,9 @@ public class Grid implements IGrid
Class<? extends IGridHost> machineClass = gridNode.getMachineClass();
Set<IGridNode> nodes = this.machines.get( machineClass );
if( nodes != null )
{
nodes.remove( gridNode );
}
gridNode.setGridStorage( null );
@@ -118,7 +122,9 @@ public class Grid implements IGrid
{
Iterator<IGridNode> n = this.getNodes().iterator();
if( n.hasNext() )
{
this.pivot = (GridNode) n.next();
}
else
{
this.pivot = null;
@@ -152,7 +158,9 @@ public class Grid implements IGrid
this.myStorage.setGrid( this );
for( IGridCache gc : this.caches.values() )
{
gc.onJoin( this.myStorage );
}
}
else if( grid != this )
{
@@ -168,10 +176,14 @@ public class Grid implements IGrid
gs.addDivided( this.myStorage );
for( IGridCache gc : ( (Grid) grid ).caches.values() )
{
gc.onSplit( tmp );
}
for( IGridCache gc : this.caches.values() )
{
gc.onJoin( tmp );
}
}
}
}
@@ -229,7 +241,9 @@ public class Grid implements IGrid
{
MachineSet s = this.machines.get( c );
if( s == null )
{
return new MachineSet( c );
}
return s;
}
@@ -262,7 +276,9 @@ public class Grid implements IGrid
{
// are there any nodes left?
if( this.pivot != null )
{
gc.onUpdateTick();
}
}
}
@@ -71,7 +71,9 @@ public class GridConnection implements IGridConnection, IPathItem
}
if( a == null || b == null )
{
throw new GridException( "Connection Forged Between null entities." );
}
if( a.hasConnection( b ) || b.hasConnection( a ) )
{
@@ -129,9 +131,13 @@ public class GridConnection implements IGridConnection, IPathItem
public IGridNode getOtherSide( IGridNode gridNode )
{
if( gridNode == this.sideA )
{
return this.sideB;
}
if( gridNode == this.sideB )
{
return this.sideA;
}
throw new GridException( "Invalid Side of Connection" );
}
@@ -140,12 +146,18 @@ public class GridConnection implements IGridConnection, IPathItem
public ForgeDirection getDirection( IGridNode side )
{
if( this.fromAtoB == ForgeDirection.UNKNOWN )
{
return this.fromAtoB;
}
if( this.sideA == side )
{
return this.fromAtoB;
}
else
{
return this.fromAtoB.getOpposite();
}
}
@Override
@@ -190,7 +202,9 @@ public class GridConnection implements IGridConnection, IPathItem
public IPathItem getControllerRoute()
{
if( this.sideA.getFlags().contains( GridFlags.CANNOT_CARRY ) )
{
return null;
}
return this.sideA;
}
@@ -198,7 +212,9 @@ public class GridConnection implements IGridConnection, IPathItem
public void setControllerRoute( IPathItem fast, boolean zeroOut )
{
if( zeroOut )
{
this.channelData &= ~0xff;
}
if( this.sideB == fast )
{
@@ -242,10 +258,14 @@ public class GridConnection implements IGridConnection, IPathItem
this.channelData |= this.channelData << 8;
if( this.sideA.getInternalGrid() != null )
{
this.sideA.getInternalGrid().postEventTo( this.sideA, EVENT );
}
if( this.sideB.getInternalGrid() != null )
{
this.sideB.getInternalGrid().postEventTo( this.sideB, EVENT );
}
}
}
+60
View File
@@ -102,7 +102,9 @@ public class GridNode implements IGridNode, IPathItem
{
this.connections.add( gridConnection );
if( gridConnection.hasDirection() )
{
this.gridProxy.onGridNotification( GridNotification.ConnectionsChanged );
}
final IGridNode gn = this;
@@ -113,7 +115,9 @@ public class GridNode implements IGridNode, IPathItem
{
this.connections.remove( gridConnection );
if( gridConnection.hasDirection() )
{
this.gridProxy.onGridNotification( GridNotification.ConnectionsChanged );
}
}
public boolean hasConnection( IGridNode otherSide )
@@ -121,7 +125,9 @@ public class GridNode implements IGridNode, IPathItem
for( IGridConnection gc : this.connections )
{
if( gc.a() == otherSide || gc.b() == otherSide )
{
return true;
}
}
return false;
}
@@ -140,7 +146,9 @@ public class GridNode implements IGridNode, IPathItem
public Grid getInternalGrid()
{
if( this.myGrid == null )
{
this.myGrid = new Grid( this );
}
return this.myGrid;
}
@@ -163,13 +171,17 @@ public class GridNode implements IGridNode, IPathItem
while( !nextRun.isEmpty() )
{
while( !nextConn.isEmpty() )
{
gcv.visitConnection( nextConn.poll() );
}
LinkedList<GridNode> thisRun = nextRun;
nextRun = new LinkedList<GridNode>();
for( GridNode n : thisRun )
{
n.visitorConnection( tracker, g, nextRun, nextConn );
}
}
}
else
@@ -180,7 +192,9 @@ public class GridNode implements IGridNode, IPathItem
nextRun = new LinkedList<GridNode>();
for( GridNode n : thisRun )
{
n.visitorNode( tracker, g, nextRun );
}
}
}
}
@@ -195,7 +209,9 @@ public class GridNode implements IGridNode, IPathItem
this.compressedData |= ( this.gridProxy.getGridColor().ordinal() << 3 );
for( ForgeDirection dir : this.gridProxy.getConnectableSides() )
{
this.compressedData |= ( 1 << ( dir.ordinal() + 8 ) );
}
this.FindConnections();
this.getInternalGrid();
@@ -216,7 +232,9 @@ public class GridNode implements IGridNode, IPathItem
public void setGrid( Grid grid )
{
if( this.myGrid == grid )
{
return;
}
if( this.myGrid != null )
{
@@ -227,7 +245,9 @@ public class GridNode implements IGridNode, IPathItem
this.myGrid.saveState();
for( IGridCache c : grid.getCaches().values() )
{
c.onJoin( this.myGrid.getMyStorage() );
}
}
}
@@ -242,7 +262,9 @@ public class GridNode implements IGridNode, IPathItem
{
// not part of this network for real anymore.
if( this.connections.size() == 1 )
{
this.setGridStorage( null );
}
IGridConnection c = this.connections.listIterator().next();
GridNode otherSide = (GridNode) c.getOtherSide( this );
@@ -251,7 +273,9 @@ public class GridNode implements IGridNode, IPathItem
}
if( this.myGrid != null )
{
this.myGrid.remove( this );
}
}
@Override
@@ -265,7 +289,9 @@ public class GridNode implements IGridNode, IPathItem
{
EnumSet<ForgeDirection> set = EnumSet.noneOf( ForgeDirection.class );
for( IGridConnection gc : this.connections )
{
set.add( gc.getDirection( this ) );
}
return set;
}
@@ -305,7 +331,9 @@ public class GridNode implements IGridNode, IPathItem
this.setGridStorage( WorldSettings.getInstance().getGridStorage( node.getLong( "g" ) ) );
}
else
{
throw new IllegalStateException( "Loading data after part of a grid, this is invalid." );
}
}
@Override
@@ -322,7 +350,9 @@ public class GridNode implements IGridNode, IPathItem
nodeData.setTag( name, node );
}
else
{
nodeData.removeTag( name );
}
}
@Override
@@ -347,7 +377,9 @@ public class GridNode implements IGridNode, IPathItem
public void setPlayerID( int playerID )
{
if( playerID >= 0 )
{
this.playerID = playerID;
}
}
public int getUsedChannels()
@@ -358,7 +390,9 @@ public class GridNode implements IGridNode, IPathItem
public void FindConnections()
{
if( !this.gridProxy.isWorldAccessible() )
{
return;
}
EnumSet<ForgeDirection> newSecurityConnections = EnumSet.noneOf( ForgeDirection.class );
@@ -370,7 +404,9 @@ public class GridNode implements IGridNode, IPathItem
{
GridNode node = (GridNode) te.getGridNode( f.getOpposite() );
if( node == null )
{
continue;
}
boolean isValidConnection = this.canConnect( node, f ) && node.canConnect( this, f.getOpposite() );
@@ -392,7 +428,9 @@ public class GridNode implements IGridNode, IPathItem
{
// if this connection is no longer valid, destroy it.
if( !isValidConnection )
{
con.destroy();
}
}
else
{
@@ -403,7 +441,9 @@ public class GridNode implements IGridNode, IPathItem
else if( isValidConnection )
{
if( node.lastSecurityKey != -1 )
{
newSecurityConnections.add( f );
}
else
{
// construct a new connection between these two nodes.
@@ -429,7 +469,9 @@ public class GridNode implements IGridNode, IPathItem
{
GridNode node = (GridNode) te.getGridNode( f.getOpposite() );
if( node == null )
{
continue;
}
// construct a new connection between these two nodes.
try
@@ -452,7 +494,9 @@ public class GridNode implements IGridNode, IPathItem
{
TileEntity te = world.getTileEntity( x, y, z );
if( te instanceof IGridHost )
{
return (IGridHost) te;
}
}
return null;
}
@@ -460,10 +504,14 @@ public class GridNode implements IGridNode, IPathItem
public boolean canConnect( GridNode from, ForgeDirection dir )
{
if( !this.isValidDirection( dir ) )
{
return false;
}
if( !from.getColor().matches( this.getColor() ) )
{
return false;
}
return true;
}
@@ -494,7 +542,9 @@ public class GridNode implements IGridNode, IPathItem
}
if( tracker == gn.visitorIterationNumber )
{
continue;
}
gn.visitorIterationNumber = tracker;
@@ -512,7 +562,9 @@ public class GridNode implements IGridNode, IPathItem
GridNode gn = (GridNode) gc.getOtherSide( this );
if( tracker == gn.visitorIterationNumber )
{
continue;
}
gn.visitorIterationNumber = tracker;
@@ -536,7 +588,9 @@ public class GridNode implements IGridNode, IPathItem
public IPathItem getControllerRoute()
{
if( this.connections.isEmpty() || this.getFlags().contains( GridFlags.CANNOT_CARRY ) )
{
return null;
}
return (IPathItem) this.connections.get( 0 );
}
@@ -545,7 +599,9 @@ public class GridNode implements IGridNode, IPathItem
public void setControllerRoute( IPathItem fast, boolean zeroOut )
{
if( zeroOut )
{
this.channelData &= ~0xff;
}
int idx = this.connections.indexOf( fast );
if( idx > 0 )
@@ -588,7 +644,9 @@ public class GridNode implements IGridNode, IPathItem
public void finalizeChannels()
{
if( this.getFlags().contains( GridFlags.CANNOT_CARRY ) )
{
return;
}
if( this.getLastUsedChannels() != this.getUsedChannels() )
{
@@ -596,7 +654,9 @@ public class GridNode implements IGridNode, IPathItem
this.channelData |= this.channelData << 8;
if( this.getInternalGrid() != null )
{
this.getInternalGrid().postEventTo( this, EVENT );
}
}
}
@@ -49,7 +49,9 @@ public class GridNodeCollection implements IReadOnlyCollection<IGridNode>
int size = 0;
for( Set<IGridNode> o : this.machines.values() )
{
size += o.size();
}
return size;
}
@@ -58,8 +60,12 @@ public class GridNodeCollection implements IReadOnlyCollection<IGridNode>
public boolean isEmpty()
{
for( Set<IGridNode> o : this.machines.values() )
{
if( !o.isEmpty() )
{
return false;
}
}
return true;
}
@@ -38,7 +38,9 @@ class GridSplitDetector implements IGridVisitor
public boolean visitNode( IGridNode n )
{
if( n == this.pivot )
{
this.pivotFound = true;
}
return !this.pivotFound;
}
@@ -48,13 +48,19 @@ public class GridStorageSearch
public boolean equals( Object obj )
{
if( obj == null )
{
return false;
}
if( this.getClass() != obj.getClass() )
{
return false;
}
GridStorageSearch other = (GridStorageSearch) obj;
if( this.id == other.id )
{
return true;
}
return false;
}
@@ -42,7 +42,9 @@ public class NetworkEventBus
public void readClass( Class listAs, Class c )
{
if( READ_CLASSES.contains( c ) )
{
return;
}
READ_CLASSES.add( c );
try
@@ -60,21 +62,29 @@ public class NetworkEventBus
Map<Class, MENetworkEventInfo> classEvents = EVENTS.get( types[0] );
if( classEvents == null )
{
EVENTS.put( types[0], classEvents = new HashMap<Class, MENetworkEventInfo>() );
}
MENetworkEventInfo thisEvent = classEvents.get( listAs );
if( thisEvent == null )
{
thisEvent = new MENetworkEventInfo();
}
thisEvent.Add( types[0], c, m );
classEvents.put( listAs, thisEvent );
}
else
{
throw new IllegalStateException( "Invalid ME Network Event Subscriber, " + m.getName() + "s Parameter must extend MENetworkEvent." );
}
}
else
{
throw new IllegalStateException( "Invalid ME Network Event Subscriber, " + m.getName() + " must have exactly 1 parameter." );
}
}
}
}
@@ -183,7 +193,9 @@ public class NetworkEventBus
}
if( e.isCanceled() )
{
throw new NetworkEventDone();
}
}
}
@@ -201,7 +213,9 @@ public class NetworkEventBus
public void invoke( Object obj, MENetworkEvent e ) throws NetworkEventDone
{
for( EventMethod em : this.methods )
{
em.invoke( obj, e );
}
}
}
}
+4
View File
@@ -544,13 +544,17 @@ public class CraftingGridCache implements ICraftingGrid, ICraftingProviderHelper
{
int comparison = ItemSorters.compareLong( nextCluster.getCoProcessors(), firstCluster.getCoProcessors() );
if( comparison != 0 )
{
return comparison;
}
return ItemSorters.compareLong( nextCluster.getAvailableStorage(), firstCluster.getAvailableStorage() );
}
int comparison = ItemSorters.compareLong( firstCluster.getCoProcessors(), nextCluster.getCoProcessors() );
if( comparison != 0 )
{
return comparison;
}
return ItemSorters.compareLong( firstCluster.getAvailableStorage(), nextCluster.getAvailableStorage() );
}
} );
+42
View File
@@ -129,11 +129,15 @@ public class EnergyGridCache implements IEnergyGrid
{
case PROVIDE_POWER:
if( ev.storage.getPowerFlow() != AccessRestriction.WRITE )
{
this.providers.add( ev.storage );
}
break;
case REQUEST_POWER:
if( ev.storage.getPowerFlow() != AccessRestriction.READ )
{
this.requesters.add( ev.storage );
}
break;
}
}
@@ -183,18 +187,26 @@ public class EnergyGridCache implements IEnergyGrid
// ticks since change..
if( currentlyHasPower == this.hasPower )
{
this.ticksSinceHasPowerChange++;
}
else
{
this.ticksSinceHasPowerChange = 0;
}
// update status..
this.hasPower = currentlyHasPower;
// update public status, this buffers power ups for 30 ticks.
if( this.hasPower && this.ticksSinceHasPowerChange > 30 )
{
this.publicPowerState( true, this.myGrid );
}
else if( !this.hasPower )
{
this.publicPowerState( false, this.myGrid );
}
this.availableTicksSinceUpdate++;
}
@@ -215,7 +227,9 @@ public class EnergyGridCache implements IEnergyGrid
private void publicPowerState( boolean newState, IGrid grid )
{
if( this.publicHasPower == newState )
{
return;
}
this.publicHasPower = newState;
( (Grid) this.myGrid ).setImportantFlag( 0, this.publicHasPower );
@@ -230,14 +244,18 @@ public class EnergyGridCache implements IEnergyGrid
this.availableTicksSinceUpdate = 0;
this.globalAvailablePower = 0;
for( IAEPowerStorage p : this.providers )
{
this.globalAvailablePower += p.getAECurrentPower();
}
}
@Override
public double extractAEPower( double amt, Actionable mode, Set<IEnergyGrid> seen )
{
if( !seen.add( this ) )
{
return 0;
}
double extractedPower = this.extra;
@@ -249,7 +267,9 @@ public class EnergyGridCache implements IEnergyGrid
{
Iterator<IEnergyGridProvider> i = this.energyGridProviders.iterator();
while( extractedPower < amt && i.hasNext() )
{
extractedPower += i.next().extractAEPower( amt - extractedPower, mode, seen );
}
}
return extractedPower;
@@ -274,7 +294,9 @@ public class EnergyGridCache implements IEnergyGrid
{
Iterator<IEnergyGridProvider> i = this.energyGridProviders.iterator();
while( extractedPower < amt && i.hasNext() )
{
extractedPower += i.next().extractAEPower( amt - extractedPower, mode, seen );
}
}
// go less or the correct amount?
@@ -287,7 +309,9 @@ public class EnergyGridCache implements IEnergyGrid
public double injectAEPower( double amt, Actionable mode, Set<IEnergyGrid> seen )
{
if( !seen.add( this ) )
{
return 0;
}
double ignore = this.extra;
amt += this.extra;
@@ -303,7 +327,9 @@ public class EnergyGridCache implements IEnergyGrid
Iterator<IEnergyGridProvider> i = this.energyGridProviders.iterator();
while( amt > 0 && i.hasNext() )
{
amt = i.next().injectAEPower( amt, mode, seen );
}
}
else
{
@@ -345,7 +371,9 @@ public class EnergyGridCache implements IEnergyGrid
public double getEnergyDemand( double maxRequired, Set<IEnergyGrid> seen )
{
if( !seen.add( this ) )
{
return 0;
}
double required = this.buffer() - this.extra;
@@ -354,7 +382,9 @@ public class EnergyGridCache implements IEnergyGrid
{
IAEPowerStorage node = it.next();
if( node.getPowerFlow() != AccessRestriction.READ )
{
required += Math.max( 0.0, node.getAEMaxPower() - node.getAECurrentPower() );
}
}
Iterator<IEnergyGridProvider> ix = this.energyGridProviders.iterator();
@@ -460,7 +490,9 @@ public class EnergyGridCache implements IEnergyGrid
public double getStoredPower()
{
if( this.availableTicksSinceUpdate > 90 )
{
this.refreshPower();
}
return Math.max( 0.0, this.globalAvailablePower );
}
@@ -482,7 +514,9 @@ public class EnergyGridCache implements IEnergyGrid
public void removeNode( IGridNode node, IGridHost machine )
{
if( machine instanceof IEnergyGridProvider )
{
this.energyGridProviders.remove( machine );
}
// idle draw.
GridNode gridNode = (GridNode) node;
@@ -501,10 +535,14 @@ public class EnergyGridCache implements IEnergyGrid
}
if( this.lastProvider == machine )
{
this.lastProvider = null;
}
if( this.lastRequester == machine )
{
this.lastRequester = null;
}
this.providers.remove( machine );
this.requesters.remove( machine );
@@ -526,7 +564,9 @@ public class EnergyGridCache implements IEnergyGrid
public void addNode( IGridNode node, IGridHost machine )
{
if( machine instanceof IEnergyGridProvider )
{
this.energyGridProviders.add( (IEnergyGridProvider) machine );
}
// idle draw...
GridNode gridNode = (GridNode) node;
@@ -555,7 +595,9 @@ public class EnergyGridCache implements IEnergyGrid
}
if( current < max && ps.getPowerFlow() != AccessRestriction.READ )
{
this.requesters.add( ps );
}
}
}
+34
View File
@@ -114,7 +114,9 @@ public class GridStorageCache implements IStorageGrid
this.myGrid.postEvent( new MENetworkCellArrayUpdate() );
if( node.isActive() )
{
this.addCellProvider( cc, new CellChangeTracker() ).applyChanges();
}
}
if( machine instanceof IStackWatcherHost )
@@ -153,7 +155,9 @@ public class GridStorageCache implements IStorageGrid
BaseActionSource actionSrc = new BaseActionSource();
if( cc instanceof IActionHost )
{
actionSrc = new MachineSource( (IActionHost) cc );
}
for( IMEInventoryHandler<IAEItemStack> h : cc.getCellArray( StorageChannel.ITEMS ) )
{
@@ -178,7 +182,9 @@ public class GridStorageCache implements IStorageGrid
BaseActionSource actionSrc = new BaseActionSource();
if( cc instanceof IActionHost )
{
actionSrc = new MachineSource( (IActionHost) cc );
}
for( IMEInventoryHandler<IAEItemStack> h : cc.getCellArray( StorageChannel.ITEMS ) )
{
@@ -214,15 +220,23 @@ public class GridStorageCache implements IStorageGrid
{
IGridNode node = ( (IActionHost) cc ).getActionableNode();
if( node != null && node.isActive() )
{
Active = true;
}
else
{
Active = false;
}
}
if( Active )
{
this.addCellProvider( cc, tracker );
}
else
{
this.removeCellProvider( cc, tracker );
}
}
this.itemMonitor.forceUpdate();
@@ -248,7 +262,9 @@ public class GridStorageCache implements IStorageGrid
public IMEInventoryHandler<IAEItemStack> getItemInventoryHandler()
{
if( this.myItemNetwork == null )
{
this.buildNetworkStorage( StorageChannel.ITEMS );
}
return this.myItemNetwork;
}
@@ -263,7 +279,9 @@ public class GridStorageCache implements IStorageGrid
for( ICellProvider cc : this.activeCellProviders )
{
for( IMEInventoryHandler<IAEFluidStack> h : cc.getCellArray( chan ) )
{
this.myFluidNetwork.addNewStorage( h );
}
}
break;
case ITEMS:
@@ -271,7 +289,9 @@ public class GridStorageCache implements IStorageGrid
for( ICellProvider cc : this.activeCellProviders )
{
for( IMEInventoryHandler<IAEItemStack> h : cc.getCellArray( chan ) )
{
this.myItemNetwork.addNewStorage( h );
}
}
break;
default:
@@ -281,7 +301,9 @@ public class GridStorageCache implements IStorageGrid
public IMEInventoryHandler<IAEFluidStack> getFluidInventoryHandler()
{
if( this.myFluidNetwork == null )
{
this.buildNetworkStorage( StorageChannel.FLUIDS );
}
return this.myFluidNetwork;
}
@@ -289,9 +311,13 @@ public class GridStorageCache implements IStorageGrid
public void postAlterationOfStoredItems( StorageChannel chan, Iterable<? extends IAEStack> input, BaseActionSource src )
{
if( chan == StorageChannel.ITEMS )
{
this.itemMonitor.postChange( true, (Iterable<IAEItemStack>) input, src );
}
else if( chan == StorageChannel.FLUIDS )
{
this.fluidMonitor.postChange( true, (Iterable<IAEFluidStack>) input, src );
}
}
@Override
@@ -335,11 +361,17 @@ public class GridStorageCache implements IStorageGrid
this.src = actionSrc;
if( channel == StorageChannel.ITEMS )
{
this.list = ( (IMEInventoryHandler<IAEItemStack>) h ).getAvailableItems( AEApi.instance().storage().createItemList() );
}
else if( channel == StorageChannel.FLUIDS )
{
this.list = ( (IMEInventoryHandler<IAEFluidStack>) h ).getAvailableItems( AEApi.instance().storage().createFluidList() );
}
else
{
this.list = null;
}
}
public void applyChanges()
@@ -362,7 +394,9 @@ public class GridStorageCache implements IStorageGrid
public void applyChanges()
{
for( CellChangeTrackerRecord rec : this.data )
{
rec.applyChanges();
}
}
}
}
+12
View File
@@ -62,9 +62,13 @@ public class NetworkMonitor<T extends IAEStack<T>> extends MEMonitorHandler<T>
IMEMonitorHandlerReceiver<T> receiver = o.getKey();
if( receiver.isValid( o.getValue() ) )
{
receiver.onListUpdate();
}
else
{
i.remove();
}
}
}
@@ -100,7 +104,9 @@ public class NetworkMonitor<T extends IAEStack<T>> extends MEMonitorHandler<T>
protected void postChange( boolean Add, Iterable<T> changes, BaseActionSource src )
{
if( DEPTH.contains( this ) )
{
return;
}
DEPTH.push( this );
@@ -114,7 +120,9 @@ public class NetworkMonitor<T extends IAEStack<T>> extends MEMonitorHandler<T>
T difference = changedItem;
if( !Add && changedItem != null )
{
( difference = changedItem.copy() ).setStackSize( -changedItem.getStackSize() );
}
if( this.myGridCache.interestManager.containsKey( changedItem ) )
{
@@ -131,7 +139,9 @@ public class NetworkMonitor<T extends IAEStack<T>> extends MEMonitorHandler<T>
this.myGridCache.interestManager.enableTransactions();
for( ItemWatcher iw : list )
{
iw.getHost().onStackChange( myStorageList, fullStack, difference, src, this.getChannel() );
}
this.myGridCache.interestManager.disableTransactions();
}
@@ -140,6 +150,8 @@ public class NetworkMonitor<T extends IAEStack<T>> extends MEMonitorHandler<T>
final NetworkMonitor<?> last = DEPTH.pop();
if( last != this )
{
throw new IllegalStateException( "Invalid Access to Networked Storage API detected." );
}
}
}
+32
View File
@@ -59,7 +59,9 @@ public class P2PCache implements IGridCache
for( PartP2PTunnel me : this.inputs.values() )
{
if( me instanceof PartP2PTunnelME )
{
tm.wakeDevice( me.getGridNode() );
}
}
}
@@ -70,7 +72,9 @@ public class P2PCache implements IGridCache
for( PartP2PTunnel me : this.inputs.values() )
{
if( me instanceof PartP2PTunnelME )
{
tm.wakeDevice( me.getGridNode() );
}
}
}
@@ -88,7 +92,9 @@ public class P2PCache implements IGridCache
if( machine instanceof PartP2PTunnelME )
{
if( !node.hasFlag( GridFlags.REQUIRE_CHANNEL ) )
{
return;
}
}
PartP2PTunnel t = (PartP2PTunnel) machine;
@@ -96,9 +102,13 @@ public class P2PCache implements IGridCache
// );
if( t.output )
{
this.outputs.remove( t.freq, t );
}
else
{
this.inputs.remove( t.freq );
}
this.updateTunnel( t.freq, !t.output, false );
}
@@ -112,7 +122,9 @@ public class P2PCache implements IGridCache
if( machine instanceof PartP2PTunnelME )
{
if( !node.hasFlag( GridFlags.REQUIRE_CHANNEL ) )
{
return;
}
}
PartP2PTunnel t = (PartP2PTunnel) machine;
@@ -120,9 +132,13 @@ public class P2PCache implements IGridCache
// );
if( t.output )
{
this.outputs.put( t.freq, t );
}
else
{
this.inputs.put( t.freq, t );
}
this.updateTunnel( t.freq, !t.output, false );
}
@@ -151,7 +167,9 @@ public class P2PCache implements IGridCache
for( PartP2PTunnel p : this.outputs.get( freq ) )
{
if( configChange )
{
p.onTunnelConfigChange();
}
p.onTunnelNetworkChange();
}
@@ -159,7 +177,9 @@ public class P2PCache implements IGridCache
if( in != null )
{
if( configChange )
{
in.onTunnelConfigChange();
}
in.onTunnelNetworkChange();
}
}
@@ -167,17 +187,25 @@ public class P2PCache implements IGridCache
public void updateFreq( PartP2PTunnel t, long NewFreq )
{
if( this.outputs.containsValue( t ) )
{
this.outputs.remove( t.freq, t );
}
if( this.inputs.containsValue( t ) )
{
this.inputs.remove( t.freq );
}
t.freq = NewFreq;
if( t.output )
{
this.outputs.put( t.freq, t );
}
else
{
this.inputs.put( t.freq, t );
}
// AELog.info( "update-" + (t.output ? "output: " : "input: ") + t.freq
// );
@@ -189,11 +217,15 @@ public class P2PCache implements IGridCache
{
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 );
if( out == null )
{
return this.NullColl;
}
return out;
}
+32
View File
@@ -93,7 +93,9 @@ public class PathGridCache implements IPathingGrid
if( this.updateNetwork )
{
if( !this.booting )
{
this.myGrid.postEvent( new MENetworkBootingStatusChange() );
}
this.booting = true;
this.updateNetwork = false;
@@ -116,7 +118,9 @@ public class PathGridCache implements IPathingGrid
int requiredChannels = this.calculateRequiredChannels();
int used = requiredChannels;
if( requiredChannels > 8 )
{
used = 0;
}
int nodes = this.myGrid.getNodes().size();
this.channelsInUse = used;
@@ -209,10 +213,14 @@ public class PathGridCache implements IPathingGrid
EnumSet<GridFlags> flags = gridNode.getGridBlock().getFlags();
if( flags.contains( GridFlags.REQUIRE_CHANNEL ) )
{
this.requireChannels.remove( gridNode );
}
if( flags.contains( GridFlags.CANNOT_CARRY_COMPRESSED ) )
{
this.blockDense.remove( gridNode );
}
this.repath();
}
@@ -229,10 +237,14 @@ public class PathGridCache implements IPathingGrid
EnumSet<GridFlags> flags = gridNode.getGridBlock().getFlags();
if( flags.contains( GridFlags.REQUIRE_CHANNEL ) )
{
this.requireChannels.add( gridNode );
}
if( flags.contains( GridFlags.CANNOT_CARRY_COMPRESSED ) )
{
this.blockDense.add( gridNode );
}
this.repath();
}
@@ -279,9 +291,13 @@ public class PathGridCache implements IPathingGrid
startingNode.beginVisit( cv );
if( cv.isValid && cv.found == this.controllers.size() )
{
this.controllerState = ControllerState.CONTROLLER_ONLINE;
}
else
{
this.controllerState = ControllerState.CONTROLLER_CONFLICT;
}
}
if( old != this.controllerState )
@@ -303,7 +319,9 @@ public class PathGridCache implements IPathingGrid
EnumSet<GridFlags> flags = gb.getFlags();
if( flags.contains( GridFlags.COMPRESSED_CHANNEL ) && !this.blockDense.isEmpty() )
{
return 9;
}
depth++;
@@ -312,7 +330,9 @@ public class PathGridCache implements IPathingGrid
IGridMultiblock gmb = (IGridMultiblock) gb;
Iterator<IGridNode> i = gmb.getMultiblockNodes();
while( i.hasNext() )
{
this.semiOpen.add( (IPathItem) i.next() );
}
}
}
}
@@ -330,7 +350,9 @@ public class PathGridCache implements IPathingGrid
{
Set<Integer> players = new HashSet<Integer>();
for( IGridNode n : this.requireChannels )
{
players.add( n.getPlayerID() );
}
for( int id : players )
{
@@ -344,13 +366,19 @@ public class PathGridCache implements IPathingGrid
private Achievements getAchievementBracket( int ch )
{
if( ch < 8 )
{
return null;
}
if( ch < 128 )
{
return Achievements.Networking1;
}
if( ch < 2048 )
{
return Achievements.Networking2;
}
return Achievements.Networking3;
}
@@ -361,9 +389,13 @@ public class PathGridCache implements IPathingGrid
IGridNode gridNode = ev.node;
if( gridNode.getGridBlock().getFlags().contains( GridFlags.REQUIRE_CHANNEL ) )
{
this.requireChannels.add( gridNode );
}
else
{
this.requireChannels.remove( gridNode );
}
this.repath();
}
+16
View File
@@ -57,7 +57,9 @@ public class SecurityCache implements ISecurityGrid
{
this.playerPerms.clear();
if( this.securityProvider.isEmpty() )
{
return;
}
this.securityProvider.get( 0 ).readPermissions( this.playerPerms );
}
@@ -88,15 +90,21 @@ public class SecurityCache implements ISecurityGrid
long lastCode = this.securityKey;
if( this.securityProvider.size() == 1 )
{
this.securityKey = this.securityProvider.get( 0 ).getSecurityKey();
}
else
{
this.securityKey = -1;
}
if( lastCode != this.securityKey )
{
this.myGrid.postEvent( new MENetworkSecurityChange() );
for( IGridNode n : this.myGrid.getNodes() )
{
( (GridNode) n ).lastSecurityKey = this.securityKey;
}
}
}
@@ -109,7 +117,9 @@ public class SecurityCache implements ISecurityGrid
this.updateSecurityKey();
}
else
{
( (GridNode) gridNode ).lastSecurityKey = this.securityKey;
}
}
@Override
@@ -152,9 +162,13 @@ public class SecurityCache implements ISecurityGrid
if( perms == null )
{
if( playerID == -1 ) // no default?
{
return false;
}
else
{
return this.hasPermission( -1, perm );
}
}
return perms.contains( perm );
@@ -166,7 +180,9 @@ public class SecurityCache implements ISecurityGrid
public int getOwner()
{
if( this.isAvailable() )
{
return this.securityProvider.get( 0 ).getOwner();
}
return -1;
}
}
+12
View File
@@ -87,7 +87,9 @@ public class SpatialPylonCache implements ISpatialCache
{
SpatialPylonCluster c = ( (TileSpatialPylon) gm.getMachine() ).getCluster();
if( c != null )
{
this.clusters.put( c, c );
}
}
}
@@ -99,9 +101,13 @@ public class SpatialPylonCache implements ISpatialCache
for( SpatialPylonCluster cl : this.clusters.values() )
{
if( this.captureMax == null )
{
this.captureMax = cl.max.copy();
}
if( this.captureMin == null )
{
this.captureMin = cl.min.copy();
}
pylonBlocks += cl.tileCount();
@@ -151,9 +157,13 @@ public class SpatialPylonCache implements ISpatialCache
this.efficiency = (double) pylonBlocks / (double) requirePylonBlocks;
if( this.efficiency > 1.0 )
{
this.efficiency = 1.0;
}
if( this.efficiency < 0.0 )
{
this.efficiency = 0.0;
}
minPower = (double) reqX * (double) reqY * reqZ * AEConfig.instance.spatialPowerMultiplier;
maxPower = Math.pow( minPower, AEConfig.instance.spatialPowerExponent );
@@ -167,7 +177,9 @@ public class SpatialPylonCache implements ISpatialCache
boolean myWasValid = cl.isValid;
cl.isValid = this.isValid;
if( myWasValid != this.isValid )
{
cl.updateStatus( false );
}
}
}
+14
View File
@@ -62,10 +62,14 @@ public class TickManagerCache implements ITickManager
TickTracker tt = this.awake.get( node );
if( tt == null )
{
tt = this.sleeping.get( node );
}
if( tt == null )
{
return -1;
}
return tt.getAvgNanos();
}
@@ -111,10 +115,14 @@ public class TickManagerCache implements ITickManager
}
if( this.awake.containsKey( tt.node ) )
{
this.addToQueue( tt );
}
}
else
{
return; // done!
}
}
}
catch( Throwable t )
@@ -154,10 +162,14 @@ public class TickManagerCache implements ITickManager
TickTracker tt = new TickTracker( tr, gridNode, (IGridTickable) machine, this.currentTick, this );
if( tr.canBeAlerted )
{
this.alertable.put( gridNode, tt );
}
if( tr.isSleeping )
{
this.sleeping.put( gridNode, tt );
}
else
{
this.awake.put( gridNode, tt );
@@ -190,7 +202,9 @@ public class TickManagerCache implements ITickManager
{
TickTracker tt = this.alertable.get( node );
if( tt == null )
{
return false;
}
// throw new RuntimeException(
// "Invalid alerted device, this node is not marked as alertable, or part of this grid." );
@@ -62,10 +62,14 @@ public class TickTracker implements Comparable<TickTracker>
this.current_rate = rate;
if( this.current_rate < this.request.minTickRate )
{
this.current_rate = this.request.minTickRate;
}
if( this.current_rate > this.request.maxTickRate )
{
this.current_rate = this.request.maxTickRate;
}
}
@Override
@@ -93,6 +97,8 @@ public class TickTracker implements Comparable<TickTracker>
DimensionalCoord dc = this.node.getGridBlock().getLocation();
if( dc != null )
{
crashreportcategory.addCrashSection( "Location", dc );
}
}
}
@@ -52,7 +52,9 @@ public class TunnelCollection<T extends PartP2PTunnel> implements Iterable<T>
public Iterator<T> iterator()
{
if( this.tunnelSources == null )
{
return new NullIterator<T>();
}
return new TunnelIterator<T>( this.tunnelSources, this.clz );
}
@@ -45,7 +45,9 @@ public class TunnelIterator<T extends PartP2PTunnel> implements Iterator<T>
{
this.Next = this.wrapped.next();
if( !this.targetType.isInstance( this.Next ) )
{
this.Next = null;
}
}
}
@@ -41,7 +41,9 @@ public abstract class MBCalculator
public void calculateMultiblock( World world, WorldCoord loc )
{
if( Platform.isClient() )
{
return;
}
try
{
@@ -50,17 +52,29 @@ public abstract class MBCalculator
// find size of MB structure...
while( this.isValidTileAt( world, min.x - 1, min.y, min.z ) )
{
min.x--;
}
while( this.isValidTileAt( world, min.x, min.y - 1, min.z ) )
{
min.y--;
}
while( this.isValidTileAt( world, min.x, min.y, min.z - 1 ) )
{
min.z--;
}
while( this.isValidTileAt( world, max.x + 1, max.y, max.z ) )
{
max.x++;
}
while( this.isValidTileAt( world, max.x, max.y + 1, max.z ) )
{
max.y++;
}
while( this.isValidTileAt( world, max.x, max.y, max.z + 1 ) )
{
max.z++;
}
if( this.checkMultiblockScale( min, max ) )
{
@@ -91,7 +105,9 @@ public abstract class MBCalculator
updateGrid = true;
}
else
{
c = cluster;
}
c.updateStatus( updateGrid );
return;
@@ -124,8 +140,12 @@ public abstract class MBCalculator
public boolean verifyUnownedRegion( World w, WorldCoord min, WorldCoord max )
{
for( ForgeDirection side : ForgeDirection.VALID_DIRECTIONS )
{
if( this.verifyUnownedRegionInner( w, min.x, min.y, min.z, max.x, max.y, max.z, side ) )
{
return false;
}
}
return true;
}
@@ -207,7 +227,9 @@ public abstract class MBCalculator
{
TileEntity te = w.getTileEntity( x, y, z );
if( this.isValidTile( te ) )
{
return true;
}
}
}
}
@@ -51,13 +51,19 @@ public class CraftingCPUCalculator extends MBCalculator
public boolean checkMultiblockScale( WorldCoord min, WorldCoord max )
{
if( max.x - min.x > 16 )
{
return false;
}
if( max.y - min.y > 16 )
{
return false;
}
if( max.z - min.z > 16 )
{
return false;
}
return true;
}
@@ -82,10 +88,14 @@ public class CraftingCPUCalculator extends MBCalculator
IAEMultiBlock te = (IAEMultiBlock) w.getTileEntity( x, y, z );
if( !te.isValid() )
{
return false;
}
if( !storage && te instanceof TileCraftingTile )
{
storage = ( (TileCraftingTile) te ).getStorageBytes() > 0;
}
}
}
}
@@ -142,14 +142,18 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU
public void updateStatus( boolean updateGrid )
{
for( TileCraftingTile r : this.tiles )
{
r.updateMeta( true );
}
}
@Override
public void destroy()
{
if( this.isDestroyed )
{
return;
}
this.isDestroyed = true;
boolean posted = false;
@@ -180,7 +184,9 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU
public void addTile( TileCraftingTile te )
{
if( this.machineSrc == null || te.isCoreBlock )
{
this.machineSrc = new MachineSource( te );
}
te.isCoreBlock = false;
te.markDirty();
@@ -192,9 +198,13 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU
this.storage.add( te );
}
else if( te.isStatus() )
{
this.status.add( (TileCraftingMonitorTile) te );
}
else if( te.isAccelerator() )
{
this.accelerator++;
}
}
public boolean canAccept( IAEStack input )
@@ -203,7 +213,9 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU
{
IAEItemStack is = this.waitingFor.findPrecise( (IAEItemStack) input );
if( is != null && is.getStackSize() > 0 )
{
return true;
}
}
return false;
}
@@ -222,7 +234,9 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU
if( this.finalOutput.equals( what ) )
{
if( this.myLastLink != null )
{
return ( (CraftingLink) this.myLastLink ).injectItems( what.copy(), type );
}
return what; // ignore it.
}
@@ -270,12 +284,16 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU
{
this.finalOutput.decStackSize( input.getStackSize() );
if( this.finalOutput.getStackSize() <= 0 )
{
this.completeJob();
}
this.updateCPU();
if( this.myLastLink != null )
{
return ( (CraftingLink) this.myLastLink ).injectItems( (IAEItemStack) input, type );
}
return input; // ignore it.
}
@@ -294,7 +312,9 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU
{
this.finalOutput.decStackSize( insert.getStackSize() );
if( this.finalOutput.getStackSize() <= 0 )
{
this.completeJob();
}
this.updateCPU();
@@ -305,7 +325,9 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU
}
if( this.myLastLink != null )
{
return ( (CraftingLink) this.myLastLink ).injectItems( (IAEItemStack) input, type );
}
return input; // ignore it.
}
@@ -328,16 +350,22 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU
// protect integrity
if( i.hasNext() )
{
single = ImmutableList.of( diff.copy() );
}
while( i.hasNext() )
{
Entry<IMEMonitorHandlerReceiver<IAEItemStack>, Object> o = i.next();
IMEMonitorHandlerReceiver<IAEItemStack> receiver = o.getKey();
if( receiver.isValid( o.getValue() ) )
{
receiver.postChange( null, single, src );
}
else
{
i.remove();
}
}
}
@@ -349,7 +377,9 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU
public void postCraftingStatusChange( IAEItemStack diff )
{
if( this.getGrid() == null )
{
return;
}
CraftingGridCache sg = this.getGrid().getCache( ICraftingGrid.class );
@@ -361,7 +391,9 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU
{
for( CraftingWatcher iw : list )
{
iw.getHost().onRequestChange( sg, diff );
}
}
}
}
@@ -369,7 +401,9 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU
private void completeJob()
{
if( this.myLastLink != null )
{
( (CraftingLink) this.myLastLink ).markDone();
}
AELog.crafting( "marking job as complete" );
this.isComplete = true;
@@ -380,10 +414,14 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU
IAEItemStack send = this.finalOutput;
if( this.finalOutput != null && this.finalOutput.getStackSize() <= 0 )
{
send = null;
}
for( TileCraftingMonitorTile t : this.status )
{
t.setJob( send );
}
}
protected Iterator<Entry<IMEMonitorHandlerReceiver<IAEItemStack>, Object>> getListeners()
@@ -405,7 +443,9 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU
{
IGrid g = gn.getGrid();
if( g != null )
{
return r.getActionableNode().getGrid();
}
}
}
@@ -441,7 +481,9 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU
}
if( !found )
{
return false;
}
}
else
{
@@ -449,7 +491,9 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU
ItemStack is = ais == null ? null : ais.getItemStack();
if( is == null || is.stackSize < g.getStackSize() )
{
return false;
}
}
}
@@ -459,12 +503,16 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU
public void cancel()
{
if( this.myLastLink != null )
{
this.myLastLink.cancel();
}
IItemList<IAEItemStack> list;
this.getListOfItem( list = AEApi.instance().storage().createItemList(), CraftingItemList.ALL );
for( IAEItemStack is : list )
{
this.postChange( is, this.machineSrc );
}
this.isComplete = true;
this.myLastLink = null;
@@ -475,7 +523,9 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU
this.waitingFor.resetStatus();
for( IAEItemStack is : items )
{
this.postCraftingStatusChange( is );
}
this.finalOutput = null;
this.updateCPU();
@@ -486,7 +536,9 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU
public void updateCraftingLogic( IGrid grid, IEnergyGrid eg, CraftingGridCache cc )
{
if( !this.getCore().isActive() )
{
return;
}
if( this.myLastLink != null )
{
@@ -500,7 +552,9 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU
if( this.isComplete )
{
if( this.inventory.getItemList().isEmpty() )
{
return;
}
this.storeItems();
return;
@@ -508,7 +562,9 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU
this.waiting = false;
if( this.waiting || this.tasks.isEmpty() ) // nothing to do here...
{
return;
}
this.remainingOperations = this.accelerator + 1 - ( this.usedOps[0] + this.usedOps[1] + this.usedOps[2] );
int started = this.remainingOperations;
@@ -527,7 +583,9 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU
this.usedOps[0] = started - this.remainingOperations;
if( this.remainingOperations > 0 && !this.somethingChanged )
{
this.waiting = true;
}
}
private void executeCrafting( IEnergyGrid eg, CraftingGridCache cc )
@@ -550,7 +608,9 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU
for( ICraftingMedium m : cc.getMediums( e.getKey() ) )
{
if( e.getValue().value <= 0 )
{
continue;
}
if( !m.isBusy() )
{
@@ -569,7 +629,9 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU
// power...
if( eg.extractAEPower( sum, Actionable.MODULATE, PowerMultiplier.CONFIG ) < sum - 0.01 )
{
continue;
}
ic = new InventoryCrafting( new ContainerNull(), 3, 3 );
boolean found = false;
@@ -620,7 +682,9 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU
}
if( !found )
{
break;
}
}
}
@@ -631,7 +695,9 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU
{
ItemStack is = ic.getStackInSlot( x );
if( is != null )
{
this.inventory.injectItems( AEItemStack.create( is ), Actionable.MODULATE, this.machineSrc );
}
}
ic = null;
break;
@@ -672,10 +738,14 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU
e.getValue().value--;
if( e.getValue().value <= 0 )
{
continue;
}
if( this.remainingOperations == 0 )
{
return;
}
}
}
}
@@ -700,7 +770,9 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU
{
IGrid g = this.getGrid();
if( g == null )
{
return;
}
IStorageGrid sg = g.getCache( IStorageGrid.class );
IMEInventory<IAEItemStack> ii = sg.getItemInventory();
@@ -716,11 +788,15 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU
}
if( is != null )
{
this.inventory.injectItems( is, Actionable.MODULATE, this.machineSrc );
}
}
if( this.inventory.getItemList().isEmpty() )
{
this.inventory = new MECraftingInventory();
}
this.markDirty();
}
@@ -728,13 +804,19 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU
public ICraftingLink submitJob( IGrid g, ICraftingJob job, BaseActionSource src, ICraftingRequester requestingMachine )
{
if( !this.tasks.isEmpty() || !this.waitingFor.isEmpty() )
{
return null;
}
if( !( job instanceof CraftingJob ) )
{
return null;
}
if( this.isBusy() || !this.isActive() || this.availableStorage < job.getByteTotal() )
{
return null;
}
IStorageGrid sg = g.getCache( IStorageGrid.class );
IMEInventory<IAEItemStack> storage = sg.getItemInventory();
@@ -757,7 +839,9 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU
this.myLastLink = new CraftingLink( this.generateLinkData( craftID, requestingMachine == null, false ), this );
if( requestingMachine == null )
{
return this.myLastLink;
}
ICraftingLink whatLink = new CraftingLink( this.generateLinkData( craftID, false, true ), requestingMachine );
@@ -768,7 +852,9 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU
this.getListOfItem( list = AEApi.instance().storage().createItemList(), CraftingItemList.ALL );
for( IAEItemStack ge : list )
{
this.postChange( ge, this.machineSrc );
}
return whatLink;
}
@@ -795,7 +881,9 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU
while( i.hasNext() )
{
if( i.next().getValue().value <= 0 )
{
i.remove();
}
}
return !this.tasks.isEmpty() || !this.waitingFor.isEmpty();
@@ -829,11 +917,15 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU
{
TileCraftingTile core = this.getCore();
if( core == null )
{
return false;
}
IGridNode node = core.getActionableNode();
if( node == null )
{
return false;
}
return node.isActive();
}
@@ -875,7 +967,9 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU
{
case ACTIVE:
for( IAEItemStack ais : this.waitingFor )
{
list.add( ais );
}
break;
case PENDING:
for( Entry<ICraftingPatternDetails, TaskProgress> t : this.tasks.entrySet() )
@@ -896,7 +990,9 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU
this.inventory.getAvailableItems( list );
for( IAEItemStack ais : this.waitingFor )
{
list.add( ais );
}
for( Entry<ICraftingPatternDetails, TaskProgress> t : this.tasks.entrySet() )
{
@@ -927,7 +1023,9 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU
TaskProgress i = this.tasks.get( details );
if( i == null )
{
this.tasks.put( details, i = new TaskProgress() );
}
i.value += crafts;
}
@@ -953,7 +1051,9 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU
for( IAEItemStack ais : t.getKey().getCondensedOutputs() )
{
if( ais.equals( is ) )
{
is.setStackSize( is.getStackSize() + ais.getStackSize() * t.getValue().value );
}
}
}
@@ -964,7 +1064,9 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU
}
if( is != null )
{
return is.copy();
}
is = what.copy();
is.setStackSize( 0 );
@@ -1002,7 +1104,9 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU
NBTTagCompound out = new NBTTagCompound();
if( finalOutput2 != null )
{
finalOutput2.writeToNBT( out );
}
return out;
}
@@ -1012,7 +1116,9 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU
NBTTagList out = new NBTTagList();
for( IAEItemStack ais : myList )
{
out.appendTag( this.writeItem( ais ) );
}
return out;
}
@@ -1037,7 +1143,9 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU
{
this.finalOutput = AEItemStack.loadItemStackFromNBT( (NBTTagCompound) data.getTag( "finalOutput" ) );
for( IAEItemStack ais : this.readList( (NBTTagList) data.getTag( "inventory" ) ) )
{
this.inventory.injectItems( ais, Actionable.MODULATE, this.machineSrc );
}
this.waiting = data.getBoolean( "waiting" );
this.isComplete = data.getBoolean( "isComplete" );
@@ -1069,7 +1177,9 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU
this.waitingFor = this.readList( (NBTTagList) data.getTag( "waitingFor" ) );
for( IAEItemStack is : this.waitingFor )
{
this.postCraftingStatusChange( is.copy() );
}
}
public void updateName()
@@ -1081,9 +1191,13 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU
if( te.hasCustomName() )
{
if( this.myName.length() > 0 )
{
this.myName += ' ' + te.getCustomName();
}
else
{
this.myName = te.getCustomName();
}
}
}
}
@@ -1092,13 +1206,17 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU
{
IItemList<IAEItemStack> out = AEApi.instance().storage().createItemList();
if( tag == null )
{
return out;
}
for( int x = 0; x < tag.tagCount(); x++ )
{
IAEItemStack ais = AEItemStack.loadItemStackFromNBT( tag.getCompoundTagAt( x ) );
if( ais != null )
{
out.add( ais );
}
}
return out;
@@ -1119,7 +1237,9 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU
{
TileCraftingTile t = this.getCore();
if( t != null )
{
t.breakCluster();
}
}
static class TaskProgress
@@ -81,7 +81,9 @@ public class QuantumCalculator extends MBCalculator
IAEMultiBlock te = (IAEMultiBlock) w.getTileEntity( x, y, z );
if( !te.isValid() )
{
return false;
}
num++;
final IBlocks blocks = AEApi.instance().definitions().blocks();
@@ -137,9 +139,13 @@ public class QuantumCalculator extends MBCalculator
else
{
if( num == 1 || num == 3 || num == 7 || num == 9 )
{
flags = (byte) ( this.tqb.corner | num );
}
else
{
flags = num;
}
c.Ring[ringNum] = te;
ringNum++;
}
@@ -88,7 +88,9 @@ public class QuantumCluster implements ILocatable, IAECluster
if( qe != 0 )
{
if( this.thisSide != 0 )
{
MinecraftForge.EVENT_BUS.post( new LocatableEventAnnounce( this, LocatableEvent.Unregister ) );
}
if( this.canUseNode( -qe ) )
{
@@ -130,7 +132,9 @@ public class QuantumCluster implements ILocatable, IAECluster
IGridNode sa = sideA.getNode();
IGridNode sb = sideB.getNode();
if( ( a == sa || b == sa ) && ( a == sb || b == sb ) )
{
return;
}
}
try
@@ -161,10 +165,14 @@ public class QuantumCluster implements ILocatable, IAECluster
}
}
else
{
shutdown = true;
}
}
else
{
shutdown = true;
}
if( shutdown && this.connection != null )
{
@@ -202,7 +210,9 @@ public class QuantumCluster implements ILocatable, IAECluster
private boolean isActive()
{
if( this.isDestroyed || !this.registered )
{
return false;
}
return this.center.isPowered() && this.hasQES();
}
@@ -221,7 +231,9 @@ public class QuantumCluster implements ILocatable, IAECluster
public void destroy()
{
if( this.isDestroyed )
{
return;
}
this.isDestroyed = true;
if( this.registered )
@@ -66,7 +66,9 @@ public class SpatialPylonCalculator extends MBCalculator
IAEMultiBlock te = (IAEMultiBlock) w.getTileEntity( x, y, z );
if( !te.isValid() )
{
return false;
}
}
}
}
@@ -48,13 +48,21 @@ public class SpatialPylonCluster implements IAECluster
this.max = _max.copy();
if( this.min.x != this.max.x )
{
this.currentAxis = Axis.X;
}
else if( this.min.y != this.max.y )
{
this.currentAxis = Axis.Y;
}
else if( this.min.z != this.max.z )
{
this.currentAxis = Axis.Z;
}
else
{
this.currentAxis = Axis.UNFORMED;
}
}
@Override
@@ -71,7 +79,9 @@ public class SpatialPylonCluster implements IAECluster
{
if( this.isDestroyed )
{
return;
}
this.isDestroyed = true;
for( TileSpatialPylon r : this.line )
@@ -36,9 +36,13 @@ public class EnergyThreshold implements Comparable<EnergyThreshold>
this.watcher = wat;
if( this.watcher != null )
{
this.hash = this.watcher.hashCode() ^ ( (Double) lim ).hashCode();
}
else
{
this.hash = ( (Double) lim ).hashCode();
}
}
@Override
@@ -94,7 +94,9 @@ public class EnergyWatcher implements IEnergyWatcher
public boolean add( Double e )
{
if( this.myInterests.contains( e ) )
{
return false;
}
EnergyThreshold eh = new EnergyThreshold( e, this );
return this.gsc.interests.add( eh ) && this.myInterests.add( eh );
@@ -119,7 +121,9 @@ public class EnergyWatcher implements IEnergyWatcher
boolean didChange = false;
for( Double o : c )
{
didChange = this.add( o ) || didChange;
}
return didChange;
}
@@ -129,7 +133,9 @@ public class EnergyWatcher implements IEnergyWatcher
{
boolean didSomething = false;
for( Object o : c )
{
didSomething = this.remove( o ) || didSomething;
}
return didSomething;
}
@@ -86,20 +86,26 @@ public class AENetworkProxy implements IGridBlock
public void writeToNBT( NBTTagCompound tag )
{
if( this.node != null )
{
this.node.saveToNBT( this.nbtName, tag );
}
}
public void setValidSides( EnumSet<ForgeDirection> validSides )
{
this.validSides = validSides;
if( this.node != null )
{
this.node.updateState();
}
}
public void validate()
{
if( this.gp instanceof AEBaseTile )
{
TickHandler.INSTANCE.addInit( (AEBaseTile) this.gp );
}
}
public void onChunkUnload()
@@ -127,7 +133,9 @@ public class AENetworkProxy implements IGridBlock
{
IOrientable ori = (IOrientable) this.gp;
if( ori.canBeRotated() )
{
ori.setOrientation( ori.getForward(), ori.getUp() );
}
}
this.getNode();
@@ -164,10 +172,14 @@ public class AENetworkProxy implements IGridBlock
{
IGrid grid = this.getGrid();
if( grid == null )
{
throw new GridAccessException();
}
IPathingGrid pg = grid.getCache( IPathingGrid.class );
if( pg == null )
{
throw new GridAccessException();
}
return pg;
}
@@ -181,10 +193,14 @@ public class AENetworkProxy implements IGridBlock
public IGrid getGrid() throws GridAccessException
{
if( this.node == null )
{
throw new GridAccessException();
}
IGrid grid = this.node.getGrid();
if( grid == null )
{
throw new GridAccessException();
}
return grid;
}
@@ -192,10 +208,14 @@ public class AENetworkProxy implements IGridBlock
{
IGrid grid = this.getGrid();
if( grid == null )
{
throw new GridAccessException();
}
ITickManager pg = grid.getCache( ITickManager.class );
if( pg == null )
{
throw new GridAccessException();
}
return pg;
}
@@ -203,12 +223,16 @@ public class AENetworkProxy implements IGridBlock
{
IGrid grid = this.getGrid();
if( grid == null )
{
throw new GridAccessException();
}
IStorageGrid pg = grid.getCache( IStorageGrid.class );
if( pg == null )
{
throw new GridAccessException();
}
return pg;
}
@@ -217,12 +241,16 @@ public class AENetworkProxy implements IGridBlock
{
IGrid grid = this.getGrid();
if( grid == null )
{
throw new GridAccessException();
}
P2PCache pg = grid.getCache( P2PCache.class );
if( pg == null )
{
throw new GridAccessException();
}
return pg;
}
@@ -231,12 +259,16 @@ public class AENetworkProxy implements IGridBlock
{
IGrid grid = this.getGrid();
if( grid == null )
{
throw new GridAccessException();
}
ISecurityGrid sg = grid.getCache( ISecurityGrid.class );
if( sg == null )
{
throw new GridAccessException();
}
return sg;
}
@@ -245,12 +277,16 @@ public class AENetworkProxy implements IGridBlock
{
IGrid grid = this.getGrid();
if( grid == null )
{
throw new GridAccessException();
}
ICraftingGrid sg = grid.getCache( ICraftingGrid.class );
if( sg == null )
{
throw new GridAccessException();
}
return sg;
}
@@ -289,7 +325,9 @@ public class AENetworkProxy implements IGridBlock
public void onGridNotification( GridNotification notification )
{
if( this.gp instanceof PartCable )
{
( (PartCable) this.gp ).markForUpdate();
}
}
@Override
@@ -357,7 +395,9 @@ public class AENetworkProxy implements IGridBlock
public boolean isActive()
{
if( this.node == null )
{
return false;
}
return this.node.isActive();
}
@@ -378,10 +418,14 @@ public class AENetworkProxy implements IGridBlock
{
IGrid grid = this.getGrid();
if( grid == null )
{
throw new GridAccessException();
}
IEnergyGrid eg = grid.getCache( IEnergyGrid.class );
if( eg == null )
{
throw new GridAccessException();
}
return eg;
}
@@ -43,7 +43,9 @@ public class AENetworkProxyMultiblock extends AENetworkProxy implements IGridMul
public Iterator<IGridNode> getMultiblockNodes()
{
if( this.getCluster() == null )
{
return new ChainedIterator<IGridNode>();
}
return new ProxyNodeIterator( this.getCluster().getTiles() );
}
@@ -41,7 +41,9 @@ public class ChannelPowerSrc implements IEnergySource
public double extractAEPower( double amt, Actionable mode, PowerMultiplier usePowerMultiplier )
{
if( this.node.isActive() )
{
return this.realSrc.extractAEPower( amt, mode, usePowerMultiplier );
}
return 0.0;
}
}
@@ -42,7 +42,9 @@ public class GenericInterestManager<T>
public void enableTransactions()
{
if( this.transDepth == 0 )
{
this.transactions = new LinkedList<SavedTransactions>();
}
this.transDepth++;
}
@@ -59,9 +61,13 @@ public class GenericInterestManager<T>
for( SavedTransactions t : myActions )
{
if( t.put )
{
this.put( t.stack, t.iw );
}
else
{
this.remove( t.stack, t.iw );
}
}
}
}
@@ -74,7 +80,9 @@ public class GenericInterestManager<T>
return true;
}
else
{
return this.container.put( stack, iw );
}
}
public boolean remove( IAEStack stack, T iw )
@@ -85,7 +93,9 @@ public class GenericInterestManager<T>
return true;
}
else
{
return this.container.remove( stack, iw );
}
}
public boolean containsKey( IAEStack stack )
@@ -71,7 +71,9 @@ public class ControllerValidator implements IGridVisitor
this.isValid = false;
}
else
{
return false;
}
return this.isValid;
}
@@ -72,9 +72,13 @@ public class PathSegment
boolean worked;
if( flags.contains( GridFlags.COMPRESSED_CHANNEL ) )
{
worked = this.useDenseChannel( pi );
}
else
{
worked = this.useChannel( pi );
}
if( worked && flags.contains( GridFlags.MULTIBLOCK ) )
{
@@ -83,7 +87,9 @@ public class PathSegment
{
IGridNode otherNodes = oni.next();
if( otherNodes != pi )
{
this.semiOpen.add( (IPathItem) otherNodes );
}
}
}
}
@@ -109,7 +115,9 @@ public class PathSegment
while( pi != null )
{
if( !pi.canSupportMoreChannels() || pi.getFlags().contains( GridFlags.CANNOT_CARRY_COMPRESSED ) )
{
return false;
}
pi = pi.getControllerRoute();
}
@@ -132,7 +140,9 @@ public class PathSegment
while( pi != null )
{
if( !pi.canSupportMoreChannels() )
{
return false;
}
pi = pi.getControllerRoute();
}
@@ -40,7 +40,9 @@ public class AEExternalHandler implements IExternalStorageHandler
public boolean canHandle( TileEntity te, ForgeDirection d, StorageChannel channel, BaseActionSource mySrc )
{
if( channel == StorageChannel.ITEMS && te instanceof ITileStorageMonitorable )
{
return ( (ITileStorageMonitorable) te ).getMonitorable( d, mySrc ) != null;
}
return te instanceof TileCondenser;
}
@@ -51,9 +53,13 @@ public class AEExternalHandler implements IExternalStorageHandler
if( te instanceof TileCondenser )
{
if( channel == StorageChannel.ITEMS )
{
return new VoidItemInventory( (TileCondenser) te );
}
else
{
return new VoidFluidInventory( (TileCondenser) te );
}
}
if( te instanceof ITileStorageMonitorable )
@@ -65,14 +71,18 @@ public class AEExternalHandler implements IExternalStorageHandler
{
IMEInventory<IAEItemStack> ii = sm.getItemInventory();
if( ii != null )
{
return ii;
}
}
if( channel == StorageChannel.FLUIDS && sm != null )
{
IMEInventory<IAEFluidStack> fi = sm.getFluidInventory();
if( fi != null )
{
return fi;
}
}
}
@@ -114,9 +114,13 @@ public class CellInventory implements ICellInventory
}
if( this.MAX_ITEM_TYPES > 63 )
{
this.MAX_ITEM_TYPES = 63;
}
if( this.MAX_ITEM_TYPES < 1 )
{
this.MAX_ITEM_TYPES = 1;
}
this.container = container;
this.tagCompound = Platform.openNbtData( o );
@@ -184,7 +188,9 @@ public class CellInventory implements ICellInventory
public static boolean isBlackListed( IAEItemStack input )
{
if( BLACK_LIST.contains( ( OreDictionary.WILDCARD_VALUE << Platform.DEF_OFFSET ) | Item.getIdFromItem( input.getItem() ) ) )
{
return true;
}
return BLACK_LIST.contains( ( input.getItemDamage() << Platform.DEF_OFFSET ) | Item.getIdFromItem( input.getItem() ) );
}
@@ -197,12 +203,18 @@ public class CellInventory implements ICellInventory
public IAEItemStack injectItems( IAEItemStack input, Actionable mode, BaseActionSource src )
{
if( input == null )
{
return null;
}
if( input.getStackSize() == 0 )
{
return null;
}
if( isBlackListed( input ) || this.CellType.isBlackListed( this.i, input ) )
{
return input;
}
ItemStack sharedItemStack = input.getItemStack();
@@ -210,7 +222,9 @@ public class CellInventory implements ICellInventory
{
IMEInventory meInventory = getCell( sharedItemStack, null );
if( meInventory != null && !this.isEmpty( meInventory ) )
{
return input;
}
}
IAEItemStack l = this.getCellItems().findPrecise( input );
@@ -218,7 +232,9 @@ public class CellInventory implements ICellInventory
{
long remainingItemSlots = this.getRemainingItemCount();
if( remainingItemSlots < 0 )
{
return input;
}
if( input.getStackSize() > remainingItemSlots )
{
@@ -284,7 +300,9 @@ public class CellInventory implements ICellInventory
public IAEItemStack extractItems( IAEItemStack request, Actionable mode, BaseActionSource src )
{
if( request == null )
{
return null;
}
long size = Math.min( Integer.MAX_VALUE, request.getStackSize() );
@@ -408,13 +426,17 @@ public class CellInventory implements ICellInventory
}
if( this.container != null )
{
this.container.saveChanges( this );
}
}
protected void loadCellItems()
{
if( this.cellItems == null )
{
this.cellItems = AEApi.instance().storage().createItemList();
}
this.cellItems.resetStatus(); // clears totals and stuff.
@@ -441,7 +463,9 @@ public class CellInventory implements ICellInventory
public IItemList getAvailableItems( IItemList out )
{
for( IAEItemStack i : this.getCellItems() )
{
out.add( i );
}
return out;
}
@@ -564,9 +588,13 @@ public class CellInventory implements ICellInventory
public int getStatusForCell()
{
if( this.canHoldNewItem() )
{
return 1;
}
if( this.getRemainingItemCount() > 0 )
{
return 2;
}
return 3;
}
}
@@ -85,7 +85,9 @@ public class CellInventoryHandler extends MEInventoryHandler<IAEItemStack> imple
{
ItemStack is = config.getStackInSlot( x );
if( is != null )
{
priorityList.add( AEItemStack.create( is ) );
}
}
this.setWhitelist( hasInverter ? IncludeExclude.BLACKLIST : IncludeExclude.WHITELIST );
@@ -93,9 +95,13 @@ public class CellInventoryHandler extends MEInventoryHandler<IAEItemStack> imple
if( !priorityList.isEmpty() )
{
if( hasFuzzy )
{
this.setPartitionList( new FuzzyPriorityList<IAEItemStack>( priorityList, fzMode ) );
}
else
{
this.setPartitionList( new PrecisePriorityList<IAEItemStack>( priorityList ) );
}
}
}
}
@@ -106,7 +112,9 @@ public class CellInventoryHandler extends MEInventoryHandler<IAEItemStack> imple
Object o = this.internal;
if( o instanceof MEPassThrough )
{
o = ( (MEPassThrough) o ).getInternal();
}
return (ICellInventory) ( o instanceof ICellInventory ? o : null );
}
@@ -139,7 +147,9 @@ public class CellInventoryHandler extends MEInventoryHandler<IAEItemStack> imple
int val = this.getCellInv().getStatusForCell();
if( val == 1 && this.isPreformatted() )
{
val = 2;
}
return val;
}
@@ -42,12 +42,14 @@ public class CreativeCellInventory implements IMEInventoryHandler<IAEItemStack>
{
CellConfig cc = new CellConfig( o );
for( ItemStack is : cc )
{
if( is != null )
{
IAEItemStack i = AEItemStack.create( is );
i.setStackSize( Integer.MAX_VALUE );
this.itemListCache.add( i );
}
}
}
public static IMEInventoryHandler getCell( ItemStack o )
@@ -60,7 +62,9 @@ public class CreativeCellInventory implements IMEInventoryHandler<IAEItemStack>
{
IAEItemStack local = this.itemListCache.findPrecise( input );
if( local == null )
{
return input;
}
return null;
}
@@ -70,7 +74,9 @@ public class CreativeCellInventory implements IMEInventoryHandler<IAEItemStack>
{
IAEItemStack local = this.itemListCache.findPrecise( request );
if( local == null )
{
return null;
}
return request.copy();
}
@@ -79,7 +85,9 @@ public class CreativeCellInventory implements IMEInventoryHandler<IAEItemStack>
public IItemList<IAEItemStack> getAvailableItems( IItemList out )
{
for( IAEItemStack ais : this.itemListCache )
{
out.add( ais );
}
return out;
}
@@ -90,7 +90,9 @@ public class ItemWatcher implements IStackWatcher
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 ItemWatcher implements IStackWatcher
boolean didChange = false;
for( IAEStack o : c )
{
didChange = this.add( o ) || didChange;
}
return didChange;
}
@@ -123,7 +127,9 @@ public class ItemWatcher implements IStackWatcher
{
boolean didSomething = false;
for( Object o : c )
{
didSomething = this.remove( o ) || didSomething;
}
return didSomething;
}
@@ -54,7 +54,9 @@ public class MEIInventoryWrapper implements IMEInventory<IAEItemStack>
{
ItemStack is = mode == Actionable.SIMULATE ? this.adaptor.simulateAdd( input ) : this.adaptor.addItems( input );
if( is == null )
{
return null;
}
return AEItemStack.create( is );
}
@@ -109,7 +111,9 @@ public class MEIInventoryWrapper implements IMEInventory<IAEItemStack>
out.stackSize -= t.stackSize;
if( mode == Actionable.MODULATE )
{
this.target.setInventorySlotContents( x, t );
}
if( out.stackSize <= 0 )
{
@@ -172,9 +176,13 @@ public class MEIInventoryWrapper implements IMEInventory<IAEItemStack>
}
if( sub.stackSize <= 0 )
{
this.target.setInventorySlotContents( x, null );
}
else
{
this.target.setInventorySlotContents( x, sub );
}
if( retrieved != null )
{
@@ -53,9 +53,13 @@ public class MEInventoryHandler<T extends IAEStack<T>> implements IMEInventoryHa
this.channel = channel;
if( i instanceof IMEInventoryHandler )
{
this.internal = (IMEInventoryHandler<T>) i;
}
else
{
this.internal = new MEPassThrough<T>( i, channel );
}
this.monitor = this.internal instanceof IMEMonitor ? (IMEMonitor<T>) this.internal : null;
@@ -102,7 +106,9 @@ public class MEInventoryHandler<T extends IAEStack<T>> implements IMEInventoryHa
public T injectItems( T input, Actionable type, BaseActionSource src )
{
if( !this.canAccept( input ) )
{
return input;
}
return this.internal.injectItems( input, type, src );
}
@@ -111,7 +117,9 @@ public class MEInventoryHandler<T extends IAEStack<T>> implements IMEInventoryHa
public T extractItems( T request, Actionable type, BaseActionSource src )
{
if( !this.hasReadAccess )
{
return null;
}
return this.internal.extractItems( request, type, src );
}
@@ -120,7 +128,9 @@ public class MEInventoryHandler<T extends IAEStack<T>> implements IMEInventoryHa
public IItemList<T> getAvailableItems( IItemList<T> out )
{
if( !this.hasReadAccess )
{
return out;
}
return this.internal.getAvailableItems( out );
}
@@ -141,7 +151,9 @@ public class MEInventoryHandler<T extends IAEStack<T>> implements IMEInventoryHa
public boolean isPrioritized( T input )
{
if( this.myWhitelist == IncludeExclude.WHITELIST )
{
return this.myPartitionList.isListed( input ) || this.internal.isPrioritized( input );
}
return false;
}
@@ -149,12 +161,18 @@ public class MEInventoryHandler<T extends IAEStack<T>> implements IMEInventoryHa
public boolean canAccept( T input )
{
if( !this.hasWriteAccess )
{
return false;
}
if( this.myWhitelist == IncludeExclude.BLACKLIST && this.myPartitionList.isListed( input ) )
{
return false;
}
if( this.myPartitionList.isEmpty() || this.myWhitelist == IncludeExclude.BLACKLIST )
{
return this.internal.canAccept( input );
}
return this.myPartitionList.isListed( input ) && this.internal.canAccept( input );
}
@@ -78,14 +78,20 @@ public class MEMonitorIInventory implements IMEMonitor<IAEItemStack>
ItemStack out = null;
if( type == Actionable.SIMULATE )
{
out = this.adaptor.simulateAdd( input.getItemStack() );
}
else
{
out = this.adaptor.addItems( input.getItemStack() );
}
this.onTick();
if( out == null )
{
return null;
}
// better then doing construction from scratch :3
IAEItemStack o = input.copy();
@@ -99,12 +105,18 @@ public class MEMonitorIInventory implements IMEMonitor<IAEItemStack>
ItemStack out = null;
if( type == Actionable.SIMULATE )
{
out = this.adaptor.simulateRemove( (int) request.getStackSize(), request.getItemStack(), null );
}
else
{
out = this.adaptor.removeItems( (int) request.getStackSize(), request.getItemStack(), null );
}
if( out == null )
{
return null;
}
// better then doing construction from scratch :3
IAEItemStack o = request.copy();
@@ -199,7 +211,9 @@ public class MEMonitorIInventory implements IMEMonitor<IAEItemStack>
}
if( !changes.isEmpty() )
{
this.postDifference( changes );
}
return changed ? TickRateModulation.URGENT : TickRateModulation.SLOWER;
}
@@ -207,10 +221,14 @@ public class MEMonitorIInventory implements IMEMonitor<IAEItemStack>
private boolean isDifferent( ItemStack a, ItemStack b )
{
if( a == b && b == null )
{
return false;
}
if( ( a == null && b != null ) || ( a != null && b == null ) )
{
return true;
}
return !Platform.isSameItemPrecise( a, b );
}
@@ -226,9 +244,13 @@ public class MEMonitorIInventory implements IMEMonitor<IAEItemStack>
Entry<IMEMonitorHandlerReceiver<IAEItemStack>, Object> l = i.next();
IMEMonitorHandlerReceiver<IAEItemStack> key = l.getKey();
if( key.isValid( l.getValue() ) )
{
key.postChange( this, a, this.mySource );
}
else
{
i.remove();
}
}
}
}
@@ -273,7 +295,9 @@ public class MEMonitorIInventory implements IMEMonitor<IAEItemStack>
public IItemList<IAEItemStack> getAvailableItems( IItemList out )
{
for( CachedItemStack is : this.memory.values() )
{
out.addStorage( is.aeStack );
}
return out;
}
@@ -46,26 +46,34 @@ public class MEMonitorPassThrough<T extends IAEStack<T>> extends MEPassThrough<T
{
super( i, channel );
if( i instanceof IMEMonitor )
{
this.monitor = (IMEMonitor<T>) i;
}
}
@Override
public void setInternal( IMEInventory<T> i )
{
if( this.monitor != null )
{
this.monitor.removeListener( this );
}
this.monitor = null;
IItemList<T> before = this.getInternal() == null ? this.channel.createList() : this.getInternal().getAvailableItems( new ItemListIgnoreCrafting( this.channel.createList() ) );
super.setInternal( i );
if( i instanceof IMEMonitor )
{
this.monitor = (IMEMonitor<T>) i;
}
IItemList<T> after = this.getInternal() == null ? this.channel.createList() : this.getInternal().getAvailableItems( new ItemListIgnoreCrafting( this.channel.createList() ) );
if( this.monitor != null )
{
this.monitor.addListener( this, this.monitor );
}
Platform.postListChanges( before, after, this, this.changeSource );
}
@@ -116,9 +124,13 @@ public class MEMonitorPassThrough<T extends IAEStack<T>> extends MEPassThrough<T
Entry<IMEMonitorHandlerReceiver<T>, Object> e = i.next();
IMEMonitorHandlerReceiver<T> receiver = e.getKey();
if( receiver.isValid( e.getValue() ) )
{
receiver.postChange( this, change, source );
}
else
{
i.remove();
}
}
}
@@ -131,9 +143,13 @@ public class MEMonitorPassThrough<T extends IAEStack<T>> extends MEPassThrough<T
Entry<IMEMonitorHandlerReceiver<T>, Object> e = i.next();
IMEMonitorHandlerReceiver<T> receiver = e.getKey();
if( receiver.isValid( e.getValue() ) )
{
receiver.onListUpdate();
}
else
{
i.remove();
}
}
}
}
@@ -77,7 +77,9 @@ public class NetworkInventoryHandler<T extends IAEStack<T>> implements IMEInvent
int priority = h.getPriority();
List<IMEInventoryHandler<T>> list = this.priorityInventory.get( priority );
if( list == null )
{
this.priorityInventory.put( priority, list = new ArrayList<IMEInventoryHandler<T>>() );
}
list.add( h );
}
@@ -86,7 +88,9 @@ public class NetworkInventoryHandler<T extends IAEStack<T>> implements IMEInvent
public T injectItems( T input, Actionable type, BaseActionSource src )
{
if( this.diveList( this, type ) )
{
return input;
}
if( this.testPermission( src, SecurityPermissions.INJECT ) )
{
@@ -127,7 +131,9 @@ public class NetworkInventoryHandler<T extends IAEStack<T>> implements IMEInvent
{
LinkedList cDepth = this.getDepth( type );
if( cDepth.contains( networkInventoryHandler ) )
{
return true;
}
cDepth.push( this );
return false;
@@ -138,7 +144,9 @@ public class NetworkInventoryHandler<T extends IAEStack<T>> implements IMEInvent
if( src.isPlayer() )
{
if( !this.security.hasPermission( ( (PlayerSource) src ).player, permission ) )
{
return true;
}
}
else if( src.isMachine() )
{
@@ -146,7 +154,9 @@ public class NetworkInventoryHandler<T extends IAEStack<T>> implements IMEInvent
{
IGridNode n = ( (MachineSource) src ).via.getActionableNode();
if( n == null )
{
return true;
}
IGrid gn = n.getGrid();
if( gn != this.security.myGrid )
@@ -157,7 +167,9 @@ public class NetworkInventoryHandler<T extends IAEStack<T>> implements IMEInvent
playerID = sg.getOwner();
if( !this.security.hasPermission( playerID, permission ) )
{
return true;
}
}
}
}
@@ -168,7 +180,9 @@ public class NetworkInventoryHandler<T extends IAEStack<T>> implements IMEInvent
private void surface( NetworkInventoryHandler<T> networkInventoryHandler, Actionable type )
{
if( this.getDepth( type ).pop() != this )
{
throw new IllegalStateException( "Invalid Access to Networked Storage API detected." );
}
}
private LinkedList getDepth( Actionable type )
@@ -178,7 +192,9 @@ public class NetworkInventoryHandler<T extends IAEStack<T>> implements IMEInvent
LinkedList s = depth.get();
if( s == null )
{
depth.set( s = new LinkedList() );
}
return s;
}
@@ -187,7 +203,9 @@ public class NetworkInventoryHandler<T extends IAEStack<T>> implements IMEInvent
public T extractItems( T request, Actionable mode, BaseActionSource src )
{
if( this.diveList( this, mode ) )
{
return null;
}
if( this.testPermission( src, SecurityPermissions.EXTRACT ) )
{
@@ -219,7 +237,9 @@ public class NetworkInventoryHandler<T extends IAEStack<T>> implements IMEInvent
this.surface( this, mode );
if( output.getStackSize() <= 0 )
{
return null;
}
return output;
}
@@ -228,12 +248,18 @@ public class NetworkInventoryHandler<T extends IAEStack<T>> implements IMEInvent
public IItemList<T> getAvailableItems( IItemList out )
{
if( this.diveIteration( this, Actionable.SIMULATE ) )
{
return out;
}
// for (Entry<Integer, IMEInventoryHandler<T>> h : priorityInventory.entries())
for( List<IMEInventoryHandler<T>> i : this.priorityInventory.values() )
{
for( IMEInventoryHandler<T> j : i )
{
out = j.getAvailableItems( out );
}
}
this.surface( this, Actionable.SIMULATE );
@@ -251,9 +277,13 @@ public class NetworkInventoryHandler<T extends IAEStack<T>> implements IMEInvent
else
{
if( currentPass == this.myPass )
{
return true;
}
else
{
this.myPass = currentPass;
}
}
cDepth.push( this );
@@ -57,7 +57,9 @@ public class SecurityInventory implements IMEInventoryHandler<IAEItemStack>
if( this.canAccept( input ) )
{
if( type == Actionable.SIMULATE )
{
return null;
}
this.storedItems.add( input );
this.securityTile.inventoryChanged();
@@ -95,7 +97,9 @@ public class SecurityInventory implements IMEInventoryHandler<IAEItemStack>
IAEItemStack output = target.copy();
if( mode == Actionable.SIMULATE )
{
return output;
}
target.setStackSize( 0 );
this.securityTile.inventoryChanged();
@@ -109,7 +113,9 @@ public class SecurityInventory implements IMEInventoryHandler<IAEItemStack>
public IItemList<IAEItemStack> getAvailableItems( IItemList out )
{
for( IAEItemStack ais : this.storedItems )
{
out.add( ais );
}
return out;
}
@@ -142,7 +148,9 @@ public class SecurityInventory implements IMEInventoryHandler<IAEItemStack>
int PlayerID = AEApi.instance().registries().players().getID( newUser );
if( this.securityTile.getOwner() == PlayerID )
{
return false;
}
for( IAEItemStack ais : this.storedItems )
{
@@ -150,10 +158,14 @@ public class SecurityInventory implements IMEInventoryHandler<IAEItemStack>
{
GameProfile thisUser = tbc.getProfile( ais.getItemStack() );
if( thisUser == newUser )
{
return false;
}
if( thisUser != null && thisUser.equals( newUser ) )
{
return false;
}
}
}
@@ -43,10 +43,14 @@ public class VoidFluidInventory implements IMEInventoryHandler<IAEFluidStack>
public IAEFluidStack injectItems( IAEFluidStack input, Actionable mode, BaseActionSource src )
{
if( mode == Actionable.SIMULATE )
{
return null;
}
if( input != null )
{
this.target.addPower( input.getStackSize() / 1000.0 );
}
return null;
}
@@ -43,10 +43,14 @@ public class VoidItemInventory implements IMEInventoryHandler<IAEItemStack>
public IAEItemStack injectItems( IAEItemStack input, Actionable mode, BaseActionSource src )
{
if( mode == Actionable.SIMULATE )
{
return null;
}
if( input != null )
{
this.target.addPower( input.getStackSize() );
}
return null;
}