Changed access to use this qualifier
This commit is contained in:
@@ -30,49 +30,49 @@ public class GridCacheWrapper implements IGridCache
|
||||
final String name;
|
||||
|
||||
public GridCacheWrapper(final IGridCache gc) {
|
||||
myCache = gc;
|
||||
name = myCache.getClass().getName();
|
||||
this.myCache = gc;
|
||||
this.name = this.myCache.getClass().getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdateTick()
|
||||
{
|
||||
myCache.onUpdateTick();
|
||||
this.myCache.onUpdateTick();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeNode(final IGridNode gridNode, final IGridHost machine)
|
||||
{
|
||||
myCache.removeNode( gridNode, machine );
|
||||
this.myCache.removeNode( gridNode, machine );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addNode(final IGridNode gridNode, final IGridHost machine)
|
||||
{
|
||||
myCache.addNode( gridNode, machine );
|
||||
this.myCache.addNode( gridNode, machine );
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return name;
|
||||
return this.name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSplit(final IGridStorage storageB)
|
||||
{
|
||||
myCache.onSplit( storageB );
|
||||
this.myCache.onSplit( storageB );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onJoin(final IGridStorage storageB)
|
||||
{
|
||||
myCache.onJoin( storageB );
|
||||
this.myCache.onJoin( storageB );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void populateGridStorage(final IGridStorage storage)
|
||||
{
|
||||
myCache.populateGridStorage( storage );
|
||||
this.myCache.populateGridStorage( storage );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -73,9 +73,9 @@ public class GridConnection implements IGridConnection, IPathItem
|
||||
if ( a.hasConnection( b ) || b.hasConnection( a ) )
|
||||
throw new GridException( "Connection already exists." );
|
||||
|
||||
sideA = a;
|
||||
this.sideA = a;
|
||||
this.fromAtoB = fromAtoB;
|
||||
sideB = b;
|
||||
this.sideB = b;
|
||||
|
||||
if ( b.getMyGrid() == null )
|
||||
{
|
||||
@@ -93,7 +93,7 @@ public class GridConnection implements IGridConnection, IPathItem
|
||||
GridPropagator gp = new GridPropagator( a.getInternalGrid() );
|
||||
b.beginVisit( gp );
|
||||
}
|
||||
else if ( isNetworkABetter( a, b ) )
|
||||
else if ( this.isNetworkABetter( a, b ) )
|
||||
{
|
||||
GridPropagator gp = new GridPropagator( a.getInternalGrid() );
|
||||
b.beginVisit( gp );
|
||||
@@ -106,11 +106,11 @@ public class GridConnection implements IGridConnection, IPathItem
|
||||
}
|
||||
|
||||
// a connection was destroyed RE-PATH!!
|
||||
IPathingGrid p = sideA.getInternalGrid().getCache( IPathingGrid.class );
|
||||
IPathingGrid p = this.sideA.getInternalGrid().getCache( IPathingGrid.class );
|
||||
p.repath();
|
||||
|
||||
sideA.addConnection( this );
|
||||
sideB.addConnection( this );
|
||||
this.sideA.addConnection( this );
|
||||
this.sideB.addConnection( this );
|
||||
}
|
||||
|
||||
private boolean isNetworkABetter(GridNode a, GridNode b)
|
||||
@@ -122,47 +122,47 @@ public class GridConnection implements IGridConnection, IPathItem
|
||||
public void destroy()
|
||||
{
|
||||
// a connection was destroyed RE-PATH!!
|
||||
IPathingGrid p = sideA.getInternalGrid().getCache( IPathingGrid.class );
|
||||
IPathingGrid p = this.sideA.getInternalGrid().getCache( IPathingGrid.class );
|
||||
p.repath();
|
||||
|
||||
sideA.removeConnection( this );
|
||||
sideB.removeConnection( this );
|
||||
this.sideA.removeConnection( this );
|
||||
this.sideB.removeConnection( this );
|
||||
|
||||
sideA.validateGrid();
|
||||
sideB.validateGrid();
|
||||
this.sideA.validateGrid();
|
||||
this.sideB.validateGrid();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IGridNode a()
|
||||
{
|
||||
return sideA;
|
||||
return this.sideA;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ForgeDirection getDirection(IGridNode side)
|
||||
{
|
||||
if ( fromAtoB == ForgeDirection.UNKNOWN )
|
||||
return fromAtoB;
|
||||
if ( this.fromAtoB == ForgeDirection.UNKNOWN )
|
||||
return this.fromAtoB;
|
||||
|
||||
if ( sideA == side )
|
||||
return fromAtoB;
|
||||
if ( this.sideA == side )
|
||||
return this.fromAtoB;
|
||||
else
|
||||
return fromAtoB.getOpposite();
|
||||
return this.fromAtoB.getOpposite();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IGridNode b()
|
||||
{
|
||||
return sideB;
|
||||
return this.sideB;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IGridNode getOtherSide(IGridNode gridNode)
|
||||
{
|
||||
if ( gridNode == sideA )
|
||||
return sideB;
|
||||
if ( gridNode == sideB )
|
||||
return sideA;
|
||||
if ( gridNode == this.sideA )
|
||||
return this.sideB;
|
||||
if ( gridNode == this.sideB )
|
||||
return this.sideA;
|
||||
|
||||
throw new GridException( "Invalid Side of Connection" );
|
||||
}
|
||||
@@ -170,74 +170,74 @@ public class GridConnection implements IGridConnection, IPathItem
|
||||
@Override
|
||||
public boolean hasDirection()
|
||||
{
|
||||
return fromAtoB != ForgeDirection.UNKNOWN;
|
||||
return this.fromAtoB != ForgeDirection.UNKNOWN;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IReadOnlyCollection<IPathItem> getPossibleOptions()
|
||||
{
|
||||
return new ReadOnlyCollection<IPathItem>( Arrays.asList( (IPathItem) a(), (IPathItem) b() ) );
|
||||
return new ReadOnlyCollection<IPathItem>( Arrays.asList( (IPathItem) this.a(), (IPathItem) this.b() ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void incrementChannelCount(int usedChannels)
|
||||
{
|
||||
channelData += usedChannels;
|
||||
this.channelData += usedChannels;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canSupportMoreChannels()
|
||||
{
|
||||
return getLastUsedChannels() < 32; // max, PERIOD.
|
||||
return this.getLastUsedChannels() < 32; // max, PERIOD.
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getUsedChannels()
|
||||
{
|
||||
return (channelData >> 8) & 0xff;
|
||||
return (this.channelData >> 8) & 0xff;
|
||||
}
|
||||
|
||||
public int getLastUsedChannels()
|
||||
{
|
||||
return channelData & 0xff;
|
||||
return this.channelData & 0xff;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPathItem getControllerRoute()
|
||||
{
|
||||
if ( sideA.getFlags().contains( GridFlags.CANNOT_CARRY ) )
|
||||
if ( this.sideA.getFlags().contains( GridFlags.CANNOT_CARRY ) )
|
||||
return null;
|
||||
return sideA;
|
||||
return this.sideA;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setControllerRoute(IPathItem fast, boolean zeroOut)
|
||||
{
|
||||
if ( zeroOut )
|
||||
channelData &= ~0xff;
|
||||
this.channelData &= ~0xff;
|
||||
|
||||
if ( sideB == fast )
|
||||
if ( this.sideB == fast )
|
||||
{
|
||||
GridNode tmp = sideA;
|
||||
sideA = sideB;
|
||||
sideB = tmp;
|
||||
fromAtoB = fromAtoB.getOpposite();
|
||||
GridNode tmp = this.sideA;
|
||||
this.sideA = this.sideB;
|
||||
this.sideB = tmp;
|
||||
this.fromAtoB = this.fromAtoB.getOpposite();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void finalizeChannels()
|
||||
{
|
||||
if ( getUsedChannels() != getLastUsedChannels() )
|
||||
if ( this.getUsedChannels() != this.getLastUsedChannels() )
|
||||
{
|
||||
channelData = (channelData & 0xff);
|
||||
channelData |= channelData << 8;
|
||||
this.channelData = (this.channelData & 0xff);
|
||||
this.channelData |= this.channelData << 8;
|
||||
|
||||
if ( sideA.getInternalGrid() != null )
|
||||
sideA.getInternalGrid().postEventTo( sideA, event );
|
||||
if ( this.sideA.getInternalGrid() != null )
|
||||
this.sideA.getInternalGrid().postEventTo( this.sideA, event );
|
||||
|
||||
if ( sideB.getInternalGrid() != null )
|
||||
sideB.getInternalGrid().postEventTo( sideB, event );
|
||||
if ( this.sideB.getInternalGrid() != null )
|
||||
this.sideB.getInternalGrid().postEventTo( this.sideB, event );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -34,9 +34,9 @@ class GridSplitDetector implements IGridVisitor
|
||||
@Override
|
||||
public boolean visitNode(IGridNode n)
|
||||
{
|
||||
if ( n == pivot )
|
||||
pivotFound = true;
|
||||
if ( n == this.pivot )
|
||||
this.pivotFound = true;
|
||||
|
||||
return !pivotFound;
|
||||
return !this.pivotFound;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,9 +51,9 @@ public class GridStorage implements IGridStorage
|
||||
* @param gss grid storage search
|
||||
*/
|
||||
public GridStorage(long id, GridStorageSearch gss) {
|
||||
myID = id;
|
||||
mySearchEntry = gss;
|
||||
data = new NBTTagCompound();
|
||||
this.myID = id;
|
||||
this.mySearchEntry = gss;
|
||||
this.data = new NBTTagCompound();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -64,8 +64,8 @@ public class GridStorage implements IGridStorage
|
||||
* @param gss grid storage search
|
||||
*/
|
||||
public GridStorage(String input, long id, GridStorageSearch gss) {
|
||||
myID = id;
|
||||
mySearchEntry = gss;
|
||||
this.myID = id;
|
||||
this.mySearchEntry = gss;
|
||||
NBTTagCompound myTag = null;
|
||||
|
||||
try
|
||||
@@ -78,23 +78,23 @@ public class GridStorage implements IGridStorage
|
||||
myTag = new NBTTagCompound();
|
||||
}
|
||||
|
||||
data = myTag;
|
||||
this.data = myTag;
|
||||
}
|
||||
|
||||
/**
|
||||
* fake storage.
|
||||
*/
|
||||
public GridStorage() {
|
||||
myID = 0;
|
||||
mySearchEntry = null;
|
||||
data = new NBTTagCompound();
|
||||
this.myID = 0;
|
||||
this.mySearchEntry = null;
|
||||
this.data = new NBTTagCompound();
|
||||
}
|
||||
|
||||
public String getValue()
|
||||
{
|
||||
isDirty = false;
|
||||
this.isDirty = false;
|
||||
|
||||
Grid currentGrid = (Grid) getGrid();
|
||||
Grid currentGrid = (Grid) this.getGrid();
|
||||
if ( currentGrid != null )
|
||||
{
|
||||
currentGrid.saveState();
|
||||
@@ -103,7 +103,7 @@ public class GridStorage implements IGridStorage
|
||||
try
|
||||
{
|
||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||
CompressedStreamTools.writeCompressed( data, out );
|
||||
CompressedStreamTools.writeCompressed( this.data, out );
|
||||
return javax.xml.bind.DatatypeConverter.printBase64Binary( out.toByteArray() );
|
||||
}
|
||||
catch (IOException e)
|
||||
@@ -117,43 +117,43 @@ public class GridStorage implements IGridStorage
|
||||
@Override
|
||||
public NBTTagCompound dataObject()
|
||||
{
|
||||
return data;
|
||||
return this.data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getID()
|
||||
{
|
||||
return myID;
|
||||
return this.myID;
|
||||
}
|
||||
|
||||
public void markDirty()
|
||||
{
|
||||
isDirty = true;
|
||||
this.isDirty = true;
|
||||
}
|
||||
|
||||
public IGrid getGrid()
|
||||
{
|
||||
return internalGrid == null ? null : internalGrid.get();
|
||||
return this.internalGrid == null ? null : this.internalGrid.get();
|
||||
}
|
||||
|
||||
public void setGrid(Grid grid)
|
||||
{
|
||||
internalGrid = new WeakReference<IGrid>( grid );
|
||||
this.internalGrid = new WeakReference<IGrid>( grid );
|
||||
}
|
||||
|
||||
public void addDivided(GridStorage gs)
|
||||
{
|
||||
divided.put( gs, true );
|
||||
this.divided.put( gs, true );
|
||||
}
|
||||
|
||||
public boolean hasDivided(GridStorage myStorage)
|
||||
{
|
||||
return divided.containsKey( myStorage );
|
||||
return this.divided.containsKey( myStorage );
|
||||
}
|
||||
|
||||
public void remove()
|
||||
{
|
||||
WorldSettings.getInstance().destroyGridStorage( getID() );
|
||||
WorldSettings.getInstance().destroyGridStorage( this.getID() );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -40,11 +40,11 @@ public class GridStorageSearch
|
||||
{
|
||||
if ( obj == null )
|
||||
return false;
|
||||
if ( getClass() != obj.getClass() )
|
||||
if ( this.getClass() != obj.getClass() )
|
||||
return false;
|
||||
|
||||
GridStorageSearch other = (GridStorageSearch) obj;
|
||||
if ( id == other.id )
|
||||
if ( this.id == other.id )
|
||||
return true;
|
||||
|
||||
return false;
|
||||
@@ -53,7 +53,7 @@ public class GridStorageSearch
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
return ((Long) id).hashCode();
|
||||
return ((Long) this.id).hashCode();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -32,13 +32,13 @@ public class MachineSet extends HashSet<IGridNode> implements IMachineSet
|
||||
private final Class<? extends IGridHost> machine;
|
||||
|
||||
MachineSet(Class<? extends IGridHost> m) {
|
||||
machine = m;
|
||||
this.machine = m;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends IGridHost> getMachineClass()
|
||||
{
|
||||
return machine;
|
||||
return this.machine;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -31,91 +31,91 @@ public class NetworkList implements Collection<Grid>
|
||||
@Override
|
||||
public boolean add(Grid e)
|
||||
{
|
||||
copy();
|
||||
return networks.add( e );
|
||||
this.copy();
|
||||
return this.networks.add( e );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addAll(Collection<? extends Grid> c)
|
||||
{
|
||||
copy();
|
||||
return networks.addAll( c );
|
||||
this.copy();
|
||||
return this.networks.addAll( c );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear()
|
||||
{
|
||||
networks = new LinkedList<Grid>();
|
||||
this.networks = new LinkedList<Grid>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contains(Object o)
|
||||
{
|
||||
return networks.contains( o );
|
||||
return this.networks.contains( o );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean containsAll(Collection<?> c)
|
||||
{
|
||||
return networks.containsAll( c );
|
||||
return this.networks.containsAll( c );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEmpty()
|
||||
{
|
||||
return networks.isEmpty();
|
||||
return this.networks.isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<Grid> iterator()
|
||||
{
|
||||
return networks.iterator();
|
||||
return this.networks.iterator();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean remove(Object o)
|
||||
{
|
||||
copy();
|
||||
return networks.remove( o );
|
||||
this.copy();
|
||||
return this.networks.remove( o );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removeAll(Collection<?> c)
|
||||
{
|
||||
copy();
|
||||
return networks.removeAll( c );
|
||||
this.copy();
|
||||
return this.networks.removeAll( c );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean retainAll(Collection<?> c)
|
||||
{
|
||||
copy();
|
||||
return networks.retainAll( c );
|
||||
this.copy();
|
||||
return this.networks.retainAll( c );
|
||||
}
|
||||
|
||||
private void copy()
|
||||
{
|
||||
List<Grid> old = networks;
|
||||
networks = new LinkedList<Grid>();
|
||||
networks.addAll( old );
|
||||
List<Grid> old = this.networks;
|
||||
this.networks = new LinkedList<Grid>();
|
||||
this.networks.addAll( old );
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size()
|
||||
{
|
||||
return networks.size();
|
||||
return this.networks.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object[] toArray()
|
||||
{
|
||||
return networks.toArray();
|
||||
return this.networks.toArray();
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T[] toArray(T[] a)
|
||||
{
|
||||
return networks.toArray( a );
|
||||
return this.networks.toArray( a );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+6
-6
@@ -104,7 +104,7 @@ public class CraftingGridCache implements ICraftingGrid, ICraftingProviderHelper
|
||||
@Override
|
||||
public boolean hasNext()
|
||||
{
|
||||
findNext();
|
||||
this.findNext();
|
||||
|
||||
return this.cpuCluster != null;
|
||||
}
|
||||
@@ -207,7 +207,7 @@ public class CraftingGridCache implements ICraftingGrid, ICraftingProviderHelper
|
||||
@MENetworkEventSubscribe
|
||||
public void updateCPUClusters(MENetworkCraftingPatternChange c)
|
||||
{
|
||||
updatePatterns();
|
||||
this.updatePatterns();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -253,7 +253,7 @@ public class CraftingGridCache implements ICraftingGrid, ICraftingProviderHelper
|
||||
{
|
||||
ICraftingWatcherHost watcherHost = (ICraftingWatcherHost) machine;
|
||||
CraftingWatcher watcher = new CraftingWatcher( this, watcherHost );
|
||||
craftingWatchers.put( gridNode, watcher );
|
||||
this.craftingWatchers.put( gridNode, watcher );
|
||||
watcherHost.updateWatcher( watcher );
|
||||
}
|
||||
|
||||
@@ -294,7 +294,7 @@ public class CraftingGridCache implements ICraftingGrid, ICraftingProviderHelper
|
||||
|
||||
if ( cluster.myLastLink != null )
|
||||
{
|
||||
addLink( (CraftingLink) cluster.myLastLink );
|
||||
this.addLink( (CraftingLink) cluster.myLastLink );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -531,7 +531,7 @@ public class CraftingGridCache implements ICraftingGrid, ICraftingProviderHelper
|
||||
|
||||
if ( cpuCluster != null )
|
||||
{
|
||||
return cpuCluster.submitJob( grid, job, src, requestingMachine );
|
||||
return cpuCluster.submitJob( this.grid, job, src, requestingMachine );
|
||||
}
|
||||
|
||||
return null;
|
||||
@@ -572,7 +572,7 @@ public class CraftingGridCache implements ICraftingGrid, ICraftingProviderHelper
|
||||
|
||||
public List<ICraftingMedium> getMediums(ICraftingPatternDetails key)
|
||||
{
|
||||
List<ICraftingMedium> mediums = craftingMethods.get( key );
|
||||
List<ICraftingMedium> mediums = this.craftingMethods.get( key );
|
||||
|
||||
if ( mediums == null )
|
||||
{
|
||||
|
||||
+114
-114
@@ -101,29 +101,29 @@ public class EnergyGridCache implements IEnergyGrid
|
||||
|
||||
private double buffer()
|
||||
{
|
||||
return providers.isEmpty() ? 1000.0 : 0.0;
|
||||
return this.providers.isEmpty() ? 1000.0 : 0.0;
|
||||
}
|
||||
|
||||
private IAEPowerStorage getFirstRequester()
|
||||
{
|
||||
if ( lastRequester == null )
|
||||
if ( this.lastRequester == null )
|
||||
{
|
||||
Iterator<IAEPowerStorage> i = requesters.iterator();
|
||||
lastRequester = i.hasNext() ? i.next() : null;
|
||||
Iterator<IAEPowerStorage> i = this.requesters.iterator();
|
||||
this.lastRequester = i.hasNext() ? i.next() : null;
|
||||
}
|
||||
|
||||
return lastRequester;
|
||||
return this.lastRequester;
|
||||
}
|
||||
|
||||
private IAEPowerStorage getFirstProvider()
|
||||
{
|
||||
if ( lastProvider == null )
|
||||
if ( this.lastProvider == null )
|
||||
{
|
||||
Iterator<IAEPowerStorage> i = providers.iterator();
|
||||
lastProvider = i.hasNext() ? i.next() : null;
|
||||
Iterator<IAEPowerStorage> i = this.providers.iterator();
|
||||
this.lastProvider = i.hasNext() ? i.next() : null;
|
||||
}
|
||||
|
||||
return lastProvider;
|
||||
return this.lastProvider;
|
||||
}
|
||||
|
||||
final Multiset<IEnergyGridProvider> energyGridProviders = HashMultiset.create();
|
||||
@@ -132,13 +132,13 @@ public class EnergyGridCache implements IEnergyGrid
|
||||
PathGridCache pgc;
|
||||
|
||||
public EnergyGridCache(IGrid g) {
|
||||
myGrid = g;
|
||||
this.myGrid = g;
|
||||
}
|
||||
|
||||
@MENetworkEventSubscribe
|
||||
public void postInit(MENetworkPostCacheConstruction pcc)
|
||||
{
|
||||
pgc = myGrid.getCache( IPathingGrid.class );
|
||||
this.pgc = this.myGrid.getCache( IPathingGrid.class );
|
||||
}
|
||||
|
||||
@MENetworkEventSubscribe
|
||||
@@ -152,7 +152,7 @@ public class EnergyGridCache implements IEnergyGrid
|
||||
double diffDraw = newDraw - node.previousDraw;
|
||||
node.previousDraw = newDraw;
|
||||
|
||||
drainPerTick += diffDraw;
|
||||
this.drainPerTick += diffDraw;
|
||||
}
|
||||
|
||||
@MENetworkEventSubscribe
|
||||
@@ -164,11 +164,11 @@ public class EnergyGridCache implements IEnergyGrid
|
||||
{
|
||||
case PROVIDE_POWER:
|
||||
if ( ev.storage.getPowerFlow() != AccessRestriction.WRITE )
|
||||
providers.add( ev.storage );
|
||||
this.providers.add( ev.storage );
|
||||
break;
|
||||
case REQUEST_POWER:
|
||||
if ( ev.storage.getPowerFlow() != AccessRestriction.READ )
|
||||
requesters.add( ev.storage );
|
||||
this.requesters.add( ev.storage );
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -181,8 +181,8 @@ public class EnergyGridCache implements IEnergyGrid
|
||||
@Override
|
||||
public double getEnergyDemand(double maxRequired)
|
||||
{
|
||||
localSeen.clear();
|
||||
return getEnergyDemand( maxRequired, localSeen );
|
||||
this.localSeen.clear();
|
||||
return this.getEnergyDemand( maxRequired, this.localSeen );
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -191,9 +191,9 @@ public class EnergyGridCache implements IEnergyGrid
|
||||
if ( !seen.add( this ) )
|
||||
return 0;
|
||||
|
||||
double required = buffer() - extra;
|
||||
double required = this.buffer() - this.extra;
|
||||
|
||||
Iterator<IAEPowerStorage> it = requesters.iterator();
|
||||
Iterator<IAEPowerStorage> it = this.requesters.iterator();
|
||||
while (required < maxRequired && it.hasNext())
|
||||
{
|
||||
IAEPowerStorage node = it.next();
|
||||
@@ -201,7 +201,7 @@ public class EnergyGridCache implements IEnergyGrid
|
||||
required += Math.max( 0.0, node.getAEMaxPower() - node.getAECurrentPower() );
|
||||
}
|
||||
|
||||
Iterator<IEnergyGridProvider> ix = energyGridProviders.iterator();
|
||||
Iterator<IEnergyGridProvider> ix = this.energyGridProviders.iterator();
|
||||
while (required < maxRequired && ix.hasNext())
|
||||
{
|
||||
IEnergyGridProvider node = ix.next();
|
||||
@@ -214,8 +214,8 @@ public class EnergyGridCache implements IEnergyGrid
|
||||
@Override
|
||||
public double injectPower(double amt, Actionable mode)
|
||||
{
|
||||
localSeen.clear();
|
||||
return injectAEPower( amt, mode, localSeen );
|
||||
this.localSeen.clear();
|
||||
return this.injectAEPower( amt, mode, this.localSeen );
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -224,40 +224,40 @@ public class EnergyGridCache implements IEnergyGrid
|
||||
if ( !seen.add( this ) )
|
||||
return 0;
|
||||
|
||||
double ignore = extra;
|
||||
amt += extra;
|
||||
double ignore = this.extra;
|
||||
amt += this.extra;
|
||||
|
||||
if ( mode == Actionable.SIMULATE )
|
||||
{
|
||||
Iterator<IAEPowerStorage> it = requesters.iterator();
|
||||
Iterator<IAEPowerStorage> it = this.requesters.iterator();
|
||||
while (amt > 0 && it.hasNext())
|
||||
{
|
||||
IAEPowerStorage node = it.next();
|
||||
amt = node.injectAEPower( amt, Actionable.SIMULATE );
|
||||
}
|
||||
|
||||
Iterator<IEnergyGridProvider> i = energyGridProviders.iterator();
|
||||
Iterator<IEnergyGridProvider> i = this.energyGridProviders.iterator();
|
||||
while (amt > 0 && i.hasNext())
|
||||
amt = i.next().injectAEPower( amt, mode, seen );
|
||||
}
|
||||
else
|
||||
{
|
||||
tickInjectionPerTick += amt - ignore;
|
||||
this.tickInjectionPerTick += amt - ignore;
|
||||
// totalInjectionPastTicks[0] += i;
|
||||
|
||||
while (amt > 0 && !requesters.isEmpty())
|
||||
while (amt > 0 && !this.requesters.isEmpty())
|
||||
{
|
||||
IAEPowerStorage node = getFirstRequester();
|
||||
IAEPowerStorage node = this.getFirstRequester();
|
||||
|
||||
amt = node.injectAEPower( amt, Actionable.MODULATE );
|
||||
if ( amt > 0 )
|
||||
{
|
||||
requesters.remove( node );
|
||||
lastRequester = null;
|
||||
this.requesters.remove( node );
|
||||
this.lastRequester = null;
|
||||
}
|
||||
}
|
||||
|
||||
Iterator<IEnergyGridProvider> i = energyGridProviders.iterator();
|
||||
Iterator<IEnergyGridProvider> i = this.energyGridProviders.iterator();
|
||||
while (amt > 0 && i.hasNext())
|
||||
{
|
||||
IEnergyGridProvider what = i.next();
|
||||
@@ -270,30 +270,30 @@ public class EnergyGridCache implements IEnergyGrid
|
||||
amt = cannotHold;
|
||||
}
|
||||
|
||||
extra = amt;
|
||||
this.extra = amt;
|
||||
}
|
||||
|
||||
return Math.max( 0.0, amt - buffer() );
|
||||
return Math.max( 0.0, amt - this.buffer() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public double extractAEPower(double amt, Actionable mode, PowerMultiplier pm)
|
||||
{
|
||||
localSeen.clear();
|
||||
return pm.divide( extractAEPower( pm.multiply( amt ), mode, localSeen ) );
|
||||
this.localSeen.clear();
|
||||
return pm.divide( this.extractAEPower( pm.multiply( amt ), mode, this.localSeen ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addNode(IGridNode node, IGridHost machine)
|
||||
{
|
||||
if ( machine instanceof IEnergyGridProvider )
|
||||
energyGridProviders.add( (IEnergyGridProvider) machine );
|
||||
this.energyGridProviders.add( (IEnergyGridProvider) machine );
|
||||
|
||||
// idle draw...
|
||||
GridNode gridNode = (GridNode) node;
|
||||
IGridBlock gb = gridNode.getGridBlock();
|
||||
gridNode.previousDraw = gb.getIdlePowerUsage();
|
||||
drainPerTick += gridNode.previousDraw;
|
||||
this.drainPerTick += gridNode.previousDraw;
|
||||
|
||||
// power storage
|
||||
if ( machine instanceof IAEPowerStorage )
|
||||
@@ -306,17 +306,17 @@ public class EnergyGridCache implements IEnergyGrid
|
||||
|
||||
if ( ps.getPowerFlow() != AccessRestriction.WRITE )
|
||||
{
|
||||
globalMaxPower += ps.getAEMaxPower();
|
||||
this.globalMaxPower += ps.getAEMaxPower();
|
||||
}
|
||||
|
||||
if ( current > 0 && ps.getPowerFlow() != AccessRestriction.WRITE )
|
||||
{
|
||||
globalAvailablePower += current;
|
||||
providers.add( ps );
|
||||
this.globalAvailablePower += current;
|
||||
this.providers.add( ps );
|
||||
}
|
||||
|
||||
if ( current < max && ps.getPowerFlow() != AccessRestriction.READ )
|
||||
requesters.add( ps );
|
||||
this.requesters.add( ps );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -324,22 +324,22 @@ public class EnergyGridCache implements IEnergyGrid
|
||||
{
|
||||
IEnergyWatcherHost swh = (IEnergyWatcherHost) machine;
|
||||
EnergyWatcher iw = new EnergyWatcher( this, swh );
|
||||
watchers.put( node, iw );
|
||||
this.watchers.put( node, iw );
|
||||
swh.updateWatcher( iw );
|
||||
}
|
||||
|
||||
myGrid.postEventTo( node, new MENetworkPowerStatusChange() );
|
||||
this.myGrid.postEventTo( node, new MENetworkPowerStatusChange() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeNode(IGridNode node, IGridHost machine)
|
||||
{
|
||||
if ( machine instanceof IEnergyGridProvider )
|
||||
energyGridProviders.remove( machine );
|
||||
this.energyGridProviders.remove( machine );
|
||||
|
||||
// idle draw.
|
||||
GridNode gridNode = (GridNode) node;
|
||||
drainPerTick -= gridNode.previousDraw;
|
||||
this.drainPerTick -= gridNode.previousDraw;
|
||||
|
||||
// power storage.
|
||||
if ( machine instanceof IAEPowerStorage )
|
||||
@@ -349,28 +349,28 @@ public class EnergyGridCache implements IEnergyGrid
|
||||
{
|
||||
if ( ps.getPowerFlow() != AccessRestriction.WRITE )
|
||||
{
|
||||
globalMaxPower -= ps.getAEMaxPower();
|
||||
globalAvailablePower -= ps.getAECurrentPower();
|
||||
this.globalMaxPower -= ps.getAEMaxPower();
|
||||
this.globalAvailablePower -= ps.getAECurrentPower();
|
||||
}
|
||||
|
||||
if ( lastProvider == machine )
|
||||
lastProvider = null;
|
||||
if ( this.lastProvider == machine )
|
||||
this.lastProvider = null;
|
||||
|
||||
if ( lastRequester == machine )
|
||||
lastRequester = null;
|
||||
if ( this.lastRequester == machine )
|
||||
this.lastRequester = null;
|
||||
|
||||
providers.remove( machine );
|
||||
requesters.remove( machine );
|
||||
this.providers.remove( machine );
|
||||
this.requesters.remove( machine );
|
||||
}
|
||||
}
|
||||
|
||||
if ( machine instanceof IStackWatcherHost )
|
||||
{
|
||||
IEnergyWatcher myWatcher = watchers.get( machine );
|
||||
IEnergyWatcher myWatcher = this.watchers.get( machine );
|
||||
if ( myWatcher != null )
|
||||
{
|
||||
myWatcher.clear();
|
||||
watchers.remove( machine );
|
||||
this.watchers.remove( machine );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -381,66 +381,66 @@ public class EnergyGridCache implements IEnergyGrid
|
||||
@Override
|
||||
public void onUpdateTick()
|
||||
{
|
||||
if ( !interests.isEmpty() )
|
||||
if ( !this.interests.isEmpty() )
|
||||
{
|
||||
double oldPower = lastStoredPower;
|
||||
lastStoredPower = getStoredPower();
|
||||
double oldPower = this.lastStoredPower;
|
||||
this.lastStoredPower = this.getStoredPower();
|
||||
|
||||
EnergyThreshold low = new EnergyThreshold( Math.min( oldPower, lastStoredPower ), null );
|
||||
EnergyThreshold high = new EnergyThreshold( Math.max( oldPower, lastStoredPower ), null );
|
||||
for (EnergyThreshold th : interests.subSet( low, true, high, true ))
|
||||
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 ))
|
||||
{
|
||||
((EnergyWatcher) th.watcher).post( this );
|
||||
}
|
||||
}
|
||||
|
||||
avgDrainPerTick *= (AvgLength - 1) / AvgLength;
|
||||
avgInjectionPerTick *= (AvgLength - 1) / AvgLength;
|
||||
this.avgDrainPerTick *= (this.AvgLength - 1) / this.AvgLength;
|
||||
this.avgInjectionPerTick *= (this.AvgLength - 1) / this.AvgLength;
|
||||
|
||||
avgDrainPerTick += tickDrainPerTick / AvgLength;
|
||||
avgInjectionPerTick += tickInjectionPerTick / AvgLength;
|
||||
this.avgDrainPerTick += this.tickDrainPerTick / this.AvgLength;
|
||||
this.avgInjectionPerTick += this.tickInjectionPerTick / this.AvgLength;
|
||||
|
||||
tickDrainPerTick = 0;
|
||||
tickInjectionPerTick = 0;
|
||||
this.tickDrainPerTick = 0;
|
||||
this.tickInjectionPerTick = 0;
|
||||
|
||||
// power information.
|
||||
boolean currentlyHasPower = false;
|
||||
|
||||
if ( drainPerTick > 0.0001 )
|
||||
if ( this.drainPerTick > 0.0001 )
|
||||
{
|
||||
double drained = extractAEPower( getIdlePowerUsage(), Actionable.MODULATE, PowerMultiplier.CONFIG );
|
||||
currentlyHasPower = drained >= drainPerTick - 0.001;
|
||||
double drained = this.extractAEPower( this.getIdlePowerUsage(), Actionable.MODULATE, PowerMultiplier.CONFIG );
|
||||
currentlyHasPower = drained >= this.drainPerTick - 0.001;
|
||||
}
|
||||
else
|
||||
{
|
||||
currentlyHasPower = extractAEPower( 0.1, Actionable.SIMULATE, PowerMultiplier.CONFIG ) > 0;
|
||||
currentlyHasPower = this.extractAEPower( 0.1, Actionable.SIMULATE, PowerMultiplier.CONFIG ) > 0;
|
||||
}
|
||||
|
||||
// ticks since change..
|
||||
if ( currentlyHasPower == hasPower )
|
||||
ticksSinceHasPowerChange++;
|
||||
if ( currentlyHasPower == this.hasPower )
|
||||
this.ticksSinceHasPowerChange++;
|
||||
else
|
||||
ticksSinceHasPowerChange = 0;
|
||||
this.ticksSinceHasPowerChange = 0;
|
||||
|
||||
// update status..
|
||||
hasPower = currentlyHasPower;
|
||||
this.hasPower = currentlyHasPower;
|
||||
|
||||
// update public status, this buffers power ups for 30 ticks.
|
||||
if ( hasPower && ticksSinceHasPowerChange > 30 )
|
||||
publicPowerState( true, myGrid );
|
||||
else if ( !hasPower )
|
||||
publicPowerState( false, myGrid );
|
||||
if ( this.hasPower && this.ticksSinceHasPowerChange > 30 )
|
||||
this.publicPowerState( true, this.myGrid );
|
||||
else if ( !this.hasPower )
|
||||
this.publicPowerState( false, this.myGrid );
|
||||
|
||||
availableTicksSinceUpdate++;
|
||||
this.availableTicksSinceUpdate++;
|
||||
}
|
||||
|
||||
private void publicPowerState(boolean newState, IGrid grid)
|
||||
{
|
||||
if ( publicHasPower == newState )
|
||||
if ( this.publicHasPower == newState )
|
||||
return;
|
||||
|
||||
publicHasPower = newState;
|
||||
((Grid) myGrid).setImportantFlag( 0, publicHasPower );
|
||||
this.publicHasPower = newState;
|
||||
((Grid) this.myGrid).setImportantFlag( 0, this.publicHasPower );
|
||||
grid.postEvent( new MENetworkPowerStatusChange() );
|
||||
}
|
||||
|
||||
@@ -449,25 +449,25 @@ public class EnergyGridCache implements IEnergyGrid
|
||||
*/
|
||||
public void refreshPower()
|
||||
{
|
||||
availableTicksSinceUpdate = 0;
|
||||
globalAvailablePower = 0;
|
||||
for (IAEPowerStorage p : providers)
|
||||
globalAvailablePower += p.getAECurrentPower();
|
||||
this.availableTicksSinceUpdate = 0;
|
||||
this.globalAvailablePower = 0;
|
||||
for (IAEPowerStorage p : this.providers)
|
||||
this.globalAvailablePower += p.getAECurrentPower();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getStoredPower()
|
||||
{
|
||||
if ( availableTicksSinceUpdate > 90 )
|
||||
refreshPower();
|
||||
if ( this.availableTicksSinceUpdate > 90 )
|
||||
this.refreshPower();
|
||||
|
||||
return Math.max( 0.0, globalAvailablePower );
|
||||
return Math.max( 0.0, this.globalAvailablePower );
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxStoredPower()
|
||||
{
|
||||
return globalMaxPower;
|
||||
return this.globalMaxPower;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -476,15 +476,15 @@ public class EnergyGridCache implements IEnergyGrid
|
||||
if ( !seen.add( this ) )
|
||||
return 0;
|
||||
|
||||
double extractedPower = extra;
|
||||
double extractedPower = this.extra;
|
||||
|
||||
if ( mode == Actionable.SIMULATE )
|
||||
{
|
||||
extractedPower += simulateExtract( extractedPower, amt );
|
||||
extractedPower += this.simulateExtract( extractedPower, amt );
|
||||
|
||||
if ( extractedPower < amt )
|
||||
{
|
||||
Iterator<IEnergyGridProvider> i = energyGridProviders.iterator();
|
||||
Iterator<IEnergyGridProvider> i = this.energyGridProviders.iterator();
|
||||
while (extractedPower < amt && i.hasNext())
|
||||
extractedPower += i.next().extractAEPower( amt - extractedPower, mode, seen );
|
||||
}
|
||||
@@ -493,38 +493,38 @@ public class EnergyGridCache implements IEnergyGrid
|
||||
}
|
||||
else
|
||||
{
|
||||
extra = 0;
|
||||
extractedPower = doExtract( extractedPower, amt );
|
||||
this.extra = 0;
|
||||
extractedPower = this.doExtract( extractedPower, amt );
|
||||
}
|
||||
|
||||
// got more then we wanted?
|
||||
if ( extractedPower > amt )
|
||||
{
|
||||
extra = extractedPower - amt;
|
||||
globalAvailablePower -= amt;
|
||||
this.extra = extractedPower - amt;
|
||||
this.globalAvailablePower -= amt;
|
||||
|
||||
tickDrainPerTick += amt;
|
||||
this.tickDrainPerTick += amt;
|
||||
return amt;
|
||||
}
|
||||
|
||||
if ( extractedPower < amt )
|
||||
{
|
||||
Iterator<IEnergyGridProvider> i = energyGridProviders.iterator();
|
||||
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?
|
||||
globalAvailablePower -= extractedPower;
|
||||
tickDrainPerTick += extractedPower;
|
||||
this.globalAvailablePower -= extractedPower;
|
||||
this.tickDrainPerTick += extractedPower;
|
||||
return extractedPower;
|
||||
}
|
||||
|
||||
private double doExtract(double extractedPower, double amt)
|
||||
{
|
||||
while (extractedPower < amt && !providers.isEmpty())
|
||||
while (extractedPower < amt && !this.providers.isEmpty())
|
||||
{
|
||||
IAEPowerStorage node = getFirstProvider();
|
||||
IAEPowerStorage node = this.getFirstProvider();
|
||||
|
||||
double req = amt - extractedPower;
|
||||
double newPower = node.extractAEPower( req, Actionable.MODULATE, PowerMultiplier.ONE );
|
||||
@@ -532,8 +532,8 @@ public class EnergyGridCache implements IEnergyGrid
|
||||
|
||||
if ( newPower < req )
|
||||
{
|
||||
providers.remove( node );
|
||||
lastProvider = null;
|
||||
this.providers.remove( node );
|
||||
this.lastProvider = null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -543,7 +543,7 @@ public class EnergyGridCache implements IEnergyGrid
|
||||
|
||||
private double simulateExtract(double extractedPower, double amt)
|
||||
{
|
||||
Iterator<IAEPowerStorage> it = providers.iterator();
|
||||
Iterator<IAEPowerStorage> it = this.providers.iterator();
|
||||
|
||||
while (extractedPower < amt && it.hasNext())
|
||||
{
|
||||
@@ -560,38 +560,38 @@ public class EnergyGridCache implements IEnergyGrid
|
||||
@Override
|
||||
public boolean isNetworkPowered()
|
||||
{
|
||||
return publicHasPower;
|
||||
return this.publicHasPower;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getIdlePowerUsage()
|
||||
{
|
||||
return drainPerTick + pgc.channelPowerUsage;
|
||||
return this.drainPerTick + this.pgc.channelPowerUsage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getAvgPowerUsage()
|
||||
{
|
||||
return avgDrainPerTick;
|
||||
return this.avgDrainPerTick;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getAvgPowerInjection()
|
||||
{
|
||||
return avgInjectionPerTick;
|
||||
return this.avgInjectionPerTick;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSplit(IGridStorage storageB)
|
||||
{
|
||||
extra /= 2;
|
||||
storageB.dataObject().setDouble( "extraEnergy", extra );
|
||||
this.extra /= 2;
|
||||
storageB.dataObject().setDouble( "extraEnergy", this.extra );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onJoin(IGridStorage storageB)
|
||||
{
|
||||
extra += storageB.dataObject().getDouble( "extraEnergy" );
|
||||
this.extra += storageB.dataObject().getDouble( "extraEnergy" );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+53
-53
@@ -57,7 +57,7 @@ public class GridStorageCache implements IStorageGrid
|
||||
{
|
||||
|
||||
final private SetMultimap<IAEStack, ItemWatcher> interests = HashMultimap.create();
|
||||
final public GenericInterestManager<ItemWatcher> interestManager = new GenericInterestManager<ItemWatcher>( interests );
|
||||
final public GenericInterestManager<ItemWatcher> interestManager = new GenericInterestManager<ItemWatcher>( this.interests );
|
||||
|
||||
final HashSet<ICellProvider> activeCellProviders = new HashSet<ICellProvider>();
|
||||
final HashSet<ICellProvider> inactiveCellProviders = new HashSet<ICellProvider>();
|
||||
@@ -72,14 +72,14 @@ public class GridStorageCache implements IStorageGrid
|
||||
private final HashMap<IGridNode, IStackWatcher> watchers = new HashMap<IGridNode, IStackWatcher>();
|
||||
|
||||
public GridStorageCache(IGrid g) {
|
||||
myGrid = g;
|
||||
this.myGrid = g;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdateTick()
|
||||
{
|
||||
itemMonitor.onTick();
|
||||
fluidMonitor.onTick();
|
||||
this.itemMonitor.onTick();
|
||||
this.fluidMonitor.onTick();
|
||||
}
|
||||
|
||||
private class CellChangeTrackerRecord
|
||||
@@ -105,7 +105,7 @@ public class GridStorageCache implements IStorageGrid
|
||||
|
||||
public void applyChanges()
|
||||
{
|
||||
postChangesToNetwork( channel, up_or_down, list, src );
|
||||
GridStorageCache.this.postChangesToNetwork( this.channel, this.up_or_down, this.list, this.src );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -117,12 +117,12 @@ public class GridStorageCache implements IStorageGrid
|
||||
|
||||
public void postChanges(StorageChannel channel, int i, IMEInventoryHandler<? extends IAEStack> h, BaseActionSource actionSrc)
|
||||
{
|
||||
data.add( new CellChangeTrackerRecord( channel, i, h, actionSrc ) );
|
||||
this.data.add( new CellChangeTrackerRecord( channel, i, h, actionSrc ) );
|
||||
}
|
||||
|
||||
public void applyChanges()
|
||||
{
|
||||
for (CellChangeTrackerRecord rec : data)
|
||||
for (CellChangeTrackerRecord rec : this.data)
|
||||
rec.applyChanges();
|
||||
}
|
||||
}
|
||||
@@ -130,23 +130,23 @@ public class GridStorageCache implements IStorageGrid
|
||||
@Override
|
||||
public void registerCellProvider(ICellProvider provider)
|
||||
{
|
||||
inactiveCellProviders.add( provider );
|
||||
addCellProvider( provider, new CellChangeTracker() ).applyChanges();
|
||||
this.inactiveCellProviders.add( provider );
|
||||
this.addCellProvider( provider, new CellChangeTracker() ).applyChanges();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unregisterCellProvider(ICellProvider provider)
|
||||
{
|
||||
removeCellProvider( provider, new CellChangeTracker() ).applyChanges();
|
||||
inactiveCellProviders.remove( provider );
|
||||
this.removeCellProvider( provider, new CellChangeTracker() ).applyChanges();
|
||||
this.inactiveCellProviders.remove( provider );
|
||||
}
|
||||
|
||||
public CellChangeTracker addCellProvider(ICellProvider cc, CellChangeTracker tracker)
|
||||
{
|
||||
if ( inactiveCellProviders.contains( cc ) )
|
||||
if ( this.inactiveCellProviders.contains( cc ) )
|
||||
{
|
||||
inactiveCellProviders.remove( cc );
|
||||
activeCellProviders.add( cc );
|
||||
this.inactiveCellProviders.remove( cc );
|
||||
this.activeCellProviders.add( cc );
|
||||
|
||||
BaseActionSource actionSrc = new BaseActionSource();
|
||||
if ( cc instanceof IActionHost )
|
||||
@@ -168,10 +168,10 @@ public class GridStorageCache implements IStorageGrid
|
||||
|
||||
public CellChangeTracker removeCellProvider(ICellProvider cc, CellChangeTracker tracker)
|
||||
{
|
||||
if ( activeCellProviders.contains( cc ) )
|
||||
if ( this.activeCellProviders.contains( cc ) )
|
||||
{
|
||||
inactiveCellProviders.add( cc );
|
||||
activeCellProviders.remove( cc );
|
||||
this.inactiveCellProviders.add( cc );
|
||||
this.activeCellProviders.remove( cc );
|
||||
|
||||
BaseActionSource actionSrc = new BaseActionSource();
|
||||
if ( cc instanceof IActionHost )
|
||||
@@ -194,12 +194,12 @@ public class GridStorageCache implements IStorageGrid
|
||||
@MENetworkEventSubscribe
|
||||
public void cellUpdate(MENetworkCellArrayUpdate ev)
|
||||
{
|
||||
myItemNetwork = null;
|
||||
myFluidNetwork = null;
|
||||
this.myItemNetwork = null;
|
||||
this.myFluidNetwork = null;
|
||||
|
||||
LinkedList<ICellProvider> ll = new LinkedList();
|
||||
ll.addAll( inactiveCellProviders );
|
||||
ll.addAll( activeCellProviders );
|
||||
ll.addAll( this.inactiveCellProviders );
|
||||
ll.addAll( this.activeCellProviders );
|
||||
|
||||
CellChangeTracker tracker = new CellChangeTracker();
|
||||
|
||||
@@ -217,13 +217,13 @@ public class GridStorageCache implements IStorageGrid
|
||||
}
|
||||
|
||||
if ( Active )
|
||||
addCellProvider( cc, tracker );
|
||||
this.addCellProvider( cc, tracker );
|
||||
else
|
||||
removeCellProvider( cc, tracker );
|
||||
this.removeCellProvider( cc, tracker );
|
||||
}
|
||||
|
||||
itemMonitor.forceUpdate();
|
||||
fluidMonitor.forceUpdate();
|
||||
this.itemMonitor.forceUpdate();
|
||||
this.fluidMonitor.forceUpdate();
|
||||
|
||||
tracker.applyChanges();
|
||||
}
|
||||
@@ -235,18 +235,18 @@ public class GridStorageCache implements IStorageGrid
|
||||
{
|
||||
ICellContainer cc = (ICellContainer) machine;
|
||||
|
||||
myGrid.postEvent( new MENetworkCellArrayUpdate() );
|
||||
removeCellProvider( cc, new CellChangeTracker() ).applyChanges();
|
||||
inactiveCellProviders.remove( cc );
|
||||
this.myGrid.postEvent( new MENetworkCellArrayUpdate() );
|
||||
this.removeCellProvider( cc, new CellChangeTracker() ).applyChanges();
|
||||
this.inactiveCellProviders.remove( cc );
|
||||
}
|
||||
|
||||
if ( machine instanceof IStackWatcherHost )
|
||||
{
|
||||
IStackWatcher myWatcher = watchers.get( machine );
|
||||
IStackWatcher myWatcher = this.watchers.get( machine );
|
||||
if ( myWatcher != null )
|
||||
{
|
||||
myWatcher.clear();
|
||||
watchers.remove( machine );
|
||||
this.watchers.remove( machine );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -257,42 +257,42 @@ public class GridStorageCache implements IStorageGrid
|
||||
if ( machine instanceof ICellContainer )
|
||||
{
|
||||
ICellContainer cc = (ICellContainer) machine;
|
||||
inactiveCellProviders.add( cc );
|
||||
this.inactiveCellProviders.add( cc );
|
||||
|
||||
myGrid.postEvent( new MENetworkCellArrayUpdate() );
|
||||
this.myGrid.postEvent( new MENetworkCellArrayUpdate() );
|
||||
if ( node.isActive() )
|
||||
addCellProvider( cc, new CellChangeTracker() ).applyChanges();
|
||||
this.addCellProvider( cc, new CellChangeTracker() ).applyChanges();
|
||||
}
|
||||
|
||||
if ( machine instanceof IStackWatcherHost )
|
||||
{
|
||||
IStackWatcherHost swh = (IStackWatcherHost) machine;
|
||||
ItemWatcher iw = new ItemWatcher( this, swh );
|
||||
watchers.put( node, iw );
|
||||
this.watchers.put( node, iw );
|
||||
swh.updateWatcher( iw );
|
||||
}
|
||||
}
|
||||
|
||||
private void buildNetworkStorage(StorageChannel chan)
|
||||
{
|
||||
SecurityCache security = myGrid.getCache( ISecurityGrid.class );
|
||||
SecurityCache security = this.myGrid.getCache( ISecurityGrid.class );
|
||||
|
||||
switch (chan)
|
||||
{
|
||||
case FLUIDS:
|
||||
myFluidNetwork = new NetworkInventoryHandler<IAEFluidStack>( StorageChannel.FLUIDS, security );
|
||||
for (ICellProvider cc : activeCellProviders)
|
||||
this.myFluidNetwork = new NetworkInventoryHandler<IAEFluidStack>( StorageChannel.FLUIDS, security );
|
||||
for (ICellProvider cc : this.activeCellProviders)
|
||||
{
|
||||
for (IMEInventoryHandler<IAEFluidStack> h : cc.getCellArray( chan ))
|
||||
myFluidNetwork.addNewStorage( h );
|
||||
this.myFluidNetwork.addNewStorage( h );
|
||||
}
|
||||
break;
|
||||
case ITEMS:
|
||||
myItemNetwork = new NetworkInventoryHandler<IAEItemStack>( StorageChannel.ITEMS, security );
|
||||
for (ICellProvider cc : activeCellProviders)
|
||||
this.myItemNetwork = new NetworkInventoryHandler<IAEItemStack>( StorageChannel.ITEMS, security );
|
||||
for (ICellProvider cc : this.activeCellProviders)
|
||||
{
|
||||
for (IMEInventoryHandler<IAEItemStack> h : cc.getCellArray( chan ))
|
||||
myItemNetwork.addNewStorage( h );
|
||||
this.myItemNetwork.addNewStorage( h );
|
||||
}
|
||||
break;
|
||||
default:
|
||||
@@ -304,10 +304,10 @@ public class GridStorageCache implements IStorageGrid
|
||||
switch (chan)
|
||||
{
|
||||
case FLUIDS:
|
||||
fluidMonitor.postChange( up_or_down > 0, availableItems, src );
|
||||
this.fluidMonitor.postChange( up_or_down > 0, availableItems, src );
|
||||
break;
|
||||
case ITEMS:
|
||||
itemMonitor.postChange( up_or_down > 0, availableItems, src );
|
||||
this.itemMonitor.postChange( up_or_down > 0, availableItems, src );
|
||||
break;
|
||||
default:
|
||||
}
|
||||
@@ -315,37 +315,37 @@ public class GridStorageCache implements IStorageGrid
|
||||
|
||||
public IMEInventoryHandler<IAEItemStack> getItemInventoryHandler()
|
||||
{
|
||||
if ( myItemNetwork == null )
|
||||
buildNetworkStorage( StorageChannel.ITEMS );
|
||||
return myItemNetwork;
|
||||
if ( this.myItemNetwork == null )
|
||||
this.buildNetworkStorage( StorageChannel.ITEMS );
|
||||
return this.myItemNetwork;
|
||||
}
|
||||
|
||||
public IMEInventoryHandler<IAEFluidStack> getFluidInventoryHandler()
|
||||
{
|
||||
if ( myFluidNetwork == null )
|
||||
buildNetworkStorage( StorageChannel.FLUIDS );
|
||||
return myFluidNetwork;
|
||||
if ( this.myFluidNetwork == null )
|
||||
this.buildNetworkStorage( StorageChannel.FLUIDS );
|
||||
return this.myFluidNetwork;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postAlterationOfStoredItems(StorageChannel chan, Iterable<? extends IAEStack> input, BaseActionSource src)
|
||||
{
|
||||
if ( chan == StorageChannel.ITEMS )
|
||||
itemMonitor.postChange( true, (Iterable<IAEItemStack>) input, src );
|
||||
this.itemMonitor.postChange( true, (Iterable<IAEItemStack>) input, src );
|
||||
else if ( chan == StorageChannel.FLUIDS )
|
||||
fluidMonitor.postChange( true, (Iterable<IAEFluidStack>) input, src );
|
||||
this.fluidMonitor.postChange( true, (Iterable<IAEFluidStack>) input, src );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMEMonitor<IAEFluidStack> getFluidInventory()
|
||||
{
|
||||
return fluidMonitor;
|
||||
return this.fluidMonitor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMEMonitor<IAEItemStack> getItemInventory()
|
||||
{
|
||||
return itemMonitor;
|
||||
return this.itemMonitor;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+19
-19
@@ -43,9 +43,9 @@ public class NetworkMonitor<T extends IAEStack<T>> extends MEMonitorHandler<T>
|
||||
|
||||
public void forceUpdate()
|
||||
{
|
||||
hasChanged = true;
|
||||
this.hasChanged = true;
|
||||
|
||||
Iterator<Entry<IMEMonitorHandlerReceiver<T>, Object>> i = getListeners();
|
||||
Iterator<Entry<IMEMonitorHandlerReceiver<T>, Object>> i = this.getListeners();
|
||||
while (i.hasNext())
|
||||
{
|
||||
Entry<IMEMonitorHandlerReceiver<T>, Object> o = i.next();
|
||||
@@ -60,8 +60,8 @@ public class NetworkMonitor<T extends IAEStack<T>> extends MEMonitorHandler<T>
|
||||
|
||||
public NetworkMonitor(GridStorageCache cache, StorageChannel chan) {
|
||||
super( null, chan );
|
||||
myGridCache = cache;
|
||||
myChannel = chan;
|
||||
this.myGridCache = cache;
|
||||
this.myChannel = chan;
|
||||
}
|
||||
|
||||
final static public LinkedList depth = new LinkedList();
|
||||
@@ -69,7 +69,7 @@ public class NetworkMonitor<T extends IAEStack<T>> extends MEMonitorHandler<T>
|
||||
@Override
|
||||
protected void postChangesToListeners(Iterable<T> changes, BaseActionSource src)
|
||||
{
|
||||
postChange( true, changes, src );
|
||||
this.postChange( true, changes, src );
|
||||
}
|
||||
|
||||
protected void postChange(boolean Add, Iterable<T> changes, BaseActionSource src)
|
||||
@@ -79,10 +79,10 @@ public class NetworkMonitor<T extends IAEStack<T>> extends MEMonitorHandler<T>
|
||||
|
||||
depth.push( this );
|
||||
|
||||
sendEvent = true;
|
||||
notifyListenersOfChange( changes, src );
|
||||
this.sendEvent = true;
|
||||
this.notifyListenersOfChange( changes, src );
|
||||
|
||||
IItemList<T> myStorageList = getStorageList();
|
||||
IItemList<T> myStorageList = this.getStorageList();
|
||||
|
||||
for (T changedItem : changes)
|
||||
{
|
||||
@@ -91,9 +91,9 @@ public class NetworkMonitor<T extends IAEStack<T>> extends MEMonitorHandler<T>
|
||||
if ( !Add && changedItem != null )
|
||||
(difference = changedItem.copy()).setStackSize( -changedItem.getStackSize() );
|
||||
|
||||
if ( myGridCache.interestManager.containsKey( changedItem ) )
|
||||
if ( this.myGridCache.interestManager.containsKey( changedItem ) )
|
||||
{
|
||||
Collection<ItemWatcher> list = myGridCache.interestManager.get( changedItem );
|
||||
Collection<ItemWatcher> list = this.myGridCache.interestManager.get( changedItem );
|
||||
if ( !list.isEmpty() )
|
||||
{
|
||||
IAEStack fullStack = myStorageList.findPrecise( changedItem );
|
||||
@@ -103,12 +103,12 @@ public class NetworkMonitor<T extends IAEStack<T>> extends MEMonitorHandler<T>
|
||||
fullStack.setStackSize( 0 );
|
||||
}
|
||||
|
||||
myGridCache.interestManager.enableTransactions();
|
||||
this.myGridCache.interestManager.enableTransactions();
|
||||
|
||||
for (ItemWatcher iw : list)
|
||||
iw.getHost().onStackChange( myStorageList, fullStack, difference, src, getChannel() );
|
||||
iw.getHost().onStackChange( myStorageList, fullStack, difference, src, this.getChannel() );
|
||||
|
||||
myGridCache.interestManager.disableTransactions();
|
||||
this.myGridCache.interestManager.disableTransactions();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -120,22 +120,22 @@ public class NetworkMonitor<T extends IAEStack<T>> extends MEMonitorHandler<T>
|
||||
|
||||
public void onTick()
|
||||
{
|
||||
if ( sendEvent )
|
||||
if ( this.sendEvent )
|
||||
{
|
||||
sendEvent = false;
|
||||
myGridCache.myGrid.postEvent( new MENetworkStorageEvent( this, myChannel ) );
|
||||
this.sendEvent = false;
|
||||
this.myGridCache.myGrid.postEvent( new MENetworkStorageEvent( this, this.myChannel ) );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected IMEInventoryHandler getHandler()
|
||||
{
|
||||
switch (myChannel)
|
||||
switch (this.myChannel)
|
||||
{
|
||||
case ITEMS:
|
||||
return myGridCache.getItemInventoryHandler();
|
||||
return this.myGridCache.getItemInventoryHandler();
|
||||
case FLUIDS:
|
||||
return myGridCache.getFluidInventoryHandler();
|
||||
return this.myGridCache.getFluidInventoryHandler();
|
||||
default:
|
||||
}
|
||||
return null;
|
||||
|
||||
+26
-26
@@ -47,14 +47,14 @@ public class P2PCache implements IGridCache
|
||||
final IGrid myGrid;
|
||||
|
||||
public P2PCache(IGrid g) {
|
||||
myGrid = g;
|
||||
this.myGrid = g;
|
||||
}
|
||||
|
||||
@MENetworkEventSubscribe
|
||||
public void bootComplete(MENetworkBootingStatusChange bootStatus)
|
||||
{
|
||||
ITickManager tm = myGrid.getCache( ITickManager.class );
|
||||
for (PartP2PTunnel me : inputs.values())
|
||||
ITickManager tm = this.myGrid.getCache( ITickManager.class );
|
||||
for (PartP2PTunnel me : this.inputs.values())
|
||||
{
|
||||
if ( me instanceof PartP2PTunnelME )
|
||||
tm.wakeDevice( me.getGridNode() );
|
||||
@@ -64,8 +64,8 @@ public class P2PCache implements IGridCache
|
||||
@MENetworkEventSubscribe
|
||||
public void bootComplete(MENetworkPowerStatusChange power)
|
||||
{
|
||||
ITickManager tm = myGrid.getCache( ITickManager.class );
|
||||
for (PartP2PTunnel me : inputs.values())
|
||||
ITickManager tm = this.myGrid.getCache( ITickManager.class );
|
||||
for (PartP2PTunnel me : this.inputs.values())
|
||||
{
|
||||
if ( me instanceof PartP2PTunnelME )
|
||||
tm.wakeDevice( me.getGridNode() );
|
||||
@@ -80,23 +80,23 @@ public class P2PCache implements IGridCache
|
||||
|
||||
public void updateFreq(PartP2PTunnel t, long NewFreq)
|
||||
{
|
||||
if ( outputs.containsValue( t ) )
|
||||
outputs.remove( t.freq, t );
|
||||
if ( this.outputs.containsValue( t ) )
|
||||
this.outputs.remove( t.freq, t );
|
||||
|
||||
if ( inputs.containsValue( t ) )
|
||||
inputs.remove( t.freq );
|
||||
if ( this.inputs.containsValue( t ) )
|
||||
this.inputs.remove( t.freq );
|
||||
|
||||
t.freq = NewFreq;
|
||||
|
||||
if ( t.output )
|
||||
outputs.put( t.freq, t );
|
||||
this.outputs.put( t.freq, t );
|
||||
else
|
||||
inputs.put( t.freq, t );
|
||||
this.inputs.put( t.freq, t );
|
||||
|
||||
// AELog.info( "update-" + (t.output ? "output: " : "input: ") + t.freq
|
||||
// );
|
||||
updateTunnel( t.freq, t.output, true );
|
||||
updateTunnel( t.freq, !t.output, true );
|
||||
this.updateTunnel( t.freq, t.output, true );
|
||||
this.updateTunnel( t.freq, !t.output, true );
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -115,11 +115,11 @@ public class P2PCache implements IGridCache
|
||||
// );
|
||||
|
||||
if ( t.output )
|
||||
outputs.put( t.freq, t );
|
||||
this.outputs.put( t.freq, t );
|
||||
else
|
||||
inputs.put( t.freq, t );
|
||||
this.inputs.put( t.freq, t );
|
||||
|
||||
updateTunnel( t.freq, !t.output, false );
|
||||
this.updateTunnel( t.freq, !t.output, false );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -139,24 +139,24 @@ public class P2PCache implements IGridCache
|
||||
// );
|
||||
|
||||
if ( t.output )
|
||||
outputs.remove( t.freq, t );
|
||||
this.outputs.remove( t.freq, t );
|
||||
else
|
||||
inputs.remove( t.freq );
|
||||
this.inputs.remove( t.freq );
|
||||
|
||||
updateTunnel( t.freq, !t.output, false );
|
||||
this.updateTunnel( t.freq, !t.output, false );
|
||||
}
|
||||
}
|
||||
|
||||
private void updateTunnel(long freq, boolean updateOutputs, boolean configChange)
|
||||
{
|
||||
for (PartP2PTunnel p : outputs.get( freq ))
|
||||
for (PartP2PTunnel p : this.outputs.get( freq ))
|
||||
{
|
||||
if ( configChange )
|
||||
p.onTunnelConfigChange();
|
||||
p.onTunnelNetworkChange();
|
||||
}
|
||||
|
||||
PartP2PTunnel in = inputs.get( freq );
|
||||
PartP2PTunnel in = this.inputs.get( freq );
|
||||
if ( in != null )
|
||||
{
|
||||
if ( configChange )
|
||||
@@ -167,20 +167,20 @@ public class P2PCache implements IGridCache
|
||||
|
||||
public TunnelCollection<PartP2PTunnel> getOutputs(long freq, Class<? extends PartP2PTunnel> c)
|
||||
{
|
||||
PartP2PTunnel in = inputs.get( freq );
|
||||
PartP2PTunnel in = this.inputs.get( freq );
|
||||
if ( in == null )
|
||||
return NullColl;
|
||||
return this.NullColl;
|
||||
|
||||
TunnelCollection<PartP2PTunnel> out = inputs.get( freq ).getCollection( outputs.get( freq ), c );
|
||||
TunnelCollection<PartP2PTunnel> out = this.inputs.get( freq ).getCollection( this.outputs.get( freq ), c );
|
||||
if ( out == null )
|
||||
return NullColl;
|
||||
return this.NullColl;
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
public PartP2PTunnel getInput(long freq)
|
||||
{
|
||||
return inputs.get( freq );
|
||||
return this.inputs.get( freq );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+78
-78
@@ -83,69 +83,69 @@ public class PathGridCache implements IPathingGrid
|
||||
|
||||
public PathGridCache(IGrid g)
|
||||
{
|
||||
myGrid = g;
|
||||
this.myGrid = g;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdateTick()
|
||||
{
|
||||
if ( recalculateControllerNextTick )
|
||||
if ( this.recalculateControllerNextTick )
|
||||
{
|
||||
recalcController();
|
||||
this.recalcController();
|
||||
}
|
||||
|
||||
if ( updateNetwork )
|
||||
if ( this.updateNetwork )
|
||||
{
|
||||
if ( !booting )
|
||||
myGrid.postEvent( new MENetworkBootingStatusChange() );
|
||||
if ( !this.booting )
|
||||
this.myGrid.postEvent( new MENetworkBootingStatusChange() );
|
||||
|
||||
booting = true;
|
||||
updateNetwork = false;
|
||||
instance++;
|
||||
channelsInUse = 0;
|
||||
this.booting = true;
|
||||
this.updateNetwork = false;
|
||||
this.instance++;
|
||||
this.channelsInUse = 0;
|
||||
|
||||
if ( !AEConfig.instance.isFeatureEnabled( AEFeature.Channels ) )
|
||||
{
|
||||
int used = calculateRequiredChannels();
|
||||
int used = this.calculateRequiredChannels();
|
||||
|
||||
int nodes = myGrid.getNodes().size();
|
||||
ticksUntilReady = 20 + Math.max( 0, nodes / 100 - 20 );
|
||||
channelsByBlocks = nodes * used;
|
||||
channelPowerUsage = channelsByBlocks / 128.0;
|
||||
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;
|
||||
|
||||
myGrid.getPivot().beginVisit( new AdHocChannelUpdater( used ) );
|
||||
this.myGrid.getPivot().beginVisit( new AdHocChannelUpdater( used ) );
|
||||
}
|
||||
else if ( controllerState == ControllerState.NO_CONTROLLER )
|
||||
else if ( this.controllerState == ControllerState.NO_CONTROLLER )
|
||||
{
|
||||
int requiredChannels = calculateRequiredChannels();
|
||||
int requiredChannels = this.calculateRequiredChannels();
|
||||
int used = requiredChannels;
|
||||
if ( requiredChannels > 8 )
|
||||
used = 0;
|
||||
|
||||
int nodes = myGrid.getNodes().size();
|
||||
channelsInUse = used;
|
||||
int nodes = this.myGrid.getNodes().size();
|
||||
this.channelsInUse = used;
|
||||
|
||||
ticksUntilReady = 20 + Math.max( 0, nodes / 100 - 20 );
|
||||
channelsByBlocks = nodes * used;
|
||||
channelPowerUsage = channelsByBlocks / 128.0;
|
||||
this.ticksUntilReady = 20 + Math.max( 0, nodes / 100 - 20 );
|
||||
this.channelsByBlocks = nodes * used;
|
||||
this.channelPowerUsage = this.channelsByBlocks / 128.0;
|
||||
|
||||
myGrid.getPivot().beginVisit( new AdHocChannelUpdater( used ) );
|
||||
this.myGrid.getPivot().beginVisit( new AdHocChannelUpdater( used ) );
|
||||
}
|
||||
else if ( controllerState == ControllerState.CONTROLLER_CONFLICT )
|
||||
else if ( this.controllerState == ControllerState.CONTROLLER_CONFLICT )
|
||||
{
|
||||
ticksUntilReady = 20;
|
||||
myGrid.getPivot().beginVisit( new AdHocChannelUpdater( 0 ) );
|
||||
this.ticksUntilReady = 20;
|
||||
this.myGrid.getPivot().beginVisit( new AdHocChannelUpdater( 0 ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
int nodes = myGrid.getNodes().size();
|
||||
ticksUntilReady = 20 + Math.max( 0, nodes / 100 - 20 );
|
||||
int nodes = this.myGrid.getNodes().size();
|
||||
this.ticksUntilReady = 20 + Math.max( 0, nodes / 100 - 20 );
|
||||
HashSet<IPathItem> closedList = new HashSet<IPathItem>();
|
||||
semiOpen = new HashSet<IPathItem>();
|
||||
this.semiOpen = new HashSet<IPathItem>();
|
||||
|
||||
// myGrid.getPivot().beginVisit( new AdHocChannelUpdater( 0 )
|
||||
// );
|
||||
for (IGridNode node : myGrid.getMachines( TileController.class ))
|
||||
for (IGridNode node : this.myGrid.getMachines( TileController.class ))
|
||||
{
|
||||
closedList.add( (IPathItem) node );
|
||||
for (IGridConnection gcc : node.getConnections())
|
||||
@@ -157,16 +157,16 @@ public class PathGridCache implements IPathingGrid
|
||||
closedList.add( gc );
|
||||
open.add( gc );
|
||||
gc.setControllerRoute( (GridNode) node, true );
|
||||
active.add( new PathSegment( this, open, semiOpen, closedList ) );
|
||||
this.active.add( new PathSegment( this, open, this.semiOpen, closedList ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( !active.isEmpty() || ticksUntilReady > 0 )
|
||||
if ( !this.active.isEmpty() || this.ticksUntilReady > 0 )
|
||||
{
|
||||
Iterator<PathSegment> i = active.iterator();
|
||||
Iterator<PathSegment> i = this.active.iterator();
|
||||
while (i.hasNext())
|
||||
{
|
||||
PathSegment pat = i.next();
|
||||
@@ -177,11 +177,11 @@ public class PathGridCache implements IPathingGrid
|
||||
}
|
||||
}
|
||||
|
||||
ticksUntilReady--;
|
||||
this.ticksUntilReady--;
|
||||
|
||||
if ( active.isEmpty() && ticksUntilReady <= 0 )
|
||||
if ( this.active.isEmpty() && this.ticksUntilReady <= 0 )
|
||||
{
|
||||
if ( controllerState == ControllerState.CONTROLLER_ONLINE )
|
||||
if ( this.controllerState == ControllerState.CONTROLLER_ONLINE )
|
||||
{
|
||||
final Iterator<TileController> controllerIterator = this.controllers.iterator();
|
||||
if (controllerIterator.hasNext())
|
||||
@@ -192,25 +192,25 @@ public class PathGridCache implements IPathingGrid
|
||||
}
|
||||
|
||||
// check for achievements
|
||||
achievementPost();
|
||||
this.achievementPost();
|
||||
|
||||
booting = false;
|
||||
channelPowerUsage = channelsByBlocks / 128.0;
|
||||
myGrid.postEvent( new MENetworkBootingStatusChange() );
|
||||
this.booting = false;
|
||||
this.channelPowerUsage = this.channelsByBlocks / 128.0;
|
||||
this.myGrid.postEvent( new MENetworkBootingStatusChange() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void achievementPost()
|
||||
{
|
||||
if ( lastChannels != channelsInUse && AEConfig.instance.isFeatureEnabled( AEFeature.Channels ) )
|
||||
if ( this.lastChannels != this.channelsInUse && AEConfig.instance.isFeatureEnabled( AEFeature.Channels ) )
|
||||
{
|
||||
Achievements currentBracket = getAchievementBracket( channelsInUse );
|
||||
Achievements lastBracket = getAchievementBracket( lastChannels );
|
||||
Achievements currentBracket = this.getAchievementBracket( this.channelsInUse );
|
||||
Achievements lastBracket = this.getAchievementBracket( this.lastChannels );
|
||||
if ( currentBracket != lastBracket && currentBracket != null )
|
||||
{
|
||||
Set<Integer> players = new HashSet<Integer>();
|
||||
for (IGridNode n : requireChannels)
|
||||
for (IGridNode n : this.requireChannels)
|
||||
players.add( n.getPlayerID() );
|
||||
|
||||
for (int id : players)
|
||||
@@ -219,7 +219,7 @@ public class PathGridCache implements IPathingGrid
|
||||
}
|
||||
}
|
||||
}
|
||||
lastChannels = channelsInUse;
|
||||
this.lastChannels = this.channelsInUse;
|
||||
}
|
||||
|
||||
private Achievements getAchievementBracket(int ch)
|
||||
@@ -239,16 +239,16 @@ public class PathGridCache implements IPathingGrid
|
||||
private int calculateRequiredChannels()
|
||||
{
|
||||
int depth = 0;
|
||||
semiOpen.clear();
|
||||
this.semiOpen.clear();
|
||||
|
||||
for (IGridNode nodes : requireChannels)
|
||||
for (IGridNode nodes : this.requireChannels)
|
||||
{
|
||||
if ( !semiOpen.contains( nodes ) )
|
||||
if ( !this.semiOpen.contains( nodes ) )
|
||||
{
|
||||
IGridBlock gb = nodes.getGridBlock();
|
||||
EnumSet<GridFlags> flags = gb.getFlags();
|
||||
|
||||
if ( flags.contains( GridFlags.COMPRESSED_CHANNEL ) && !blockDense.isEmpty() )
|
||||
if ( flags.contains( GridFlags.COMPRESSED_CHANNEL ) && !this.blockDense.isEmpty() )
|
||||
return 9;
|
||||
|
||||
depth++;
|
||||
@@ -258,7 +258,7 @@ public class PathGridCache implements IPathingGrid
|
||||
IGridMultiblock gmb = (IGridMultiblock) gb;
|
||||
Iterator<IGridNode> i = gmb.getMultiblockNodes();
|
||||
while (i.hasNext())
|
||||
semiOpen.add( (IPathItem) i.next() );
|
||||
this.semiOpen.add( (IPathItem) i.next() );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -270,10 +270,10 @@ public class PathGridCache implements IPathingGrid
|
||||
public void repath()
|
||||
{
|
||||
// clean up...
|
||||
active.clear();
|
||||
this.active.clear();
|
||||
|
||||
channelsByBlocks = 0;
|
||||
updateNetwork = true;
|
||||
this.channelsByBlocks = 0;
|
||||
this.updateNetwork = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -281,19 +281,19 @@ public class PathGridCache implements IPathingGrid
|
||||
{
|
||||
if ( machine instanceof TileController )
|
||||
{
|
||||
controllers.remove( machine );
|
||||
recalculateControllerNextTick = true;
|
||||
this.controllers.remove( machine );
|
||||
this.recalculateControllerNextTick = true;
|
||||
}
|
||||
|
||||
EnumSet<GridFlags> flags = gridNode.getGridBlock().getFlags();
|
||||
|
||||
if ( flags.contains( GridFlags.REQUIRE_CHANNEL ) )
|
||||
requireChannels.remove( gridNode );
|
||||
this.requireChannels.remove( gridNode );
|
||||
|
||||
if ( flags.contains( GridFlags.CANNOT_CARRY_COMPRESSED ) )
|
||||
blockDense.remove( gridNode );
|
||||
this.blockDense.remove( gridNode );
|
||||
|
||||
repath();
|
||||
this.repath();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -301,19 +301,19 @@ public class PathGridCache implements IPathingGrid
|
||||
{
|
||||
if ( machine instanceof TileController )
|
||||
{
|
||||
controllers.add( (TileController) machine );
|
||||
recalculateControllerNextTick = true;
|
||||
this.controllers.add( (TileController) machine );
|
||||
this.recalculateControllerNextTick = true;
|
||||
}
|
||||
|
||||
EnumSet<GridFlags> flags = gridNode.getGridBlock().getFlags();
|
||||
|
||||
if ( flags.contains( GridFlags.REQUIRE_CHANNEL ) )
|
||||
requireChannels.add( gridNode );
|
||||
this.requireChannels.add( gridNode );
|
||||
|
||||
if ( flags.contains( GridFlags.CANNOT_CARRY_COMPRESSED ) )
|
||||
blockDense.add( gridNode );
|
||||
this.blockDense.add( gridNode );
|
||||
|
||||
repath();
|
||||
this.repath();
|
||||
}
|
||||
|
||||
@MENetworkEventSubscribe
|
||||
@@ -322,28 +322,28 @@ public class PathGridCache implements IPathingGrid
|
||||
IGridNode gridNode = ev.node;
|
||||
|
||||
if ( gridNode.getGridBlock().getFlags().contains( GridFlags.REQUIRE_CHANNEL ) )
|
||||
requireChannels.add( gridNode );
|
||||
this.requireChannels.add( gridNode );
|
||||
else
|
||||
requireChannels.remove( gridNode );
|
||||
this.requireChannels.remove( gridNode );
|
||||
|
||||
repath();
|
||||
this.repath();
|
||||
}
|
||||
|
||||
private void recalcController()
|
||||
{
|
||||
recalculateControllerNextTick = false;
|
||||
ControllerState old = controllerState;
|
||||
this.recalculateControllerNextTick = false;
|
||||
ControllerState old = this.controllerState;
|
||||
|
||||
if ( controllers.isEmpty() )
|
||||
if ( this.controllers.isEmpty() )
|
||||
{
|
||||
controllerState = ControllerState.NO_CONTROLLER;
|
||||
this.controllerState = ControllerState.NO_CONTROLLER;
|
||||
}
|
||||
else
|
||||
{
|
||||
IGridNode startingNode = controllers.iterator().next().getGridNode( ForgeDirection.UNKNOWN );
|
||||
IGridNode startingNode = this.controllers.iterator().next().getGridNode( ForgeDirection.UNKNOWN );
|
||||
if ( startingNode == null )
|
||||
{
|
||||
controllerState = ControllerState.CONTROLLER_CONFLICT;
|
||||
this.controllerState = ControllerState.CONTROLLER_CONFLICT;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -352,15 +352,15 @@ public class PathGridCache implements IPathingGrid
|
||||
|
||||
startingNode.beginVisit( cv );
|
||||
|
||||
if ( cv.isValid && cv.found == controllers.size() )
|
||||
controllerState = ControllerState.CONTROLLER_ONLINE;
|
||||
if ( cv.isValid && cv.found == this.controllers.size() )
|
||||
this.controllerState = ControllerState.CONTROLLER_ONLINE;
|
||||
else
|
||||
controllerState = ControllerState.CONTROLLER_CONFLICT;
|
||||
this.controllerState = ControllerState.CONTROLLER_CONFLICT;
|
||||
}
|
||||
|
||||
if ( old != controllerState )
|
||||
if ( old != this.controllerState )
|
||||
{
|
||||
myGrid.postEvent( new MENetworkControllerChange() );
|
||||
this.myGrid.postEvent( new MENetworkControllerChange() );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+25
-25
@@ -43,7 +43,7 @@ public class SecurityCache implements ISecurityGrid
|
||||
final private HashMap<Integer, EnumSet<SecurityPermissions>> playerPerms = new HashMap<Integer, EnumSet<SecurityPermissions>>();
|
||||
|
||||
public SecurityCache(IGrid g) {
|
||||
myGrid = g;
|
||||
this.myGrid = g;
|
||||
}
|
||||
|
||||
private long securityKey = -1;
|
||||
@@ -52,43 +52,43 @@ public class SecurityCache implements ISecurityGrid
|
||||
@MENetworkEventSubscribe
|
||||
public void updatePermissions(MENetworkSecurityChange ev)
|
||||
{
|
||||
playerPerms.clear();
|
||||
if ( securityProvider.isEmpty() )
|
||||
this.playerPerms.clear();
|
||||
if ( this.securityProvider.isEmpty() )
|
||||
return;
|
||||
|
||||
securityProvider.get( 0 ).readPermissions( playerPerms );
|
||||
this.securityProvider.get( 0 ).readPermissions( this.playerPerms );
|
||||
}
|
||||
|
||||
public long getSecurityKey()
|
||||
{
|
||||
return securityKey;
|
||||
return this.securityKey;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAvailable()
|
||||
{
|
||||
return securityProvider.size() == 1 && securityProvider.get( 0 ).isSecurityEnabled();
|
||||
return this.securityProvider.size() == 1 && this.securityProvider.get( 0 ).isSecurityEnabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPermission(EntityPlayer player, SecurityPermissions perm)
|
||||
{
|
||||
return hasPermission( player == null ? -1 : WorldSettings.getInstance().getPlayerID( player.getGameProfile() ), perm );
|
||||
return this.hasPermission( player == null ? -1 : WorldSettings.getInstance().getPlayerID( player.getGameProfile() ), perm );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPermission(int playerID, SecurityPermissions perm)
|
||||
{
|
||||
if ( isAvailable() )
|
||||
if ( this.isAvailable() )
|
||||
{
|
||||
EnumSet<SecurityPermissions> perms = playerPerms.get( playerID );
|
||||
EnumSet<SecurityPermissions> perms = this.playerPerms.get( playerID );
|
||||
|
||||
if ( perms == null )
|
||||
{
|
||||
if ( playerID == -1 ) // no default?
|
||||
return false;
|
||||
else
|
||||
return hasPermission( -1, perm );
|
||||
return this.hasPermission( -1, perm );
|
||||
}
|
||||
|
||||
return perms.contains( perm );
|
||||
@@ -98,18 +98,18 @@ public class SecurityCache implements ISecurityGrid
|
||||
|
||||
private void updateSecurityKey()
|
||||
{
|
||||
long lastCode = securityKey;
|
||||
long lastCode = this.securityKey;
|
||||
|
||||
if ( securityProvider.size() == 1 )
|
||||
securityKey = securityProvider.get( 0 ).getSecurityKey();
|
||||
if ( this.securityProvider.size() == 1 )
|
||||
this.securityKey = this.securityProvider.get( 0 ).getSecurityKey();
|
||||
else
|
||||
securityKey = -1;
|
||||
this.securityKey = -1;
|
||||
|
||||
if ( lastCode != securityKey )
|
||||
if ( lastCode != this.securityKey )
|
||||
{
|
||||
myGrid.postEvent( new MENetworkSecurityChange() );
|
||||
for (IGridNode n : myGrid.getNodes())
|
||||
((GridNode) n).lastSecurityKey = securityKey;
|
||||
this.myGrid.postEvent( new MENetworkSecurityChange() );
|
||||
for (IGridNode n : this.myGrid.getNodes())
|
||||
((GridNode) n).lastSecurityKey = this.securityKey;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -118,8 +118,8 @@ public class SecurityCache implements ISecurityGrid
|
||||
{
|
||||
if ( machine instanceof ISecurityProvider )
|
||||
{
|
||||
securityProvider.remove( machine );
|
||||
updateSecurityKey();
|
||||
this.securityProvider.remove( machine );
|
||||
this.updateSecurityKey();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -128,11 +128,11 @@ public class SecurityCache implements ISecurityGrid
|
||||
{
|
||||
if ( machine instanceof ISecurityProvider )
|
||||
{
|
||||
securityProvider.add( (ISecurityProvider) machine );
|
||||
updateSecurityKey();
|
||||
this.securityProvider.add( (ISecurityProvider) machine );
|
||||
this.updateSecurityKey();
|
||||
}
|
||||
else
|
||||
((GridNode) gridNode).lastSecurityKey = securityKey;
|
||||
((GridNode) gridNode).lastSecurityKey = this.securityKey;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -162,8 +162,8 @@ public class SecurityCache implements ISecurityGrid
|
||||
@Override
|
||||
public int getOwner()
|
||||
{
|
||||
if ( isAvailable() )
|
||||
return securityProvider.get( 0 ).getOwner();
|
||||
if ( this.isAvailable() )
|
||||
return this.securityProvider.get( 0 ).getOwner();
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
+49
-49
@@ -54,37 +54,37 @@ public class SpatialPylonCache implements ISpatialCache
|
||||
final IGrid myGrid;
|
||||
|
||||
public SpatialPylonCache(IGrid g) {
|
||||
myGrid = g;
|
||||
this.myGrid = g;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long requiredPower()
|
||||
{
|
||||
return powerRequired;
|
||||
return this.powerRequired;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasRegion()
|
||||
{
|
||||
return captureMin != null;
|
||||
return this.captureMin != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValidRegion()
|
||||
{
|
||||
return hasRegion() && isValid;
|
||||
return this.hasRegion() && this.isValid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DimensionalCoord getMin()
|
||||
{
|
||||
return captureMin;
|
||||
return this.captureMin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DimensionalCoord getMax()
|
||||
{
|
||||
return captureMax;
|
||||
return this.captureMax;
|
||||
}
|
||||
|
||||
public void reset(IGrid grid)
|
||||
@@ -97,12 +97,12 @@ public class SpatialPylonCache implements ISpatialCache
|
||||
double minPower = 0;
|
||||
double maxPower = 0;
|
||||
|
||||
clusters = new HashMap<SpatialPylonCluster, SpatialPylonCluster>();
|
||||
ioPorts = new LinkedList<TileSpatialIOPort>();
|
||||
this.clusters = new HashMap<SpatialPylonCluster, SpatialPylonCluster>();
|
||||
this.ioPorts = new LinkedList<TileSpatialIOPort>();
|
||||
|
||||
for (IGridNode gm : grid.getMachines( TileSpatialIOPort.class ))
|
||||
{
|
||||
ioPorts.add( (TileSpatialIOPort) gm.getMachine() );
|
||||
this.ioPorts.add( (TileSpatialIOPort) gm.getMachine() );
|
||||
}
|
||||
|
||||
IReadOnlyCollection<IGridNode> set = grid.getMachines( TileSpatialPylon.class );
|
||||
@@ -112,89 +112,89 @@ public class SpatialPylonCache implements ISpatialCache
|
||||
{
|
||||
SpatialPylonCluster c = ((TileSpatialPylon) gm.getMachine()).getCluster();
|
||||
if ( c != null )
|
||||
clusters.put( c, c );
|
||||
this.clusters.put( c, c );
|
||||
}
|
||||
}
|
||||
|
||||
captureMax = null;
|
||||
captureMin = null;
|
||||
isValid = true;
|
||||
this.captureMax = null;
|
||||
this.captureMin = null;
|
||||
this.isValid = true;
|
||||
|
||||
int pylonBlocks = 0;
|
||||
for (SpatialPylonCluster cl : clusters.values())
|
||||
for (SpatialPylonCluster cl : this.clusters.values())
|
||||
{
|
||||
if ( captureMax == null )
|
||||
captureMax = cl.max.copy();
|
||||
if ( captureMin == null )
|
||||
captureMin = cl.min.copy();
|
||||
if ( this.captureMax == null )
|
||||
this.captureMax = cl.max.copy();
|
||||
if ( this.captureMin == null )
|
||||
this.captureMin = cl.min.copy();
|
||||
|
||||
pylonBlocks += cl.tileCount();
|
||||
|
||||
captureMin.x = Math.min( captureMin.x, cl.min.x );
|
||||
captureMin.y = Math.min( captureMin.y, cl.min.y );
|
||||
captureMin.z = Math.min( captureMin.z, cl.min.z );
|
||||
this.captureMin.x = Math.min( this.captureMin.x, cl.min.x );
|
||||
this.captureMin.y = Math.min( this.captureMin.y, cl.min.y );
|
||||
this.captureMin.z = Math.min( this.captureMin.z, cl.min.z );
|
||||
|
||||
captureMax.x = Math.max( captureMax.x, cl.max.x );
|
||||
captureMax.y = Math.max( captureMax.y, cl.max.y );
|
||||
captureMax.z = Math.max( captureMax.z, cl.max.z );
|
||||
this.captureMax.x = Math.max( this.captureMax.x, cl.max.x );
|
||||
this.captureMax.y = Math.max( this.captureMax.y, cl.max.y );
|
||||
this.captureMax.z = Math.max( this.captureMax.z, cl.max.z );
|
||||
}
|
||||
|
||||
if ( hasRegion() )
|
||||
if ( this.hasRegion() )
|
||||
{
|
||||
isValid = captureMax.x - captureMin.x > 1 && captureMax.y - captureMin.y > 1 && captureMax.z - captureMin.z > 1;
|
||||
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 : clusters.values())
|
||||
for (SpatialPylonCluster cl : this.clusters.values())
|
||||
{
|
||||
switch (cl.currentAxis)
|
||||
{
|
||||
case X:
|
||||
|
||||
isValid = isValid && ((captureMax.y == cl.min.y || captureMin.y == cl.max.y) || (captureMax.z == cl.min.z || captureMin.z == cl.max.z))
|
||||
&& ((captureMax.y == cl.max.y || captureMin.y == cl.min.y) || (captureMax.z == cl.max.z || captureMin.z == cl.min.z));
|
||||
this.isValid = this.isValid && ((this.captureMax.y == cl.min.y || this.captureMin.y == cl.max.y) || (this.captureMax.z == cl.min.z || this.captureMin.z == cl.max.z))
|
||||
&& ((this.captureMax.y == cl.max.y || this.captureMin.y == cl.min.y) || (this.captureMax.z == cl.max.z || this.captureMin.z == cl.min.z));
|
||||
|
||||
break;
|
||||
case Y:
|
||||
|
||||
isValid = isValid && ((captureMax.x == cl.min.x || captureMin.x == cl.max.x) || (captureMax.z == cl.min.z || captureMin.z == cl.max.z))
|
||||
&& ((captureMax.x == cl.max.x || captureMin.x == cl.min.x) || (captureMax.z == cl.max.z || captureMin.z == cl.min.z));
|
||||
this.isValid = this.isValid && ((this.captureMax.x == cl.min.x || this.captureMin.x == cl.max.x) || (this.captureMax.z == cl.min.z || this.captureMin.z == cl.max.z))
|
||||
&& ((this.captureMax.x == cl.max.x || this.captureMin.x == cl.min.x) || (this.captureMax.z == cl.max.z || this.captureMin.z == cl.min.z));
|
||||
|
||||
break;
|
||||
case Z:
|
||||
|
||||
isValid = isValid && ((captureMax.y == cl.min.y || captureMin.y == cl.max.y) || (captureMax.x == cl.min.x || captureMin.x == cl.max.x))
|
||||
&& ((captureMax.y == cl.max.y || captureMin.y == cl.min.y) || (captureMax.x == cl.max.x || captureMin.x == cl.min.x));
|
||||
this.isValid = this.isValid && ((this.captureMax.y == cl.min.y || this.captureMin.y == cl.max.y) || (this.captureMax.x == cl.min.x || this.captureMin.x == cl.max.x))
|
||||
&& ((this.captureMax.y == cl.max.y || this.captureMin.y == cl.min.y) || (this.captureMax.x == cl.max.x || this.captureMin.x == cl.min.x));
|
||||
|
||||
break;
|
||||
case UNFORMED:
|
||||
isValid = false;
|
||||
this.isValid = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
reqX = captureMax.x - captureMin.x;
|
||||
reqY = captureMax.y - captureMin.y;
|
||||
reqZ = captureMax.z - captureMin.z;
|
||||
reqX = this.captureMax.x - this.captureMin.x;
|
||||
reqY = this.captureMax.y - this.captureMin.y;
|
||||
reqZ = this.captureMax.z - this.captureMin.z;
|
||||
requirePylonBlocks = Math.max( 6, ((reqX * reqZ + reqX * reqY + reqY * reqZ) * 3) / 8 );
|
||||
|
||||
efficiency = (double) pylonBlocks / (double) requirePylonBlocks;
|
||||
this.efficiency = (double) pylonBlocks / (double) requirePylonBlocks;
|
||||
|
||||
if ( efficiency > 1.0 )
|
||||
efficiency = 1.0;
|
||||
if ( efficiency < 0.0 )
|
||||
efficiency = 0.0;
|
||||
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 );
|
||||
}
|
||||
|
||||
double affective_efficiency = Math.pow( efficiency, 0.25 );
|
||||
powerRequired = (long) (affective_efficiency * minPower + (1.0 - affective_efficiency) * maxPower);
|
||||
double affective_efficiency = Math.pow( this.efficiency, 0.25 );
|
||||
this.powerRequired = (long) (affective_efficiency * minPower + (1.0 - affective_efficiency) * maxPower);
|
||||
|
||||
for (SpatialPylonCluster cl : clusters.values())
|
||||
for (SpatialPylonCluster cl : this.clusters.values())
|
||||
{
|
||||
boolean myWasValid = cl.isValid;
|
||||
cl.isValid = isValid;
|
||||
if ( myWasValid != isValid )
|
||||
cl.isValid = this.isValid;
|
||||
if ( myWasValid != this.isValid )
|
||||
cl.updateStatus( false );
|
||||
}
|
||||
}
|
||||
@@ -202,13 +202,13 @@ public class SpatialPylonCache implements ISpatialCache
|
||||
@Override
|
||||
public float currentEfficiency()
|
||||
{
|
||||
return (float) efficiency * 100;
|
||||
return (float) this.efficiency * 100;
|
||||
}
|
||||
|
||||
@MENetworkEventSubscribe
|
||||
public void bootingRender(MENetworkBootingStatusChange c)
|
||||
{
|
||||
reset( myGrid );
|
||||
this.reset( this.myGrid );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+36
-36
@@ -42,7 +42,7 @@ public class TickManagerCache implements ITickManager
|
||||
final IGrid myGrid;
|
||||
|
||||
public TickManagerCache(IGrid g) {
|
||||
myGrid = g;
|
||||
this.myGrid = g;
|
||||
}
|
||||
|
||||
final HashMap<IGridNode, TickTracker> alertable = new HashMap<IGridNode, TickTracker>();
|
||||
@@ -54,15 +54,15 @@ public class TickManagerCache implements ITickManager
|
||||
|
||||
public long getCurrentTick()
|
||||
{
|
||||
return currentTick;
|
||||
return this.currentTick;
|
||||
}
|
||||
|
||||
public long getAvgNanoTime(IGridNode node)
|
||||
{
|
||||
TickTracker tt = awake.get( node );
|
||||
TickTracker tt = this.awake.get( node );
|
||||
|
||||
if ( tt == null )
|
||||
tt = sleeping.get( node );
|
||||
tt = this.sleeping.get( node );
|
||||
|
||||
if ( tt == null )
|
||||
return -1;
|
||||
@@ -76,15 +76,15 @@ public class TickManagerCache implements ITickManager
|
||||
TickTracker tt = null;
|
||||
try
|
||||
{
|
||||
currentTick++;
|
||||
while (!upcomingTicks.isEmpty())
|
||||
this.currentTick++;
|
||||
while (!this.upcomingTicks.isEmpty())
|
||||
{
|
||||
tt = upcomingTicks.peek();
|
||||
int diff = (int) (currentTick - tt.lastTick);
|
||||
tt = this.upcomingTicks.peek();
|
||||
int diff = (int) (this.currentTick - tt.lastTick);
|
||||
if ( diff >= tt.current_rate )
|
||||
{
|
||||
// remove tt..
|
||||
upcomingTicks.poll();
|
||||
this.upcomingTicks.poll();
|
||||
TickRateModulation mod = tt.gt.tickingRequest( tt.node, diff );
|
||||
|
||||
switch (mod)
|
||||
@@ -98,7 +98,7 @@ public class TickManagerCache implements ITickManager
|
||||
case SAME:
|
||||
break;
|
||||
case SLEEP:
|
||||
sleepDevice( tt.node );
|
||||
this.sleepDevice( tt.node );
|
||||
break;
|
||||
case SLOWER:
|
||||
tt.setRate( tt.current_rate + 1 );
|
||||
@@ -110,8 +110,8 @@ public class TickManagerCache implements ITickManager
|
||||
break;
|
||||
}
|
||||
|
||||
if ( awake.containsKey( tt.node ) )
|
||||
addToQueue( tt );
|
||||
if ( this.awake.containsKey( tt.node ) )
|
||||
this.addToQueue( tt );
|
||||
}
|
||||
else
|
||||
return; // done!
|
||||
@@ -128,30 +128,30 @@ public class TickManagerCache implements ITickManager
|
||||
|
||||
private void addToQueue(TickTracker tt)
|
||||
{
|
||||
tt.lastTick = currentTick;
|
||||
upcomingTicks.add( tt );
|
||||
tt.lastTick = this.currentTick;
|
||||
this.upcomingTicks.add( tt );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean alertDevice(IGridNode node)
|
||||
{
|
||||
TickTracker tt = alertable.get( node );
|
||||
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." );
|
||||
|
||||
// set to awake, this is for sanity.
|
||||
sleeping.remove( node );
|
||||
awake.put( node, tt );
|
||||
this.sleeping.remove( node );
|
||||
this.awake.put( node, tt );
|
||||
|
||||
// configure sort.
|
||||
tt.lastTick = tt.lastTick - tt.request.maxTickRate;
|
||||
tt.current_rate = tt.request.minTickRate;
|
||||
|
||||
// prevent dupes and tick build up.
|
||||
upcomingTicks.remove( tt );
|
||||
upcomingTicks.add( tt );
|
||||
this.upcomingTicks.remove( tt );
|
||||
this.upcomingTicks.add( tt );
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -159,11 +159,11 @@ public class TickManagerCache implements ITickManager
|
||||
@Override
|
||||
public boolean sleepDevice(IGridNode node)
|
||||
{
|
||||
if ( awake.containsKey( node ) )
|
||||
if ( this.awake.containsKey( node ) )
|
||||
{
|
||||
TickTracker gt = awake.get( node );
|
||||
awake.remove( node );
|
||||
sleeping.put( node, gt );
|
||||
TickTracker gt = this.awake.get( node );
|
||||
this.awake.remove( node );
|
||||
this.sleeping.put( node, gt );
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -174,12 +174,12 @@ public class TickManagerCache implements ITickManager
|
||||
@Override
|
||||
public boolean wakeDevice(IGridNode node)
|
||||
{
|
||||
if ( sleeping.containsKey( node ) )
|
||||
if ( this.sleeping.containsKey( node ) )
|
||||
{
|
||||
TickTracker gt = sleeping.get( node );
|
||||
sleeping.remove( node );
|
||||
awake.put( node, gt );
|
||||
addToQueue( gt );
|
||||
TickTracker gt = this.sleeping.get( node );
|
||||
this.sleeping.remove( node );
|
||||
this.awake.put( node, gt );
|
||||
this.addToQueue( gt );
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -192,9 +192,9 @@ public class TickManagerCache implements ITickManager
|
||||
{
|
||||
if ( machine instanceof IGridTickable )
|
||||
{
|
||||
alertable.remove( gridNode );
|
||||
sleeping.remove( gridNode );
|
||||
awake.remove( gridNode );
|
||||
this.alertable.remove( gridNode );
|
||||
this.sleeping.remove( gridNode );
|
||||
this.awake.remove( gridNode );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -206,17 +206,17 @@ public class TickManagerCache implements ITickManager
|
||||
TickingRequest tr = ((IGridTickable) machine).getTickingRequest( gridNode );
|
||||
if ( tr != null )
|
||||
{
|
||||
TickTracker tt = new TickTracker( tr, gridNode, (IGridTickable) machine, currentTick, this );
|
||||
TickTracker tt = new TickTracker( tr, gridNode, (IGridTickable) machine, this.currentTick, this );
|
||||
|
||||
if ( tr.canBeAlerted )
|
||||
alertable.put( gridNode, tt );
|
||||
this.alertable.put( gridNode, tt );
|
||||
|
||||
if ( tr.isSleeping )
|
||||
sleeping.put( gridNode, tt );
|
||||
this.sleeping.put( gridNode, tt );
|
||||
else
|
||||
{
|
||||
awake.put( gridNode, tt );
|
||||
addToQueue( tt );
|
||||
this.awake.put( gridNode, tt );
|
||||
this.addToQueue( tt );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ public class ConnectionWrapper
|
||||
public IGridConnection connection;
|
||||
|
||||
public ConnectionWrapper(IGridConnection gc) {
|
||||
connection = gc;
|
||||
this.connection = gc;
|
||||
}
|
||||
|
||||
}
|
||||
+6
-6
@@ -34,27 +34,27 @@ public class Connections implements Callable
|
||||
public boolean destroy = false;
|
||||
|
||||
public Connections(PartP2PTunnelME o) {
|
||||
me = o;
|
||||
this.me = o;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object call() throws Exception
|
||||
{
|
||||
me.updateConnections( this );
|
||||
this.me.updateConnections( this );
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public void markDestroy()
|
||||
{
|
||||
create = false;
|
||||
destroy = true;
|
||||
this.create = false;
|
||||
this.destroy = true;
|
||||
}
|
||||
|
||||
public void markCreate()
|
||||
{
|
||||
create = true;
|
||||
destroy = false;
|
||||
this.create = true;
|
||||
this.destroy = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+21
-21
@@ -40,54 +40,54 @@ public class TickTracker implements Comparable<TickTracker>
|
||||
public int current_rate;
|
||||
|
||||
public TickTracker(TickingRequest req, IGridNode node, IGridTickable gt, long currentTick, TickManagerCache tickManagerCache) {
|
||||
request = req;
|
||||
this.request = req;
|
||||
this.gt = gt;
|
||||
this.node = node;
|
||||
current_rate = (req.minTickRate + req.maxTickRate) / 2;
|
||||
lastTick = currentTick;
|
||||
host = tickManagerCache;
|
||||
this.current_rate = (req.minTickRate + req.maxTickRate) / 2;
|
||||
this.lastTick = currentTick;
|
||||
this.host = tickManagerCache;
|
||||
}
|
||||
|
||||
public long getAvgNanos()
|
||||
{
|
||||
return (LastFiveTicksTime / 5);
|
||||
return (this.LastFiveTicksTime / 5);
|
||||
}
|
||||
|
||||
public void setRate(int rate)
|
||||
{
|
||||
current_rate = rate;
|
||||
this.current_rate = rate;
|
||||
|
||||
if ( current_rate < request.minTickRate )
|
||||
current_rate = request.minTickRate;
|
||||
if ( this.current_rate < this.request.minTickRate )
|
||||
this.current_rate = this.request.minTickRate;
|
||||
|
||||
if ( current_rate > request.maxTickRate )
|
||||
current_rate = request.maxTickRate;
|
||||
if ( this.current_rate > this.request.maxTickRate )
|
||||
this.current_rate = this.request.maxTickRate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(TickTracker t)
|
||||
{
|
||||
int nextTick = (int) ((lastTick - host.getCurrentTick()) + current_rate);
|
||||
int ts_nextTick = (int) ((t.lastTick - host.getCurrentTick()) + t.current_rate);
|
||||
int nextTick = (int) ((this.lastTick - this.host.getCurrentTick()) + this.current_rate);
|
||||
int ts_nextTick = (int) ((t.lastTick - this.host.getCurrentTick()) + t.current_rate);
|
||||
return nextTick - ts_nextTick;
|
||||
}
|
||||
|
||||
public void addEntityCrashInfo(CrashReportCategory crashreportcategory)
|
||||
{
|
||||
if ( gt instanceof AEBasePart )
|
||||
if ( this.gt instanceof AEBasePart )
|
||||
{
|
||||
AEBasePart part = (AEBasePart)gt;
|
||||
AEBasePart part = (AEBasePart)this.gt;
|
||||
part.addEntityCrashInfo( crashreportcategory );
|
||||
}
|
||||
|
||||
crashreportcategory.addCrashSection( "CurrentTickRate", current_rate );
|
||||
crashreportcategory.addCrashSection( "MinTickRate", request.minTickRate );
|
||||
crashreportcategory.addCrashSection( "MaxTickRate", request.maxTickRate );
|
||||
crashreportcategory.addCrashSection( "MachineType", gt.getClass().getName() );
|
||||
crashreportcategory.addCrashSection( "GridBlockType", node.getGridBlock().getClass().getName() );
|
||||
crashreportcategory.addCrashSection( "ConnectedSides", node.getConnectedSides() );
|
||||
crashreportcategory.addCrashSection( "CurrentTickRate", this.current_rate );
|
||||
crashreportcategory.addCrashSection( "MinTickRate", this.request.minTickRate );
|
||||
crashreportcategory.addCrashSection( "MaxTickRate", this.request.maxTickRate );
|
||||
crashreportcategory.addCrashSection( "MachineType", this.gt.getClass().getName() );
|
||||
crashreportcategory.addCrashSection( "GridBlockType", this.node.getGridBlock().getClass().getName() );
|
||||
crashreportcategory.addCrashSection( "ConnectedSides", this.node.getConnectedSides() );
|
||||
|
||||
DimensionalCoord dc = node.getGridBlock().getLocation();
|
||||
DimensionalCoord dc = this.node.getGridBlock().getLocation();
|
||||
if ( dc != null )
|
||||
crashreportcategory.addCrashSection( "Location", dc );
|
||||
}
|
||||
|
||||
@@ -31,35 +31,35 @@ public class TunnelCollection<T extends PartP2PTunnel> implements Iterable<T>
|
||||
Collection<T> tunnelSources;
|
||||
|
||||
public TunnelCollection(Collection<T> src, Class c) {
|
||||
tunnelSources = src;
|
||||
clz = c;
|
||||
this.tunnelSources = src;
|
||||
this.clz = c;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<T> iterator()
|
||||
{
|
||||
if ( tunnelSources == null )
|
||||
if ( this.tunnelSources == null )
|
||||
return new NullIterator<T>();
|
||||
return new TunnelIterator<T>( tunnelSources, clz );
|
||||
return new TunnelIterator<T>( this.tunnelSources, this.clz );
|
||||
}
|
||||
|
||||
public void setSource(Collection<T> c)
|
||||
{
|
||||
tunnelSources = c;
|
||||
this.tunnelSources = c;
|
||||
}
|
||||
|
||||
public boolean isEmpty()
|
||||
{
|
||||
return !iterator().hasNext();
|
||||
return !this.iterator().hasNext();
|
||||
}
|
||||
|
||||
public boolean matches(Class<? extends PartP2PTunnel> c)
|
||||
{
|
||||
return clz == c;
|
||||
return this.clz == c;
|
||||
}
|
||||
|
||||
public Class<? extends PartP2PTunnel> getClz()
|
||||
{
|
||||
return clz;
|
||||
return this.clz;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ public class TunnelConnection
|
||||
final public IGridConnection c;
|
||||
|
||||
public TunnelConnection(PartP2PTunnelME t, IGridConnection con) {
|
||||
tunnel = t;
|
||||
c = con;
|
||||
this.tunnel = t;
|
||||
this.c = con;
|
||||
}
|
||||
}
|
||||
+11
-11
@@ -32,32 +32,32 @@ public class TunnelIterator<T extends PartP2PTunnel> implements Iterator<T>
|
||||
|
||||
private void findNext()
|
||||
{
|
||||
while (Next == null && wrapped.hasNext())
|
||||
while (this.Next == null && this.wrapped.hasNext())
|
||||
{
|
||||
Next = wrapped.next();
|
||||
if ( !targetType.isInstance( Next ) )
|
||||
Next = null;
|
||||
this.Next = this.wrapped.next();
|
||||
if ( !this.targetType.isInstance( this.Next ) )
|
||||
this.Next = null;
|
||||
}
|
||||
}
|
||||
|
||||
public TunnelIterator(Collection<T> tunnelSources, Class clz) {
|
||||
wrapped = tunnelSources.iterator();
|
||||
targetType = clz;
|
||||
findNext();
|
||||
this.wrapped = tunnelSources.iterator();
|
||||
this.targetType = clz;
|
||||
this.findNext();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasNext()
|
||||
{
|
||||
findNext();
|
||||
return Next != null;
|
||||
this.findNext();
|
||||
return this.Next != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public T next()
|
||||
{
|
||||
T tmp = Next;
|
||||
Next = null;
|
||||
T tmp = this.Next;
|
||||
this.Next = null;
|
||||
return tmp;
|
||||
}
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ public abstract class MBCalculator
|
||||
final private IAEMultiBlock target;
|
||||
|
||||
public MBCalculator(IAEMultiBlock t) {
|
||||
target = t;
|
||||
this.target = t;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -78,7 +78,7 @@ public abstract class MBCalculator
|
||||
|
||||
public boolean isValidTileAt(World w, int x, int y, int z)
|
||||
{
|
||||
return isValidTile( w.getTileEntity( x, y, z ) );
|
||||
return this.isValidTile( w.getTileEntity( x, y, z ) );
|
||||
}
|
||||
|
||||
public void calculateMultiblock(World world, WorldCoord loc)
|
||||
@@ -92,44 +92,44 @@ public abstract class MBCalculator
|
||||
WorldCoord max = loc.copy();
|
||||
|
||||
// find size of MB structure...
|
||||
while (isValidTileAt( world, min.x - 1, min.y, min.z ))
|
||||
while (this.isValidTileAt( world, min.x - 1, min.y, min.z ))
|
||||
min.x--;
|
||||
while (isValidTileAt( world, min.x, min.y - 1, min.z ))
|
||||
while (this.isValidTileAt( world, min.x, min.y - 1, min.z ))
|
||||
min.y--;
|
||||
while (isValidTileAt( world, min.x, min.y, min.z - 1 ))
|
||||
while (this.isValidTileAt( world, min.x, min.y, min.z - 1 ))
|
||||
min.z--;
|
||||
while (isValidTileAt( world, max.x + 1, max.y, max.z ))
|
||||
while (this.isValidTileAt( world, max.x + 1, max.y, max.z ))
|
||||
max.x++;
|
||||
while (isValidTileAt( world, max.x, max.y + 1, max.z ))
|
||||
while (this.isValidTileAt( world, max.x, max.y + 1, max.z ))
|
||||
max.y++;
|
||||
while (isValidTileAt( world, max.x, max.y, max.z + 1 ))
|
||||
while (this.isValidTileAt( world, max.x, max.y, max.z + 1 ))
|
||||
max.z++;
|
||||
|
||||
if ( checkMultiblockScale( min, max ) )
|
||||
if ( this.checkMultiblockScale( min, max ) )
|
||||
{
|
||||
if ( verifyUnownedRegion( world, min, max ) )
|
||||
if ( this.verifyUnownedRegion( world, min, max ) )
|
||||
{
|
||||
IAECluster c = createCluster( world, min, max );
|
||||
IAECluster c = this.createCluster( world, min, max );
|
||||
|
||||
try
|
||||
{
|
||||
if ( !verifyInternalStructure( world, min, max ) )
|
||||
if ( !this.verifyInternalStructure( world, min, max ) )
|
||||
{
|
||||
disconnect();
|
||||
this.disconnect();
|
||||
return;
|
||||
}
|
||||
}
|
||||
catch (Exception err)
|
||||
{
|
||||
disconnect();
|
||||
this.disconnect();
|
||||
return;
|
||||
}
|
||||
|
||||
boolean updateGrid = false;
|
||||
IAECluster cluster = target.getCluster();
|
||||
IAECluster cluster = this.target.getCluster();
|
||||
if ( cluster == null )
|
||||
{
|
||||
updateTiles( c, world, min, max );
|
||||
this.updateTiles( c, world, min, max );
|
||||
|
||||
updateGrid = true;
|
||||
}
|
||||
@@ -146,7 +146,7 @@ public abstract class MBCalculator
|
||||
AELog.error( err );
|
||||
}
|
||||
|
||||
disconnect();
|
||||
this.disconnect();
|
||||
}
|
||||
|
||||
public abstract boolean verifyInternalStructure(World worldObj, WorldCoord min, WorldCoord max);
|
||||
@@ -190,7 +190,7 @@ public abstract class MBCalculator
|
||||
for (int z = minZ; z <= maxZ; z++)
|
||||
{
|
||||
TileEntity te = w.getTileEntity( x, y, z );
|
||||
if ( isValidTile( te ) )
|
||||
if ( this.isValidTile( te ) )
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -202,7 +202,7 @@ public abstract class MBCalculator
|
||||
public boolean verifyUnownedRegion(World w, WorldCoord min, WorldCoord max)
|
||||
{
|
||||
for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS)
|
||||
if ( verifyUnownedRegionInner( w, min.x, min.y, min.z, max.x, max.y, max.z, side ) )
|
||||
if ( this.verifyUnownedRegionInner( w, min.x, min.y, min.z, max.x, max.y, max.z, side ) )
|
||||
return false;
|
||||
|
||||
return true;
|
||||
|
||||
@@ -40,7 +40,7 @@ public class CraftingCPUCalculator extends MBCalculator
|
||||
|
||||
public CraftingCPUCalculator(IAEMultiBlock t) {
|
||||
super( t );
|
||||
tqb = (TileCraftingTile) t;
|
||||
this.tqb = (TileCraftingTile) t;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -110,7 +110,7 @@ public class CraftingCPUCalculator extends MBCalculator
|
||||
@Override
|
||||
public void disconnect()
|
||||
{
|
||||
tqb.disconnect( true );
|
||||
this.tqb.disconnect( true );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -122,12 +122,12 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU
|
||||
|
||||
protected Iterator<Entry<IMEMonitorHandlerReceiver<IAEItemStack>, Object>> getListeners()
|
||||
{
|
||||
return listeners.entrySet().iterator();
|
||||
return this.listeners.entrySet().iterator();
|
||||
}
|
||||
|
||||
protected void postChange(IAEItemStack diff, BaseActionSource src)
|
||||
{
|
||||
Iterator<Entry<IMEMonitorHandlerReceiver<IAEItemStack>, Object>> i = getListeners();
|
||||
Iterator<Entry<IMEMonitorHandlerReceiver<IAEItemStack>, Object>> i = this.getListeners();
|
||||
|
||||
ImmutableList<IAEItemStack> single = null;
|
||||
|
||||
@@ -152,7 +152,7 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU
|
||||
@Override
|
||||
public void addListener(IMEMonitorHandlerReceiver<IAEItemStack> l, Object verificationToken)
|
||||
{
|
||||
listeners.put( l, verificationToken );
|
||||
this.listeners.put( l, verificationToken );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -161,7 +161,7 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU
|
||||
@Override
|
||||
public void removeListener(IMEMonitorHandlerReceiver<IAEItemStack> l)
|
||||
{
|
||||
listeners.remove( l );
|
||||
this.listeners.remove( l );
|
||||
}
|
||||
|
||||
public void getListOfItem(IItemList<IAEItemStack> list, CraftingItemList whichList)
|
||||
@@ -169,11 +169,11 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU
|
||||
switch (whichList)
|
||||
{
|
||||
case ACTIVE:
|
||||
for (IAEItemStack ais : waitingFor)
|
||||
for (IAEItemStack ais : this.waitingFor)
|
||||
list.add( ais );
|
||||
break;
|
||||
case PENDING:
|
||||
for (Entry<ICraftingPatternDetails, TaskProgress> t : tasks.entrySet())
|
||||
for (Entry<ICraftingPatternDetails, TaskProgress> t : this.tasks.entrySet())
|
||||
{
|
||||
for (IAEItemStack ais : t.getKey().getCondensedOutputs())
|
||||
{
|
||||
@@ -184,16 +184,16 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU
|
||||
}
|
||||
break;
|
||||
case STORAGE:
|
||||
inventory.getAvailableItems( list );
|
||||
this.inventory.getAvailableItems( list );
|
||||
break;
|
||||
default:
|
||||
case ALL:
|
||||
inventory.getAvailableItems( list );
|
||||
this.inventory.getAvailableItems( list );
|
||||
|
||||
for (IAEItemStack ais : waitingFor)
|
||||
for (IAEItemStack ais : this.waitingFor)
|
||||
list.add( ais );
|
||||
|
||||
for (Entry<ICraftingPatternDetails, TaskProgress> t : tasks.entrySet())
|
||||
for (Entry<ICraftingPatternDetails, TaskProgress> t : this.tasks.entrySet())
|
||||
{
|
||||
for (IAEItemStack ais : t.getKey().getCondensedOutputs())
|
||||
{
|
||||
@@ -210,37 +210,37 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU
|
||||
@Override
|
||||
public Iterator<IGridHost> getTiles()
|
||||
{
|
||||
return (Iterator) tiles.iterator();
|
||||
return (Iterator) this.tiles.iterator();
|
||||
}
|
||||
|
||||
public IMEInventory<IAEItemStack> getInventory()
|
||||
{
|
||||
return inventory;
|
||||
return this.inventory;
|
||||
}
|
||||
|
||||
public CraftingCPUCluster(WorldCoord _min, WorldCoord _max)
|
||||
{
|
||||
min = _min;
|
||||
max = _max;
|
||||
this.min = _min;
|
||||
this.max = _max;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateStatus(boolean updateGrid)
|
||||
{
|
||||
for (TileCraftingTile r : tiles)
|
||||
for (TileCraftingTile r : this.tiles)
|
||||
r.updateMeta( true );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy()
|
||||
{
|
||||
if ( isDestroyed )
|
||||
if ( this.isDestroyed )
|
||||
return;
|
||||
isDestroyed = true;
|
||||
this.isDestroyed = true;
|
||||
|
||||
boolean posted = false;
|
||||
|
||||
for (TileCraftingTile r : tiles)
|
||||
for (TileCraftingTile r : this.tiles)
|
||||
{
|
||||
IGridNode n = r.getActionableNode();
|
||||
if ( n != null && !posted )
|
||||
@@ -260,40 +260,40 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU
|
||||
@Override
|
||||
public long getAvailableStorage()
|
||||
{
|
||||
return availableStorage;
|
||||
return this.availableStorage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCoProcessors()
|
||||
{
|
||||
return accelerator;
|
||||
return this.accelerator;
|
||||
}
|
||||
|
||||
public void addTile(TileCraftingTile te)
|
||||
{
|
||||
if ( machineSrc == null || te.isCoreBlock )
|
||||
machineSrc = new MachineSource( te );
|
||||
if ( this.machineSrc == null || te.isCoreBlock )
|
||||
this.machineSrc = new MachineSource( te );
|
||||
|
||||
te.isCoreBlock = false;
|
||||
te.markDirty();
|
||||
tiles.push( te );
|
||||
this.tiles.push( te );
|
||||
|
||||
if ( te.isStorage() )
|
||||
{
|
||||
availableStorage += te.getStorageBytes();
|
||||
storage.add( te );
|
||||
this.availableStorage += te.getStorageBytes();
|
||||
this.storage.add( te );
|
||||
}
|
||||
else if ( te.isStatus() )
|
||||
status.add( (TileCraftingMonitorTile) te );
|
||||
this.status.add( (TileCraftingMonitorTile) te );
|
||||
else if ( te.isAccelerator() )
|
||||
accelerator++;
|
||||
this.accelerator++;
|
||||
}
|
||||
|
||||
public boolean canAccept(IAEStack input)
|
||||
{
|
||||
if ( input instanceof IAEItemStack )
|
||||
{
|
||||
IAEItemStack is = waitingFor.findPrecise( (IAEItemStack) input );
|
||||
IAEItemStack is = this.waitingFor.findPrecise( (IAEItemStack) input );
|
||||
if ( is != null && is.getStackSize() > 0 )
|
||||
return true;
|
||||
}
|
||||
@@ -302,10 +302,10 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU
|
||||
|
||||
public void postCraftingStatusChange(IAEItemStack diff)
|
||||
{
|
||||
if ( getGrid() == null )
|
||||
if ( this.getGrid() == null )
|
||||
return;
|
||||
|
||||
CraftingGridCache sg = getGrid().getCache( ICraftingGrid.class );
|
||||
CraftingGridCache sg = this.getGrid().getCache( ICraftingGrid.class );
|
||||
|
||||
if ( sg.interestManager.containsKey( diff ) )
|
||||
{
|
||||
@@ -326,16 +326,16 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU
|
||||
if ( input instanceof IAEItemStack && type == Actionable.SIMULATE )// causes crafting to lock up?
|
||||
{
|
||||
IAEItemStack what = (IAEItemStack) input.copy();
|
||||
IAEItemStack is = waitingFor.findPrecise( what );
|
||||
IAEItemStack is = this.waitingFor.findPrecise( what );
|
||||
|
||||
if ( is != null && is.getStackSize() > 0 )
|
||||
{
|
||||
if ( is.getStackSize() >= what.getStackSize() )
|
||||
{
|
||||
if ( finalOutput.equals( what ) )
|
||||
if ( this.finalOutput.equals( what ) )
|
||||
{
|
||||
if ( myLastLink != null )
|
||||
return ((CraftingLink) myLastLink).injectItems( what.copy(), type );
|
||||
if ( this.myLastLink != null )
|
||||
return ((CraftingLink) this.myLastLink).injectItems( what.copy(), type );
|
||||
|
||||
return what; // ignore it.
|
||||
}
|
||||
@@ -349,11 +349,11 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU
|
||||
IAEItemStack used = what.copy();
|
||||
used.setStackSize( is.getStackSize() );
|
||||
|
||||
if ( finalOutput.equals( what ) )
|
||||
if ( this.finalOutput.equals( what ) )
|
||||
{
|
||||
if ( myLastLink != null )
|
||||
if ( this.myLastLink != null )
|
||||
{
|
||||
leftOver.add( ((CraftingLink) myLastLink).injectItems( used.copy(), type ) );
|
||||
leftOver.add( ((CraftingLink) this.myLastLink).injectItems( used.copy(), type ) );
|
||||
return leftOver;
|
||||
}
|
||||
|
||||
@@ -366,35 +366,35 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU
|
||||
else if ( input instanceof IAEItemStack && type == Actionable.MODULATE )
|
||||
{
|
||||
IAEItemStack what = (IAEItemStack) input;
|
||||
IAEItemStack is = waitingFor.findPrecise( what );
|
||||
IAEItemStack is = this.waitingFor.findPrecise( what );
|
||||
|
||||
if ( is != null && is.getStackSize() > 0 )
|
||||
{
|
||||
waiting = false;
|
||||
postChange( (IAEItemStack) input, src );
|
||||
this.waiting = false;
|
||||
this.postChange( (IAEItemStack) input, src );
|
||||
|
||||
if ( is.getStackSize() >= input.getStackSize() )
|
||||
{
|
||||
is.decStackSize( input.getStackSize() );
|
||||
markDirty();
|
||||
postCraftingStatusChange( is );
|
||||
this.markDirty();
|
||||
this.postCraftingStatusChange( is );
|
||||
|
||||
if ( finalOutput.equals( input ) )
|
||||
if ( this.finalOutput.equals( input ) )
|
||||
{
|
||||
finalOutput.decStackSize( input.getStackSize() );
|
||||
if ( finalOutput.getStackSize() <= 0 )
|
||||
completeJob();
|
||||
this.finalOutput.decStackSize( input.getStackSize() );
|
||||
if ( this.finalOutput.getStackSize() <= 0 )
|
||||
this.completeJob();
|
||||
|
||||
updateCPU();
|
||||
this.updateCPU();
|
||||
|
||||
if ( myLastLink != null )
|
||||
return ((CraftingLink) myLastLink).injectItems( (IAEItemStack) input, type );
|
||||
if ( this.myLastLink != null )
|
||||
return ((CraftingLink) this.myLastLink).injectItems( (IAEItemStack) input, type );
|
||||
|
||||
return input; // ignore it.
|
||||
}
|
||||
|
||||
// 2000
|
||||
return inventory.injectItems( what, type, src );
|
||||
return this.inventory.injectItems( what, type, src );
|
||||
}
|
||||
|
||||
IAEItemStack insert = what.copy();
|
||||
@@ -403,28 +403,28 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU
|
||||
|
||||
is.setStackSize( 0 );
|
||||
|
||||
if ( finalOutput.equals( insert ) )
|
||||
if ( this.finalOutput.equals( insert ) )
|
||||
{
|
||||
finalOutput.decStackSize( insert.getStackSize() );
|
||||
if ( finalOutput.getStackSize() <= 0 )
|
||||
completeJob();
|
||||
this.finalOutput.decStackSize( insert.getStackSize() );
|
||||
if ( this.finalOutput.getStackSize() <= 0 )
|
||||
this.completeJob();
|
||||
|
||||
updateCPU();
|
||||
this.updateCPU();
|
||||
|
||||
if ( myLastLink != null )
|
||||
if ( this.myLastLink != null )
|
||||
{
|
||||
what.add( ((CraftingLink) myLastLink).injectItems( insert.copy(), type ) );
|
||||
what.add( ((CraftingLink) this.myLastLink).injectItems( insert.copy(), type ) );
|
||||
return what;
|
||||
}
|
||||
|
||||
if ( myLastLink != null )
|
||||
return ((CraftingLink) myLastLink).injectItems( (IAEItemStack) input, type );
|
||||
if ( this.myLastLink != null )
|
||||
return ((CraftingLink) this.myLastLink).injectItems( (IAEItemStack) input, type );
|
||||
|
||||
return input; // ignore it.
|
||||
}
|
||||
|
||||
inventory.injectItems( insert, type, src );
|
||||
markDirty();
|
||||
this.inventory.injectItems( insert, type, src );
|
||||
this.markDirty();
|
||||
|
||||
return what;
|
||||
}
|
||||
@@ -435,18 +435,18 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU
|
||||
|
||||
private void updateCPU()
|
||||
{
|
||||
IAEItemStack send = finalOutput;
|
||||
IAEItemStack send = this.finalOutput;
|
||||
|
||||
if ( finalOutput != null && finalOutput.getStackSize() <= 0 )
|
||||
if ( this.finalOutput != null && this.finalOutput.getStackSize() <= 0 )
|
||||
send = null;
|
||||
|
||||
for (TileCraftingMonitorTile t : status)
|
||||
for (TileCraftingMonitorTile t : this.status)
|
||||
t.setJob( send );
|
||||
}
|
||||
|
||||
public IGrid getGrid()
|
||||
{
|
||||
for (TileCraftingTile r : tiles)
|
||||
for (TileCraftingTile r : this.tiles)
|
||||
{
|
||||
IGridNode gn = r.getActionableNode();
|
||||
if ( gn != null )
|
||||
@@ -462,11 +462,11 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU
|
||||
|
||||
private void completeJob()
|
||||
{
|
||||
if ( myLastLink != null )
|
||||
((CraftingLink) myLastLink).markDone();
|
||||
if ( this.myLastLink != null )
|
||||
((CraftingLink) this.myLastLink).markDone();
|
||||
|
||||
AELog.crafting( "marking job as complete" );
|
||||
isComplete = true;
|
||||
this.isComplete = true;
|
||||
}
|
||||
|
||||
private boolean canCraft(ICraftingPatternDetails details, IAEItemStack[] condensedInputs)
|
||||
@@ -478,11 +478,11 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU
|
||||
{
|
||||
boolean found = false;
|
||||
|
||||
for (IAEItemStack fuzz : inventory.getItemList().findFuzzy( g, FuzzyMode.IGNORE_ALL ))
|
||||
for (IAEItemStack fuzz : this.inventory.getItemList().findFuzzy( g, FuzzyMode.IGNORE_ALL ))
|
||||
{
|
||||
fuzz = fuzz.copy();
|
||||
fuzz.setStackSize( g.getStackSize() );
|
||||
IAEItemStack ais = inventory.extractItems( fuzz, Actionable.SIMULATE, machineSrc );
|
||||
IAEItemStack ais = this.inventory.extractItems( fuzz, Actionable.SIMULATE, this.machineSrc );
|
||||
ItemStack is = ais == null ? null : ais.getItemStack();
|
||||
|
||||
if ( is != null && is.stackSize == g.getStackSize() )
|
||||
@@ -502,7 +502,7 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU
|
||||
}
|
||||
else
|
||||
{
|
||||
IAEItemStack ais = inventory.extractItems( g.copy(), Actionable.SIMULATE, machineSrc );
|
||||
IAEItemStack ais = this.inventory.extractItems( g.copy(), Actionable.SIMULATE, this.machineSrc );
|
||||
ItemStack is = ais == null ? null : ais.getItemStack();
|
||||
|
||||
if ( is == null || is.stackSize < g.getStackSize() )
|
||||
@@ -515,76 +515,76 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU
|
||||
|
||||
public void cancel()
|
||||
{
|
||||
if ( myLastLink != null )
|
||||
myLastLink.cancel();
|
||||
if ( this.myLastLink != null )
|
||||
this.myLastLink.cancel();
|
||||
|
||||
IItemList<IAEItemStack> list;
|
||||
getListOfItem( list = AEApi.instance().storage().createItemList(), CraftingItemList.ALL );
|
||||
this.getListOfItem( list = AEApi.instance().storage().createItemList(), CraftingItemList.ALL );
|
||||
for (IAEItemStack is : list)
|
||||
postChange( is, machineSrc );
|
||||
this.postChange( is, this.machineSrc );
|
||||
|
||||
isComplete = true;
|
||||
myLastLink = null;
|
||||
tasks.clear();
|
||||
this.isComplete = true;
|
||||
this.myLastLink = null;
|
||||
this.tasks.clear();
|
||||
|
||||
ImmutableSet<IAEItemStack> items = ImmutableSet.copyOf( waitingFor );
|
||||
ImmutableSet<IAEItemStack> items = ImmutableSet.copyOf( this.waitingFor );
|
||||
|
||||
waitingFor.resetStatus();
|
||||
this.waitingFor.resetStatus();
|
||||
|
||||
for (IAEItemStack is : items)
|
||||
postCraftingStatusChange( is );
|
||||
this.postCraftingStatusChange( is );
|
||||
|
||||
finalOutput = null;
|
||||
updateCPU();
|
||||
this.finalOutput = null;
|
||||
this.updateCPU();
|
||||
|
||||
storeItems(); // marks dirty
|
||||
this.storeItems(); // marks dirty
|
||||
}
|
||||
|
||||
public void updateCraftingLogic(IGrid grid, IEnergyGrid eg, CraftingGridCache cc)
|
||||
{
|
||||
if ( !getCore().isActive() )
|
||||
if ( !this.getCore().isActive() )
|
||||
return;
|
||||
|
||||
if ( myLastLink != null )
|
||||
if ( this.myLastLink != null )
|
||||
{
|
||||
if ( myLastLink.isCanceled() )
|
||||
if ( this.myLastLink.isCanceled() )
|
||||
{
|
||||
myLastLink = null;
|
||||
cancel();
|
||||
this.myLastLink = null;
|
||||
this.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
if ( isComplete )
|
||||
if ( this.isComplete )
|
||||
{
|
||||
if ( inventory.getItemList().isEmpty() )
|
||||
if ( this.inventory.getItemList().isEmpty() )
|
||||
return;
|
||||
|
||||
storeItems();
|
||||
this.storeItems();
|
||||
return;
|
||||
}
|
||||
|
||||
waiting = false;
|
||||
if ( waiting || tasks.isEmpty() ) // nothing to do here...
|
||||
this.waiting = false;
|
||||
if ( this.waiting || this.tasks.isEmpty() ) // nothing to do here...
|
||||
return;
|
||||
|
||||
remainingOperations = accelerator + 1 - (usedOps[0] + usedOps[1] + usedOps[2]);
|
||||
int started = remainingOperations;
|
||||
this.remainingOperations = this.accelerator + 1 - (this.usedOps[0] + this.usedOps[1] + this.usedOps[2]);
|
||||
int started = this.remainingOperations;
|
||||
|
||||
if ( remainingOperations > 0 )
|
||||
if ( this.remainingOperations > 0 )
|
||||
{
|
||||
do
|
||||
{
|
||||
somethingChanged = false;
|
||||
executeCrafting( eg, cc );
|
||||
this.somethingChanged = false;
|
||||
this.executeCrafting( eg, cc );
|
||||
}
|
||||
while (somethingChanged && remainingOperations > 0);
|
||||
while (this.somethingChanged && this.remainingOperations > 0);
|
||||
}
|
||||
usedOps[2] = usedOps[1];
|
||||
usedOps[1] = usedOps[0];
|
||||
usedOps[0] = started - remainingOperations;
|
||||
this.usedOps[2] = this.usedOps[1];
|
||||
this.usedOps[1] = this.usedOps[0];
|
||||
this.usedOps[0] = started - this.remainingOperations;
|
||||
|
||||
if ( remainingOperations > 0 && !somethingChanged )
|
||||
waiting = true;
|
||||
if ( this.remainingOperations > 0 && !this.somethingChanged )
|
||||
this.waiting = true;
|
||||
}
|
||||
|
||||
private int remainingOperations;
|
||||
@@ -592,7 +592,7 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU
|
||||
|
||||
private void executeCrafting(IEnergyGrid eg, CraftingGridCache cc)
|
||||
{
|
||||
Iterator<Entry<ICraftingPatternDetails, TaskProgress>> i = tasks.entrySet().iterator();
|
||||
Iterator<Entry<ICraftingPatternDetails, TaskProgress>> i = this.tasks.entrySet().iterator();
|
||||
while (i.hasNext())
|
||||
{
|
||||
Entry<ICraftingPatternDetails, TaskProgress> e = i.next();
|
||||
@@ -603,7 +603,7 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU
|
||||
}
|
||||
|
||||
ICraftingPatternDetails details = e.getKey();
|
||||
if ( canCraft( details, details.getCondensedInputs() ) )
|
||||
if ( this.canCraft( details, details.getCondensedInputs() ) )
|
||||
{
|
||||
InventoryCrafting ic = null;
|
||||
|
||||
@@ -642,19 +642,19 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU
|
||||
found = false;
|
||||
if ( details.isCraftable() )
|
||||
{
|
||||
for (IAEItemStack fuzz : inventory.getItemList().findFuzzy( input[x], FuzzyMode.IGNORE_ALL ))
|
||||
for (IAEItemStack fuzz : this.inventory.getItemList().findFuzzy( input[x], FuzzyMode.IGNORE_ALL ))
|
||||
{
|
||||
fuzz = fuzz.copy();
|
||||
fuzz.setStackSize( input[x].getStackSize() );
|
||||
|
||||
if ( details.isValidItemForSlot( x, fuzz.getItemStack(), getWorld() ) )
|
||||
if ( details.isValidItemForSlot( x, fuzz.getItemStack(), this.getWorld() ) )
|
||||
{
|
||||
IAEItemStack ais = inventory.extractItems( fuzz, Actionable.MODULATE, machineSrc );
|
||||
IAEItemStack ais = this.inventory.extractItems( fuzz, Actionable.MODULATE, this.machineSrc );
|
||||
ItemStack is = ais == null ? null : ais.getItemStack();
|
||||
|
||||
if ( is != null )
|
||||
{
|
||||
postChange( AEItemStack.create( is ), machineSrc );
|
||||
this.postChange( AEItemStack.create( is ), this.machineSrc );
|
||||
ic.setInventorySlotContents( x, is );
|
||||
found = true;
|
||||
break;
|
||||
@@ -664,12 +664,12 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU
|
||||
}
|
||||
else
|
||||
{
|
||||
IAEItemStack ais = inventory.extractItems( input[x].copy(), Actionable.MODULATE, machineSrc );
|
||||
IAEItemStack ais = this.inventory.extractItems( input[x].copy(), Actionable.MODULATE, this.machineSrc );
|
||||
ItemStack is = ais == null ? null : ais.getItemStack();
|
||||
|
||||
if ( is != null )
|
||||
{
|
||||
postChange( input[x], machineSrc );
|
||||
this.postChange( input[x], this.machineSrc );
|
||||
ic.setInventorySlotContents( x, is );
|
||||
if ( is.stackSize == input[x].getStackSize() )
|
||||
{
|
||||
@@ -692,7 +692,7 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU
|
||||
{
|
||||
ItemStack is = ic.getStackInSlot( x );
|
||||
if ( is != null )
|
||||
inventory.injectItems( AEItemStack.create( is ), Actionable.MODULATE, machineSrc );
|
||||
this.inventory.injectItems( AEItemStack.create( is ), Actionable.MODULATE, this.machineSrc );
|
||||
}
|
||||
ic = null;
|
||||
break;
|
||||
@@ -701,20 +701,20 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU
|
||||
|
||||
if ( m.pushPattern( details, ic ) )
|
||||
{
|
||||
somethingChanged = true;
|
||||
remainingOperations--;
|
||||
this.somethingChanged = true;
|
||||
this.remainingOperations--;
|
||||
|
||||
for (IAEItemStack out : details.getCondensedOutputs())
|
||||
{
|
||||
postChange( out, machineSrc );
|
||||
waitingFor.add( out.copy() );
|
||||
postCraftingStatusChange( out.copy() );
|
||||
this.postChange( out, this.machineSrc );
|
||||
this.waitingFor.add( out.copy() );
|
||||
this.postCraftingStatusChange( out.copy() );
|
||||
}
|
||||
|
||||
if ( details.isCraftable() )
|
||||
{
|
||||
FMLCommonHandler.instance().firePlayerCraftingEvent( Platform.getPlayer( (WorldServer) getWorld() ),
|
||||
details.getOutput( ic, getWorld() ), ic );
|
||||
FMLCommonHandler.instance().firePlayerCraftingEvent( Platform.getPlayer( (WorldServer) this.getWorld() ),
|
||||
details.getOutput( ic, this.getWorld() ), ic );
|
||||
|
||||
for (int x = 0; x < ic.getSizeInventory(); x++)
|
||||
{
|
||||
@@ -722,21 +722,21 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU
|
||||
if ( output != null )
|
||||
{
|
||||
IAEItemStack cItem = AEItemStack.create( output );
|
||||
postChange( cItem, machineSrc );
|
||||
waitingFor.add( cItem );
|
||||
postCraftingStatusChange( cItem );
|
||||
this.postChange( cItem, this.machineSrc );
|
||||
this.waitingFor.add( cItem );
|
||||
this.postCraftingStatusChange( cItem );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ic = null; // hand off complete!
|
||||
markDirty();
|
||||
this.markDirty();
|
||||
|
||||
e.getValue().value--;
|
||||
if ( e.getValue().value <= 0 )
|
||||
continue;
|
||||
|
||||
if ( remainingOperations == 0 )
|
||||
if ( this.remainingOperations == 0 )
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -750,7 +750,7 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU
|
||||
ItemStack is = ic.getStackInSlot( x );
|
||||
if ( is != null )
|
||||
{
|
||||
inventory.injectItems( AEItemStack.create( is ), Actionable.MODULATE, machineSrc );
|
||||
this.inventory.injectItems( AEItemStack.create( is ), Actionable.MODULATE, this.machineSrc );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -760,47 +760,47 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU
|
||||
|
||||
private void storeItems()
|
||||
{
|
||||
IGrid g = getGrid();
|
||||
IGrid g = this.getGrid();
|
||||
if ( g == null )
|
||||
return;
|
||||
|
||||
IStorageGrid sg = g.getCache( IStorageGrid.class );
|
||||
IMEInventory<IAEItemStack> ii = sg.getItemInventory();
|
||||
|
||||
for (IAEItemStack is : inventory.getItemList())
|
||||
for (IAEItemStack is : this.inventory.getItemList())
|
||||
{
|
||||
is = inventory.extractItems( is.copy(), Actionable.MODULATE, machineSrc );
|
||||
is = this.inventory.extractItems( is.copy(), Actionable.MODULATE, this.machineSrc );
|
||||
|
||||
if ( is != null )
|
||||
{
|
||||
postChange( is, machineSrc );
|
||||
is = ii.injectItems( is, Actionable.MODULATE, machineSrc );
|
||||
this.postChange( is, this.machineSrc );
|
||||
is = ii.injectItems( is, Actionable.MODULATE, this.machineSrc );
|
||||
}
|
||||
|
||||
if ( is != null )
|
||||
inventory.injectItems( is, Actionable.MODULATE, machineSrc );
|
||||
this.inventory.injectItems( is, Actionable.MODULATE, this.machineSrc );
|
||||
}
|
||||
|
||||
if ( inventory.getItemList().isEmpty() )
|
||||
inventory = new MECraftingInventory();
|
||||
if ( this.inventory.getItemList().isEmpty() )
|
||||
this.inventory = new MECraftingInventory();
|
||||
|
||||
markDirty();
|
||||
this.markDirty();
|
||||
}
|
||||
|
||||
private World getWorld()
|
||||
{
|
||||
return getCore().getWorldObj();
|
||||
return this.getCore().getWorldObj();
|
||||
}
|
||||
|
||||
public ICraftingLink submitJob(IGrid g, ICraftingJob job, BaseActionSource src, ICraftingRequester requestingMachine)
|
||||
{
|
||||
if ( !tasks.isEmpty() || !waitingFor.isEmpty() )
|
||||
if ( !this.tasks.isEmpty() || !this.waitingFor.isEmpty() )
|
||||
return null;
|
||||
|
||||
if ( !(job instanceof CraftingJob) )
|
||||
return null;
|
||||
|
||||
if ( isBusy() || !isActive() || getAvailableStorage() < job.getByteTotal() )
|
||||
if ( this.isBusy() || !this.isActive() || this.getAvailableStorage() < job.getByteTotal() )
|
||||
return null;
|
||||
|
||||
IStorageGrid sg = g.getCache( IStorageGrid.class );
|
||||
@@ -809,46 +809,46 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU
|
||||
|
||||
try
|
||||
{
|
||||
waitingFor.resetStatus();
|
||||
this.waitingFor.resetStatus();
|
||||
((CraftingJob) job).tree.setJob( ci, this, src );
|
||||
if ( ci.commit( src ) )
|
||||
{
|
||||
finalOutput = job.getOutput();
|
||||
waiting = false;
|
||||
isComplete = false;
|
||||
markDirty();
|
||||
this.finalOutput = job.getOutput();
|
||||
this.waiting = false;
|
||||
this.isComplete = false;
|
||||
this.markDirty();
|
||||
|
||||
updateCPU();
|
||||
String craftID = generateCraftingID();
|
||||
this.updateCPU();
|
||||
String craftID = this.generateCraftingID();
|
||||
|
||||
myLastLink = new CraftingLink( generateLinkData( craftID, requestingMachine == null, false ), this );
|
||||
this.myLastLink = new CraftingLink( this.generateLinkData( craftID, requestingMachine == null, false ), this );
|
||||
|
||||
if ( requestingMachine == null )
|
||||
return myLastLink;
|
||||
return this.myLastLink;
|
||||
|
||||
ICraftingLink whatLink = new CraftingLink( generateLinkData( craftID, false, true ), requestingMachine );
|
||||
ICraftingLink whatLink = new CraftingLink( this.generateLinkData( craftID, false, true ), requestingMachine );
|
||||
|
||||
submitLink( myLastLink );
|
||||
submitLink( whatLink );
|
||||
this.submitLink( this.myLastLink );
|
||||
this.submitLink( whatLink );
|
||||
|
||||
IItemList<IAEItemStack> list;
|
||||
getListOfItem( list = AEApi.instance().storage().createItemList(), CraftingItemList.ALL );
|
||||
this.getListOfItem( list = AEApi.instance().storage().createItemList(), CraftingItemList.ALL );
|
||||
|
||||
for (IAEItemStack ge : list)
|
||||
postChange( ge, machineSrc );
|
||||
this.postChange( ge, this.machineSrc );
|
||||
|
||||
return whatLink;
|
||||
}
|
||||
else
|
||||
{
|
||||
tasks.clear();
|
||||
inventory.getItemList().resetStatus();
|
||||
this.tasks.clear();
|
||||
this.inventory.getItemList().resetStatus();
|
||||
}
|
||||
}
|
||||
catch (CraftBranchFailure e)
|
||||
{
|
||||
tasks.clear();
|
||||
inventory.getItemList().resetStatus();
|
||||
this.tasks.clear();
|
||||
this.inventory.getItemList().resetStatus();
|
||||
// AELog.error( e );
|
||||
}
|
||||
|
||||
@@ -857,9 +857,9 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU
|
||||
|
||||
private void submitLink(ICraftingLink myLastLink2)
|
||||
{
|
||||
if ( getGrid() != null )
|
||||
if ( this.getGrid() != null )
|
||||
{
|
||||
CraftingGridCache cc = getGrid().getCache( ICraftingGrid.class );
|
||||
CraftingGridCache cc = this.getGrid().getCache( ICraftingGrid.class );
|
||||
cc.addLink( (CraftingLink) myLastLink2 );
|
||||
}
|
||||
}
|
||||
@@ -868,7 +868,7 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU
|
||||
{
|
||||
long now = System.currentTimeMillis();
|
||||
int hash = System.identityHashCode( this );
|
||||
int hmm = finalOutput == null ? 0 : finalOutput.hashCode();
|
||||
int hmm = this.finalOutput == null ? 0 : this.finalOutput.hashCode();
|
||||
|
||||
return Long.toString( now, Character.MAX_RADIX ) + '-' + Integer.toString( hash, Character.MAX_RADIX ) + '-'
|
||||
+ Integer.toString( hmm, Character.MAX_RADIX );
|
||||
@@ -889,31 +889,31 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU
|
||||
|
||||
private void markDirty()
|
||||
{
|
||||
getCore().markDirty();
|
||||
this.getCore().markDirty();
|
||||
}
|
||||
|
||||
private TileCraftingTile getCore()
|
||||
{
|
||||
return (TileCraftingTile) machineSrc.via;
|
||||
return (TileCraftingTile) this.machineSrc.via;
|
||||
}
|
||||
|
||||
public void addStorage(IAEItemStack extractItems)
|
||||
{
|
||||
inventory.injectItems( extractItems, Actionable.MODULATE, null );
|
||||
this.inventory.injectItems( extractItems, Actionable.MODULATE, null );
|
||||
}
|
||||
|
||||
public void addEmitable(IAEItemStack i)
|
||||
{
|
||||
waitingFor.add( i );
|
||||
postCraftingStatusChange( i );
|
||||
this.waitingFor.add( i );
|
||||
this.postCraftingStatusChange( i );
|
||||
}
|
||||
|
||||
public void addCrafting(ICraftingPatternDetails details, long crafts)
|
||||
{
|
||||
TaskProgress i = tasks.get( details );
|
||||
TaskProgress i = this.tasks.get( details );
|
||||
|
||||
if ( i == null )
|
||||
tasks.put( details, i = new TaskProgress() );
|
||||
this.tasks.put( details, i = new TaskProgress() );
|
||||
|
||||
i.value += crafts;
|
||||
}
|
||||
@@ -921,14 +921,14 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU
|
||||
@Override
|
||||
public boolean isBusy()
|
||||
{
|
||||
Iterator<Entry<ICraftingPatternDetails, TaskProgress>> i = tasks.entrySet().iterator();
|
||||
Iterator<Entry<ICraftingPatternDetails, TaskProgress>> i = this.tasks.entrySet().iterator();
|
||||
while (i.hasNext())
|
||||
{
|
||||
if ( i.next().getValue().value <= 0 )
|
||||
i.remove();
|
||||
}
|
||||
|
||||
return !tasks.isEmpty() || !waitingFor.isEmpty();
|
||||
return !this.tasks.isEmpty() || !this.waitingFor.isEmpty();
|
||||
}
|
||||
|
||||
public IAEItemStack getItemStack(IAEItemStack what, CraftingItemList storage2)
|
||||
@@ -937,17 +937,17 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU
|
||||
switch (storage2)
|
||||
{
|
||||
case STORAGE:
|
||||
is = inventory.getItemList().findPrecise( what );
|
||||
is = this.inventory.getItemList().findPrecise( what );
|
||||
break;
|
||||
case ACTIVE:
|
||||
is = waitingFor.findPrecise( what );
|
||||
is = this.waitingFor.findPrecise( what );
|
||||
break;
|
||||
case PENDING:
|
||||
|
||||
is = what.copy();
|
||||
is.setStackSize( 0 );
|
||||
|
||||
for (Entry<ICraftingPatternDetails, TaskProgress> t : tasks.entrySet())
|
||||
for (Entry<ICraftingPatternDetails, TaskProgress> t : this.tasks.entrySet())
|
||||
{
|
||||
for (IAEItemStack ais : t.getKey().getCondensedOutputs())
|
||||
{
|
||||
@@ -972,18 +972,18 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU
|
||||
|
||||
public void readFromNBT(NBTTagCompound data)
|
||||
{
|
||||
finalOutput = AEItemStack.loadItemStackFromNBT( (NBTTagCompound) data.getTag( "finalOutput" ) );
|
||||
for (IAEItemStack ais : readList( (NBTTagList) data.getTag( "inventory" ) ))
|
||||
inventory.injectItems( ais, Actionable.MODULATE, machineSrc );
|
||||
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 );
|
||||
|
||||
waiting = data.getBoolean( "waiting" );
|
||||
isComplete = data.getBoolean( "isComplete" );
|
||||
this.waiting = data.getBoolean( "waiting" );
|
||||
this.isComplete = data.getBoolean( "isComplete" );
|
||||
|
||||
if ( data.hasKey( "link" ) )
|
||||
{
|
||||
NBTTagCompound link = data.getCompoundTag( "link" );
|
||||
myLastLink = new CraftingLink( link, this );
|
||||
submitLink( myLastLink );
|
||||
this.myLastLink = new CraftingLink( link, this );
|
||||
this.submitLink( this.myLastLink );
|
||||
}
|
||||
|
||||
NBTTagList list = data.getTagList( "tasks", 10 );
|
||||
@@ -994,45 +994,45 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU
|
||||
if ( pattern != null && pattern.getItem() instanceof ICraftingPatternItem )
|
||||
{
|
||||
ICraftingPatternItem cpi = (ICraftingPatternItem) pattern.getItem();
|
||||
ICraftingPatternDetails details = cpi.getPatternForItem( pattern.getItemStack(), getWorld() );
|
||||
ICraftingPatternDetails details = cpi.getPatternForItem( pattern.getItemStack(), this.getWorld() );
|
||||
if ( details != null )
|
||||
{
|
||||
TaskProgress tp = new TaskProgress();
|
||||
tp.value = item.getLong( "craftingProgress" );
|
||||
tasks.put( details, tp );
|
||||
this.tasks.put( details, tp );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
waitingFor = readList( (NBTTagList) data.getTag( "waitingFor" ) );
|
||||
for (IAEItemStack is : waitingFor)
|
||||
postCraftingStatusChange( is.copy() );
|
||||
this.waitingFor = this.readList( (NBTTagList) data.getTag( "waitingFor" ) );
|
||||
for (IAEItemStack is : this.waitingFor)
|
||||
this.postCraftingStatusChange( is.copy() );
|
||||
}
|
||||
|
||||
public void writeToNBT(NBTTagCompound data)
|
||||
{
|
||||
data.setTag( "finalOutput", writeItem( finalOutput ) );
|
||||
data.setTag( "inventory", writeList( inventory.getItemList() ) );
|
||||
data.setBoolean( "waiting", waiting );
|
||||
data.setBoolean( "isComplete", isComplete );
|
||||
data.setTag( "finalOutput", this.writeItem( this.finalOutput ) );
|
||||
data.setTag( "inventory", this.writeList( this.inventory.getItemList() ) );
|
||||
data.setBoolean( "waiting", this.waiting );
|
||||
data.setBoolean( "isComplete", this.isComplete );
|
||||
|
||||
if ( myLastLink != null )
|
||||
if ( this.myLastLink != null )
|
||||
{
|
||||
NBTTagCompound link = new NBTTagCompound();
|
||||
myLastLink.writeToNBT( link );
|
||||
this.myLastLink.writeToNBT( link );
|
||||
data.setTag( "link", link );
|
||||
}
|
||||
|
||||
NBTTagList list = new NBTTagList();
|
||||
for (Entry<ICraftingPatternDetails, TaskProgress> e : tasks.entrySet())
|
||||
for (Entry<ICraftingPatternDetails, TaskProgress> e : this.tasks.entrySet())
|
||||
{
|
||||
NBTTagCompound item = writeItem( AEItemStack.create( e.getKey().getPattern() ) );
|
||||
NBTTagCompound item = this.writeItem( AEItemStack.create( e.getKey().getPattern() ) );
|
||||
item.setLong( "craftingProgress", e.getValue().value );
|
||||
list.appendTag( item );
|
||||
}
|
||||
data.setTag( "tasks", list );
|
||||
|
||||
data.setTag( "waitingFor", writeList( waitingFor ) );
|
||||
data.setTag( "waitingFor", this.writeList( this.waitingFor ) );
|
||||
}
|
||||
|
||||
private IItemList<IAEItemStack> readList(NBTTagList tag)
|
||||
@@ -1056,7 +1056,7 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU
|
||||
NBTTagList out = new NBTTagList();
|
||||
|
||||
for (IAEItemStack ais : myList)
|
||||
out.appendTag( writeItem( ais ) );
|
||||
out.appendTag( this.writeItem( ais ) );
|
||||
|
||||
return out;
|
||||
}
|
||||
@@ -1073,44 +1073,44 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU
|
||||
|
||||
public void done()
|
||||
{
|
||||
TileCraftingTile core = getCore();
|
||||
TileCraftingTile core = this.getCore();
|
||||
|
||||
core.isCoreBlock = true;
|
||||
|
||||
if ( core.previousState != null )
|
||||
{
|
||||
readFromNBT( core.previousState );
|
||||
this.readFromNBT( core.previousState );
|
||||
core.previousState = null;
|
||||
}
|
||||
|
||||
updateCPU();
|
||||
updateName();
|
||||
this.updateCPU();
|
||||
this.updateName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseActionSource getActionSource()
|
||||
{
|
||||
return machineSrc;
|
||||
return this.machineSrc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
return myName;
|
||||
return this.myName;
|
||||
}
|
||||
|
||||
public void updateName()
|
||||
{
|
||||
myName = "";
|
||||
for (TileCraftingTile te : tiles)
|
||||
this.myName = "";
|
||||
for (TileCraftingTile te : this.tiles)
|
||||
{
|
||||
|
||||
if ( te.hasCustomName() )
|
||||
{
|
||||
if ( myName.length() > 0 )
|
||||
myName += ' ' + te.getCustomName();
|
||||
if ( this.myName.length() > 0 )
|
||||
this.myName += ' ' + te.getCustomName();
|
||||
else
|
||||
myName = te.getCustomName();
|
||||
this.myName = te.getCustomName();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1118,7 +1118,7 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU
|
||||
|
||||
public boolean isActive()
|
||||
{
|
||||
TileCraftingTile core = getCore();
|
||||
TileCraftingTile core = this.getCore();
|
||||
if ( core == null )
|
||||
return false;
|
||||
|
||||
@@ -1131,13 +1131,13 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU
|
||||
|
||||
public boolean isMaking(IAEItemStack what)
|
||||
{
|
||||
IAEItemStack wat = waitingFor.findPrecise( what );
|
||||
IAEItemStack wat = this.waitingFor.findPrecise( what );
|
||||
return wat != null && wat.getStackSize() > 0;
|
||||
}
|
||||
|
||||
public void breakCluster()
|
||||
{
|
||||
TileCraftingTile t = getCore();
|
||||
TileCraftingTile t = this.getCore();
|
||||
if ( t != null )
|
||||
t.breakCluster();
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ public class QuantumCalculator extends MBCalculator
|
||||
|
||||
public QuantumCalculator(IAEMultiBlock t) {
|
||||
super( t );
|
||||
tqb = (TileQuantumBridge) t;
|
||||
this.tqb = (TileQuantumBridge) t;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -85,7 +85,7 @@ public class QuantumCalculator extends MBCalculator
|
||||
else
|
||||
{
|
||||
if ( num == 1 || num == 3 || num == 7 || num == 9 )
|
||||
flags = (byte) (tqb.corner | num);
|
||||
flags = (byte) (this.tqb.corner | num);
|
||||
else
|
||||
flags = num;
|
||||
c.Ring[ringNum++] = te;
|
||||
@@ -107,7 +107,7 @@ public class QuantumCalculator extends MBCalculator
|
||||
@Override
|
||||
public void disconnect()
|
||||
{
|
||||
tqb.disconnect(true);
|
||||
this.tqb.disconnect(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -61,20 +61,20 @@ public class QuantumCluster implements ILocatable, IAECluster
|
||||
@Override
|
||||
public Iterator<IGridHost> getTiles()
|
||||
{
|
||||
return new ChainedIterator<IGridHost>( Ring[0], Ring[1], Ring[2], Ring[3], Ring[4], Ring[5], Ring[6], Ring[7], center );
|
||||
return new ChainedIterator<IGridHost>( this.Ring[0], this.Ring[1], this.Ring[2], this.Ring[3], this.Ring[4], this.Ring[5], this.Ring[6], this.Ring[7], this.center );
|
||||
}
|
||||
|
||||
public void setCenter(TileQuantumBridge c)
|
||||
{
|
||||
registered = true;
|
||||
this.registered = true;
|
||||
MinecraftForge.EVENT_BUS.register( this );
|
||||
center = c;
|
||||
this.center = c;
|
||||
}
|
||||
|
||||
public QuantumCluster(WorldCoord _min, WorldCoord _max) {
|
||||
min = _min;
|
||||
max = _max;
|
||||
Ring = new TileQuantumBridge[8];
|
||||
this.min = _min;
|
||||
this.max = _max;
|
||||
this.Ring = new TileQuantumBridge[8];
|
||||
}
|
||||
|
||||
public boolean canUseNode(long qe)
|
||||
@@ -102,10 +102,10 @@ public class QuantumCluster implements ILocatable, IAECluster
|
||||
@SubscribeEvent
|
||||
public void onUnload(WorldEvent.Unload e)
|
||||
{
|
||||
if ( center.getWorldObj() == e.world )
|
||||
if ( this.center.getWorldObj() == e.world )
|
||||
{
|
||||
updateStatus = false;
|
||||
destroy();
|
||||
this.updateStatus = false;
|
||||
this.destroy();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -114,24 +114,24 @@ public class QuantumCluster implements ILocatable, IAECluster
|
||||
{
|
||||
long qe;
|
||||
|
||||
qe = center.getQEFrequency();
|
||||
qe = this.center.getQEFrequency();
|
||||
|
||||
if ( thisSide != qe && thisSide != -qe )
|
||||
if ( this.thisSide != qe && this.thisSide != -qe )
|
||||
{
|
||||
if ( qe != 0 )
|
||||
{
|
||||
if ( thisSide != 0 )
|
||||
if ( this.thisSide != 0 )
|
||||
MinecraftForge.EVENT_BUS.post( new LocatableEventAnnounce( this, LocatableEvent.Unregister ) );
|
||||
|
||||
if ( canUseNode( -qe ) )
|
||||
if ( this.canUseNode( -qe ) )
|
||||
{
|
||||
otherSide = qe;
|
||||
thisSide = -qe;
|
||||
this.otherSide = qe;
|
||||
this.thisSide = -qe;
|
||||
}
|
||||
else if ( canUseNode( qe ) )
|
||||
else if ( this.canUseNode( qe ) )
|
||||
{
|
||||
thisSide = qe;
|
||||
otherSide = -qe;
|
||||
this.thisSide = qe;
|
||||
this.otherSide = -qe;
|
||||
}
|
||||
|
||||
MinecraftForge.EVENT_BUS.post( new LocatableEventAnnounce( this, LocatableEvent.Register ) );
|
||||
@@ -140,12 +140,12 @@ public class QuantumCluster implements ILocatable, IAECluster
|
||||
{
|
||||
MinecraftForge.EVENT_BUS.post( new LocatableEventAnnounce( this, LocatableEvent.Unregister ) );
|
||||
|
||||
otherSide = 0;
|
||||
thisSide = 0;
|
||||
this.otherSide = 0;
|
||||
this.thisSide = 0;
|
||||
}
|
||||
}
|
||||
|
||||
Object myOtherSide = otherSide == 0 ? null : AEApi.instance().registries().locatable().findLocatableBySerial( otherSide );
|
||||
Object myOtherSide = this.otherSide == 0 ? null : AEApi.instance().registries().locatable().findLocatableBySerial( this.otherSide );
|
||||
|
||||
boolean shutdown = false;
|
||||
|
||||
@@ -156,10 +156,10 @@ public class QuantumCluster implements ILocatable, IAECluster
|
||||
|
||||
if ( sideA.isActive() && sideB.isActive() )
|
||||
{
|
||||
if ( connection != null && connection.connection != null )
|
||||
if ( this.connection != null && this.connection.connection != null )
|
||||
{
|
||||
IGridNode a = connection.connection.a();
|
||||
IGridNode b = connection.connection.b();
|
||||
IGridNode a = this.connection.connection.a();
|
||||
IGridNode b = this.connection.connection.b();
|
||||
IGridNode sa = sideA.getNode();
|
||||
IGridNode sb = sideB.getNode();
|
||||
if ( (a == sa || b == sa) && (a == sb || b == sb) )
|
||||
@@ -199,13 +199,13 @@ public class QuantumCluster implements ILocatable, IAECluster
|
||||
else
|
||||
shutdown = true;
|
||||
|
||||
if ( shutdown && connection != null )
|
||||
if ( shutdown && this.connection != null )
|
||||
{
|
||||
if ( connection.connection != null )
|
||||
if ( this.connection.connection != null )
|
||||
{
|
||||
connection.connection.destroy();
|
||||
connection.connection = null;
|
||||
connection = new ConnectionWrapper( null );
|
||||
this.connection.connection.destroy();
|
||||
this.connection.connection = null;
|
||||
this.connection = new ConnectionWrapper( null );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -213,65 +213,65 @@ public class QuantumCluster implements ILocatable, IAECluster
|
||||
@Override
|
||||
public void destroy()
|
||||
{
|
||||
if ( isDestroyed )
|
||||
if ( this.isDestroyed )
|
||||
return;
|
||||
isDestroyed = true;
|
||||
this.isDestroyed = true;
|
||||
|
||||
if ( registered )
|
||||
if ( this.registered )
|
||||
{
|
||||
MinecraftForge.EVENT_BUS.unregister( this );
|
||||
registered = false;
|
||||
this.registered = false;
|
||||
}
|
||||
|
||||
if ( getLocatableSerial() != 0 )
|
||||
if ( this.getLocatableSerial() != 0 )
|
||||
{
|
||||
updateStatus( true );
|
||||
this.updateStatus( true );
|
||||
MinecraftForge.EVENT_BUS.post( new LocatableEventAnnounce( this, LocatableEvent.Unregister ) );
|
||||
}
|
||||
|
||||
center.updateStatus( null, (byte) -1, updateStatus );
|
||||
this.center.updateStatus( null, (byte) -1, this.updateStatus );
|
||||
|
||||
for (TileQuantumBridge r : Ring)
|
||||
for (TileQuantumBridge r : this.Ring)
|
||||
{
|
||||
r.updateStatus( null, (byte) -1, updateStatus );
|
||||
r.updateStatus( null, (byte) -1, this.updateStatus );
|
||||
}
|
||||
|
||||
center = null;
|
||||
Ring = new TileQuantumBridge[8];
|
||||
this.center = null;
|
||||
this.Ring = new TileQuantumBridge[8];
|
||||
}
|
||||
|
||||
public boolean isCorner(TileQuantumBridge tileQuantumBridge)
|
||||
{
|
||||
return Ring[0] == tileQuantumBridge || Ring[2] == tileQuantumBridge || Ring[4] == tileQuantumBridge || Ring[6] == tileQuantumBridge;
|
||||
return this.Ring[0] == tileQuantumBridge || this.Ring[2] == tileQuantumBridge || this.Ring[4] == tileQuantumBridge || this.Ring[6] == tileQuantumBridge;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getLocatableSerial()
|
||||
{
|
||||
return thisSide;
|
||||
return this.thisSide;
|
||||
}
|
||||
|
||||
public TileQuantumBridge getCenter()
|
||||
{
|
||||
return center;
|
||||
return this.center;
|
||||
}
|
||||
|
||||
public boolean hasQES()
|
||||
{
|
||||
return getLocatableSerial() != 0;
|
||||
return this.getLocatableSerial() != 0;
|
||||
}
|
||||
|
||||
private IGridNode getNode()
|
||||
{
|
||||
return center.getGridNode( ForgeDirection.UNKNOWN );
|
||||
return this.center.getGridNode( ForgeDirection.UNKNOWN );
|
||||
}
|
||||
|
||||
private boolean isActive()
|
||||
{
|
||||
if ( isDestroyed || !registered )
|
||||
if ( this.isDestroyed || !this.registered )
|
||||
return false;
|
||||
|
||||
return center.isPowered() && hasQES();
|
||||
return this.center.isPowered() && this.hasQES();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ public class SpatialPylonCalculator extends MBCalculator
|
||||
|
||||
public SpatialPylonCalculator(IAEMultiBlock t) {
|
||||
super( t );
|
||||
tqb = (TileSpatialPylon) t;
|
||||
this.tqb = (TileSpatialPylon) t;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -78,7 +78,7 @@ public class SpatialPylonCalculator extends MBCalculator
|
||||
@Override
|
||||
public void disconnect()
|
||||
{
|
||||
tqb.disconnect(true);
|
||||
this.tqb.disconnect(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -47,23 +47,23 @@ public class SpatialPylonCluster implements IAECluster
|
||||
public boolean hasChannel;
|
||||
|
||||
public SpatialPylonCluster(DimensionalCoord _min, DimensionalCoord _max) {
|
||||
min = _min.copy();
|
||||
max = _max.copy();
|
||||
this.min = _min.copy();
|
||||
this.max = _max.copy();
|
||||
|
||||
if ( min.x != max.x )
|
||||
currentAxis = Axis.X;
|
||||
else if ( min.y != max.y )
|
||||
currentAxis = Axis.Y;
|
||||
else if ( min.z != max.z )
|
||||
currentAxis = Axis.Z;
|
||||
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
|
||||
currentAxis = Axis.UNFORMED;
|
||||
this.currentAxis = Axis.UNFORMED;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateStatus(boolean updateGrid)
|
||||
{
|
||||
for (TileSpatialPylon r : line)
|
||||
for (TileSpatialPylon r : this.line)
|
||||
{
|
||||
r.recalculateDisplay();
|
||||
}
|
||||
@@ -73,11 +73,11 @@ public class SpatialPylonCluster implements IAECluster
|
||||
public void destroy()
|
||||
{
|
||||
|
||||
if ( isDestroyed )
|
||||
if ( this.isDestroyed )
|
||||
return;
|
||||
isDestroyed = true;
|
||||
this.isDestroyed = true;
|
||||
|
||||
for (TileSpatialPylon r : line)
|
||||
for (TileSpatialPylon r : this.line)
|
||||
{
|
||||
r.updateStatus( null );
|
||||
}
|
||||
@@ -86,13 +86,13 @@ public class SpatialPylonCluster implements IAECluster
|
||||
|
||||
public int tileCount()
|
||||
{
|
||||
return line.size();
|
||||
return this.line.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<IGridHost> getTiles()
|
||||
{
|
||||
return (Iterator) line.iterator();
|
||||
return (Iterator) this.line.iterator();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -29,25 +29,25 @@ public class EnergyThreshold implements Comparable<EnergyThreshold>
|
||||
final int hash;
|
||||
|
||||
public EnergyThreshold(double lim, IEnergyWatcher wat) {
|
||||
Limit = lim;
|
||||
watcher = wat;
|
||||
this.Limit = lim;
|
||||
this.watcher = wat;
|
||||
|
||||
if ( watcher != null )
|
||||
hash = watcher.hashCode() ^ ((Double) lim).hashCode();
|
||||
if ( this.watcher != null )
|
||||
this.hash = this.watcher.hashCode() ^ ((Double) lim).hashCode();
|
||||
else
|
||||
hash = ((Double) lim).hashCode();
|
||||
this.hash = ((Double) lim).hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
return hash;
|
||||
return this.hash;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(EnergyThreshold o)
|
||||
{
|
||||
return ItemSorters.compareDouble( Limit, o.Limit );
|
||||
return ItemSorters.compareDouble( this.Limit, o.Limit );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -40,28 +40,28 @@ public class EnergyWatcher implements IEnergyWatcher
|
||||
EnergyThreshold myLast;
|
||||
|
||||
public EnergyWatcherIterator(EnergyWatcher parent, Iterator<EnergyThreshold> i) {
|
||||
watcher = parent;
|
||||
interestIterator = i;
|
||||
this.watcher = parent;
|
||||
this.interestIterator = i;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasNext()
|
||||
{
|
||||
return interestIterator.hasNext();
|
||||
return this.interestIterator.hasNext();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Double next()
|
||||
{
|
||||
myLast = interestIterator.next();
|
||||
return myLast.Limit;
|
||||
this.myLast = this.interestIterator.next();
|
||||
return this.myLast.Limit;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove()
|
||||
{
|
||||
gsc.interests.remove( myLast );
|
||||
interestIterator.remove();
|
||||
EnergyWatcher.this.gsc.interests.remove( this.myLast );
|
||||
this.interestIterator.remove();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -72,27 +72,27 @@ public class EnergyWatcher implements IEnergyWatcher
|
||||
|
||||
public void post(EnergyGridCache energyGridCache)
|
||||
{
|
||||
myObject.onThresholdPass( energyGridCache );
|
||||
this.myObject.onThresholdPass( energyGridCache );
|
||||
}
|
||||
|
||||
public EnergyWatcher(EnergyGridCache cache, IEnergyWatcherHost host) {
|
||||
gsc = cache;
|
||||
myObject = host;
|
||||
this.gsc = cache;
|
||||
this.myObject = host;
|
||||
}
|
||||
|
||||
public IEnergyWatcherHost getHost()
|
||||
{
|
||||
return myObject;
|
||||
return this.myObject;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean add(Double e)
|
||||
{
|
||||
if ( myInterests.contains( e ) )
|
||||
if ( this.myInterests.contains( e ) )
|
||||
return false;
|
||||
|
||||
EnergyThreshold eh = new EnergyThreshold( e, this );
|
||||
return gsc.interests.add( eh ) && myInterests.add( eh );
|
||||
return this.gsc.interests.add( eh ) && this.myInterests.add( eh );
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -101,7 +101,7 @@ public class EnergyWatcher implements IEnergyWatcher
|
||||
boolean didChange = false;
|
||||
|
||||
for (Double o : c)
|
||||
didChange = add( o ) || didChange;
|
||||
didChange = this.add( o ) || didChange;
|
||||
|
||||
return didChange;
|
||||
}
|
||||
@@ -109,10 +109,10 @@ public class EnergyWatcher implements IEnergyWatcher
|
||||
@Override
|
||||
public void clear()
|
||||
{
|
||||
Iterator<EnergyThreshold> i = myInterests.iterator();
|
||||
Iterator<EnergyThreshold> i = this.myInterests.iterator();
|
||||
while (i.hasNext())
|
||||
{
|
||||
gsc.interests.remove( i.next() );
|
||||
this.gsc.interests.remove( i.next() );
|
||||
i.remove();
|
||||
}
|
||||
}
|
||||
@@ -120,32 +120,32 @@ public class EnergyWatcher implements IEnergyWatcher
|
||||
@Override
|
||||
public boolean contains(Object o)
|
||||
{
|
||||
return myInterests.contains( o );
|
||||
return this.myInterests.contains( o );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean containsAll(Collection<?> c)
|
||||
{
|
||||
return myInterests.containsAll( c );
|
||||
return this.myInterests.containsAll( c );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEmpty()
|
||||
{
|
||||
return myInterests.isEmpty();
|
||||
return this.myInterests.isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<Double> iterator()
|
||||
{
|
||||
return new EnergyWatcherIterator( this, myInterests.iterator() );
|
||||
return new EnergyWatcherIterator( this, this.myInterests.iterator() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean remove(Object o)
|
||||
{
|
||||
EnergyThreshold eh = new EnergyThreshold( (Double) o, this );
|
||||
return myInterests.remove( eh ) && gsc.interests.remove( eh );
|
||||
return this.myInterests.remove( eh ) && this.gsc.interests.remove( eh );
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -153,7 +153,7 @@ public class EnergyWatcher implements IEnergyWatcher
|
||||
{
|
||||
boolean didSomething = false;
|
||||
for (Object o : c)
|
||||
didSomething = remove( o ) || didSomething;
|
||||
didSomething = this.remove( o ) || didSomething;
|
||||
return didSomething;
|
||||
}
|
||||
|
||||
@@ -161,7 +161,7 @@ public class EnergyWatcher implements IEnergyWatcher
|
||||
public boolean retainAll(Collection<?> c)
|
||||
{
|
||||
boolean changed = false;
|
||||
Iterator<Double> i = iterator();
|
||||
Iterator<Double> i = this.iterator();
|
||||
|
||||
while (i.hasNext())
|
||||
{
|
||||
@@ -178,19 +178,19 @@ public class EnergyWatcher implements IEnergyWatcher
|
||||
@Override
|
||||
public int size()
|
||||
{
|
||||
return myInterests.size();
|
||||
return this.myInterests.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object[] toArray()
|
||||
{
|
||||
return myInterests.toArray();
|
||||
return this.myInterests.toArray();
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T[] toArray(T[] a)
|
||||
{
|
||||
return myInterests.toArray( a );
|
||||
return this.myInterests.toArray( a );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -75,60 +75,60 @@ public class AENetworkProxy implements IGridBlock
|
||||
@Override
|
||||
public ItemStack getMachineRepresentation()
|
||||
{
|
||||
return myRepInstance;
|
||||
return this.myRepInstance;
|
||||
}
|
||||
|
||||
public void setVisualRepresentation(ItemStack is)
|
||||
{
|
||||
myRepInstance = is;
|
||||
this.myRepInstance = is;
|
||||
}
|
||||
|
||||
public AENetworkProxy(IGridProxyable te, String nbtName, ItemStack visual, boolean inWorld) {
|
||||
this.gp = te;
|
||||
this.nbtName = nbtName;
|
||||
worldNode = inWorld;
|
||||
myRepInstance = visual;
|
||||
validSides = EnumSet.allOf( ForgeDirection.class );
|
||||
this.worldNode = inWorld;
|
||||
this.myRepInstance = visual;
|
||||
this.validSides = EnumSet.allOf( ForgeDirection.class );
|
||||
}
|
||||
|
||||
public void writeToNBT(NBTTagCompound tag)
|
||||
{
|
||||
if ( node != null )
|
||||
node.saveToNBT( nbtName, tag );
|
||||
if ( this.node != null )
|
||||
this.node.saveToNBT( this.nbtName, tag );
|
||||
}
|
||||
|
||||
public void readFromNBT(NBTTagCompound tag)
|
||||
{
|
||||
data = tag;
|
||||
if ( node != null && data != null )
|
||||
this.data = tag;
|
||||
if ( this.node != null && this.data != null )
|
||||
{
|
||||
node.loadFromNBT( nbtName, data );
|
||||
data = null;
|
||||
this.node.loadFromNBT( this.nbtName, this.data );
|
||||
this.data = null;
|
||||
}
|
||||
else if ( node != null && owner != null )
|
||||
else if ( this.node != null && this.owner != null )
|
||||
{
|
||||
node.setPlayerID( WorldSettings.getInstance().getPlayerID( owner.getGameProfile() ) );
|
||||
owner = null;
|
||||
this.node.setPlayerID( WorldSettings.getInstance().getPlayerID( this.owner.getGameProfile() ) );
|
||||
this.owner = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public DimensionalCoord getLocation()
|
||||
{
|
||||
return gp.getLocation();
|
||||
return this.gp.getLocation();
|
||||
}
|
||||
|
||||
@Override
|
||||
public AEColor getGridColor()
|
||||
{
|
||||
return myColor;
|
||||
return this.myColor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGridNotification(GridNotification notification)
|
||||
{
|
||||
if ( gp instanceof PartCable )
|
||||
((PartCable) gp).markForUpdate();
|
||||
if ( this.gp instanceof PartCable )
|
||||
((PartCable) this.gp).markForUpdate();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -140,69 +140,69 @@ public class AENetworkProxy implements IGridBlock
|
||||
@Override
|
||||
public EnumSet<ForgeDirection> getConnectableSides()
|
||||
{
|
||||
return validSides;
|
||||
return this.validSides;
|
||||
}
|
||||
|
||||
public void setValidSides(EnumSet<ForgeDirection> validSides)
|
||||
{
|
||||
this.validSides = validSides;
|
||||
if ( node != null )
|
||||
node.updateState();
|
||||
if ( this.node != null )
|
||||
this.node.updateState();
|
||||
}
|
||||
|
||||
public IGridNode getNode()
|
||||
{
|
||||
if ( node == null && Platform.isServer() && isReady )
|
||||
if ( this.node == null && Platform.isServer() && this.isReady )
|
||||
{
|
||||
node = AEApi.instance().createGridNode( this );
|
||||
readFromNBT( data );
|
||||
node.updateState();
|
||||
this.node = AEApi.instance().createGridNode( this );
|
||||
this.readFromNBT( this.data );
|
||||
this.node.updateState();
|
||||
}
|
||||
|
||||
return node;
|
||||
return this.node;
|
||||
}
|
||||
|
||||
public void validate()
|
||||
{
|
||||
if ( gp instanceof AEBaseTile )
|
||||
TickHandler.instance.addInit( (AEBaseTile) gp );
|
||||
if ( this.gp instanceof AEBaseTile )
|
||||
TickHandler.instance.addInit( (AEBaseTile) this.gp );
|
||||
}
|
||||
|
||||
public void onChunkUnload()
|
||||
{
|
||||
isReady = false;
|
||||
invalidate();
|
||||
this.isReady = false;
|
||||
this.invalidate();
|
||||
}
|
||||
|
||||
public void invalidate()
|
||||
{
|
||||
isReady = false;
|
||||
if ( node != null )
|
||||
this.isReady = false;
|
||||
if ( this.node != null )
|
||||
{
|
||||
node.destroy();
|
||||
node = null;
|
||||
this.node.destroy();
|
||||
this.node = null;
|
||||
}
|
||||
}
|
||||
|
||||
public void onReady()
|
||||
{
|
||||
isReady = true;
|
||||
this.isReady = true;
|
||||
|
||||
// send orientation based directionality to the node.
|
||||
if ( gp instanceof IOrientable )
|
||||
if ( this.gp instanceof IOrientable )
|
||||
{
|
||||
IOrientable ori = (IOrientable) gp;
|
||||
IOrientable ori = (IOrientable) this.gp;
|
||||
if ( ori.canBeRotated() )
|
||||
ori.setOrientation( ori.getForward(), ori.getUp() );
|
||||
}
|
||||
|
||||
getNode();
|
||||
this.getNode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IGridHost getMachine()
|
||||
{
|
||||
return gp;
|
||||
return this.gp;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -213,9 +213,9 @@ public class AENetworkProxy implements IGridBlock
|
||||
*/
|
||||
public IGrid getGrid() throws GridAccessException
|
||||
{
|
||||
if ( node == null )
|
||||
if ( this.node == null )
|
||||
throw new GridAccessException();
|
||||
IGrid grid = node.getGrid();
|
||||
IGrid grid = this.node.getGrid();
|
||||
if ( grid == null )
|
||||
throw new GridAccessException();
|
||||
return grid;
|
||||
@@ -223,7 +223,7 @@ public class AENetworkProxy implements IGridBlock
|
||||
|
||||
public IEnergyGrid getEnergy() throws GridAccessException
|
||||
{
|
||||
IGrid grid = getGrid();
|
||||
IGrid grid = this.getGrid();
|
||||
if ( grid == null )
|
||||
throw new GridAccessException();
|
||||
IEnergyGrid eg = grid.getCache( IEnergyGrid.class );
|
||||
@@ -234,7 +234,7 @@ public class AENetworkProxy implements IGridBlock
|
||||
|
||||
public IPathingGrid getPath() throws GridAccessException
|
||||
{
|
||||
IGrid grid = getGrid();
|
||||
IGrid grid = this.getGrid();
|
||||
if ( grid == null )
|
||||
throw new GridAccessException();
|
||||
IPathingGrid pg = grid.getCache( IPathingGrid.class );
|
||||
@@ -245,7 +245,7 @@ public class AENetworkProxy implements IGridBlock
|
||||
|
||||
public ITickManager getTick() throws GridAccessException
|
||||
{
|
||||
IGrid grid = getGrid();
|
||||
IGrid grid = this.getGrid();
|
||||
if ( grid == null )
|
||||
throw new GridAccessException();
|
||||
ITickManager pg = grid.getCache( ITickManager.class );
|
||||
@@ -256,7 +256,7 @@ public class AENetworkProxy implements IGridBlock
|
||||
|
||||
public IStorageGrid getStorage() throws GridAccessException
|
||||
{
|
||||
IGrid grid = getGrid();
|
||||
IGrid grid = this.getGrid();
|
||||
if ( grid == null )
|
||||
throw new GridAccessException();
|
||||
|
||||
@@ -270,7 +270,7 @@ public class AENetworkProxy implements IGridBlock
|
||||
|
||||
public P2PCache getP2P() throws GridAccessException
|
||||
{
|
||||
IGrid grid = getGrid();
|
||||
IGrid grid = this.getGrid();
|
||||
if ( grid == null )
|
||||
throw new GridAccessException();
|
||||
|
||||
@@ -284,7 +284,7 @@ public class AENetworkProxy implements IGridBlock
|
||||
|
||||
public ISecurityGrid getSecurity() throws GridAccessException
|
||||
{
|
||||
IGrid grid = getGrid();
|
||||
IGrid grid = this.getGrid();
|
||||
if ( grid == null )
|
||||
throw new GridAccessException();
|
||||
|
||||
@@ -298,7 +298,7 @@ public class AENetworkProxy implements IGridBlock
|
||||
|
||||
public ICraftingGrid getCrafting() throws GridAccessException
|
||||
{
|
||||
IGrid grid = getGrid();
|
||||
IGrid grid = this.getGrid();
|
||||
if ( grid == null )
|
||||
throw new GridAccessException();
|
||||
|
||||
@@ -313,13 +313,13 @@ public class AENetworkProxy implements IGridBlock
|
||||
@Override
|
||||
public boolean isWorldAccessible()
|
||||
{
|
||||
return worldNode;
|
||||
return this.worldNode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumSet<GridFlags> getFlags()
|
||||
{
|
||||
return flags;
|
||||
return this.flags;
|
||||
}
|
||||
|
||||
public void setFlags(GridFlags... requireChannel)
|
||||
@@ -334,19 +334,19 @@ public class AENetworkProxy implements IGridBlock
|
||||
@Override
|
||||
public double getIdlePowerUsage()
|
||||
{
|
||||
return idleDraw;
|
||||
return this.idleDraw;
|
||||
}
|
||||
|
||||
public void setIdlePowerUsage(double idle)
|
||||
{
|
||||
idleDraw = idle;
|
||||
this.idleDraw = idle;
|
||||
|
||||
if ( node != null )
|
||||
if ( this.node != null )
|
||||
{
|
||||
try
|
||||
{
|
||||
IGrid g = getGrid();
|
||||
g.postEvent( new MENetworkPowerIdleChange( node ) );
|
||||
IGrid g = this.getGrid();
|
||||
g.postEvent( new MENetworkPowerIdleChange( this.node ) );
|
||||
}
|
||||
catch (GridAccessException e)
|
||||
{
|
||||
@@ -357,22 +357,22 @@ public class AENetworkProxy implements IGridBlock
|
||||
|
||||
public boolean isReady()
|
||||
{
|
||||
return isReady;
|
||||
return this.isReady;
|
||||
}
|
||||
|
||||
public boolean isActive()
|
||||
{
|
||||
if ( node == null )
|
||||
if ( this.node == null )
|
||||
return false;
|
||||
|
||||
return node.isActive();
|
||||
return this.node.isActive();
|
||||
}
|
||||
|
||||
public boolean isPowered()
|
||||
{
|
||||
try
|
||||
{
|
||||
return getEnergy().isNetworkPowered();
|
||||
return this.getEnergy().isNetworkPowered();
|
||||
}
|
||||
catch (GridAccessException e)
|
||||
{
|
||||
@@ -383,12 +383,12 @@ public class AENetworkProxy implements IGridBlock
|
||||
@Override
|
||||
public void gridChanged()
|
||||
{
|
||||
gp.gridChanged();
|
||||
this.gp.gridChanged();
|
||||
}
|
||||
|
||||
public void setOwner(EntityPlayer player)
|
||||
{
|
||||
owner = player;
|
||||
this.owner = player;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ public class AENetworkProxyMultiblock extends AENetworkProxy implements IGridMul
|
||||
|
||||
IAECluster getCluster()
|
||||
{
|
||||
return ((IAEMultiBlock) getMachine()).getCluster();
|
||||
return ((IAEMultiBlock) this.getMachine()).getCluster();
|
||||
}
|
||||
|
||||
public AENetworkProxyMultiblock(IGridProxyable te, String nbtName, ItemStack itemStack, boolean inWorld) {
|
||||
@@ -43,9 +43,9 @@ public class AENetworkProxyMultiblock extends AENetworkProxy implements IGridMul
|
||||
@Override
|
||||
public Iterator<IGridNode> getMultiblockNodes()
|
||||
{
|
||||
if ( getCluster() == null )
|
||||
if ( this.getCluster() == null )
|
||||
return new ChainedIterator<IGridNode>();
|
||||
|
||||
return new ProxyNodeIterator( getCluster().getTiles() );
|
||||
return new ProxyNodeIterator( this.getCluster().getTiles() );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,15 +30,15 @@ public class ChannelPowerSrc implements IEnergySource
|
||||
final IEnergySource realSrc;
|
||||
|
||||
public ChannelPowerSrc(IGridNode networkNode, IEnergySource src) {
|
||||
node = networkNode;
|
||||
realSrc = src;
|
||||
this.node = networkNode;
|
||||
this.realSrc = src;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double extractAEPower(double amt, Actionable mode, PowerMultiplier usePowerMultiplier)
|
||||
{
|
||||
if ( node.isActive() )
|
||||
return realSrc.extractAEPower( amt, mode, usePowerMultiplier );
|
||||
if ( this.node.isActive() )
|
||||
return this.realSrc.extractAEPower( amt, mode, usePowerMultiplier );
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
|
||||
@@ -36,9 +36,9 @@ public class GenericInterestManager<T>
|
||||
public final T iw;
|
||||
|
||||
public SavedTransactions(boolean putOperation, IAEStack myStack, T watcher) {
|
||||
put = putOperation;
|
||||
stack = myStack;
|
||||
iw = watcher;
|
||||
this.put = putOperation;
|
||||
this.stack = myStack;
|
||||
this.iw = watcher;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,66 +47,66 @@ public class GenericInterestManager<T>
|
||||
private int transDepth = 0;
|
||||
|
||||
public GenericInterestManager(Multimap<IAEStack, T> interests) {
|
||||
container = interests;
|
||||
this.container = interests;
|
||||
}
|
||||
|
||||
public void enableTransactions()
|
||||
{
|
||||
if ( transDepth == 0 )
|
||||
transactions = new LinkedList<SavedTransactions>();
|
||||
if ( this.transDepth == 0 )
|
||||
this.transactions = new LinkedList<SavedTransactions>();
|
||||
|
||||
transDepth++;
|
||||
this.transDepth++;
|
||||
}
|
||||
|
||||
public void disableTransactions()
|
||||
{
|
||||
transDepth--;
|
||||
this.transDepth--;
|
||||
|
||||
if ( transDepth == 0 )
|
||||
if ( this.transDepth == 0 )
|
||||
{
|
||||
LinkedList<SavedTransactions> myActions = transactions;
|
||||
transactions = null;
|
||||
LinkedList<SavedTransactions> myActions = this.transactions;
|
||||
this.transactions = null;
|
||||
|
||||
for (SavedTransactions t : myActions)
|
||||
{
|
||||
if ( t.put )
|
||||
put( t.stack, t.iw );
|
||||
this.put( t.stack, t.iw );
|
||||
else
|
||||
remove( t.stack, t.iw );
|
||||
this.remove( t.stack, t.iw );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean containsKey(IAEStack stack)
|
||||
{
|
||||
return container.containsKey( stack );
|
||||
return this.container.containsKey( stack );
|
||||
}
|
||||
|
||||
public Collection<T> get(IAEStack stack)
|
||||
{
|
||||
return container.get( stack );
|
||||
return this.container.get( stack );
|
||||
}
|
||||
|
||||
public boolean put(IAEStack stack, T iw)
|
||||
{
|
||||
if ( transactions != null )
|
||||
if ( this.transactions != null )
|
||||
{
|
||||
transactions.add( new SavedTransactions( true, stack, iw ) );
|
||||
this.transactions.add( new SavedTransactions( true, stack, iw ) );
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return container.put( stack, iw );
|
||||
return this.container.put( stack, iw );
|
||||
}
|
||||
|
||||
public boolean remove(IAEStack stack, T iw)
|
||||
{
|
||||
if ( transactions != null )
|
||||
if ( this.transactions != null )
|
||||
{
|
||||
transactions.add( new SavedTransactions( true, stack, iw ) );
|
||||
this.transactions.add( new SavedTransactions( true, stack, iw ) );
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return container.remove( stack, iw );
|
||||
return this.container.remove( stack, iw );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ public class AdHocChannelUpdater implements IGridConnectionVisitor
|
||||
final private int usedChannels;
|
||||
|
||||
public AdHocChannelUpdater(int used) {
|
||||
usedChannels = used;
|
||||
this.usedChannels = used;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -38,7 +38,7 @@ public class AdHocChannelUpdater implements IGridConnectionVisitor
|
||||
{
|
||||
GridNode gn = (GridNode) n;
|
||||
gn.setControllerRoute( null, true );
|
||||
gn.incrementChannelCount( usedChannels );
|
||||
gn.incrementChannelCount( this.usedChannels );
|
||||
gn.finalizeChannels();
|
||||
return true;
|
||||
}
|
||||
@@ -48,7 +48,7 @@ public class AdHocChannelUpdater implements IGridConnectionVisitor
|
||||
{
|
||||
GridConnection gc = (GridConnection) gcc;
|
||||
gc.setControllerRoute( null, true );
|
||||
gc.incrementChannelCount( usedChannels );
|
||||
gc.incrementChannelCount( this.usedChannels );
|
||||
gc.finalizeChannels();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,40 +38,40 @@ public class ControllerValidator implements IGridVisitor
|
||||
public int found = 0;
|
||||
|
||||
public ControllerValidator(int x, int y, int z) {
|
||||
minX = x;
|
||||
minY = y;
|
||||
minZ = z;
|
||||
maxX = x;
|
||||
maxY = y;
|
||||
maxZ = z;
|
||||
this.minX = x;
|
||||
this.minY = y;
|
||||
this.minZ = z;
|
||||
this.maxX = x;
|
||||
this.maxY = y;
|
||||
this.maxZ = z;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean visitNode(IGridNode n)
|
||||
{
|
||||
IGridHost host = n.getMachine();
|
||||
if ( isValid && host instanceof TileController )
|
||||
if ( this.isValid && host instanceof TileController )
|
||||
{
|
||||
TileController c = (TileController) host;
|
||||
|
||||
minX = Math.min( c.xCoord, minX );
|
||||
maxX = Math.max( c.xCoord, maxX );
|
||||
minY = Math.min( c.yCoord, minY );
|
||||
maxY = Math.max( c.yCoord, maxY );
|
||||
minZ = Math.min( c.zCoord, minZ );
|
||||
maxZ = Math.max( c.zCoord, maxZ );
|
||||
this.minX = Math.min( c.xCoord, this.minX );
|
||||
this.maxX = Math.max( c.xCoord, this.maxX );
|
||||
this.minY = Math.min( c.yCoord, this.minY );
|
||||
this.maxY = Math.max( c.yCoord, this.maxY );
|
||||
this.minZ = Math.min( c.zCoord, this.minZ );
|
||||
this.maxZ = Math.max( c.zCoord, this.maxZ );
|
||||
|
||||
if ( maxX - minX < 7 && maxY - minY < 7 && maxZ - minZ < 7 )
|
||||
if ( this.maxX - this.minX < 7 && this.maxY - this.minY < 7 && this.maxZ - this.minZ < 7 )
|
||||
{
|
||||
found++;
|
||||
this.found++;
|
||||
return true;
|
||||
}
|
||||
|
||||
isValid = false;
|
||||
this.isValid = false;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
|
||||
return isValid;
|
||||
return this.isValid;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,8 +41,8 @@ public class PathSegment
|
||||
this.open = open;
|
||||
this.semiOpen = semiOpen;
|
||||
this.closed = closed;
|
||||
pgc = myPGC;
|
||||
isDead = false;
|
||||
this.pgc = myPGC;
|
||||
this.isDead = false;
|
||||
}
|
||||
|
||||
List<IPathItem> open;
|
||||
@@ -51,8 +51,8 @@ public class PathSegment
|
||||
|
||||
public boolean step()
|
||||
{
|
||||
List<IPathItem> oldOpen = open;
|
||||
open = new LinkedList<IPathItem>();
|
||||
List<IPathItem> oldOpen = this.open;
|
||||
this.open = new LinkedList<IPathItem>();
|
||||
|
||||
for (IPathItem i : oldOpen)
|
||||
{
|
||||
@@ -60,21 +60,21 @@ public class PathSegment
|
||||
{
|
||||
EnumSet<GridFlags> flags = pi.getFlags();
|
||||
|
||||
if ( !closed.contains( pi ) )
|
||||
if ( !this.closed.contains( pi ) )
|
||||
{
|
||||
pi.setControllerRoute( i, true );
|
||||
|
||||
if ( flags.contains( GridFlags.REQUIRE_CHANNEL ) )
|
||||
{
|
||||
// close the semi open.
|
||||
if ( !semiOpen.contains( pi ) )
|
||||
if ( !this.semiOpen.contains( pi ) )
|
||||
{
|
||||
boolean worked;
|
||||
|
||||
if ( flags.contains( GridFlags.COMPRESSED_CHANNEL ) )
|
||||
worked = useDenseChannel( pi );
|
||||
worked = this.useDenseChannel( pi );
|
||||
else
|
||||
worked = useChannel( pi );
|
||||
worked = this.useChannel( pi );
|
||||
|
||||
if ( worked && flags.contains( GridFlags.MULTIBLOCK ) )
|
||||
{
|
||||
@@ -83,24 +83,24 @@ public class PathSegment
|
||||
{
|
||||
IGridNode otherNodes = oni.next();
|
||||
if ( otherNodes != pi )
|
||||
semiOpen.add( (IPathItem) otherNodes );
|
||||
this.semiOpen.add( (IPathItem) otherNodes );
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
pi.incrementChannelCount( 1 ); // give a channel.
|
||||
semiOpen.remove( pi );
|
||||
this.semiOpen.remove( pi );
|
||||
}
|
||||
}
|
||||
|
||||
closed.add( pi );
|
||||
open.add( pi );
|
||||
this.closed.add( pi );
|
||||
this.open.add( pi );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return open.isEmpty();
|
||||
return this.open.isEmpty();
|
||||
}
|
||||
|
||||
private boolean useChannel(IPathItem start)
|
||||
@@ -117,12 +117,12 @@ public class PathSegment
|
||||
pi = start;
|
||||
while (pi != null)
|
||||
{
|
||||
pgc.channelsByBlocks++;
|
||||
this.pgc.channelsByBlocks++;
|
||||
pi.incrementChannelCount( 1 );
|
||||
pi = pi.getControllerRoute();
|
||||
}
|
||||
|
||||
pgc.channelsInUse++;
|
||||
this.pgc.channelsInUse++;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -140,12 +140,12 @@ public class PathSegment
|
||||
pi = start;
|
||||
while (pi != null)
|
||||
{
|
||||
pgc.channelsByBlocks++;
|
||||
this.pgc.channelsByBlocks++;
|
||||
pi.incrementChannelCount( 1 );
|
||||
pi = pi.getControllerRoute();
|
||||
}
|
||||
|
||||
pgc.channelsInUse++;
|
||||
this.pgc.channelsInUse++;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -69,29 +69,29 @@ public class CellInventory implements ICellInventory
|
||||
final protected ISaveProvider container;
|
||||
|
||||
protected CellInventory(NBTTagCompound data, ISaveProvider container) {
|
||||
tagCompound = data;
|
||||
this.tagCompound = data;
|
||||
this.container = container;
|
||||
}
|
||||
|
||||
protected void loadCellItems()
|
||||
{
|
||||
if ( cellItems == null )
|
||||
cellItems = AEApi.instance().storage().createItemList();
|
||||
if ( this.cellItems == null )
|
||||
this.cellItems = AEApi.instance().storage().createItemList();
|
||||
|
||||
cellItems.resetStatus(); // clears totals and stuff.
|
||||
this.cellItems.resetStatus(); // clears totals and stuff.
|
||||
|
||||
int types = (int) getStoredItemTypes();
|
||||
int types = (int) this.getStoredItemTypes();
|
||||
|
||||
for (int x = 0; x < types; x++)
|
||||
{
|
||||
ItemStack t = ItemStack.loadItemStackFromNBT( tagCompound.getCompoundTag( ITEM_SLOT_ARR[x] ) );
|
||||
ItemStack t = ItemStack.loadItemStackFromNBT( this.tagCompound.getCompoundTag( ITEM_SLOT_ARR[x] ) );
|
||||
if ( t != null )
|
||||
{
|
||||
t.stackSize = tagCompound.getInteger( ITEM_SLOT_COUNT_ARR[x] );
|
||||
t.stackSize = this.tagCompound.getInteger( ITEM_SLOT_COUNT_ARR[x] );
|
||||
|
||||
if ( t.stackSize > 0 )
|
||||
{
|
||||
cellItems.add( AEItemStack.create( t ) );
|
||||
this.cellItems.add( AEItemStack.create( t ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -106,11 +106,11 @@ public class CellInventory implements ICellInventory
|
||||
|
||||
// add new pretty stuff...
|
||||
int x = 0;
|
||||
for (IAEItemStack v : cellItems)
|
||||
for (IAEItemStack v : this.cellItems)
|
||||
{
|
||||
itemCount += v.getStackSize();
|
||||
|
||||
NBTBase c = tagCompound.getTag( ITEM_SLOT_ARR[x] );
|
||||
NBTBase c = this.tagCompound.getTag( ITEM_SLOT_ARR[x] );
|
||||
if ( c instanceof NBTTagCompound )
|
||||
{
|
||||
v.writeToNBT( (NBTTagCompound) c );
|
||||
@@ -119,21 +119,21 @@ public class CellInventory implements ICellInventory
|
||||
{
|
||||
NBTTagCompound g = new NBTTagCompound();
|
||||
v.writeToNBT( g );
|
||||
tagCompound.setTag( ITEM_SLOT_ARR[x], g );
|
||||
this.tagCompound.setTag( ITEM_SLOT_ARR[x], g );
|
||||
}
|
||||
|
||||
/*
|
||||
* NBTBase tagSlotCount = tagCompound.getTag( ITEM_SLOT_COUNT_ARR[x] ); if ( tagSlotCount instanceof
|
||||
* NBTTagInt ) ((NBTTagInt) tagSlotCount).data = (int) v.getStackSize(); else
|
||||
*/
|
||||
tagCompound.setInteger( ITEM_SLOT_COUNT_ARR[x], (int) v.getStackSize() );
|
||||
this.tagCompound.setInteger( ITEM_SLOT_COUNT_ARR[x], (int) v.getStackSize() );
|
||||
|
||||
x++;
|
||||
}
|
||||
|
||||
// NBTBase tagType = tagCompound.getTag( ITEM_TYPE_TAG );
|
||||
// NBTBase tagCount = tagCompound.getTag( ITEM_COUNT_TAG );
|
||||
short oldStoredItems = storedItems;
|
||||
short oldStoredItems = this.storedItems;
|
||||
|
||||
/*
|
||||
* if ( tagType instanceof NBTTagShort ) ((NBTTagShort) tagType).data = storedItems = (short) cellItems.size();
|
||||
@@ -163,23 +163,23 @@ public class CellInventory implements ICellInventory
|
||||
}
|
||||
|
||||
// clean any old crusty stuff...
|
||||
for (; x < oldStoredItems && x < MAX_ITEM_TYPES; x++)
|
||||
for (; x < oldStoredItems && x < this.MAX_ITEM_TYPES; x++)
|
||||
{
|
||||
tagCompound.removeTag( ITEM_SLOT_ARR[x] );
|
||||
tagCompound.removeTag( ITEM_SLOT_COUNT_ARR[x] );
|
||||
this.tagCompound.removeTag( ITEM_SLOT_ARR[x] );
|
||||
this.tagCompound.removeTag( ITEM_SLOT_COUNT_ARR[x] );
|
||||
}
|
||||
|
||||
if ( container != null )
|
||||
container.saveChanges( this );
|
||||
if ( this.container != null )
|
||||
this.container.saveChanges( this );
|
||||
}
|
||||
|
||||
protected CellInventory(ItemStack o, ISaveProvider container) throws AppEngException {
|
||||
if ( ITEM_SLOT_ARR == null )
|
||||
{
|
||||
ITEM_SLOT_ARR = new String[MAX_ITEM_TYPES];
|
||||
ITEM_SLOT_COUNT_ARR = new String[MAX_ITEM_TYPES];
|
||||
ITEM_SLOT_ARR = new String[this.MAX_ITEM_TYPES];
|
||||
ITEM_SLOT_COUNT_ARR = new String[this.MAX_ITEM_TYPES];
|
||||
|
||||
for (int x = 0; x < MAX_ITEM_TYPES; x++)
|
||||
for (int x = 0; x < this.MAX_ITEM_TYPES; x++)
|
||||
{
|
||||
ITEM_SLOT_ARR[x] = ITEM_SLOT + x;
|
||||
ITEM_SLOT_COUNT_ARR[x] = ITEM_SLOT_COUNT + x;
|
||||
@@ -191,60 +191,60 @@ public class CellInventory implements ICellInventory
|
||||
throw new AppEngException( "ItemStack was used as a cell, but was not a cell!" );
|
||||
}
|
||||
|
||||
CellType = null;
|
||||
i = o;
|
||||
this.CellType = null;
|
||||
this.i = o;
|
||||
|
||||
Item type = i.getItem();
|
||||
Item type = this.i.getItem();
|
||||
if ( type instanceof IStorageCell )
|
||||
{
|
||||
CellType = (IStorageCell) i.getItem();
|
||||
MAX_ITEM_TYPES = CellType.getTotalTypes( i );
|
||||
this.CellType = (IStorageCell) this.i.getItem();
|
||||
this.MAX_ITEM_TYPES = this.CellType.getTotalTypes( this.i );
|
||||
}
|
||||
|
||||
if ( CellType == null )
|
||||
if ( this.CellType == null )
|
||||
{
|
||||
throw new AppEngException( "ItemStack was used as a cell, but was not a cell!" );
|
||||
}
|
||||
|
||||
if ( !CellType.isStorageCell( i ) )
|
||||
if ( !this.CellType.isStorageCell( this.i ) )
|
||||
{
|
||||
throw new AppEngException( "ItemStack was used as a cell, but was not a cell!" );
|
||||
}
|
||||
|
||||
if ( MAX_ITEM_TYPES > 63 )
|
||||
MAX_ITEM_TYPES = 63;
|
||||
if ( MAX_ITEM_TYPES < 1 )
|
||||
MAX_ITEM_TYPES = 1;
|
||||
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;
|
||||
tagCompound = Platform.openNbtData( o );
|
||||
storedItems = tagCompound.getShort( ITEM_TYPE_TAG );
|
||||
storedItemCount = tagCompound.getInteger( ITEM_COUNT_TAG );
|
||||
cellItems = null;
|
||||
this.tagCompound = Platform.openNbtData( o );
|
||||
this.storedItems = this.tagCompound.getShort( ITEM_TYPE_TAG );
|
||||
this.storedItemCount = this.tagCompound.getInteger( ITEM_COUNT_TAG );
|
||||
this.cellItems = null;
|
||||
}
|
||||
|
||||
IItemList<IAEItemStack> getCellItems()
|
||||
{
|
||||
if ( cellItems == null )
|
||||
if ( this.cellItems == null )
|
||||
{
|
||||
cellItems = AEApi.instance().storage().createItemList();
|
||||
loadCellItems();
|
||||
this.cellItems = AEApi.instance().storage().createItemList();
|
||||
this.loadCellItems();
|
||||
}
|
||||
|
||||
return cellItems;
|
||||
return this.cellItems;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBytesPerType()
|
||||
{
|
||||
return CellType.BytePerType( i );
|
||||
return this.CellType.BytePerType( this.i );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canHoldNewItem()
|
||||
{
|
||||
long bytesFree = getFreeBytes();
|
||||
return (bytesFree > getBytesPerType() || (bytesFree == getBytesPerType() && getUnusedItemCount() > 0)) && getRemainingItemTypes() > 0;
|
||||
long bytesFree = this.getFreeBytes();
|
||||
return (bytesFree > this.getBytesPerType() || (bytesFree == this.getBytesPerType() && this.getUnusedItemCount() > 0)) && this.getRemainingItemTypes() > 0;
|
||||
}
|
||||
|
||||
public static IMEInventoryHandler getCell(ItemStack o, ISaveProvider container2)
|
||||
@@ -301,64 +301,64 @@ public class CellInventory implements ICellInventory
|
||||
@Override
|
||||
public long getTotalBytes()
|
||||
{
|
||||
return CellType.getBytes( i );
|
||||
return this.CellType.getBytes( this.i );
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getFreeBytes()
|
||||
{
|
||||
return getTotalBytes() - getUsedBytes();
|
||||
return this.getTotalBytes() - this.getUsedBytes();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getUsedBytes()
|
||||
{
|
||||
long bytesForItemCount = (getStoredItemCount() + getUnusedItemCount()) / 8;
|
||||
return getStoredItemTypes() * getBytesPerType() + bytesForItemCount;
|
||||
long bytesForItemCount = (this.getStoredItemCount() + this.getUnusedItemCount()) / 8;
|
||||
return this.getStoredItemTypes() * this.getBytesPerType() + bytesForItemCount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getTotalItemTypes()
|
||||
{
|
||||
return MAX_ITEM_TYPES;
|
||||
return this.MAX_ITEM_TYPES;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getStoredItemTypes()
|
||||
{
|
||||
return storedItems;
|
||||
return this.storedItems;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getStoredItemCount()
|
||||
{
|
||||
return storedItemCount;
|
||||
return this.storedItemCount;
|
||||
}
|
||||
|
||||
private void updateItemCount(long delta)
|
||||
{
|
||||
tagCompound.setInteger( ITEM_COUNT_TAG, storedItemCount = (int) (storedItemCount + delta) );
|
||||
this.tagCompound.setInteger( ITEM_COUNT_TAG, this.storedItemCount = (int) (this.storedItemCount + delta) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getRemainingItemTypes()
|
||||
{
|
||||
long basedOnStorage = getFreeBytes() / getBytesPerType();
|
||||
long baseOnTotal = getTotalItemTypes() - getStoredItemTypes();
|
||||
long basedOnStorage = this.getFreeBytes() / this.getBytesPerType();
|
||||
long baseOnTotal = this.getTotalItemTypes() - this.getStoredItemTypes();
|
||||
return basedOnStorage > baseOnTotal ? baseOnTotal : basedOnStorage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getRemainingItemCount()
|
||||
{
|
||||
long remaining = getFreeBytes() * 8 + getUnusedItemCount();
|
||||
long remaining = this.getFreeBytes() * 8 + this.getUnusedItemCount();
|
||||
return remaining > 0 ? remaining : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getUnusedItemCount()
|
||||
{
|
||||
int div = (int) (getStoredItemCount() % 8);
|
||||
int div = (int) (this.getStoredItemCount() % 8);
|
||||
|
||||
if ( div == 0 )
|
||||
{
|
||||
@@ -395,7 +395,7 @@ public class CellInventory implements ICellInventory
|
||||
if ( input.getStackSize() == 0 )
|
||||
return null;
|
||||
|
||||
if ( isBlackListed( input ) || CellType.isBlackListed( i, input ) )
|
||||
if ( isBlackListed( input ) || this.CellType.isBlackListed( this.i, input ) )
|
||||
return input;
|
||||
|
||||
ItemStack sharedItemStack = input.getItemStack();
|
||||
@@ -403,14 +403,14 @@ public class CellInventory implements ICellInventory
|
||||
if ( CellInventory.isStorageCell( sharedItemStack ) )
|
||||
{
|
||||
IMEInventory meInventory = getCell( sharedItemStack, null );
|
||||
if ( meInventory != null && !isEmpty( meInventory ) )
|
||||
if ( meInventory != null && !this.isEmpty( meInventory ) )
|
||||
return input;
|
||||
}
|
||||
|
||||
IAEItemStack l = getCellItems().findPrecise( input );
|
||||
IAEItemStack l = this.getCellItems().findPrecise( input );
|
||||
if ( l != null )
|
||||
{
|
||||
long remainingItemSlots = getRemainingItemCount();
|
||||
long remainingItemSlots = this.getRemainingItemCount();
|
||||
if ( remainingItemSlots < 0 )
|
||||
return input;
|
||||
|
||||
@@ -421,8 +421,8 @@ public class CellInventory implements ICellInventory
|
||||
if ( mode == Actionable.MODULATE )
|
||||
{
|
||||
l.setStackSize( l.getStackSize() + remainingItemSlots );
|
||||
updateItemCount( remainingItemSlots );
|
||||
saveChanges();
|
||||
this.updateItemCount( remainingItemSlots );
|
||||
this.saveChanges();
|
||||
}
|
||||
return r;
|
||||
}
|
||||
@@ -431,16 +431,16 @@ public class CellInventory implements ICellInventory
|
||||
if ( mode == Actionable.MODULATE )
|
||||
{
|
||||
l.setStackSize( l.getStackSize() + input.getStackSize() );
|
||||
updateItemCount( input.getStackSize() );
|
||||
saveChanges();
|
||||
this.updateItemCount( input.getStackSize() );
|
||||
this.saveChanges();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
if ( canHoldNewItem() ) // room for new type, and for at least one item!
|
||||
if ( this.canHoldNewItem() ) // room for new type, and for at least one item!
|
||||
{
|
||||
int remainingItemCount = (int) getRemainingItemCount() - getBytesPerType() * 8;
|
||||
int remainingItemCount = (int) this.getRemainingItemCount() - this.getBytesPerType() * 8;
|
||||
if ( remainingItemCount > 0 )
|
||||
{
|
||||
if ( input.getStackSize() > remainingItemCount )
|
||||
@@ -452,19 +452,19 @@ public class CellInventory implements ICellInventory
|
||||
ItemStack toWrite = Platform.cloneItemStack( sharedItemStack );
|
||||
toWrite.stackSize = remainingItemCount;
|
||||
|
||||
cellItems.add( AEItemStack.create( toWrite ) );
|
||||
updateItemCount( toWrite.stackSize );
|
||||
this.cellItems.add( AEItemStack.create( toWrite ) );
|
||||
this.updateItemCount( toWrite.stackSize );
|
||||
|
||||
saveChanges();
|
||||
this.saveChanges();
|
||||
}
|
||||
return AEItemStack.create( toReturn );
|
||||
}
|
||||
|
||||
if ( mode == Actionable.MODULATE )
|
||||
{
|
||||
updateItemCount( input.getStackSize() );
|
||||
cellItems.add( input );
|
||||
saveChanges();
|
||||
this.updateItemCount( input.getStackSize() );
|
||||
this.cellItems.add( input );
|
||||
this.saveChanges();
|
||||
}
|
||||
|
||||
return null;
|
||||
@@ -485,7 +485,7 @@ public class CellInventory implements ICellInventory
|
||||
|
||||
IAEItemStack Results = null;
|
||||
|
||||
IAEItemStack l = getCellItems().findPrecise( request );
|
||||
IAEItemStack l = this.getCellItems().findPrecise( request );
|
||||
if ( l != null )
|
||||
{
|
||||
Results = l.copy();
|
||||
@@ -495,9 +495,9 @@ public class CellInventory implements ICellInventory
|
||||
Results.setStackSize( l.getStackSize() );
|
||||
if ( mode == Actionable.MODULATE )
|
||||
{
|
||||
updateItemCount( -l.getStackSize() );
|
||||
this.updateItemCount( -l.getStackSize() );
|
||||
l.setStackSize( 0 );
|
||||
saveChanges();
|
||||
this.saveChanges();
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -506,8 +506,8 @@ public class CellInventory implements ICellInventory
|
||||
if ( mode == Actionable.MODULATE )
|
||||
{
|
||||
l.setStackSize( l.getStackSize() - size );
|
||||
updateItemCount( -size );
|
||||
saveChanges();
|
||||
this.updateItemCount( -size );
|
||||
this.saveChanges();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -518,7 +518,7 @@ public class CellInventory implements ICellInventory
|
||||
@Override
|
||||
public IItemList getAvailableItems(IItemList out)
|
||||
{
|
||||
for (IAEItemStack i : getCellItems())
|
||||
for (IAEItemStack i : this.getCellItems())
|
||||
out.add( i );
|
||||
|
||||
return out;
|
||||
@@ -533,33 +533,33 @@ public class CellInventory implements ICellInventory
|
||||
@Override
|
||||
public double getIdleDrain()
|
||||
{
|
||||
return CellType.getIdleDrain();
|
||||
return this.CellType.getIdleDrain();
|
||||
}
|
||||
|
||||
@Override
|
||||
public FuzzyMode getFuzzyMode()
|
||||
{
|
||||
return CellType.getFuzzyMode( this.i );
|
||||
return this.CellType.getFuzzyMode( this.i );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IInventory getConfigInventory()
|
||||
{
|
||||
return CellType.getConfigInventory( this.i );
|
||||
return this.CellType.getConfigInventory( this.i );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IInventory getUpgradesInventory()
|
||||
{
|
||||
return CellType.getUpgradesInventory( this.i );
|
||||
return this.CellType.getUpgradesInventory( this.i );
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStatusForCell()
|
||||
{
|
||||
if ( canHoldNewItem() )
|
||||
if ( this.canHoldNewItem() )
|
||||
return 1;
|
||||
if ( getRemainingItemCount() > 0 )
|
||||
if ( this.getRemainingItemCount() > 0 )
|
||||
return 2;
|
||||
return 3;
|
||||
}
|
||||
@@ -567,7 +567,7 @@ public class CellInventory implements ICellInventory
|
||||
@Override
|
||||
public ItemStack getItemStack()
|
||||
{
|
||||
return i;
|
||||
return this.i;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ public class CellInventoryHandler extends MEInventoryHandler<IAEItemStack> imple
|
||||
|
||||
NBTTagCompound openNbtData()
|
||||
{
|
||||
return Platform.openNbtData( getCellInv().getItemStack() );
|
||||
return Platform.openNbtData( this.getCellInv().getItemStack() );
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -59,7 +59,7 @@ public class CellInventoryHandler extends MEInventoryHandler<IAEItemStack> imple
|
||||
CellInventoryHandler(IMEInventory c) {
|
||||
super( c, StorageChannel.ITEMS );
|
||||
|
||||
ICellInventory ci = getCellInv();
|
||||
ICellInventory ci = this.getCellInv();
|
||||
if ( ci != null )
|
||||
{
|
||||
IItemList<IAEItemStack> priorityList = AEApi.instance().storage().createItemList();
|
||||
@@ -100,14 +100,14 @@ public class CellInventoryHandler extends MEInventoryHandler<IAEItemStack> imple
|
||||
priorityList.add( AEItemStack.create( is ) );
|
||||
}
|
||||
|
||||
myWhitelist = hasInverter ? IncludeExclude.BLACKLIST : IncludeExclude.WHITELIST;
|
||||
this.myWhitelist = hasInverter ? IncludeExclude.BLACKLIST : IncludeExclude.WHITELIST;
|
||||
|
||||
if ( !priorityList.isEmpty() )
|
||||
{
|
||||
if ( hasFuzzy )
|
||||
myPartitionList = new FuzzyPriorityList<IAEItemStack>( priorityList, fzMode );
|
||||
this.myPartitionList = new FuzzyPriorityList<IAEItemStack>( priorityList, fzMode );
|
||||
else
|
||||
myPartitionList = new PrecisePriorityList<IAEItemStack>( priorityList );
|
||||
this.myPartitionList = new PrecisePriorityList<IAEItemStack>( priorityList );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -115,26 +115,26 @@ public class CellInventoryHandler extends MEInventoryHandler<IAEItemStack> imple
|
||||
@Override
|
||||
public boolean isPreformatted()
|
||||
{
|
||||
return ! myPartitionList.isEmpty();
|
||||
return ! this.myPartitionList.isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFuzzy()
|
||||
{
|
||||
return myPartitionList instanceof FuzzyPriorityList;
|
||||
return this.myPartitionList instanceof FuzzyPriorityList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IncludeExclude getIncludeExcludeMode()
|
||||
{
|
||||
return myWhitelist;
|
||||
return this.myWhitelist;
|
||||
}
|
||||
|
||||
public int getStatusForCell()
|
||||
{
|
||||
int val = getCellInv().getStatusForCell();
|
||||
int val = this.getCellInv().getStatusForCell();
|
||||
|
||||
if ( val == 1 && isPreformatted() )
|
||||
if ( val == 1 && this.isPreformatted() )
|
||||
val = 2;
|
||||
|
||||
return val;
|
||||
|
||||
@@ -48,14 +48,14 @@ public class CreativeCellInventory implements IMEInventoryHandler<IAEItemStack>
|
||||
{
|
||||
IAEItemStack i = AEItemStack.create( is );
|
||||
i.setStackSize( Integer.MAX_VALUE );
|
||||
itemListCache.add( i );
|
||||
this.itemListCache.add( i );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAEItemStack injectItems(IAEItemStack input, Actionable mode, BaseActionSource src)
|
||||
{
|
||||
IAEItemStack local = itemListCache.findPrecise( input );
|
||||
IAEItemStack local = this.itemListCache.findPrecise( input );
|
||||
if ( local == null )
|
||||
return input;
|
||||
|
||||
@@ -65,7 +65,7 @@ public class CreativeCellInventory implements IMEInventoryHandler<IAEItemStack>
|
||||
@Override
|
||||
public IAEItemStack extractItems(IAEItemStack request, Actionable mode, BaseActionSource src)
|
||||
{
|
||||
IAEItemStack local = itemListCache.findPrecise( request );
|
||||
IAEItemStack local = this.itemListCache.findPrecise( request );
|
||||
if ( local == null )
|
||||
return null;
|
||||
|
||||
@@ -75,7 +75,7 @@ public class CreativeCellInventory implements IMEInventoryHandler<IAEItemStack>
|
||||
@Override
|
||||
public IItemList<IAEItemStack> getAvailableItems(IItemList out)
|
||||
{
|
||||
for (IAEItemStack ais : itemListCache)
|
||||
for (IAEItemStack ais : this.itemListCache)
|
||||
out.add( ais );
|
||||
return out;
|
||||
}
|
||||
@@ -95,13 +95,13 @@ public class CreativeCellInventory implements IMEInventoryHandler<IAEItemStack>
|
||||
@Override
|
||||
public boolean isPrioritized(IAEItemStack input)
|
||||
{
|
||||
return itemListCache.findPrecise( input ) != null;
|
||||
return this.itemListCache.findPrecise( input ) != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canAccept(IAEItemStack input)
|
||||
{
|
||||
return itemListCache.findPrecise( input ) != null;
|
||||
return this.itemListCache.findPrecise( input ) != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -37,8 +37,8 @@ public class DriveWatcher<T extends IAEStack<T>> extends MEInventoryHandler<T>
|
||||
public DriveWatcher(IMEInventory<T> i, ItemStack is, ICellHandler han, IChestOrDrive cod) {
|
||||
super( i, i.getChannel() );
|
||||
this.is = is;
|
||||
handler = han;
|
||||
cord = cod;
|
||||
this.handler = han;
|
||||
this.cord = cod;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -50,11 +50,11 @@ public class DriveWatcher<T extends IAEStack<T>> extends MEInventoryHandler<T>
|
||||
|
||||
if ( a == null || a.getStackSize() != size )
|
||||
{
|
||||
int newStatus = handler.getStatusForCell( is, getInternal() );
|
||||
int newStatus = this.handler.getStatusForCell( this.is, this.getInternal() );
|
||||
|
||||
if ( newStatus != oldStatus )
|
||||
if ( newStatus != this.oldStatus )
|
||||
{
|
||||
cord.blinkCell( getSlot() );
|
||||
this.cord.blinkCell( this.getSlot() );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,11 +68,11 @@ public class DriveWatcher<T extends IAEStack<T>> extends MEInventoryHandler<T>
|
||||
|
||||
if ( a != null )
|
||||
{
|
||||
int newStatus = handler.getStatusForCell( is, getInternal() );
|
||||
int newStatus = this.handler.getStatusForCell( this.is, this.getInternal() );
|
||||
|
||||
if ( newStatus != oldStatus )
|
||||
if ( newStatus != this.oldStatus )
|
||||
{
|
||||
cord.blinkCell( getSlot() );
|
||||
this.cord.blinkCell( this.getSlot() );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -41,27 +41,27 @@ public class ItemWatcher implements IStackWatcher
|
||||
IAEStack myLast;
|
||||
|
||||
public ItemWatcherIterator(ItemWatcher parent, Iterator<IAEStack> i) {
|
||||
watcher = parent;
|
||||
interestIterator = i;
|
||||
this.watcher = parent;
|
||||
this.interestIterator = i;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasNext()
|
||||
{
|
||||
return interestIterator.hasNext();
|
||||
return this.interestIterator.hasNext();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAEStack next()
|
||||
{
|
||||
return myLast = interestIterator.next();
|
||||
return this.myLast = this.interestIterator.next();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove()
|
||||
{
|
||||
gsc.interestManager.remove( myLast, watcher );
|
||||
interestIterator.remove();
|
||||
ItemWatcher.this.gsc.interestManager.remove( this.myLast, this.watcher );
|
||||
this.interestIterator.remove();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -71,22 +71,22 @@ public class ItemWatcher implements IStackWatcher
|
||||
final HashSet<IAEStack> myInterests = new HashSet<IAEStack>();
|
||||
|
||||
public ItemWatcher(GridStorageCache cache, IStackWatcherHost host) {
|
||||
gsc = cache;
|
||||
myObject = host;
|
||||
this.gsc = cache;
|
||||
this.myObject = host;
|
||||
}
|
||||
|
||||
public IStackWatcherHost getHost()
|
||||
{
|
||||
return myObject;
|
||||
return this.myObject;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean add(IAEStack e)
|
||||
{
|
||||
if ( myInterests.contains( e ) )
|
||||
if ( this.myInterests.contains( e ) )
|
||||
return false;
|
||||
|
||||
return myInterests.add( e.copy() ) && gsc.interestManager.put( e, this );
|
||||
return this.myInterests.add( e.copy() ) && this.gsc.interestManager.put( e, this );
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -95,7 +95,7 @@ public class ItemWatcher implements IStackWatcher
|
||||
boolean didChange = false;
|
||||
|
||||
for (IAEStack o : c)
|
||||
didChange = add( o ) || didChange;
|
||||
didChange = this.add( o ) || didChange;
|
||||
|
||||
return didChange;
|
||||
}
|
||||
@@ -103,10 +103,10 @@ public class ItemWatcher implements IStackWatcher
|
||||
@Override
|
||||
public void clear()
|
||||
{
|
||||
Iterator<IAEStack> i = myInterests.iterator();
|
||||
Iterator<IAEStack> i = this.myInterests.iterator();
|
||||
while (i.hasNext())
|
||||
{
|
||||
gsc.interestManager.remove( i.next(), this );
|
||||
this.gsc.interestManager.remove( i.next(), this );
|
||||
i.remove();
|
||||
}
|
||||
}
|
||||
@@ -114,31 +114,31 @@ public class ItemWatcher implements IStackWatcher
|
||||
@Override
|
||||
public boolean contains(Object o)
|
||||
{
|
||||
return myInterests.contains( o );
|
||||
return this.myInterests.contains( o );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean containsAll(Collection<?> c)
|
||||
{
|
||||
return myInterests.containsAll( c );
|
||||
return this.myInterests.containsAll( c );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEmpty()
|
||||
{
|
||||
return myInterests.isEmpty();
|
||||
return this.myInterests.isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<IAEStack> iterator()
|
||||
{
|
||||
return new ItemWatcherIterator( this, myInterests.iterator() );
|
||||
return new ItemWatcherIterator( this, this.myInterests.iterator() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean remove(Object o)
|
||||
{
|
||||
return myInterests.remove( o ) && gsc.interestManager.remove( (IAEStack)o, this );
|
||||
return this.myInterests.remove( o ) && this.gsc.interestManager.remove( (IAEStack)o, this );
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -146,7 +146,7 @@ public class ItemWatcher implements IStackWatcher
|
||||
{
|
||||
boolean didSomething = false;
|
||||
for (Object o : c)
|
||||
didSomething = remove( o ) || didSomething;
|
||||
didSomething = this.remove( o ) || didSomething;
|
||||
return didSomething;
|
||||
}
|
||||
|
||||
@@ -154,7 +154,7 @@ public class ItemWatcher implements IStackWatcher
|
||||
public boolean retainAll(Collection<?> c)
|
||||
{
|
||||
boolean changed = false;
|
||||
Iterator<IAEStack> i = iterator();
|
||||
Iterator<IAEStack> i = this.iterator();
|
||||
|
||||
while (i.hasNext())
|
||||
{
|
||||
@@ -171,19 +171,19 @@ public class ItemWatcher implements IStackWatcher
|
||||
@Override
|
||||
public int size()
|
||||
{
|
||||
return myInterests.size();
|
||||
return this.myInterests.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object[] toArray()
|
||||
{
|
||||
return myInterests.toArray();
|
||||
return this.myInterests.toArray();
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T[] toArray(T[] a)
|
||||
{
|
||||
return myInterests.toArray( a );
|
||||
return this.myInterests.toArray( a );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -37,8 +37,8 @@ public class MEIInventoryWrapper implements IMEInventory<IAEItemStack>
|
||||
protected final InventoryAdaptor adaptor;
|
||||
|
||||
public MEIInventoryWrapper(IInventory m, InventoryAdaptor ia) {
|
||||
target = m;
|
||||
adaptor = ia;
|
||||
this.target = m;
|
||||
this.adaptor = ia;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -52,9 +52,9 @@ public class MEIInventoryWrapper implements IMEInventory<IAEItemStack>
|
||||
{
|
||||
ItemStack input = iox.getItemStack();
|
||||
|
||||
if ( adaptor != null )
|
||||
if ( this.adaptor != null )
|
||||
{
|
||||
ItemStack is = mode == Actionable.SIMULATE ? adaptor.simulateAdd( input ) : adaptor.addItems( input );
|
||||
ItemStack is = mode == Actionable.SIMULATE ? this.adaptor.simulateAdd( input ) : this.adaptor.addItems( input );
|
||||
if ( is == null )
|
||||
return null;
|
||||
return AEItemStack.create( is );
|
||||
@@ -64,20 +64,20 @@ public class MEIInventoryWrapper implements IMEInventory<IAEItemStack>
|
||||
|
||||
if ( mode == Actionable.MODULATE ) // absolutely no need for a first run in simulate mode.
|
||||
{
|
||||
for (int x = 0; x < target.getSizeInventory(); x++)
|
||||
for (int x = 0; x < this.target.getSizeInventory(); x++)
|
||||
{
|
||||
ItemStack t = target.getStackInSlot( x );
|
||||
ItemStack t = this.target.getStackInSlot( x );
|
||||
|
||||
if ( Platform.isSameItem( t, input ) )
|
||||
{
|
||||
int oriStack = t.stackSize;
|
||||
t.stackSize += out.stackSize;
|
||||
|
||||
target.setInventorySlotContents( x, t );
|
||||
this.target.setInventorySlotContents( x, t );
|
||||
|
||||
if ( t.stackSize > target.getInventoryStackLimit() )
|
||||
if ( t.stackSize > this.target.getInventoryStackLimit() )
|
||||
{
|
||||
t.stackSize = target.getInventoryStackLimit();
|
||||
t.stackSize = this.target.getInventoryStackLimit();
|
||||
}
|
||||
|
||||
if ( t.stackSize > t.getMaxStackSize() )
|
||||
@@ -95,23 +95,23 @@ public class MEIInventoryWrapper implements IMEInventory<IAEItemStack>
|
||||
}
|
||||
}
|
||||
|
||||
for (int x = 0; x < target.getSizeInventory(); x++)
|
||||
for (int x = 0; x < this.target.getSizeInventory(); x++)
|
||||
{
|
||||
ItemStack t = target.getStackInSlot( x );
|
||||
ItemStack t = this.target.getStackInSlot( x );
|
||||
|
||||
if ( t == null )
|
||||
{
|
||||
t = Platform.cloneItemStack( input );
|
||||
t.stackSize = out.stackSize;
|
||||
|
||||
if ( t.stackSize > target.getInventoryStackLimit() )
|
||||
if ( t.stackSize > this.target.getInventoryStackLimit() )
|
||||
{
|
||||
t.stackSize = target.getInventoryStackLimit();
|
||||
t.stackSize = this.target.getInventoryStackLimit();
|
||||
}
|
||||
|
||||
out.stackSize -= t.stackSize;
|
||||
if ( mode == Actionable.MODULATE )
|
||||
target.setInventorySlotContents( x, t );
|
||||
this.target.setInventorySlotContents( x, t );
|
||||
|
||||
if ( out.stackSize <= 0 )
|
||||
{
|
||||
@@ -138,9 +138,9 @@ public class MEIInventoryWrapper implements IMEInventory<IAEItemStack>
|
||||
|
||||
Req.stackSize = request_stackSize;
|
||||
|
||||
if ( adaptor != null )
|
||||
if ( this.adaptor != null )
|
||||
{
|
||||
Gathered = adaptor.removeItems( Req.stackSize, Req, null );
|
||||
Gathered = this.adaptor.removeItems( Req.stackSize, Req, null );
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -148,9 +148,9 @@ public class MEIInventoryWrapper implements IMEInventory<IAEItemStack>
|
||||
Gathered.stackSize = 0;
|
||||
|
||||
// try to find matching inventories that already have it...
|
||||
for (int x = 0; x < target.getSizeInventory(); x++)
|
||||
for (int x = 0; x < this.target.getSizeInventory(); x++)
|
||||
{
|
||||
ItemStack sub = target.getStackInSlot( x );
|
||||
ItemStack sub = this.target.getStackInSlot( x );
|
||||
|
||||
if ( Platform.isSameItem( sub, Req ) )
|
||||
{
|
||||
@@ -174,9 +174,9 @@ public class MEIInventoryWrapper implements IMEInventory<IAEItemStack>
|
||||
}
|
||||
|
||||
if ( sub.stackSize <= 0 )
|
||||
target.setInventorySlotContents( x, null );
|
||||
this.target.setInventorySlotContents( x, null );
|
||||
else
|
||||
target.setInventorySlotContents( x, sub );
|
||||
this.target.setInventorySlotContents( x, sub );
|
||||
|
||||
if ( retrieved != null )
|
||||
{
|
||||
@@ -204,9 +204,9 @@ public class MEIInventoryWrapper implements IMEInventory<IAEItemStack>
|
||||
@Override
|
||||
public IItemList<IAEItemStack> getAvailableItems(IItemList<IAEItemStack> out)
|
||||
{
|
||||
for (int x = 0; x < target.getSizeInventory(); x++)
|
||||
for (int x = 0; x < this.target.getSizeInventory(); x++)
|
||||
{
|
||||
out.addStorage( AEItemStack.create( target.getStackInSlot( x ) ) );
|
||||
out.addStorage( AEItemStack.create( this.target.getStackInSlot( x ) ) );
|
||||
}
|
||||
|
||||
return out;
|
||||
|
||||
@@ -47,11 +47,11 @@ public class MEInventoryHandler<T extends IAEStack<T>> implements IMEInventoryHa
|
||||
this.channel = channel;
|
||||
|
||||
if ( i instanceof IMEInventoryHandler )
|
||||
internal = (IMEInventoryHandler<T>) i;
|
||||
this.internal = (IMEInventoryHandler<T>) i;
|
||||
else
|
||||
internal = new MEPassThrough<T>( i, channel );
|
||||
this.internal = new MEPassThrough<T>( i, channel );
|
||||
|
||||
monitor = internal instanceof IMEMonitor ? (IMEMonitor<T>) internal : null;
|
||||
this.monitor = this.internal instanceof IMEMonitor ? (IMEMonitor<T>) this.internal : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -60,75 +60,75 @@ public class MEInventoryHandler<T extends IAEStack<T>> implements IMEInventoryHa
|
||||
if ( !this.canAccept( input ) )
|
||||
return input;
|
||||
|
||||
return internal.injectItems( input, type, src );
|
||||
return this.internal.injectItems( input, type, src );
|
||||
}
|
||||
|
||||
@Override
|
||||
public T extractItems(T request, Actionable type, BaseActionSource src)
|
||||
{
|
||||
if ( !getAccess().hasPermission( AccessRestriction.READ ) )
|
||||
if ( !this.getAccess().hasPermission( AccessRestriction.READ ) )
|
||||
return null;
|
||||
|
||||
return internal.extractItems( request, type, src );
|
||||
return this.internal.extractItems( request, type, src );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemList<T> getAvailableItems(IItemList<T> out)
|
||||
{
|
||||
if ( !getAccess().hasPermission( AccessRestriction.READ ) )
|
||||
if ( !this.getAccess().hasPermission( AccessRestriction.READ ) )
|
||||
return out;
|
||||
|
||||
return internal.getAvailableItems( out );
|
||||
return this.internal.getAvailableItems( out );
|
||||
}
|
||||
|
||||
@Override
|
||||
public StorageChannel getChannel()
|
||||
{
|
||||
return internal.getChannel();
|
||||
return this.internal.getChannel();
|
||||
}
|
||||
|
||||
@Override
|
||||
public AccessRestriction getAccess()
|
||||
{
|
||||
return myAccess.restrictPermissions( internal.getAccess() );
|
||||
return this.myAccess.restrictPermissions( this.internal.getAccess() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPrioritized(T input)
|
||||
{
|
||||
if ( myWhitelist == IncludeExclude.WHITELIST )
|
||||
return myPartitionList.isListed( input ) || internal.isPrioritized( input );
|
||||
if ( this.myWhitelist == IncludeExclude.WHITELIST )
|
||||
return this.myPartitionList.isListed( input ) || this.internal.isPrioritized( input );
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canAccept(T input)
|
||||
{
|
||||
if ( !getAccess().hasPermission( AccessRestriction.WRITE ) )
|
||||
if ( !this.getAccess().hasPermission( AccessRestriction.WRITE ) )
|
||||
return false;
|
||||
|
||||
if ( myWhitelist == IncludeExclude.BLACKLIST && myPartitionList.isListed( input ) )
|
||||
if ( this.myWhitelist == IncludeExclude.BLACKLIST && this.myPartitionList.isListed( input ) )
|
||||
return false;
|
||||
if ( myPartitionList.isEmpty() || myWhitelist == IncludeExclude.BLACKLIST )
|
||||
return internal.canAccept( input );
|
||||
return myPartitionList.isListed( input ) && internal.canAccept( input );
|
||||
if ( this.myPartitionList.isEmpty() || this.myWhitelist == IncludeExclude.BLACKLIST )
|
||||
return this.internal.canAccept( input );
|
||||
return this.myPartitionList.isListed( input ) && this.internal.canAccept( input );
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPriority()
|
||||
{
|
||||
return myPriority;
|
||||
return this.myPriority;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSlot()
|
||||
{
|
||||
return internal.getSlot();
|
||||
return this.internal.getSlot();
|
||||
}
|
||||
|
||||
public IMEInventory<T> getInternal()
|
||||
{
|
||||
return internal;
|
||||
return this.internal;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -52,13 +52,13 @@ public class MEMonitorIInventory implements IMEMonitor<IAEItemStack>
|
||||
{
|
||||
if ( is == null )
|
||||
{
|
||||
itemStack = null;
|
||||
aeStack = null;
|
||||
this.itemStack = null;
|
||||
this.aeStack = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
itemStack = is.copy();
|
||||
aeStack = AEApi.instance().storage().createItemStack( is );
|
||||
this.itemStack = is.copy();
|
||||
this.aeStack = AEApi.instance().storage().createItemStack( is );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -78,19 +78,19 @@ public class MEMonitorIInventory implements IMEMonitor<IAEItemStack>
|
||||
@Override
|
||||
public void addListener(IMEMonitorHandlerReceiver<IAEItemStack> l, Object verificationToken)
|
||||
{
|
||||
listeners.put( l, verificationToken );
|
||||
this.listeners.put( l, verificationToken );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeListener(IMEMonitorHandlerReceiver<IAEItemStack> l)
|
||||
{
|
||||
listeners.remove( l );
|
||||
this.listeners.remove( l );
|
||||
}
|
||||
|
||||
public MEMonitorIInventory(InventoryAdaptor adaptor)
|
||||
{
|
||||
this.adaptor = adaptor;
|
||||
memory = new ConcurrentSkipListMap<Integer, CachedItemStack>();
|
||||
this.memory = new ConcurrentSkipListMap<Integer, CachedItemStack>();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -99,11 +99,11 @@ public class MEMonitorIInventory implements IMEMonitor<IAEItemStack>
|
||||
ItemStack out = null;
|
||||
|
||||
if ( type == Actionable.SIMULATE )
|
||||
out = adaptor.simulateAdd( input.getItemStack() );
|
||||
out = this.adaptor.simulateAdd( input.getItemStack() );
|
||||
else
|
||||
out = adaptor.addItems( input.getItemStack() );
|
||||
out = this.adaptor.addItems( input.getItemStack() );
|
||||
|
||||
onTick();
|
||||
this.onTick();
|
||||
|
||||
if ( out == null )
|
||||
return null;
|
||||
@@ -147,13 +147,13 @@ public class MEMonitorIInventory implements IMEMonitor<IAEItemStack>
|
||||
@Override
|
||||
public IItemList<IAEItemStack> getStorageList()
|
||||
{
|
||||
return list;
|
||||
return this.list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemList<IAEItemStack> getAvailableItems(IItemList out)
|
||||
{
|
||||
for (CachedItemStack is : memory.values())
|
||||
for (CachedItemStack is : this.memory.values())
|
||||
out.addStorage( is.aeStack );
|
||||
|
||||
return out;
|
||||
@@ -165,9 +165,9 @@ public class MEMonitorIInventory implements IMEMonitor<IAEItemStack>
|
||||
ItemStack out = null;
|
||||
|
||||
if ( type == Actionable.SIMULATE )
|
||||
out = adaptor.simulateRemove( (int) request.getStackSize(), request.getItemStack(), null );
|
||||
out = this.adaptor.simulateRemove( (int) request.getStackSize(), request.getItemStack(), null );
|
||||
else
|
||||
out = adaptor.removeItems( (int) request.getStackSize(), request.getItemStack(), null );
|
||||
out = this.adaptor.removeItems( (int) request.getStackSize(), request.getItemStack(), null );
|
||||
|
||||
if ( out == null )
|
||||
return null;
|
||||
@@ -176,7 +176,7 @@ public class MEMonitorIInventory implements IMEMonitor<IAEItemStack>
|
||||
IAEItemStack o = request.copy();
|
||||
o.setStackSize( out.stackSize );
|
||||
|
||||
onTick();
|
||||
this.onTick();
|
||||
|
||||
return o;
|
||||
}
|
||||
@@ -188,19 +188,19 @@ public class MEMonitorIInventory implements IMEMonitor<IAEItemStack>
|
||||
LinkedList<IAEItemStack> changes = new LinkedList<IAEItemStack>();
|
||||
|
||||
int high = 0;
|
||||
list.resetStatus();
|
||||
for (ItemSlot is : adaptor)
|
||||
this.list.resetStatus();
|
||||
for (ItemSlot is : this.adaptor)
|
||||
{
|
||||
CachedItemStack old = memory.get( is.slot );
|
||||
CachedItemStack old = this.memory.get( is.slot );
|
||||
high = Math.max( high, is.slot );
|
||||
|
||||
ItemStack newIS = !is.isExtractable && mode == StorageFilter.EXTRACTABLE_ONLY ? null : is.getItemStack();
|
||||
ItemStack newIS = !is.isExtractable && this.mode == StorageFilter.EXTRACTABLE_ONLY ? null : is.getItemStack();
|
||||
ItemStack oldIS = old == null ? null : old.itemStack;
|
||||
|
||||
if ( isDifferent( newIS, oldIS ) )
|
||||
if ( this.isDifferent( newIS, oldIS ) )
|
||||
{
|
||||
CachedItemStack cis = new CachedItemStack( is.getItemStack() );
|
||||
memory.put( is.slot, cis );
|
||||
this.memory.put( is.slot, cis );
|
||||
|
||||
if ( old != null && old.aeStack != null )
|
||||
{
|
||||
@@ -211,7 +211,7 @@ public class MEMonitorIInventory implements IMEMonitor<IAEItemStack>
|
||||
if ( cis.aeStack != null )
|
||||
{
|
||||
changes.add( cis.aeStack );
|
||||
list.add( cis.aeStack );
|
||||
this.list.add( cis.aeStack );
|
||||
}
|
||||
|
||||
changed = true;
|
||||
@@ -225,13 +225,13 @@ public class MEMonitorIInventory implements IMEMonitor<IAEItemStack>
|
||||
if ( stack != null )
|
||||
{
|
||||
stack.setStackSize( newSize );
|
||||
list.add( stack );
|
||||
this.list.add( stack );
|
||||
}
|
||||
|
||||
if ( diff != 0 && stack != null )
|
||||
{
|
||||
CachedItemStack cis = new CachedItemStack( is.getItemStack() );
|
||||
memory.put( is.slot, cis );
|
||||
this.memory.put( is.slot, cis );
|
||||
|
||||
IAEItemStack a = stack.copy();
|
||||
a.setStackSize( diff );
|
||||
@@ -242,7 +242,7 @@ public class MEMonitorIInventory implements IMEMonitor<IAEItemStack>
|
||||
}
|
||||
|
||||
// detect dropped items; should fix non IISided Inventory Changes.
|
||||
NavigableMap<Integer, CachedItemStack> end = memory.tailMap( high, false );
|
||||
NavigableMap<Integer, CachedItemStack> end = this.memory.tailMap( high, false );
|
||||
if ( !end.isEmpty() )
|
||||
{
|
||||
for (CachedItemStack cis : end.values())
|
||||
@@ -259,7 +259,7 @@ public class MEMonitorIInventory implements IMEMonitor<IAEItemStack>
|
||||
}
|
||||
|
||||
if ( !changes.isEmpty() )
|
||||
postDifference( changes );
|
||||
this.postDifference( changes );
|
||||
|
||||
return changed ? TickRateModulation.URGENT : TickRateModulation.SLOWER;
|
||||
}
|
||||
@@ -280,13 +280,13 @@ public class MEMonitorIInventory implements IMEMonitor<IAEItemStack>
|
||||
// AELog.info( a.getItemStack().getUnlocalizedName() + " @ " + a.getStackSize() );
|
||||
if ( a != null )
|
||||
{
|
||||
Iterator<Entry<IMEMonitorHandlerReceiver<IAEItemStack>, Object>> i = listeners.entrySet().iterator();
|
||||
Iterator<Entry<IMEMonitorHandlerReceiver<IAEItemStack>, Object>> i = this.listeners.entrySet().iterator();
|
||||
while (i.hasNext())
|
||||
{
|
||||
Entry<IMEMonitorHandlerReceiver<IAEItemStack>, Object> l = i.next();
|
||||
IMEMonitorHandlerReceiver<IAEItemStack> key = l.getKey();
|
||||
if ( key.isValid( l.getValue() ) )
|
||||
key.postChange( this, a, mySource );
|
||||
key.postChange( this, a, this.mySource );
|
||||
else
|
||||
i.remove();
|
||||
}
|
||||
|
||||
@@ -44,30 +44,30 @@ public class MEMonitorPassThrough<T extends IAEStack<T>> extends MEPassThrough<T
|
||||
public MEMonitorPassThrough(IMEInventory<T> i, StorageChannel channel) {
|
||||
super( i, channel );
|
||||
if ( i instanceof IMEMonitor )
|
||||
monitor = (IMEMonitor<T>) i;
|
||||
this.monitor = (IMEMonitor<T>) i;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInternal(IMEInventory<T> i)
|
||||
{
|
||||
if ( monitor != null )
|
||||
monitor.removeListener( this );
|
||||
if ( this.monitor != null )
|
||||
this.monitor.removeListener( this );
|
||||
|
||||
monitor = null;
|
||||
IItemList<T> before = getInternal() == null ? channel.createList() : getInternal()
|
||||
.getAvailableItems( new ItemListIgnoreCrafting( channel.createList() ) );
|
||||
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 )
|
||||
monitor = (IMEMonitor<T>) i;
|
||||
this.monitor = (IMEMonitor<T>) i;
|
||||
|
||||
IItemList<T> after = getInternal() == null ? channel.createList() : getInternal()
|
||||
.getAvailableItems( new ItemListIgnoreCrafting( channel.createList() ) );
|
||||
IItemList<T> after = this.getInternal() == null ? this.channel.createList() : this.getInternal()
|
||||
.getAvailableItems( new ItemListIgnoreCrafting( this.channel.createList() ) );
|
||||
|
||||
if ( monitor != null )
|
||||
monitor.addListener( this, monitor );
|
||||
if ( this.monitor != null )
|
||||
this.monitor.addListener( this, this.monitor );
|
||||
|
||||
Platform.postListChanges( before, after, this, changeSource );
|
||||
Platform.postListChanges( before, after, this, this.changeSource );
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -80,37 +80,37 @@ public class MEMonitorPassThrough<T extends IAEStack<T>> extends MEPassThrough<T
|
||||
@Override
|
||||
public void addListener(IMEMonitorHandlerReceiver<T> l, Object verificationToken)
|
||||
{
|
||||
listeners.put( l, verificationToken );
|
||||
this.listeners.put( l, verificationToken );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeListener(IMEMonitorHandlerReceiver<T> l)
|
||||
{
|
||||
listeners.remove( l );
|
||||
this.listeners.remove( l );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemList<T> getStorageList()
|
||||
{
|
||||
if ( monitor == null )
|
||||
if ( this.monitor == null )
|
||||
{
|
||||
IItemList<T> out = channel.createList();
|
||||
getInternal().getAvailableItems( new ItemListIgnoreCrafting( out ) );
|
||||
IItemList<T> out = this.channel.createList();
|
||||
this.getInternal().getAvailableItems( new ItemListIgnoreCrafting( out ) );
|
||||
return out;
|
||||
}
|
||||
return monitor.getStorageList();
|
||||
return this.monitor.getStorageList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid(Object verificationToken)
|
||||
{
|
||||
return verificationToken == monitor;
|
||||
return verificationToken == this.monitor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postChange(IBaseMonitor<T> monitor, Iterable<T> change, BaseActionSource source)
|
||||
{
|
||||
Iterator<Entry<IMEMonitorHandlerReceiver<T>, Object>> i = listeners.entrySet().iterator();
|
||||
Iterator<Entry<IMEMonitorHandlerReceiver<T>, Object>> i = this.listeners.entrySet().iterator();
|
||||
while (i.hasNext())
|
||||
{
|
||||
Entry<IMEMonitorHandlerReceiver<T>, Object> e = i.next();
|
||||
@@ -125,7 +125,7 @@ public class MEMonitorPassThrough<T extends IAEStack<T>> extends MEPassThrough<T
|
||||
@Override
|
||||
public void onListUpdate()
|
||||
{
|
||||
Iterator<Entry<IMEMonitorHandlerReceiver<T>, Object>> i = listeners.entrySet().iterator();
|
||||
Iterator<Entry<IMEMonitorHandlerReceiver<T>, Object>> i = this.listeners.entrySet().iterator();
|
||||
while (i.hasNext())
|
||||
{
|
||||
Entry<IMEMonitorHandlerReceiver<T>, Object> e = i.next();
|
||||
|
||||
@@ -35,41 +35,41 @@ public class MEPassThrough<T extends IAEStack<T>> implements IMEInventoryHandler
|
||||
|
||||
protected IMEInventory<T> getInternal()
|
||||
{
|
||||
return internal;
|
||||
return this.internal;
|
||||
}
|
||||
|
||||
public MEPassThrough(IMEInventory<T> i, StorageChannel channel) {
|
||||
this.channel = channel;
|
||||
setInternal( i );
|
||||
this.setInternal( i );
|
||||
}
|
||||
|
||||
public void setInternal(IMEInventory<T> i)
|
||||
{
|
||||
internal = i;
|
||||
this.internal = i;
|
||||
}
|
||||
|
||||
@Override
|
||||
public T injectItems(T input, Actionable type, BaseActionSource src)
|
||||
{
|
||||
return internal.injectItems( input, type, src );
|
||||
return this.internal.injectItems( input, type, src );
|
||||
}
|
||||
|
||||
@Override
|
||||
public T extractItems(T request, Actionable type, BaseActionSource src)
|
||||
{
|
||||
return internal.extractItems( request, type, src );
|
||||
return this.internal.extractItems( request, type, src );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemList<T> getAvailableItems(IItemList out)
|
||||
{
|
||||
return internal.getAvailableItems( out );
|
||||
return this.internal.getAvailableItems( out );
|
||||
}
|
||||
|
||||
@Override
|
||||
public StorageChannel getChannel()
|
||||
{
|
||||
return internal.getChannel();
|
||||
return this.internal.getChannel();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -62,17 +62,17 @@ public class NetworkInventoryHandler<T extends IAEStack<T>> implements IMEInvent
|
||||
private final NavigableMap<Integer, List<IMEInventoryHandler<T>>> priorityInventory;
|
||||
|
||||
public NetworkInventoryHandler(StorageChannel chan, SecurityCache security) {
|
||||
myChannel = chan;
|
||||
this.myChannel = chan;
|
||||
this.security = security;
|
||||
priorityInventory = new ConcurrentSkipListMap<Integer, List<IMEInventoryHandler<T>>>( prioritySorter ); // TreeMultimap.create( prioritySorter, hashSorter );
|
||||
this.priorityInventory = new ConcurrentSkipListMap<Integer, List<IMEInventoryHandler<T>>>( prioritySorter ); // TreeMultimap.create( prioritySorter, hashSorter );
|
||||
}
|
||||
|
||||
public void addNewStorage(IMEInventoryHandler<T> h)
|
||||
{
|
||||
int priority = h.getPriority();
|
||||
List<IMEInventoryHandler<T>> list = priorityInventory.get( priority );
|
||||
List<IMEInventoryHandler<T>> list = this.priorityInventory.get( priority );
|
||||
if ( list == null )
|
||||
priorityInventory.put( priority, list = new ArrayList<IMEInventoryHandler<T>>() );
|
||||
this.priorityInventory.put( priority, list = new ArrayList<IMEInventoryHandler<T>>() );
|
||||
|
||||
list.add( h );
|
||||
}
|
||||
@@ -96,7 +96,7 @@ public class NetworkInventoryHandler<T extends IAEStack<T>> implements IMEInvent
|
||||
|
||||
private boolean diveList(NetworkInventoryHandler<T> networkInventoryHandler, Actionable type)
|
||||
{
|
||||
LinkedList cDepth = getDepth( type );
|
||||
LinkedList cDepth = this.getDepth( type );
|
||||
if ( cDepth.contains( networkInventoryHandler ) )
|
||||
return true;
|
||||
|
||||
@@ -106,18 +106,18 @@ public class NetworkInventoryHandler<T extends IAEStack<T>> implements IMEInvent
|
||||
|
||||
private boolean diveIteration(NetworkInventoryHandler<T> networkInventoryHandler, Actionable type)
|
||||
{
|
||||
LinkedList cDepth = getDepth( type );
|
||||
LinkedList cDepth = this.getDepth( type );
|
||||
if ( cDepth.isEmpty() )
|
||||
{
|
||||
currentPass++;
|
||||
myPass = currentPass;
|
||||
this.myPass = currentPass;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( currentPass == myPass )
|
||||
if ( currentPass == this.myPass )
|
||||
return true;
|
||||
else
|
||||
myPass = currentPass;
|
||||
this.myPass = currentPass;
|
||||
}
|
||||
|
||||
cDepth.push( this );
|
||||
@@ -126,7 +126,7 @@ public class NetworkInventoryHandler<T extends IAEStack<T>> implements IMEInvent
|
||||
|
||||
private void surface(NetworkInventoryHandler<T> networkInventoryHandler, Actionable type)
|
||||
{
|
||||
if ( getDepth( type ).pop() != this )
|
||||
if ( this.getDepth( type ).pop() != this )
|
||||
throw new RuntimeException( "Invalid Access to Networked Storage API detected." );
|
||||
}
|
||||
|
||||
@@ -134,26 +134,26 @@ public class NetworkInventoryHandler<T extends IAEStack<T>> implements IMEInvent
|
||||
{
|
||||
if ( src.isPlayer() )
|
||||
{
|
||||
if ( !security.hasPermission( ((PlayerSource) src).player, permission ) )
|
||||
if ( !this.security.hasPermission( ((PlayerSource) src).player, permission ) )
|
||||
return true;
|
||||
}
|
||||
else if ( src.isMachine() )
|
||||
{
|
||||
if ( security.isAvailable() )
|
||||
if ( this.security.isAvailable() )
|
||||
{
|
||||
IGridNode n = ((MachineSource) src).via.getActionableNode();
|
||||
if ( n == null )
|
||||
return true;
|
||||
|
||||
IGrid gn = n.getGrid();
|
||||
if ( gn != security.myGrid )
|
||||
if ( gn != this.security.myGrid )
|
||||
{
|
||||
int playerID = -1;
|
||||
|
||||
ISecurityGrid sg = gn.getCache( ISecurityGrid.class );
|
||||
playerID = sg.getOwner();
|
||||
|
||||
if ( !security.hasPermission( playerID, permission ) )
|
||||
if ( !this.security.hasPermission( playerID, permission ) )
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -165,16 +165,16 @@ public class NetworkInventoryHandler<T extends IAEStack<T>> implements IMEInvent
|
||||
@Override
|
||||
public T injectItems(T input, Actionable type, BaseActionSource src)
|
||||
{
|
||||
if ( diveList( this, type ) )
|
||||
if ( this.diveList( this, type ) )
|
||||
return input;
|
||||
|
||||
if ( testPermission( src, SecurityPermissions.INJECT ) )
|
||||
if ( this.testPermission( src, SecurityPermissions.INJECT ) )
|
||||
{
|
||||
surface( this, type );
|
||||
this.surface( this, type );
|
||||
return input;
|
||||
}
|
||||
|
||||
for (List<IMEInventoryHandler<T>> invList : priorityInventory.values())
|
||||
for (List<IMEInventoryHandler<T>> invList : this.priorityInventory.values())
|
||||
{
|
||||
Iterator<IMEInventoryHandler<T>> ii = invList.iterator();
|
||||
while (ii.hasNext() && input != null)
|
||||
@@ -199,7 +199,7 @@ public class NetworkInventoryHandler<T extends IAEStack<T>> implements IMEInvent
|
||||
}
|
||||
}
|
||||
|
||||
surface( this, type );
|
||||
this.surface( this, type );
|
||||
|
||||
return input;
|
||||
}
|
||||
@@ -207,16 +207,16 @@ public class NetworkInventoryHandler<T extends IAEStack<T>> implements IMEInvent
|
||||
@Override
|
||||
public T extractItems(T request, Actionable mode, BaseActionSource src)
|
||||
{
|
||||
if ( diveList( this, mode ) )
|
||||
if ( this.diveList( this, mode ) )
|
||||
return null;
|
||||
|
||||
if ( testPermission( src, SecurityPermissions.EXTRACT ) )
|
||||
if ( this.testPermission( src, SecurityPermissions.EXTRACT ) )
|
||||
{
|
||||
surface( this, mode );
|
||||
this.surface( this, mode );
|
||||
return null;
|
||||
}
|
||||
|
||||
Iterator<List<IMEInventoryHandler<T>>> i = priorityInventory.descendingMap().values().iterator();// priorityInventory.asMap().descendingMap().entrySet().iterator();
|
||||
Iterator<List<IMEInventoryHandler<T>>> i = this.priorityInventory.descendingMap().values().iterator();// priorityInventory.asMap().descendingMap().entrySet().iterator();
|
||||
|
||||
T output = request.copy();
|
||||
request = request.copy();
|
||||
@@ -237,7 +237,7 @@ public class NetworkInventoryHandler<T extends IAEStack<T>> implements IMEInvent
|
||||
}
|
||||
}
|
||||
|
||||
surface( this, mode );
|
||||
this.surface( this, mode );
|
||||
|
||||
if ( output.getStackSize() <= 0 )
|
||||
return null;
|
||||
@@ -248,15 +248,15 @@ public class NetworkInventoryHandler<T extends IAEStack<T>> implements IMEInvent
|
||||
@Override
|
||||
public IItemList<T> getAvailableItems(IItemList out)
|
||||
{
|
||||
if ( diveIteration( this, Actionable.SIMULATE ) )
|
||||
if ( this.diveIteration( this, Actionable.SIMULATE ) )
|
||||
return out;
|
||||
|
||||
// for (Entry<Integer, IMEInventoryHandler<T>> h : priorityInventory.entries())
|
||||
for (List<IMEInventoryHandler<T>> i : priorityInventory.values())
|
||||
for (List<IMEInventoryHandler<T>> i : this.priorityInventory.values())
|
||||
for (IMEInventoryHandler<T> j : i)
|
||||
out = j.getAvailableItems( out );
|
||||
|
||||
surface( this, Actionable.SIMULATE );
|
||||
this.surface( this, Actionable.SIMULATE );
|
||||
|
||||
return out;
|
||||
}
|
||||
@@ -264,7 +264,7 @@ public class NetworkInventoryHandler<T extends IAEStack<T>> implements IMEInvent
|
||||
@Override
|
||||
public StorageChannel getChannel()
|
||||
{
|
||||
return myChannel;
|
||||
return this.myChannel;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -41,7 +41,7 @@ public class SecurityInventory implements IMEInventoryHandler<IAEItemStack>
|
||||
final public IItemList<IAEItemStack> storedItems = AEApi.instance().storage().createItemList();
|
||||
|
||||
public SecurityInventory(TileSecurity ts) {
|
||||
securityTile = ts;
|
||||
this.securityTile = ts;
|
||||
}
|
||||
|
||||
private boolean hasPermission(BaseActionSource src)
|
||||
@@ -50,7 +50,7 @@ public class SecurityInventory implements IMEInventoryHandler<IAEItemStack>
|
||||
{
|
||||
try
|
||||
{
|
||||
return securityTile.getProxy().getSecurity().hasPermission( ((PlayerSource) src).player, SecurityPermissions.SECURITY );
|
||||
return this.securityTile.getProxy().getSecurity().hasPermission( ((PlayerSource) src).player, SecurityPermissions.SECURITY );
|
||||
}
|
||||
catch (GridAccessException e)
|
||||
{
|
||||
@@ -63,15 +63,15 @@ public class SecurityInventory implements IMEInventoryHandler<IAEItemStack>
|
||||
@Override
|
||||
public IAEItemStack injectItems(IAEItemStack input, Actionable type, BaseActionSource src)
|
||||
{
|
||||
if ( hasPermission( src ) && AEApi.instance().items().itemBiometricCard.sameAsStack( input.getItemStack() ) )
|
||||
if ( this.hasPermission( src ) && AEApi.instance().items().itemBiometricCard.sameAsStack( input.getItemStack() ) )
|
||||
{
|
||||
if ( canAccept( input ) )
|
||||
if ( this.canAccept( input ) )
|
||||
{
|
||||
if ( type == Actionable.SIMULATE )
|
||||
return null;
|
||||
|
||||
storedItems.add( input );
|
||||
securityTile.inventoryChanged();
|
||||
this.storedItems.add( input );
|
||||
this.securityTile.inventoryChanged();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -81,9 +81,9 @@ public class SecurityInventory implements IMEInventoryHandler<IAEItemStack>
|
||||
@Override
|
||||
public IAEItemStack extractItems(IAEItemStack request, Actionable mode, BaseActionSource src)
|
||||
{
|
||||
if ( hasPermission( src ) )
|
||||
if ( this.hasPermission( src ) )
|
||||
{
|
||||
IAEItemStack target = storedItems.findPrecise( request );
|
||||
IAEItemStack target = this.storedItems.findPrecise( request );
|
||||
if ( target != null )
|
||||
{
|
||||
IAEItemStack output = target.copy();
|
||||
@@ -92,7 +92,7 @@ public class SecurityInventory implements IMEInventoryHandler<IAEItemStack>
|
||||
return output;
|
||||
|
||||
target.setStackSize( 0 );
|
||||
securityTile.inventoryChanged();
|
||||
this.securityTile.inventoryChanged();
|
||||
return output;
|
||||
}
|
||||
}
|
||||
@@ -102,7 +102,7 @@ public class SecurityInventory implements IMEInventoryHandler<IAEItemStack>
|
||||
@Override
|
||||
public IItemList<IAEItemStack> getAvailableItems(IItemList out)
|
||||
{
|
||||
for (IAEItemStack ais : storedItems)
|
||||
for (IAEItemStack ais : this.storedItems)
|
||||
out.add( ais );
|
||||
|
||||
return out;
|
||||
@@ -135,10 +135,10 @@ public class SecurityInventory implements IMEInventoryHandler<IAEItemStack>
|
||||
GameProfile newUser = tbc.getProfile( input.getItemStack() );
|
||||
|
||||
int PlayerID = AEApi.instance().registries().players().getID( newUser );
|
||||
if ( securityTile.getOwner() == PlayerID )
|
||||
if ( this.securityTile.getOwner() == PlayerID )
|
||||
return false;
|
||||
|
||||
for (IAEItemStack ais : storedItems)
|
||||
for (IAEItemStack ais : this.storedItems)
|
||||
{
|
||||
if ( ais.isMeaningful() )
|
||||
{
|
||||
|
||||
@@ -36,7 +36,7 @@ public class VoidFluidInventory implements IMEInventoryHandler<IAEFluidStack>
|
||||
|
||||
public VoidFluidInventory( TileCondenser te )
|
||||
{
|
||||
target = te;
|
||||
this.target = te;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -46,7 +46,7 @@ public class VoidFluidInventory implements IMEInventoryHandler<IAEFluidStack>
|
||||
return null;
|
||||
|
||||
if ( input != null )
|
||||
target.addPower( input.getStackSize() / 1000.0 );
|
||||
this.target.addPower( input.getStackSize() / 1000.0 );
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ public class VoidItemInventory implements IMEInventoryHandler<IAEItemStack>
|
||||
|
||||
public VoidItemInventory( TileCondenser te )
|
||||
{
|
||||
target = te;
|
||||
this.target = te;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -46,7 +46,7 @@ public class VoidItemInventory implements IMEInventoryHandler<IAEItemStack>
|
||||
return null;
|
||||
|
||||
if ( input != null )
|
||||
target.addPower( input.getStackSize() );
|
||||
this.target.addPower( input.getStackSize() );
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user