Reduces visibility of internal fields/methods
Reduces the visibility of all fields to private and create setters/getters when necessary. Exceptions are fields with GuiSync as these need to be public. Reduces the visibility of internal methods to private/protected/default when possible.
This commit is contained in:
@@ -71,17 +71,17 @@ public class Grid implements IGrid
|
||||
center.setGrid( this );
|
||||
}
|
||||
|
||||
public int getPriority()
|
||||
int getPriority()
|
||||
{
|
||||
return this.priority;
|
||||
}
|
||||
|
||||
public IGridStorage getMyStorage()
|
||||
IGridStorage getMyStorage()
|
||||
{
|
||||
return this.myStorage;
|
||||
}
|
||||
|
||||
public Map<Class<? extends IGridCache>, GridCacheWrapper> getCaches()
|
||||
Map<Class<? extends IGridCache>, GridCacheWrapper> getCaches()
|
||||
{
|
||||
return this.caches;
|
||||
}
|
||||
@@ -91,7 +91,7 @@ public class Grid implements IGrid
|
||||
return this.machines.keySet();
|
||||
}
|
||||
|
||||
public int size()
|
||||
int size()
|
||||
{
|
||||
int out = 0;
|
||||
for( final Collection<?> x : this.machines.values() )
|
||||
@@ -101,7 +101,7 @@ public class Grid implements IGrid
|
||||
return out;
|
||||
}
|
||||
|
||||
public void remove( final GridNode gridNode )
|
||||
void remove( final GridNode gridNode )
|
||||
{
|
||||
for( final IGridCache c : this.caches.values() )
|
||||
{
|
||||
@@ -134,7 +134,7 @@ public class Grid implements IGrid
|
||||
}
|
||||
}
|
||||
|
||||
public void add( final GridNode gridNode )
|
||||
void add( final GridNode gridNode )
|
||||
{
|
||||
final Class<? extends IGridHost> mClass = gridNode.getMachineClass();
|
||||
|
||||
@@ -213,7 +213,7 @@ public class Grid implements IGrid
|
||||
@SuppressWarnings( "unchecked" )
|
||||
public <C extends IGridCache> C getCache( final Class<? extends IGridCache> iface )
|
||||
{
|
||||
return (C) this.caches.get( iface ).myCache;
|
||||
return (C) this.caches.get( iface ).getCache();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -265,7 +265,7 @@ public class Grid implements IGrid
|
||||
return this.pivot;
|
||||
}
|
||||
|
||||
public void setPivot( final GridNode pivot )
|
||||
void setPivot( final GridNode pivot )
|
||||
{
|
||||
this.pivot = pivot;
|
||||
}
|
||||
@@ -282,7 +282,7 @@ public class Grid implements IGrid
|
||||
}
|
||||
}
|
||||
|
||||
public void saveState()
|
||||
void saveState()
|
||||
{
|
||||
for( final IGridCache c : this.caches.values() )
|
||||
{
|
||||
|
||||
@@ -28,53 +28,58 @@ import appeng.api.networking.IGridStorage;
|
||||
public class GridCacheWrapper implements IGridCache
|
||||
{
|
||||
|
||||
final IGridCache myCache;
|
||||
final String name;
|
||||
private final IGridCache myCache;
|
||||
private final String name;
|
||||
|
||||
public GridCacheWrapper( final IGridCache gc )
|
||||
{
|
||||
this.myCache = gc;
|
||||
this.name = this.myCache.getClass().getName();
|
||||
this.name = this.getCache().getClass().getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdateTick()
|
||||
{
|
||||
this.myCache.onUpdateTick();
|
||||
this.getCache().onUpdateTick();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeNode( final IGridNode gridNode, final IGridHost machine )
|
||||
{
|
||||
this.myCache.removeNode( gridNode, machine );
|
||||
this.getCache().removeNode( gridNode, machine );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addNode( final IGridNode gridNode, final IGridHost machine )
|
||||
{
|
||||
this.myCache.addNode( gridNode, machine );
|
||||
this.getCache().addNode( gridNode, machine );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSplit( final IGridStorage storageB )
|
||||
{
|
||||
this.myCache.onSplit( storageB );
|
||||
this.getCache().onSplit( storageB );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onJoin( final IGridStorage storageB )
|
||||
{
|
||||
this.myCache.onJoin( storageB );
|
||||
this.getCache().onJoin( storageB );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void populateGridStorage( final IGridStorage storage )
|
||||
{
|
||||
this.myCache.populateGridStorage( storage );
|
||||
this.getCache().populateGridStorage( storage );
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return this.name;
|
||||
}
|
||||
|
||||
IGridCache getCache()
|
||||
{
|
||||
return this.myCache;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,8 +48,8 @@ public class GridConnection implements IGridConnection, IPathItem
|
||||
private static final String EXISTING_CONNECTION_MESSAGE = "Connection between node [machine=%s, %s] and [machine=%s, %s] on [%s] already exists.";
|
||||
|
||||
private static final MENetworkChannelsChanged EVENT = new MENetworkChannelsChanged();
|
||||
public int channelData = 0;
|
||||
Object visitorIterationNumber = null;
|
||||
private int channelData = 0;
|
||||
private Object visitorIterationNumber = null;
|
||||
private GridNode sideA;
|
||||
private AEPartLocation fromAtoB;
|
||||
private GridNode sideB;
|
||||
@@ -67,8 +67,8 @@ public class GridConnection implements IGridConnection, IPathItem
|
||||
final DimensionalCoord aCoordinates = a.getGridBlock().getLocation();
|
||||
final DimensionalCoord bCoordinates = b.getGridBlock().getLocation();
|
||||
|
||||
AELog.info( "Security audit 1 failed at [%s] belonging to player [id=%d]", aCoordinates.toString(), a.playerID );
|
||||
AELog.info( "Security audit 2 failed at [%s] belonging to player [id=%d]", bCoordinates.toString(), b.playerID );
|
||||
AELog.info( "Security audit 1 failed at [%s] belonging to player [id=%d]", aCoordinates.toString(), a.getPlayerID() );
|
||||
AELog.info( "Security audit 2 failed at [%s] belonging to player [id=%d]", bCoordinates.toString(), b.getPlayerID() );
|
||||
}
|
||||
|
||||
throw new SecurityConnectionException();
|
||||
@@ -276,8 +276,18 @@ public class GridConnection implements IGridConnection, IPathItem
|
||||
}
|
||||
}
|
||||
|
||||
public int getLastUsedChannels()
|
||||
private int getLastUsedChannels()
|
||||
{
|
||||
return this.channelData & 0xff;
|
||||
}
|
||||
|
||||
Object getVisitorIterationNumber()
|
||||
{
|
||||
return this.visitorIterationNumber;
|
||||
}
|
||||
|
||||
void setVisitorIterationNumber( final Object visitorIterationNumber )
|
||||
{
|
||||
this.visitorIterationNumber = visitorIterationNumber;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,9 +64,9 @@ public class GridNode implements IGridNode, IPathItem
|
||||
private final List<IGridConnection> connections = new LinkedList<IGridConnection>();
|
||||
private final IGridBlock gridProxy;
|
||||
// old power draw, used to diff
|
||||
public double previousDraw = 0.0;
|
||||
public long lastSecurityKey = -1;
|
||||
public int playerID = -1;
|
||||
private double previousDraw = 0.0;
|
||||
private long lastSecurityKey = -1;
|
||||
private int playerID = -1;
|
||||
private GridStorage myStorage = null;
|
||||
private Grid myGrid;
|
||||
private Object visitorIterationNumber = null;
|
||||
@@ -80,12 +80,12 @@ public class GridNode implements IGridNode, IPathItem
|
||||
this.gridProxy = what;
|
||||
}
|
||||
|
||||
public IGridBlock getGridProxy()
|
||||
IGridBlock getGridProxy()
|
||||
{
|
||||
return this.gridProxy;
|
||||
}
|
||||
|
||||
public Grid getMyGrid()
|
||||
Grid getMyGrid()
|
||||
{
|
||||
return this.myGrid;
|
||||
}
|
||||
@@ -95,12 +95,12 @@ public class GridNode implements IGridNode, IPathItem
|
||||
return this.lastUsedChannels;
|
||||
}
|
||||
|
||||
public Class<? extends IGridHost> getMachineClass()
|
||||
Class<? extends IGridHost> getMachineClass()
|
||||
{
|
||||
return this.getMachine().getClass();
|
||||
}
|
||||
|
||||
public void addConnection( final IGridConnection gridConnection )
|
||||
void addConnection( final IGridConnection gridConnection )
|
||||
{
|
||||
this.connections.add( gridConnection );
|
||||
if( gridConnection.hasDirection() )
|
||||
@@ -113,7 +113,7 @@ public class GridNode implements IGridNode, IPathItem
|
||||
Collections.sort( this.connections, new ConnectionComparator( gn ) );
|
||||
}
|
||||
|
||||
public void removeConnection( final IGridConnection gridConnection )
|
||||
void removeConnection( final IGridConnection gridConnection )
|
||||
{
|
||||
this.connections.remove( gridConnection );
|
||||
if( gridConnection.hasDirection() )
|
||||
@@ -122,7 +122,7 @@ public class GridNode implements IGridNode, IPathItem
|
||||
}
|
||||
}
|
||||
|
||||
public boolean hasConnection( final IGridNode otherSide )
|
||||
boolean hasConnection( final IGridNode otherSide )
|
||||
{
|
||||
for( final IGridConnection gc : this.connections )
|
||||
{
|
||||
@@ -134,11 +134,11 @@ public class GridNode implements IGridNode, IPathItem
|
||||
return false;
|
||||
}
|
||||
|
||||
public void validateGrid()
|
||||
void validateGrid()
|
||||
{
|
||||
final GridSplitDetector gsd = new GridSplitDetector( this.getInternalGrid().getPivot() );
|
||||
this.beginVisit( gsd );
|
||||
if( !gsd.pivotFound )
|
||||
if( !gsd.isPivotFound() )
|
||||
{
|
||||
final IGridVisitor gp = new GridPropagator( new Grid( this ) );
|
||||
this.beginVisit( gp );
|
||||
@@ -231,7 +231,7 @@ public class GridNode implements IGridNode, IPathItem
|
||||
return this.myGrid;
|
||||
}
|
||||
|
||||
public void setGrid( final Grid grid )
|
||||
void setGrid( final Grid grid )
|
||||
{
|
||||
if( this.myGrid == grid )
|
||||
{
|
||||
@@ -329,7 +329,7 @@ public class GridNode implements IGridNode, IPathItem
|
||||
{
|
||||
final NBTTagCompound node = nodeData.getCompoundTag( name );
|
||||
this.playerID = node.getInteger( "p" );
|
||||
this.lastSecurityKey = node.getLong( "k" );
|
||||
this.setLastSecurityKey( node.getLong( "k" ) );
|
||||
|
||||
final long storageID = node.getLong( "g" );
|
||||
final GridStorage gridStorage = WorldData.instance().storageData().getGridStorage( storageID );
|
||||
@@ -349,7 +349,7 @@ public class GridNode implements IGridNode, IPathItem
|
||||
final NBTTagCompound node = new NBTTagCompound();
|
||||
|
||||
node.setInteger( "p", this.playerID );
|
||||
node.setLong( "k", this.lastSecurityKey );
|
||||
node.setLong( "k", this.getLastSecurityKey() );
|
||||
node.setLong( "g", this.myStorage.getID() );
|
||||
|
||||
nodeData.setTag( name, node );
|
||||
@@ -387,12 +387,12 @@ public class GridNode implements IGridNode, IPathItem
|
||||
}
|
||||
}
|
||||
|
||||
public int getUsedChannels()
|
||||
private int getUsedChannels()
|
||||
{
|
||||
return this.usedChannels;
|
||||
}
|
||||
|
||||
public void FindConnections()
|
||||
private void FindConnections()
|
||||
{
|
||||
if( !this.gridProxy.isWorldAccessible() )
|
||||
{
|
||||
@@ -445,7 +445,7 @@ public class GridNode implements IGridNode, IPathItem
|
||||
}
|
||||
else if( isValidConnection )
|
||||
{
|
||||
if( node.lastSecurityKey != -1 )
|
||||
if( node.getLastSecurityKey() != -1 )
|
||||
{
|
||||
newSecurityConnections.add( f );
|
||||
}
|
||||
@@ -495,7 +495,7 @@ public class GridNode implements IGridNode, IPathItem
|
||||
|
||||
private IGridHost findGridHost( final World world, final int x, final int y, final int z )
|
||||
{
|
||||
final BlockPos pos = new BlockPos(x,y,z);
|
||||
final BlockPos pos = new BlockPos( x, y, z );
|
||||
if( world.isBlockLoaded( pos ) )
|
||||
{
|
||||
final TileEntity te = world.getTileEntity( pos );
|
||||
@@ -507,7 +507,7 @@ public class GridNode implements IGridNode, IPathItem
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean canConnect( final GridNode from, final AEPartLocation dir )
|
||||
private boolean canConnect( final GridNode from, final AEPartLocation dir )
|
||||
{
|
||||
if( !this.isValidDirection( dir ) )
|
||||
{
|
||||
@@ -527,7 +527,7 @@ public class GridNode implements IGridNode, IPathItem
|
||||
return ( this.compressedData & ( 1 << ( 8 + dir.ordinal() ) ) ) > 0;
|
||||
}
|
||||
|
||||
public AEColor getColor()
|
||||
private AEColor getColor()
|
||||
{
|
||||
return AEColor.values()[( this.compressedData >> 3 ) & 0x1F];
|
||||
}
|
||||
@@ -541,9 +541,9 @@ public class GridNode implements IGridNode, IPathItem
|
||||
final GridNode gn = (GridNode) gc.getOtherSide( this );
|
||||
final GridConnection gcc = (GridConnection) gc;
|
||||
|
||||
if( gcc.visitorIterationNumber != tracker )
|
||||
if( gcc.getVisitorIterationNumber() != tracker )
|
||||
{
|
||||
gcc.visitorIterationNumber = tracker;
|
||||
gcc.setVisitorIterationNumber( tracker );
|
||||
nextConnections.add( gc );
|
||||
}
|
||||
|
||||
@@ -579,12 +579,12 @@ public class GridNode implements IGridNode, IPathItem
|
||||
}
|
||||
}
|
||||
|
||||
public GridStorage getGridStorage()
|
||||
GridStorage getGridStorage()
|
||||
{
|
||||
return this.myStorage;
|
||||
}
|
||||
|
||||
public void setGridStorage( final GridStorage s )
|
||||
void setGridStorage( final GridStorage s )
|
||||
{
|
||||
this.myStorage = s;
|
||||
this.usedChannels = 0;
|
||||
@@ -624,7 +624,7 @@ public class GridNode implements IGridNode, IPathItem
|
||||
return this.getUsedChannels() < this.getMaxChannels();
|
||||
}
|
||||
|
||||
public int getMaxChannels()
|
||||
private int getMaxChannels()
|
||||
{
|
||||
return CHANNEL_COUNT[this.compressedData & 0x03];
|
||||
}
|
||||
@@ -666,11 +666,31 @@ public class GridNode implements IGridNode, IPathItem
|
||||
}
|
||||
}
|
||||
|
||||
public int getLastUsedChannels()
|
||||
private int getLastUsedChannels()
|
||||
{
|
||||
return this.lastUsedChannels;
|
||||
}
|
||||
|
||||
public long getLastSecurityKey()
|
||||
{
|
||||
return this.lastSecurityKey;
|
||||
}
|
||||
|
||||
public void setLastSecurityKey( final long lastSecurityKey )
|
||||
{
|
||||
this.lastSecurityKey = lastSecurityKey;
|
||||
}
|
||||
|
||||
public double getPreviousDraw()
|
||||
{
|
||||
return this.previousDraw;
|
||||
}
|
||||
|
||||
public void setPreviousDraw( final double previousDraw )
|
||||
{
|
||||
this.previousDraw = previousDraw;
|
||||
}
|
||||
|
||||
private static class MachineSecurityBreak implements IWorldCallable<Void>
|
||||
{
|
||||
private final GridNode node;
|
||||
@@ -681,7 +701,7 @@ public class GridNode implements IGridNode, IPathItem
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void call( final World world) throws Exception
|
||||
public Void call( final World world ) throws Exception
|
||||
{
|
||||
this.node.getMachine().securityBreak();
|
||||
|
||||
|
||||
@@ -26,8 +26,8 @@ import appeng.api.networking.IGridVisitor;
|
||||
class GridSplitDetector implements IGridVisitor
|
||||
{
|
||||
|
||||
final IGridNode pivot;
|
||||
boolean pivotFound;
|
||||
private final IGridNode pivot;
|
||||
private boolean pivotFound;
|
||||
|
||||
public GridSplitDetector( final IGridNode pivot )
|
||||
{
|
||||
@@ -39,9 +39,19 @@ class GridSplitDetector implements IGridVisitor
|
||||
{
|
||||
if( n == this.pivot )
|
||||
{
|
||||
this.pivotFound = true;
|
||||
this.setPivotFound( true );
|
||||
}
|
||||
|
||||
return !this.pivotFound;
|
||||
return !this.isPivotFound();
|
||||
}
|
||||
|
||||
public boolean isPivotFound()
|
||||
{
|
||||
return this.pivotFound;
|
||||
}
|
||||
|
||||
private void setPivotFound( final boolean pivotFound )
|
||||
{
|
||||
this.pivotFound = pivotFound;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,11 +36,10 @@ import appeng.core.worlddata.WorldData;
|
||||
public class GridStorage implements IGridStorage
|
||||
{
|
||||
|
||||
final long myID;
|
||||
final NBTTagCompound data;
|
||||
final GridStorageSearch mySearchEntry; // keep myself in the list until I'm
|
||||
private final long myID;
|
||||
private final NBTTagCompound data;
|
||||
private final GridStorageSearch mySearchEntry; // keep myself in the list until I'm
|
||||
private final WeakHashMap<GridStorage, Boolean> divided = new WeakHashMap<GridStorage, Boolean>();
|
||||
public boolean isDirty = false;
|
||||
private WeakReference<IGrid> internalGrid = null;
|
||||
// lost...
|
||||
|
||||
@@ -95,8 +94,6 @@ public class GridStorage implements IGridStorage
|
||||
|
||||
public String getValue()
|
||||
{
|
||||
this.isDirty = false;
|
||||
|
||||
final Grid currentGrid = (Grid) this.getGrid();
|
||||
if( currentGrid != null )
|
||||
{
|
||||
@@ -122,7 +119,7 @@ public class GridStorage implements IGridStorage
|
||||
return this.internalGrid == null ? null : this.internalGrid.get();
|
||||
}
|
||||
|
||||
public void setGrid( final Grid grid )
|
||||
void setGrid( final Grid grid )
|
||||
{
|
||||
this.internalGrid = new WeakReference<IGrid>( grid );
|
||||
}
|
||||
@@ -139,22 +136,17 @@ public class GridStorage implements IGridStorage
|
||||
return this.myID;
|
||||
}
|
||||
|
||||
public void markDirty()
|
||||
{
|
||||
this.isDirty = true;
|
||||
}
|
||||
|
||||
public void addDivided( final GridStorage gs )
|
||||
void addDivided( final GridStorage gs )
|
||||
{
|
||||
this.divided.put( gs, true );
|
||||
}
|
||||
|
||||
public boolean hasDivided( final GridStorage myStorage )
|
||||
boolean hasDivided( final GridStorage myStorage )
|
||||
{
|
||||
return this.divided.containsKey( myStorage );
|
||||
}
|
||||
|
||||
public void remove()
|
||||
void remove()
|
||||
{
|
||||
WorldData.instance().storageData().destroyGridStorage( this.myID );
|
||||
}
|
||||
|
||||
@@ -25,8 +25,8 @@ import java.lang.ref.WeakReference;
|
||||
public class GridStorageSearch
|
||||
{
|
||||
|
||||
final long id;
|
||||
public WeakReference<GridStorage> gridStorage;
|
||||
private final long id;
|
||||
private WeakReference<GridStorage> gridStorage;
|
||||
|
||||
/**
|
||||
* for use with the world settings
|
||||
@@ -64,4 +64,14 @@ public class GridStorageSearch
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public WeakReference<GridStorage> getGridStorage()
|
||||
{
|
||||
return this.gridStorage;
|
||||
}
|
||||
|
||||
public void setGridStorage( final WeakReference<GridStorage> gridStorage )
|
||||
{
|
||||
this.gridStorage = gridStorage;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ public class NetworkEventBus
|
||||
private static final Collection<Class> READ_CLASSES = new HashSet<Class>();
|
||||
private static final Map<Class<? extends MENetworkEvent>, Map<Class, MENetworkEventInfo>> EVENTS = new HashMap<Class<? extends MENetworkEvent>, Map<Class, MENetworkEventInfo>>();
|
||||
|
||||
public void readClass( final Class listAs, final Class c )
|
||||
void readClass( final Class listAs, final Class c )
|
||||
{
|
||||
if( READ_CLASSES.contains( c ) )
|
||||
{
|
||||
@@ -94,7 +94,7 @@ public class NetworkEventBus
|
||||
}
|
||||
}
|
||||
|
||||
public MENetworkEvent postEvent( final Grid g, final MENetworkEvent e )
|
||||
MENetworkEvent postEvent( final Grid g, final MENetworkEvent e )
|
||||
{
|
||||
final Map<Class, MENetworkEventInfo> subscribers = EVENTS.get( e.getClass() );
|
||||
int x = 0;
|
||||
@@ -110,7 +110,7 @@ public class NetworkEventBus
|
||||
if( cache != null )
|
||||
{
|
||||
x++;
|
||||
target.invoke( cache.myCache, e );
|
||||
target.invoke( cache.getCache(), e );
|
||||
}
|
||||
|
||||
for( final IGridNode obj : g.getMachines( subscriber.getKey() ) )
|
||||
@@ -130,7 +130,7 @@ public class NetworkEventBus
|
||||
return e;
|
||||
}
|
||||
|
||||
public MENetworkEvent postEventTo( final Grid grid, final GridNode node, final MENetworkEvent e )
|
||||
MENetworkEvent postEventTo( final Grid grid, final GridNode node, final MENetworkEvent e )
|
||||
{
|
||||
final Map<Class, MENetworkEventInfo> subscribers = EVENTS.get( e.getClass() );
|
||||
int x = 0;
|
||||
@@ -156,19 +156,18 @@ public class NetworkEventBus
|
||||
return e;
|
||||
}
|
||||
|
||||
static class NetworkEventDone extends Throwable
|
||||
private static class NetworkEventDone extends Throwable
|
||||
{
|
||||
|
||||
private static final long serialVersionUID = -3079021487019171205L;
|
||||
}
|
||||
|
||||
|
||||
class EventMethod
|
||||
private class EventMethod
|
||||
{
|
||||
|
||||
public final Class objClass;
|
||||
public final Method objMethod;
|
||||
public final Class objEvent;
|
||||
private final Class objClass;
|
||||
private final Method objMethod;
|
||||
private final Class objEvent;
|
||||
|
||||
public EventMethod( final Class Event, final Class ObjClass, final Method ObjMethod )
|
||||
{
|
||||
@@ -177,7 +176,7 @@ public class NetworkEventBus
|
||||
this.objEvent = Event;
|
||||
}
|
||||
|
||||
public void invoke( final Object obj, final MENetworkEvent e ) throws NetworkEventDone
|
||||
private void invoke( final Object obj, final MENetworkEvent e ) throws NetworkEventDone
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -199,18 +198,17 @@ public class NetworkEventBus
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class MENetworkEventInfo
|
||||
private class MENetworkEventInfo
|
||||
{
|
||||
|
||||
private final List<EventMethod> methods = new ArrayList<EventMethod>();
|
||||
|
||||
public void Add( final Class Event, final Class ObjClass, final Method ObjMethod )
|
||||
private void Add( final Class Event, final Class ObjClass, final Method ObjMethod )
|
||||
{
|
||||
this.methods.add( new EventMethod( Event, ObjClass, ObjMethod ) );
|
||||
}
|
||||
|
||||
public void invoke( final Object obj, final MENetworkEvent e ) throws NetworkEventDone
|
||||
private void invoke( final Object obj, final MENetworkEvent e ) throws NetworkEventDone
|
||||
{
|
||||
for( final EventMethod em : this.methods )
|
||||
{
|
||||
|
||||
+9
-4
@@ -88,8 +88,8 @@ import com.google.common.collect.Multimap;
|
||||
public class CraftingGridCache implements ICraftingGrid, ICraftingProviderHelper, ICellProvider, IMEInventoryHandler<IAEStack>
|
||||
{
|
||||
|
||||
public static final ExecutorService CRAFTING_POOL;
|
||||
static final Comparator<ICraftingPatternDetails> COMPARATOR = new Comparator<ICraftingPatternDetails>()
|
||||
private static final ExecutorService CRAFTING_POOL;
|
||||
private static final Comparator<ICraftingPatternDetails> COMPARATOR = new Comparator<ICraftingPatternDetails>()
|
||||
{
|
||||
@Override
|
||||
public int compare( final ICraftingPatternDetails firstDetail, final ICraftingPatternDetails nextDetail )
|
||||
@@ -122,7 +122,7 @@ public class CraftingGridCache implements ICraftingGrid, ICraftingProviderHelper
|
||||
private final Set<IAEItemStack> emitableItems = new HashSet<IAEItemStack>();
|
||||
private final Map<String, CraftingLinkNexus> craftingLinks = new HashMap<String, CraftingLinkNexus>();
|
||||
private final Multimap<IAEStack, CraftingWatcher> interests = HashMultimap.create();
|
||||
public final GenericInterestManager<CraftingWatcher> interestManager = new GenericInterestManager<CraftingWatcher>( this.interests );
|
||||
private final GenericInterestManager<CraftingWatcher> interestManager = new GenericInterestManager<CraftingWatcher>( this.interests );
|
||||
private IStorageGrid storageGrid;
|
||||
private IEnergyGrid energyGrid;
|
||||
private boolean updateList = false;
|
||||
@@ -615,7 +615,12 @@ public class CraftingGridCache implements ICraftingGrid, ICraftingProviderHelper
|
||||
return this.craftingCPUClusters.contains( cpu );
|
||||
}
|
||||
|
||||
static class ActiveCpuIterator implements Iterator<ICraftingCPU>
|
||||
public GenericInterestManager<CraftingWatcher> getInterestManager()
|
||||
{
|
||||
return this.interestManager;
|
||||
}
|
||||
|
||||
private static class ActiveCpuIterator implements Iterator<ICraftingCPU>
|
||||
{
|
||||
|
||||
private final Iterator<CraftingCPUCluster> iterator;
|
||||
|
||||
+37
-32
@@ -58,42 +58,42 @@ import com.google.common.collect.Multiset;
|
||||
public class EnergyGridCache implements IEnergyGrid
|
||||
{
|
||||
|
||||
public final TreeSet<EnergyThreshold> interests = new TreeSet<EnergyThreshold>();
|
||||
final double AvgLength = 40.0;
|
||||
final Set<IAEPowerStorage> providers = new LinkedHashSet<IAEPowerStorage>();
|
||||
final Set<IAEPowerStorage> requesters = new LinkedHashSet<IAEPowerStorage>();
|
||||
final Multiset<IEnergyGridProvider> energyGridProviders = HashMultiset.create();
|
||||
final IGrid myGrid;
|
||||
private final TreeSet<EnergyThreshold> interests = new TreeSet<EnergyThreshold>();
|
||||
private final double AvgLength = 40.0;
|
||||
private final Set<IAEPowerStorage> providers = new LinkedHashSet<IAEPowerStorage>();
|
||||
private final Set<IAEPowerStorage> requesters = new LinkedHashSet<IAEPowerStorage>();
|
||||
private final Multiset<IEnergyGridProvider> energyGridProviders = HashMultiset.create();
|
||||
private final IGrid myGrid;
|
||||
private final HashMap<IGridNode, IEnergyWatcher> watchers = new HashMap<IGridNode, IEnergyWatcher>();
|
||||
private final Set<IEnergyGrid> localSeen = new HashSet<IEnergyGrid>();
|
||||
/**
|
||||
* estimated power available.
|
||||
*/
|
||||
int availableTicksSinceUpdate = 0;
|
||||
double globalAvailablePower = 0;
|
||||
double globalMaxPower = 0;
|
||||
private int availableTicksSinceUpdate = 0;
|
||||
private double globalAvailablePower = 0;
|
||||
private double globalMaxPower = 0;
|
||||
/**
|
||||
* idle draw.
|
||||
*/
|
||||
double drainPerTick = 0;
|
||||
double avgDrainPerTick = 0;
|
||||
double avgInjectionPerTick = 0;
|
||||
double tickDrainPerTick = 0;
|
||||
double tickInjectionPerTick = 0;
|
||||
private double drainPerTick = 0;
|
||||
private double avgDrainPerTick = 0;
|
||||
private double avgInjectionPerTick = 0;
|
||||
private double tickDrainPerTick = 0;
|
||||
private double tickInjectionPerTick = 0;
|
||||
/**
|
||||
* power status
|
||||
*/
|
||||
boolean publicHasPower = false;
|
||||
boolean hasPower = true;
|
||||
long ticksSinceHasPowerChange = 900;
|
||||
private boolean publicHasPower = false;
|
||||
private boolean hasPower = true;
|
||||
private long ticksSinceHasPowerChange = 900;
|
||||
/**
|
||||
* excess power in the system.
|
||||
*/
|
||||
double extra = 0;
|
||||
IAEPowerStorage lastProvider;
|
||||
IAEPowerStorage lastRequester;
|
||||
PathGridCache pgc;
|
||||
double lastStoredPower = -1;
|
||||
private double extra = 0;
|
||||
private IAEPowerStorage lastProvider;
|
||||
private IAEPowerStorage lastRequester;
|
||||
private PathGridCache pgc;
|
||||
private double lastStoredPower = -1;
|
||||
|
||||
public EnergyGridCache( final IGrid g )
|
||||
{
|
||||
@@ -114,8 +114,8 @@ public class EnergyGridCache implements IEnergyGrid
|
||||
final IGridBlock gb = node.getGridBlock();
|
||||
|
||||
final double newDraw = gb.getIdlePowerUsage();
|
||||
final double diffDraw = newDraw - node.previousDraw;
|
||||
node.previousDraw = newDraw;
|
||||
final double diffDraw = newDraw - node.getPreviousDraw();
|
||||
node.setPreviousDraw( newDraw );
|
||||
|
||||
this.drainPerTick += diffDraw;
|
||||
}
|
||||
@@ -150,16 +150,16 @@ public class EnergyGridCache implements IEnergyGrid
|
||||
@Override
|
||||
public void onUpdateTick()
|
||||
{
|
||||
if( !this.interests.isEmpty() )
|
||||
if( !this.getInterests().isEmpty() )
|
||||
{
|
||||
final double oldPower = this.lastStoredPower;
|
||||
this.lastStoredPower = this.getStoredPower();
|
||||
|
||||
final EnergyThreshold low = new EnergyThreshold( Math.min( oldPower, this.lastStoredPower ), null );
|
||||
final EnergyThreshold high = new EnergyThreshold( Math.max( oldPower, this.lastStoredPower ), null );
|
||||
for( final EnergyThreshold th : this.interests.subSet( low, true, high, true ) )
|
||||
for( final EnergyThreshold th : this.getInterests().subSet( low, true, high, true ) )
|
||||
{
|
||||
( (EnergyWatcher) th.watcher ).post( this );
|
||||
( (EnergyWatcher) th.getWatcher() ).post( this );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -221,7 +221,7 @@ public class EnergyGridCache implements IEnergyGrid
|
||||
@Override
|
||||
public double getIdlePowerUsage()
|
||||
{
|
||||
return this.drainPerTick + this.pgc.channelPowerUsage;
|
||||
return this.drainPerTick + this.pgc.getChannelPowerUsage();
|
||||
}
|
||||
|
||||
private void publicPowerState( final boolean newState, final IGrid grid )
|
||||
@@ -239,7 +239,7 @@ public class EnergyGridCache implements IEnergyGrid
|
||||
/**
|
||||
* refresh current stored power.
|
||||
*/
|
||||
public void refreshPower()
|
||||
private void refreshPower()
|
||||
{
|
||||
this.availableTicksSinceUpdate = 0;
|
||||
this.globalAvailablePower = 0;
|
||||
@@ -520,7 +520,7 @@ public class EnergyGridCache implements IEnergyGrid
|
||||
|
||||
// idle draw.
|
||||
final GridNode gridNode = (GridNode) node;
|
||||
this.drainPerTick -= gridNode.previousDraw;
|
||||
this.drainPerTick -= gridNode.getPreviousDraw();
|
||||
|
||||
// power storage.
|
||||
if( machine instanceof IAEPowerStorage )
|
||||
@@ -571,8 +571,8 @@ public class EnergyGridCache implements IEnergyGrid
|
||||
// idle draw...
|
||||
final GridNode gridNode = (GridNode) node;
|
||||
final IGridBlock gb = gridNode.getGridBlock();
|
||||
gridNode.previousDraw = gb.getIdlePowerUsage();
|
||||
this.drainPerTick += gridNode.previousDraw;
|
||||
gridNode.setPreviousDraw( gb.getIdlePowerUsage() );
|
||||
this.drainPerTick += gridNode.getPreviousDraw();
|
||||
|
||||
// power storage
|
||||
if( machine instanceof IAEPowerStorage )
|
||||
@@ -630,4 +630,9 @@ public class EnergyGridCache implements IEnergyGrid
|
||||
{
|
||||
storage.dataObject().setDouble( "extraEnergy", this.extra );
|
||||
}
|
||||
|
||||
public TreeSet<EnergyThreshold> getInterests()
|
||||
{
|
||||
return this.interests;
|
||||
}
|
||||
}
|
||||
|
||||
+21
-11
@@ -58,11 +58,11 @@ import com.google.common.collect.SetMultimap;
|
||||
public class GridStorageCache implements IStorageGrid
|
||||
{
|
||||
|
||||
public final IGrid myGrid;
|
||||
final HashSet<ICellProvider> activeCellProviders = new HashSet<ICellProvider>();
|
||||
final HashSet<ICellProvider> inactiveCellProviders = new HashSet<ICellProvider>();
|
||||
private final IGrid myGrid;
|
||||
private final HashSet<ICellProvider> activeCellProviders = new HashSet<ICellProvider>();
|
||||
private final HashSet<ICellProvider> inactiveCellProviders = new HashSet<ICellProvider>();
|
||||
private final SetMultimap<IAEStack, ItemWatcher> interests = HashMultimap.create();
|
||||
public final GenericInterestManager<ItemWatcher> interestManager = new GenericInterestManager<ItemWatcher>( this.interests );
|
||||
private final GenericInterestManager<ItemWatcher> interestManager = new GenericInterestManager<ItemWatcher>( this.interests );
|
||||
private final NetworkMonitor<IAEItemStack> itemMonitor = new NetworkMonitor<IAEItemStack>( this, StorageChannel.ITEMS );
|
||||
private final NetworkMonitor<IAEFluidStack> fluidMonitor = new NetworkMonitor<IAEFluidStack>( this, StorageChannel.FLUIDS );
|
||||
private final HashMap<IGridNode, IStackWatcher> watchers = new HashMap<IGridNode, IStackWatcher>();
|
||||
@@ -88,7 +88,7 @@ public class GridStorageCache implements IStorageGrid
|
||||
{
|
||||
final ICellContainer cc = (ICellContainer) machine;
|
||||
|
||||
this.myGrid.postEvent( new MENetworkCellArrayUpdate() );
|
||||
this.getGrid().postEvent( new MENetworkCellArrayUpdate() );
|
||||
this.removeCellProvider( cc, new CellChangeTracker() ).applyChanges();
|
||||
this.inactiveCellProviders.remove( cc );
|
||||
}
|
||||
@@ -112,7 +112,7 @@ public class GridStorageCache implements IStorageGrid
|
||||
final ICellContainer cc = (ICellContainer) machine;
|
||||
this.inactiveCellProviders.add( cc );
|
||||
|
||||
this.myGrid.postEvent( new MENetworkCellArrayUpdate() );
|
||||
this.getGrid().postEvent( new MENetworkCellArrayUpdate() );
|
||||
if( node.isActive() )
|
||||
{
|
||||
this.addCellProvider( cc, new CellChangeTracker() ).applyChanges();
|
||||
@@ -146,7 +146,7 @@ public class GridStorageCache implements IStorageGrid
|
||||
|
||||
}
|
||||
|
||||
public CellChangeTracker addCellProvider( final ICellProvider cc, final CellChangeTracker tracker )
|
||||
private CellChangeTracker addCellProvider( final ICellProvider cc, final CellChangeTracker tracker )
|
||||
{
|
||||
if( this.inactiveCellProviders.contains( cc ) )
|
||||
{
|
||||
@@ -173,7 +173,7 @@ public class GridStorageCache implements IStorageGrid
|
||||
return tracker;
|
||||
}
|
||||
|
||||
public CellChangeTracker removeCellProvider( final ICellProvider cc, final CellChangeTracker tracker )
|
||||
private CellChangeTracker removeCellProvider( final ICellProvider cc, final CellChangeTracker tracker )
|
||||
{
|
||||
if( this.activeCellProviders.contains( cc ) )
|
||||
{
|
||||
@@ -259,7 +259,7 @@ public class GridStorageCache implements IStorageGrid
|
||||
}
|
||||
}
|
||||
|
||||
public IMEInventoryHandler<IAEItemStack> getItemInventoryHandler()
|
||||
IMEInventoryHandler<IAEItemStack> getItemInventoryHandler()
|
||||
{
|
||||
if( this.myItemNetwork == null )
|
||||
{
|
||||
@@ -270,7 +270,7 @@ public class GridStorageCache implements IStorageGrid
|
||||
|
||||
private void buildNetworkStorage( final StorageChannel chan )
|
||||
{
|
||||
final SecurityCache security = this.myGrid.getCache( ISecurityGrid.class );
|
||||
final SecurityCache security = this.getGrid().getCache( ISecurityGrid.class );
|
||||
|
||||
switch( chan )
|
||||
{
|
||||
@@ -298,7 +298,7 @@ public class GridStorageCache implements IStorageGrid
|
||||
}
|
||||
}
|
||||
|
||||
public IMEInventoryHandler<IAEFluidStack> getFluidInventoryHandler()
|
||||
IMEInventoryHandler<IAEFluidStack> getFluidInventoryHandler()
|
||||
{
|
||||
if( this.myFluidNetwork == null )
|
||||
{
|
||||
@@ -346,6 +346,16 @@ public class GridStorageCache implements IStorageGrid
|
||||
return this.fluidMonitor;
|
||||
}
|
||||
|
||||
public GenericInterestManager<ItemWatcher> getInterestManager()
|
||||
{
|
||||
return this.interestManager;
|
||||
}
|
||||
|
||||
IGrid getGrid()
|
||||
{
|
||||
return this.myGrid;
|
||||
}
|
||||
|
||||
private class CellChangeTrackerRecord
|
||||
{
|
||||
|
||||
|
||||
+8
-8
@@ -42,7 +42,7 @@ public class NetworkMonitor<T extends IAEStack<T>> extends MEMonitorHandler<T>
|
||||
private static final Deque<NetworkMonitor<?>> DEPTH = new LinkedList<NetworkMonitor<?>>();
|
||||
private final GridStorageCache myGridCache;
|
||||
private final StorageChannel myChannel;
|
||||
boolean sendEvent = false;
|
||||
private boolean sendEvent = false;
|
||||
|
||||
public NetworkMonitor( final GridStorageCache cache, final StorageChannel chan )
|
||||
{
|
||||
@@ -51,7 +51,7 @@ public class NetworkMonitor<T extends IAEStack<T>> extends MEMonitorHandler<T>
|
||||
this.myChannel = chan;
|
||||
}
|
||||
|
||||
public void forceUpdate()
|
||||
void forceUpdate()
|
||||
{
|
||||
this.hasChanged = true;
|
||||
|
||||
@@ -72,12 +72,12 @@ public class NetworkMonitor<T extends IAEStack<T>> extends MEMonitorHandler<T>
|
||||
}
|
||||
}
|
||||
|
||||
public void onTick()
|
||||
void onTick()
|
||||
{
|
||||
if( this.sendEvent )
|
||||
{
|
||||
this.sendEvent = false;
|
||||
this.myGridCache.myGrid.postEvent( new MENetworkStorageEvent( this, this.myChannel ) );
|
||||
this.myGridCache.getGrid().postEvent( new MENetworkStorageEvent( this, this.myChannel ) );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -124,9 +124,9 @@ public class NetworkMonitor<T extends IAEStack<T>> extends MEMonitorHandler<T>
|
||||
( difference = changedItem.copy() ).setStackSize( -changedItem.getStackSize() );
|
||||
}
|
||||
|
||||
if( this.myGridCache.interestManager.containsKey( changedItem ) )
|
||||
if( this.myGridCache.getInterestManager().containsKey( changedItem ) )
|
||||
{
|
||||
final Collection<ItemWatcher> list = this.myGridCache.interestManager.get( changedItem );
|
||||
final Collection<ItemWatcher> list = this.myGridCache.getInterestManager().get( changedItem );
|
||||
if( !list.isEmpty() )
|
||||
{
|
||||
IAEStack fullStack = myStorageList.findPrecise( changedItem );
|
||||
@@ -136,14 +136,14 @@ public class NetworkMonitor<T extends IAEStack<T>> extends MEMonitorHandler<T>
|
||||
fullStack.setStackSize( 0 );
|
||||
}
|
||||
|
||||
this.myGridCache.interestManager.enableTransactions();
|
||||
this.myGridCache.getInterestManager().enableTransactions();
|
||||
|
||||
for( final ItemWatcher iw : list )
|
||||
{
|
||||
iw.getHost().onStackChange( myStorageList, fullStack, difference, src, this.getChannel() );
|
||||
}
|
||||
|
||||
this.myGridCache.interestManager.disableTransactions();
|
||||
this.myGridCache.getInterestManager().disableTransactions();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+17
-17
@@ -42,7 +42,7 @@ import com.google.common.collect.Multimap;
|
||||
public class P2PCache implements IGridCache
|
||||
{
|
||||
|
||||
final IGrid myGrid;
|
||||
private final IGrid myGrid;
|
||||
private final HashMap<Long, PartP2PTunnel> inputs = new HashMap<Long, PartP2PTunnel>();
|
||||
private final Multimap<Long, PartP2PTunnel> outputs = LinkedHashMultimap.create();
|
||||
private final TunnelCollection NullColl = new TunnelCollection<PartP2PTunnel>( null, null );
|
||||
@@ -101,16 +101,16 @@ public class P2PCache implements IGridCache
|
||||
// AELog.info( "rmv-" + (t.output ? "output: " : "input: ") + t.freq
|
||||
// );
|
||||
|
||||
if( t.output )
|
||||
if( t.isOutput() )
|
||||
{
|
||||
this.outputs.remove( t.freq, t );
|
||||
this.outputs.remove( t.getFrequency(), t );
|
||||
}
|
||||
else
|
||||
{
|
||||
this.inputs.remove( t.freq );
|
||||
this.inputs.remove( t.getFrequency() );
|
||||
}
|
||||
|
||||
this.updateTunnel( t.freq, !t.output, false );
|
||||
this.updateTunnel( t.getFrequency(), !t.isOutput(), false );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -131,16 +131,16 @@ public class P2PCache implements IGridCache
|
||||
// AELog.info( "add-" + (t.output ? "output: " : "input: ") + t.freq
|
||||
// );
|
||||
|
||||
if( t.output )
|
||||
if( t.isOutput() )
|
||||
{
|
||||
this.outputs.put( t.freq, t );
|
||||
this.outputs.put( t.getFrequency(), t );
|
||||
}
|
||||
else
|
||||
{
|
||||
this.inputs.put( t.freq, t );
|
||||
this.inputs.put( t.getFrequency(), t );
|
||||
}
|
||||
|
||||
this.updateTunnel( t.freq, !t.output, false );
|
||||
this.updateTunnel( t.getFrequency(), !t.isOutput(), false );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -188,29 +188,29 @@ public class P2PCache implements IGridCache
|
||||
{
|
||||
if( this.outputs.containsValue( t ) )
|
||||
{
|
||||
this.outputs.remove( t.freq, t );
|
||||
this.outputs.remove( t.getFrequency(), t );
|
||||
}
|
||||
|
||||
if( this.inputs.containsValue( t ) )
|
||||
{
|
||||
this.inputs.remove( t.freq );
|
||||
this.inputs.remove( t.getFrequency() );
|
||||
}
|
||||
|
||||
t.freq = newFrequency;
|
||||
t.setFrequency( newFrequency );
|
||||
|
||||
if( t.output )
|
||||
if( t.isOutput() )
|
||||
{
|
||||
this.outputs.put( t.freq, t );
|
||||
this.outputs.put( t.getFrequency(), t );
|
||||
}
|
||||
else
|
||||
{
|
||||
this.inputs.put( t.freq, t );
|
||||
this.inputs.put( t.getFrequency(), t );
|
||||
}
|
||||
|
||||
// AELog.info( "update-" + (t.output ? "output: " : "input: ") + t.freq
|
||||
// );
|
||||
this.updateTunnel( t.freq, t.output, true );
|
||||
this.updateTunnel( t.freq, !t.output, true );
|
||||
this.updateTunnel( t.getFrequency(), t.isOutput(), true );
|
||||
this.updateTunnel( t.getFrequency(), !t.isOutput(), true );
|
||||
}
|
||||
|
||||
public TunnelCollection<PartP2PTunnel> getOutputs( final long freq, final Class<? extends PartP2PTunnel> c )
|
||||
|
||||
+57
-29
@@ -59,21 +59,20 @@ import appeng.util.Platform;
|
||||
public class PathGridCache implements IPathingGrid
|
||||
{
|
||||
|
||||
final LinkedList<PathSegment> active = new LinkedList<PathSegment>();
|
||||
final Set<TileController> controllers = new HashSet<TileController>();
|
||||
final Set<IGridNode> requireChannels = new HashSet<IGridNode>();
|
||||
final Set<IGridNode> blockDense = new HashSet<IGridNode>();
|
||||
final IGrid myGrid;
|
||||
public int channelsInUse = 0;
|
||||
public int channelsByBlocks = 0;
|
||||
public double channelPowerUsage = 0.0;
|
||||
boolean recalculateControllerNextTick = true;
|
||||
boolean updateNetwork = true;
|
||||
boolean booting = false;
|
||||
ControllerState controllerState = ControllerState.NO_CONTROLLER;
|
||||
int instance = Integer.MIN_VALUE;
|
||||
int ticksUntilReady = 20;
|
||||
int lastChannels = 0;
|
||||
private final LinkedList<PathSegment> active = new LinkedList<PathSegment>();
|
||||
private final Set<TileController> controllers = new HashSet<TileController>();
|
||||
private final Set<IGridNode> requireChannels = new HashSet<IGridNode>();
|
||||
private final Set<IGridNode> blockDense = new HashSet<IGridNode>();
|
||||
private final IGrid myGrid;
|
||||
private int channelsInUse = 0;
|
||||
private int channelsByBlocks = 0;
|
||||
private double channelPowerUsage = 0.0;
|
||||
private boolean recalculateControllerNextTick = true;
|
||||
private boolean updateNetwork = true;
|
||||
private boolean booting = false;
|
||||
private ControllerState controllerState = ControllerState.NO_CONTROLLER;
|
||||
private int ticksUntilReady = 20;
|
||||
private int lastChannels = 0;
|
||||
private HashSet<IPathItem> semiOpen = new HashSet<IPathItem>();
|
||||
|
||||
public PathGridCache( final IGrid g )
|
||||
@@ -98,8 +97,7 @@ public class PathGridCache implements IPathingGrid
|
||||
|
||||
this.booting = true;
|
||||
this.updateNetwork = false;
|
||||
this.instance++;
|
||||
this.channelsInUse = 0;
|
||||
this.setChannelsInUse( 0 );
|
||||
|
||||
if( !AEConfig.instance.isFeatureEnabled( AEFeature.Channels ) )
|
||||
{
|
||||
@@ -107,8 +105,8 @@ public class PathGridCache implements IPathingGrid
|
||||
|
||||
final int nodes = this.myGrid.getNodes().size();
|
||||
this.ticksUntilReady = 20 + Math.max( 0, nodes / 100 - 20 );
|
||||
this.channelsByBlocks = nodes * used;
|
||||
this.channelPowerUsage = this.channelsByBlocks / 128.0;
|
||||
this.setChannelsByBlocks( nodes * used );
|
||||
this.setChannelPowerUsage( this.getChannelsByBlocks() / 128.0 );
|
||||
|
||||
this.myGrid.getPivot().beginVisit( new AdHocChannelUpdater( used ) );
|
||||
}
|
||||
@@ -122,11 +120,11 @@ public class PathGridCache implements IPathingGrid
|
||||
}
|
||||
|
||||
final int nodes = this.myGrid.getNodes().size();
|
||||
this.channelsInUse = used;
|
||||
this.setChannelsInUse( used );
|
||||
|
||||
this.ticksUntilReady = 20 + Math.max( 0, nodes / 100 - 20 );
|
||||
this.channelsByBlocks = nodes * used;
|
||||
this.channelPowerUsage = this.channelsByBlocks / 128.0;
|
||||
this.setChannelsByBlocks( nodes * used );
|
||||
this.setChannelPowerUsage( this.getChannelsByBlocks() / 128.0 );
|
||||
|
||||
this.myGrid.getPivot().beginVisit( new AdHocChannelUpdater( used ) );
|
||||
}
|
||||
@@ -171,7 +169,7 @@ public class PathGridCache implements IPathingGrid
|
||||
final PathSegment pat = i.next();
|
||||
if( pat.step() )
|
||||
{
|
||||
pat.isDead = true;
|
||||
pat.setDead( true );
|
||||
i.remove();
|
||||
}
|
||||
}
|
||||
@@ -194,7 +192,7 @@ public class PathGridCache implements IPathingGrid
|
||||
this.achievementPost();
|
||||
|
||||
this.booting = false;
|
||||
this.channelPowerUsage = this.channelsByBlocks / 128.0;
|
||||
this.setChannelPowerUsage( this.getChannelsByBlocks() / 128.0 );
|
||||
this.myGrid.postEvent( new MENetworkBootingStatusChange() );
|
||||
}
|
||||
}
|
||||
@@ -289,7 +287,7 @@ public class PathGridCache implements IPathingGrid
|
||||
|
||||
startingNode.beginVisit( cv );
|
||||
|
||||
if( cv.isValid && cv.found == this.controllers.size() )
|
||||
if( cv.isValid() && cv.getFound() == this.controllers.size() )
|
||||
{
|
||||
this.controllerState = ControllerState.CONTROLLER_ONLINE;
|
||||
}
|
||||
@@ -341,9 +339,9 @@ public class PathGridCache implements IPathingGrid
|
||||
|
||||
private void achievementPost()
|
||||
{
|
||||
if( this.lastChannels != this.channelsInUse && AEConfig.instance.isFeatureEnabled( AEFeature.Channels ) )
|
||||
if( this.lastChannels != this.getChannelsInUse() && AEConfig.instance.isFeatureEnabled( AEFeature.Channels ) )
|
||||
{
|
||||
final Achievements currentBracket = this.getAchievementBracket( this.channelsInUse );
|
||||
final Achievements currentBracket = this.getAchievementBracket( this.getChannelsInUse() );
|
||||
final Achievements lastBracket = this.getAchievementBracket( this.lastChannels );
|
||||
if( currentBracket != lastBracket && currentBracket != null )
|
||||
{
|
||||
@@ -359,7 +357,7 @@ public class PathGridCache implements IPathingGrid
|
||||
}
|
||||
}
|
||||
}
|
||||
this.lastChannels = this.channelsInUse;
|
||||
this.lastChannels = this.getChannelsInUse();
|
||||
}
|
||||
|
||||
private Achievements getAchievementBracket( final int ch )
|
||||
@@ -417,7 +415,37 @@ public class PathGridCache implements IPathingGrid
|
||||
// clean up...
|
||||
this.active.clear();
|
||||
|
||||
this.channelsByBlocks = 0;
|
||||
this.setChannelsByBlocks( 0 );
|
||||
this.updateNetwork = true;
|
||||
}
|
||||
|
||||
double getChannelPowerUsage()
|
||||
{
|
||||
return this.channelPowerUsage;
|
||||
}
|
||||
|
||||
private void setChannelPowerUsage( final double channelPowerUsage )
|
||||
{
|
||||
this.channelPowerUsage = channelPowerUsage;
|
||||
}
|
||||
|
||||
public int getChannelsByBlocks()
|
||||
{
|
||||
return this.channelsByBlocks;
|
||||
}
|
||||
|
||||
public void setChannelsByBlocks( final int channelsByBlocks )
|
||||
{
|
||||
this.channelsByBlocks = channelsByBlocks;
|
||||
}
|
||||
|
||||
public int getChannelsInUse()
|
||||
{
|
||||
return this.channelsInUse;
|
||||
}
|
||||
|
||||
public void setChannelsInUse( final int channelsInUse )
|
||||
{
|
||||
this.channelsInUse = channelsInUse;
|
||||
}
|
||||
}
|
||||
|
||||
+10
-5
@@ -44,7 +44,7 @@ import appeng.me.GridNode;
|
||||
public class SecurityCache implements ISecurityGrid
|
||||
{
|
||||
|
||||
public final IGrid myGrid;
|
||||
private final IGrid myGrid;
|
||||
private final List<ISecurityProvider> securityProvider = new ArrayList<ISecurityProvider>();
|
||||
private final HashMap<Integer, EnumSet<SecurityPermissions>> playerPerms = new HashMap<Integer, EnumSet<SecurityPermissions>>();
|
||||
private long securityKey = -1;
|
||||
@@ -102,10 +102,10 @@ public class SecurityCache implements ISecurityGrid
|
||||
|
||||
if( lastCode != this.securityKey )
|
||||
{
|
||||
this.myGrid.postEvent( new MENetworkSecurityChange() );
|
||||
for( final IGridNode n : this.myGrid.getNodes() )
|
||||
this.getGrid().postEvent( new MENetworkSecurityChange() );
|
||||
for( final IGridNode n : this.getGrid().getNodes() )
|
||||
{
|
||||
( (GridNode) n ).lastSecurityKey = this.securityKey;
|
||||
( (GridNode) n ).setLastSecurityKey( this.securityKey );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -120,7 +120,7 @@ public class SecurityCache implements ISecurityGrid
|
||||
}
|
||||
else
|
||||
{
|
||||
( (GridNode) gridNode ).lastSecurityKey = this.securityKey;
|
||||
( (GridNode) gridNode ).setLastSecurityKey( this.securityKey );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -193,4 +193,9 @@ public class SecurityCache implements ISecurityGrid
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
public IGrid getGrid()
|
||||
{
|
||||
return this.myGrid;
|
||||
}
|
||||
}
|
||||
|
||||
+23
-24
@@ -41,15 +41,14 @@ import appeng.tile.spatial.TileSpatialPylon;
|
||||
public class SpatialPylonCache implements ISpatialCache
|
||||
{
|
||||
|
||||
final IGrid myGrid;
|
||||
long powerRequired = 0;
|
||||
double efficiency = 0.0;
|
||||
DimensionalCoord captureMin;
|
||||
DimensionalCoord captureMax;
|
||||
boolean isValid = false;
|
||||
List<TileSpatialIOPort> ioPorts = new LinkedList<TileSpatialIOPort>();
|
||||
HashMap<SpatialPylonCluster, SpatialPylonCluster> clusters = new HashMap<SpatialPylonCluster, SpatialPylonCluster>();
|
||||
boolean needsUpdate = false;
|
||||
private final IGrid myGrid;
|
||||
private long powerRequired = 0;
|
||||
private double efficiency = 0.0;
|
||||
private DimensionalCoord captureMin;
|
||||
private DimensionalCoord captureMax;
|
||||
private boolean isValid = false;
|
||||
private List<TileSpatialIOPort> ioPorts = new LinkedList<TileSpatialIOPort>();
|
||||
private HashMap<SpatialPylonCluster, SpatialPylonCluster> clusters = new HashMap<SpatialPylonCluster, SpatialPylonCluster>();
|
||||
|
||||
public SpatialPylonCache( final IGrid g )
|
||||
{
|
||||
@@ -62,7 +61,7 @@ public class SpatialPylonCache implements ISpatialCache
|
||||
this.reset( this.myGrid );
|
||||
}
|
||||
|
||||
public void reset( final IGrid grid )
|
||||
private void reset( final IGrid grid )
|
||||
{
|
||||
|
||||
this.clusters = new HashMap<SpatialPylonCluster, SpatialPylonCluster>();
|
||||
@@ -95,22 +94,22 @@ public class SpatialPylonCache implements ISpatialCache
|
||||
{
|
||||
if( this.captureMax == null )
|
||||
{
|
||||
this.captureMax = cl.max.copy();
|
||||
this.captureMax = cl.getMax().copy();
|
||||
}
|
||||
if( this.captureMin == null )
|
||||
{
|
||||
this.captureMin = cl.min.copy();
|
||||
this.captureMin = cl.getMin().copy();
|
||||
}
|
||||
|
||||
pylonBlocks += cl.tileCount();
|
||||
|
||||
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 );
|
||||
this.captureMin.x = Math.min( this.captureMin.x, cl.getMin().x );
|
||||
this.captureMin.y = Math.min( this.captureMin.y, cl.getMin().y );
|
||||
this.captureMin.z = Math.min( this.captureMin.z, cl.getMin().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 );
|
||||
this.captureMax.x = Math.max( this.captureMax.x, cl.getMax().x );
|
||||
this.captureMax.y = Math.max( this.captureMax.y, cl.getMax().y );
|
||||
this.captureMax.z = Math.max( this.captureMax.z, cl.getMax().z );
|
||||
}
|
||||
|
||||
double maxPower = 0;
|
||||
@@ -121,21 +120,21 @@ public class SpatialPylonCache implements ISpatialCache
|
||||
|
||||
for( final SpatialPylonCluster cl : this.clusters.values() )
|
||||
{
|
||||
switch( cl.currentAxis )
|
||||
switch( cl.getCurrentAxis() )
|
||||
{
|
||||
case X:
|
||||
|
||||
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 ) );
|
||||
this.isValid = this.isValid && ( ( this.captureMax.y == cl.getMin().y || this.captureMin.y == cl.getMax().y ) || ( this.captureMax.z == cl.getMin().z || this.captureMin.z == cl.getMax().z ) ) && ( ( this.captureMax.y == cl.getMax().y || this.captureMin.y == cl.getMin().y ) || ( this.captureMax.z == cl.getMax().z || this.captureMin.z == cl.getMin().z ) );
|
||||
|
||||
break;
|
||||
case Y:
|
||||
|
||||
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 ) );
|
||||
this.isValid = this.isValid && ( ( this.captureMax.x == cl.getMin().x || this.captureMin.x == cl.getMax().x ) || ( this.captureMax.z == cl.getMin().z || this.captureMin.z == cl.getMax().z ) ) && ( ( this.captureMax.x == cl.getMax().x || this.captureMin.x == cl.getMin().x ) || ( this.captureMax.z == cl.getMax().z || this.captureMin.z == cl.getMin().z ) );
|
||||
|
||||
break;
|
||||
case Z:
|
||||
|
||||
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 ) );
|
||||
this.isValid = this.isValid && ( ( this.captureMax.y == cl.getMin().y || this.captureMin.y == cl.getMax().y ) || ( this.captureMax.x == cl.getMin().x || this.captureMin.x == cl.getMax().x ) ) && ( ( this.captureMax.y == cl.getMax().y || this.captureMin.y == cl.getMin().y ) || ( this.captureMax.x == cl.getMax().x || this.captureMin.x == cl.getMin().x ) );
|
||||
|
||||
break;
|
||||
case UNFORMED:
|
||||
@@ -169,8 +168,8 @@ public class SpatialPylonCache implements ISpatialCache
|
||||
|
||||
for( final SpatialPylonCluster cl : this.clusters.values() )
|
||||
{
|
||||
final boolean myWasValid = cl.isValid;
|
||||
cl.isValid = this.isValid;
|
||||
final boolean myWasValid = cl.isValid();
|
||||
cl.setValid( this.isValid );
|
||||
if( myWasValid != this.isValid )
|
||||
{
|
||||
cl.updateStatus( false );
|
||||
|
||||
+17
-17
@@ -39,11 +39,11 @@ import appeng.me.cache.helpers.TickTracker;
|
||||
public class TickManagerCache implements ITickManager
|
||||
{
|
||||
|
||||
final IGrid myGrid;
|
||||
final HashMap<IGridNode, TickTracker> alertable = new HashMap<IGridNode, TickTracker>();
|
||||
final HashMap<IGridNode, TickTracker> sleeping = new HashMap<IGridNode, TickTracker>();
|
||||
final HashMap<IGridNode, TickTracker> awake = new HashMap<IGridNode, TickTracker>();
|
||||
final PriorityQueue<TickTracker> upcomingTicks = new PriorityQueue<TickTracker>();
|
||||
private final IGrid myGrid;
|
||||
private final HashMap<IGridNode, TickTracker> alertable = new HashMap<IGridNode, TickTracker>();
|
||||
private final HashMap<IGridNode, TickTracker> sleeping = new HashMap<IGridNode, TickTracker>();
|
||||
private final HashMap<IGridNode, TickTracker> awake = new HashMap<IGridNode, TickTracker>();
|
||||
private final PriorityQueue<TickTracker> upcomingTicks = new PriorityQueue<TickTracker>();
|
||||
private long currentTick = 0;
|
||||
|
||||
public TickManagerCache( final IGrid g )
|
||||
@@ -83,28 +83,28 @@ public class TickManagerCache implements ITickManager
|
||||
while( !this.upcomingTicks.isEmpty() )
|
||||
{
|
||||
tt = this.upcomingTicks.peek();
|
||||
final int diff = (int) ( this.currentTick - tt.lastTick );
|
||||
if( diff >= tt.current_rate )
|
||||
final int diff = (int) ( this.currentTick - tt.getLastTick() );
|
||||
if( diff >= tt.getCurrentRate() )
|
||||
{
|
||||
// remove tt..
|
||||
this.upcomingTicks.poll();
|
||||
final TickRateModulation mod = tt.gt.tickingRequest( tt.node, diff );
|
||||
final TickRateModulation mod = tt.getGridTickable().tickingRequest( tt.getNode(), diff );
|
||||
|
||||
switch( mod )
|
||||
{
|
||||
case FASTER:
|
||||
tt.setRate( tt.current_rate - 2 );
|
||||
tt.setRate( tt.getCurrentRate() - 2 );
|
||||
break;
|
||||
case IDLE:
|
||||
tt.setRate( tt.request.maxTickRate );
|
||||
tt.setRate( tt.getRequest().maxTickRate );
|
||||
break;
|
||||
case SAME:
|
||||
break;
|
||||
case SLEEP:
|
||||
this.sleepDevice( tt.node );
|
||||
this.sleepDevice( tt.getNode() );
|
||||
break;
|
||||
case SLOWER:
|
||||
tt.setRate( tt.current_rate + 1 );
|
||||
tt.setRate( tt.getCurrentRate() + 1 );
|
||||
break;
|
||||
case URGENT:
|
||||
tt.setRate( 0 );
|
||||
@@ -113,7 +113,7 @@ public class TickManagerCache implements ITickManager
|
||||
break;
|
||||
}
|
||||
|
||||
if( this.awake.containsKey( tt.node ) )
|
||||
if( this.awake.containsKey( tt.getNode() ) )
|
||||
{
|
||||
this.addToQueue( tt );
|
||||
}
|
||||
@@ -127,7 +127,7 @@ public class TickManagerCache implements ITickManager
|
||||
catch( final Throwable t )
|
||||
{
|
||||
final CrashReport crashreport = CrashReport.makeCrashReport( t, "Ticking GridNode" );
|
||||
final CrashReportCategory crashreportcategory = crashreport.makeCategory( tt.gt.getClass().getSimpleName() + " being ticked." );
|
||||
final CrashReportCategory crashreportcategory = crashreport.makeCategory( tt.getGridTickable().getClass().getSimpleName() + " being ticked." );
|
||||
tt.addEntityCrashInfo( crashreportcategory );
|
||||
throw new ReportedException( crashreport );
|
||||
}
|
||||
@@ -135,7 +135,7 @@ public class TickManagerCache implements ITickManager
|
||||
|
||||
private void addToQueue( final TickTracker tt )
|
||||
{
|
||||
tt.lastTick = this.currentTick;
|
||||
tt.setLastTick( this.currentTick );
|
||||
this.upcomingTicks.add( tt );
|
||||
}
|
||||
|
||||
@@ -212,8 +212,8 @@ public class TickManagerCache implements ITickManager
|
||||
this.awake.put( node, tt );
|
||||
|
||||
// configure sort.
|
||||
tt.lastTick -= tt.request.maxTickRate;
|
||||
tt.current_rate = tt.request.minTickRate;
|
||||
tt.setLastTick( tt.getLastTick() - tt.getRequest().maxTickRate );
|
||||
tt.setCurrentRate( tt.getRequest().minTickRate );
|
||||
|
||||
// prevent dupes and tick build up.
|
||||
this.upcomingTicks.remove( tt );
|
||||
|
||||
@@ -25,10 +25,20 @@ import appeng.api.networking.IGridConnection;
|
||||
public class ConnectionWrapper
|
||||
{
|
||||
|
||||
public IGridConnection connection;
|
||||
private IGridConnection connection;
|
||||
|
||||
public ConnectionWrapper( final IGridConnection gc )
|
||||
{
|
||||
this.connection = gc;
|
||||
this.setConnection( gc );
|
||||
}
|
||||
|
||||
public IGridConnection getConnection()
|
||||
{
|
||||
return this.connection;
|
||||
}
|
||||
|
||||
public void setConnection( final IGridConnection connection )
|
||||
{
|
||||
this.connection = connection;
|
||||
}
|
||||
}
|
||||
+32
-7
@@ -31,10 +31,10 @@ import appeng.util.IWorldCallable;
|
||||
public class Connections implements IWorldCallable<Void>
|
||||
{
|
||||
|
||||
public final HashMap<IGridNode, TunnelConnection> connections = new HashMap<IGridNode, TunnelConnection>();
|
||||
private final HashMap<IGridNode, TunnelConnection> connections = new HashMap<IGridNode, TunnelConnection>();
|
||||
private final PartP2PTunnelME me;
|
||||
public boolean create = false;
|
||||
public boolean destroy = false;
|
||||
private boolean create = false;
|
||||
private boolean destroy = false;
|
||||
|
||||
public Connections( final PartP2PTunnelME o )
|
||||
{
|
||||
@@ -51,13 +51,38 @@ public class Connections implements IWorldCallable<Void>
|
||||
|
||||
public void markDestroy()
|
||||
{
|
||||
this.create = false;
|
||||
this.destroy = true;
|
||||
this.setCreate( false );
|
||||
this.setDestroy( true );
|
||||
}
|
||||
|
||||
public void markCreate()
|
||||
{
|
||||
this.create = true;
|
||||
this.destroy = false;
|
||||
this.setCreate( true );
|
||||
this.setDestroy( false );
|
||||
}
|
||||
|
||||
public HashMap<IGridNode, TunnelConnection> getConnections()
|
||||
{
|
||||
return this.connections;
|
||||
}
|
||||
|
||||
public boolean isCreate()
|
||||
{
|
||||
return this.create;
|
||||
}
|
||||
|
||||
private void setCreate( final boolean create )
|
||||
{
|
||||
this.create = create;
|
||||
}
|
||||
|
||||
public boolean isDestroy()
|
||||
{
|
||||
return this.destroy;
|
||||
}
|
||||
|
||||
private void setDestroy( final boolean destroy )
|
||||
{
|
||||
this.destroy = destroy;
|
||||
}
|
||||
}
|
||||
|
||||
+60
-25
@@ -33,23 +33,23 @@ import appeng.parts.AEBasePart;
|
||||
public class TickTracker implements Comparable<TickTracker>
|
||||
{
|
||||
|
||||
public final TickingRequest request;
|
||||
public final IGridTickable gt;
|
||||
public final IGridNode node;
|
||||
public final TickManagerCache host;
|
||||
private final TickingRequest request;
|
||||
private final IGridTickable gt;
|
||||
private final IGridNode node;
|
||||
private final TickManagerCache host;
|
||||
|
||||
public final long LastFiveTicksTime = 0;
|
||||
private final long LastFiveTicksTime = 0;
|
||||
|
||||
public long lastTick;
|
||||
public int current_rate;
|
||||
private long lastTick;
|
||||
private int currentRate;
|
||||
|
||||
public TickTracker( final TickingRequest req, final IGridNode node, final IGridTickable gt, final long currentTick, final TickManagerCache tickManagerCache )
|
||||
{
|
||||
this.request = req;
|
||||
this.gt = gt;
|
||||
this.node = node;
|
||||
this.current_rate = ( req.minTickRate + req.maxTickRate ) / 2;
|
||||
this.lastTick = currentTick;
|
||||
this.setCurrentRate( ( req.minTickRate + req.maxTickRate ) / 2 );
|
||||
this.setLastTick( currentTick );
|
||||
this.host = tickManagerCache;
|
||||
}
|
||||
|
||||
@@ -60,46 +60,81 @@ public class TickTracker implements Comparable<TickTracker>
|
||||
|
||||
public void setRate( final int rate )
|
||||
{
|
||||
this.current_rate = rate;
|
||||
this.setCurrentRate( rate );
|
||||
|
||||
if( this.current_rate < this.request.minTickRate )
|
||||
if( this.getCurrentRate() < this.getRequest().minTickRate )
|
||||
{
|
||||
this.current_rate = this.request.minTickRate;
|
||||
this.setCurrentRate( this.getRequest().minTickRate );
|
||||
}
|
||||
|
||||
if( this.current_rate > this.request.maxTickRate )
|
||||
if( this.getCurrentRate() > this.getRequest().maxTickRate )
|
||||
{
|
||||
this.current_rate = this.request.maxTickRate;
|
||||
this.setCurrentRate( this.getRequest().maxTickRate );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo( @Nonnull final TickTracker t )
|
||||
{
|
||||
final int nextTick = (int) ( ( this.lastTick - this.host.getCurrentTick() ) + this.current_rate );
|
||||
final int ts_nextTick = (int) ( ( t.lastTick - this.host.getCurrentTick() ) + t.current_rate );
|
||||
final int nextTick = (int) ( ( this.getLastTick() - this.host.getCurrentTick() ) + this.getCurrentRate() );
|
||||
final int ts_nextTick = (int) ( ( t.getLastTick() - this.host.getCurrentTick() ) + t.getCurrentRate() );
|
||||
return nextTick - ts_nextTick;
|
||||
}
|
||||
|
||||
public void addEntityCrashInfo( final CrashReportCategory crashreportcategory )
|
||||
{
|
||||
if( this.gt instanceof AEBasePart )
|
||||
if( this.getGridTickable() instanceof AEBasePart )
|
||||
{
|
||||
final AEBasePart part = (AEBasePart) this.gt;
|
||||
final AEBasePart part = (AEBasePart) this.getGridTickable();
|
||||
part.addEntityCrashInfo( crashreportcategory );
|
||||
}
|
||||
|
||||
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() );
|
||||
crashreportcategory.addCrashSection( "CurrentTickRate", this.getCurrentRate() );
|
||||
crashreportcategory.addCrashSection( "MinTickRate", this.getRequest().minTickRate );
|
||||
crashreportcategory.addCrashSection( "MaxTickRate", this.getRequest().maxTickRate );
|
||||
crashreportcategory.addCrashSection( "MachineType", this.getGridTickable().getClass().getName() );
|
||||
crashreportcategory.addCrashSection( "GridBlockType", this.getNode().getGridBlock().getClass().getName() );
|
||||
crashreportcategory.addCrashSection( "ConnectedSides", this.getNode().getConnectedSides() );
|
||||
|
||||
final DimensionalCoord dc = this.node.getGridBlock().getLocation();
|
||||
final DimensionalCoord dc = this.getNode().getGridBlock().getLocation();
|
||||
if( dc != null )
|
||||
{
|
||||
crashreportcategory.addCrashSection( "Location", dc );
|
||||
}
|
||||
}
|
||||
|
||||
public int getCurrentRate()
|
||||
{
|
||||
return this.currentRate;
|
||||
}
|
||||
|
||||
public void setCurrentRate( final int currentRate )
|
||||
{
|
||||
this.currentRate = currentRate;
|
||||
}
|
||||
|
||||
public long getLastTick()
|
||||
{
|
||||
return this.lastTick;
|
||||
}
|
||||
|
||||
public void setLastTick( final long lastTick )
|
||||
{
|
||||
this.lastTick = lastTick;
|
||||
}
|
||||
|
||||
public IGridNode getNode()
|
||||
{
|
||||
return this.node;
|
||||
}
|
||||
|
||||
public IGridTickable getGridTickable()
|
||||
{
|
||||
return this.gt;
|
||||
}
|
||||
|
||||
public TickingRequest getRequest()
|
||||
{
|
||||
return this.request;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,8 +29,8 @@ import appeng.util.iterators.NullIterator;
|
||||
public class TunnelCollection<T extends PartP2PTunnel> implements Iterable<T>
|
||||
{
|
||||
|
||||
final Class clz;
|
||||
Collection<T> tunnelSources;
|
||||
private final Class clz;
|
||||
private Collection<T> tunnelSources;
|
||||
|
||||
public TunnelCollection( final Collection<T> src, final Class c )
|
||||
{
|
||||
|
||||
+12
-2
@@ -26,12 +26,22 @@ import appeng.parts.p2p.PartP2PTunnelME;
|
||||
public class TunnelConnection
|
||||
{
|
||||
|
||||
public final PartP2PTunnelME tunnel;
|
||||
public final IGridConnection c;
|
||||
private final PartP2PTunnelME tunnel;
|
||||
private final IGridConnection c;
|
||||
|
||||
public TunnelConnection( final PartP2PTunnelME t, final IGridConnection con )
|
||||
{
|
||||
this.tunnel = t;
|
||||
this.c = con;
|
||||
}
|
||||
|
||||
public IGridConnection getConnection()
|
||||
{
|
||||
return this.c;
|
||||
}
|
||||
|
||||
public PartP2PTunnelME getTunnel()
|
||||
{
|
||||
return this.tunnel;
|
||||
}
|
||||
}
|
||||
@@ -28,9 +28,9 @@ import appeng.parts.p2p.PartP2PTunnel;
|
||||
public class TunnelIterator<T extends PartP2PTunnel> implements Iterator<T>
|
||||
{
|
||||
|
||||
final Iterator<T> wrapped;
|
||||
final Class targetType;
|
||||
T Next;
|
||||
private final Iterator<T> wrapped;
|
||||
private final Class targetType;
|
||||
private T Next;
|
||||
|
||||
public TunnelIterator( final Collection<T> tunnelSources, final Class clz )
|
||||
{
|
||||
|
||||
@@ -122,7 +122,7 @@ public abstract class MBCalculator
|
||||
this.disconnect();
|
||||
}
|
||||
|
||||
public boolean isValidTileAt( final World w, final int x, final int y, final int z )
|
||||
private boolean isValidTileAt( final World w, final int x, final int y, final int z )
|
||||
{
|
||||
return this.isValidTile( w.getTileEntity( new BlockPos( x, y, z ) ) );
|
||||
}
|
||||
@@ -137,7 +137,7 @@ public abstract class MBCalculator
|
||||
*/
|
||||
public abstract boolean checkMultiblockScale( WorldCoord min, WorldCoord max );
|
||||
|
||||
public boolean verifyUnownedRegion( final World w, final WorldCoord min, final WorldCoord max )
|
||||
private boolean verifyUnownedRegion( final World w, final WorldCoord min, final WorldCoord max )
|
||||
{
|
||||
for( final AEPartLocation side : AEPartLocation.SIDE_LOCATIONS )
|
||||
{
|
||||
@@ -153,7 +153,7 @@ public abstract class MBCalculator
|
||||
/**
|
||||
* construct the correct cluster, usually very simple.
|
||||
*
|
||||
* @param w world
|
||||
* @param w world
|
||||
* @param min min world coord
|
||||
* @param max max world coord
|
||||
*
|
||||
@@ -171,8 +171,8 @@ public abstract class MBCalculator
|
||||
/**
|
||||
* configure the multi-block tiles, most of the important stuff is in here.
|
||||
*
|
||||
* @param c updated cluster
|
||||
* @param w in world
|
||||
* @param c updated cluster
|
||||
* @param w in world
|
||||
* @param min min world coord
|
||||
* @param max max world coord
|
||||
*/
|
||||
@@ -187,7 +187,7 @@ public abstract class MBCalculator
|
||||
*/
|
||||
public abstract boolean isValidTile( TileEntity te );
|
||||
|
||||
public boolean verifyUnownedRegionInner( final World w, int minX, int minY, int minZ, int maxX, int maxY, int maxZ, final AEPartLocation side )
|
||||
private boolean verifyUnownedRegionInner( final World w, int minX, int minY, int minZ, int maxX, int maxY, int maxZ, final AEPartLocation side )
|
||||
{
|
||||
switch( side )
|
||||
{
|
||||
|
||||
@@ -39,7 +39,7 @@ import appeng.tile.crafting.TileCraftingTile;
|
||||
public class CraftingCPUCalculator extends MBCalculator
|
||||
{
|
||||
|
||||
final TileCraftingTile tqb;
|
||||
private final TileCraftingTile tqb;
|
||||
|
||||
public CraftingCPUCalculator( final IAEMultiBlock t )
|
||||
{
|
||||
|
||||
@@ -194,14 +194,14 @@ public final class CraftingCPUCluster implements IAECluster, ICraftingCPU
|
||||
return (Iterator) this.tiles.iterator();
|
||||
}
|
||||
|
||||
public void addTile( final TileCraftingTile te )
|
||||
void addTile( final TileCraftingTile te )
|
||||
{
|
||||
if( this.machineSrc == null || te.isCoreBlock )
|
||||
if( this.machineSrc == null || te.isCoreBlock() )
|
||||
{
|
||||
this.machineSrc = new MachineSource( te );
|
||||
}
|
||||
|
||||
te.isCoreBlock = false;
|
||||
te.setCoreBlock( false );
|
||||
te.markDirty();
|
||||
this.tiles.push( te );
|
||||
|
||||
@@ -362,7 +362,7 @@ public final class CraftingCPUCluster implements IAECluster, ICraftingCPU
|
||||
return input;
|
||||
}
|
||||
|
||||
protected void postChange( final IAEItemStack diff, final BaseActionSource src )
|
||||
private void postChange( final IAEItemStack diff, final BaseActionSource src )
|
||||
{
|
||||
final Iterator<Entry<IMEMonitorHandlerReceiver<IAEItemStack>, Object>> i = this.getListeners();
|
||||
|
||||
@@ -394,7 +394,7 @@ public final class CraftingCPUCluster implements IAECluster, ICraftingCPU
|
||||
this.getCore().markDirty();
|
||||
}
|
||||
|
||||
public void postCraftingStatusChange( final IAEItemStack diff )
|
||||
private void postCraftingStatusChange( final IAEItemStack diff )
|
||||
{
|
||||
if( this.getGrid() == null )
|
||||
{
|
||||
@@ -403,9 +403,9 @@ public final class CraftingCPUCluster implements IAECluster, ICraftingCPU
|
||||
|
||||
final CraftingGridCache sg = this.getGrid().getCache( ICraftingGrid.class );
|
||||
|
||||
if( sg.interestManager.containsKey( diff ) )
|
||||
if( sg.getInterestManager().containsKey( diff ) )
|
||||
{
|
||||
final Collection<CraftingWatcher> list = sg.interestManager.get( diff );
|
||||
final Collection<CraftingWatcher> list = sg.getInterestManager().get( diff );
|
||||
|
||||
if( !list.isEmpty() )
|
||||
{
|
||||
@@ -448,7 +448,7 @@ public final class CraftingCPUCluster implements IAECluster, ICraftingCPU
|
||||
}
|
||||
}
|
||||
|
||||
protected Iterator<Entry<IMEMonitorHandlerReceiver<IAEItemStack>, Object>> getListeners()
|
||||
private Iterator<Entry<IMEMonitorHandlerReceiver<IAEItemStack>, Object>> getListeners()
|
||||
{
|
||||
return this.listeners.entrySet().iterator();
|
||||
}
|
||||
@@ -458,7 +458,7 @@ public final class CraftingCPUCluster implements IAECluster, ICraftingCPU
|
||||
return (TileCraftingTile) this.machineSrc.via;
|
||||
}
|
||||
|
||||
public IGrid getGrid()
|
||||
private IGrid getGrid()
|
||||
{
|
||||
for( final TileCraftingTile r : this.tiles )
|
||||
{
|
||||
@@ -853,7 +853,7 @@ public final class CraftingCPUCluster implements IAECluster, ICraftingCPU
|
||||
try
|
||||
{
|
||||
this.waitingFor.resetStatus();
|
||||
( (CraftingJob) job ).tree.setJob( ci, this, src );
|
||||
( (CraftingJob) job ).getTree().setJob( ci, this, src );
|
||||
if( ci.commit( src ) )
|
||||
{
|
||||
this.finalOutput = job.getOutput();
|
||||
@@ -1159,16 +1159,16 @@ public final class CraftingCPUCluster implements IAECluster, ICraftingCPU
|
||||
return out;
|
||||
}
|
||||
|
||||
public void done()
|
||||
void done()
|
||||
{
|
||||
final TileCraftingTile core = this.getCore();
|
||||
|
||||
core.isCoreBlock = true;
|
||||
core.setCoreBlock( true );
|
||||
|
||||
if( core.previousState != null )
|
||||
if( core.getPreviousState() != null )
|
||||
{
|
||||
this.readFromNBT( core.previousState );
|
||||
core.previousState = null;
|
||||
this.readFromNBT( core.getPreviousState() );
|
||||
core.setPreviousState( null );
|
||||
}
|
||||
|
||||
this.updateCPU();
|
||||
@@ -1328,8 +1328,8 @@ public final class CraftingCPUCluster implements IAECluster, ICraftingCPU
|
||||
return this.startItemCount;
|
||||
}
|
||||
|
||||
static class TaskProgress
|
||||
private static class TaskProgress
|
||||
{
|
||||
long value;
|
||||
private long value;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -140,13 +140,13 @@ public class QuantumCalculator extends MBCalculator
|
||||
{
|
||||
if( num == 1 || num == 3 || num == 7 || num == 9 )
|
||||
{
|
||||
flags = (byte) ( this.tqb.corner | num );
|
||||
flags = (byte) ( this.tqb.getCorner() | num );
|
||||
}
|
||||
else
|
||||
{
|
||||
flags = num;
|
||||
}
|
||||
c.Ring[ringNum] = te;
|
||||
c.getRing()[ringNum] = te;
|
||||
ringNum++;
|
||||
}
|
||||
|
||||
|
||||
@@ -46,13 +46,13 @@ import appeng.util.iterators.ChainedIterator;
|
||||
public class QuantumCluster implements ILocatable, IAECluster
|
||||
{
|
||||
|
||||
public final WorldCoord min;
|
||||
public final WorldCoord max;
|
||||
public boolean isDestroyed = false;
|
||||
public boolean updateStatus = true;
|
||||
public TileQuantumBridge[] Ring;
|
||||
boolean registered = false;
|
||||
ConnectionWrapper connection;
|
||||
private final WorldCoord min;
|
||||
private final WorldCoord max;
|
||||
private boolean isDestroyed = false;
|
||||
private boolean updateStatus = true;
|
||||
private TileQuantumBridge[] Ring;
|
||||
private boolean registered = false;
|
||||
private ConnectionWrapper connection;
|
||||
private long thisSide;
|
||||
private long otherSide;
|
||||
private TileQuantumBridge center;
|
||||
@@ -61,7 +61,7 @@ public class QuantumCluster implements ILocatable, IAECluster
|
||||
{
|
||||
this.min = min;
|
||||
this.max = max;
|
||||
this.Ring = new TileQuantumBridge[8];
|
||||
this.setRing( new TileQuantumBridge[8] );
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
@@ -69,7 +69,7 @@ public class QuantumCluster implements ILocatable, IAECluster
|
||||
{
|
||||
if( this.center.getWorld() == e.world )
|
||||
{
|
||||
this.updateStatus = false;
|
||||
this.setUpdateStatus( false );
|
||||
this.destroy();
|
||||
}
|
||||
}
|
||||
@@ -122,10 +122,10 @@ public class QuantumCluster implements ILocatable, IAECluster
|
||||
|
||||
if( sideA.isActive() && sideB.isActive() )
|
||||
{
|
||||
if( this.connection != null && this.connection.connection != null )
|
||||
if( this.connection != null && this.connection.getConnection() != null )
|
||||
{
|
||||
final IGridNode a = this.connection.connection.a();
|
||||
final IGridNode b = this.connection.connection.b();
|
||||
final IGridNode a = this.connection.getConnection().a();
|
||||
final IGridNode b = this.connection.getConnection().b();
|
||||
final IGridNode sa = sideA.getNode();
|
||||
final IGridNode sb = sideB.getNode();
|
||||
if( ( a == sa || b == sa ) && ( a == sb || b == sb ) )
|
||||
@@ -138,18 +138,18 @@ public class QuantumCluster implements ILocatable, IAECluster
|
||||
{
|
||||
if( sideA.connection != null )
|
||||
{
|
||||
if( sideA.connection.connection != null )
|
||||
if( sideA.connection.getConnection() != null )
|
||||
{
|
||||
sideA.connection.connection.destroy();
|
||||
sideA.connection.getConnection().destroy();
|
||||
sideA.connection = new ConnectionWrapper( null );
|
||||
}
|
||||
}
|
||||
|
||||
if( sideB.connection != null )
|
||||
{
|
||||
if( sideB.connection.connection != null )
|
||||
if( sideB.connection.getConnection() != null )
|
||||
{
|
||||
sideB.connection.connection.destroy();
|
||||
sideB.connection.getConnection().destroy();
|
||||
sideB.connection = new ConnectionWrapper( null );
|
||||
}
|
||||
}
|
||||
@@ -173,16 +173,16 @@ public class QuantumCluster implements ILocatable, IAECluster
|
||||
|
||||
if( shutdown && this.connection != null )
|
||||
{
|
||||
if( this.connection.connection != null )
|
||||
if( this.connection.getConnection() != null )
|
||||
{
|
||||
this.connection.connection.destroy();
|
||||
this.connection.connection = null;
|
||||
this.connection.getConnection().destroy();
|
||||
this.connection.setConnection( null );
|
||||
this.connection = new ConnectionWrapper( null );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean canUseNode( final long qe )
|
||||
private boolean canUseNode( final long qe )
|
||||
{
|
||||
final QuantumCluster qc = (QuantumCluster) AEApi.instance().registries().locatable().getLocatableBy( qe );
|
||||
if( qc != null )
|
||||
@@ -219,7 +219,7 @@ public class QuantumCluster implements ILocatable, IAECluster
|
||||
return this.center.getGridNode( AEPartLocation.INTERNAL );
|
||||
}
|
||||
|
||||
public boolean hasQES()
|
||||
private boolean hasQES()
|
||||
{
|
||||
return this.thisSide != 0;
|
||||
}
|
||||
@@ -245,26 +245,26 @@ public class QuantumCluster implements ILocatable, IAECluster
|
||||
MinecraftForge.EVENT_BUS.post( new LocatableEventAnnounce( this, LocatableEvent.Unregister ) );
|
||||
}
|
||||
|
||||
this.center.updateStatus( null, (byte) -1, this.updateStatus );
|
||||
this.center.updateStatus( null, (byte) -1, this.isUpdateStatus() );
|
||||
|
||||
for( final TileQuantumBridge r : this.Ring )
|
||||
for( final TileQuantumBridge r : this.getRing() )
|
||||
{
|
||||
r.updateStatus( null, (byte) -1, this.updateStatus );
|
||||
r.updateStatus( null, (byte) -1, this.isUpdateStatus() );
|
||||
}
|
||||
|
||||
this.center = null;
|
||||
this.Ring = new TileQuantumBridge[8];
|
||||
this.setRing( new TileQuantumBridge[8] );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<IGridHost> getTiles()
|
||||
{
|
||||
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 );
|
||||
return new ChainedIterator<IGridHost>( this.getRing()[0], this.getRing()[1], this.getRing()[2], this.getRing()[3], this.getRing()[4], this.getRing()[5], this.getRing()[6], this.getRing()[7], this.center );
|
||||
}
|
||||
|
||||
public boolean isCorner( final TileQuantumBridge tileQuantumBridge )
|
||||
{
|
||||
return this.Ring[0] == tileQuantumBridge || this.Ring[2] == tileQuantumBridge || this.Ring[4] == tileQuantumBridge || this.Ring[6] == tileQuantumBridge;
|
||||
return this.getRing()[0] == tileQuantumBridge || this.getRing()[2] == tileQuantumBridge || this.getRing()[4] == tileQuantumBridge || this.getRing()[6] == tileQuantumBridge;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -278,10 +278,30 @@ public class QuantumCluster implements ILocatable, IAECluster
|
||||
return this.center;
|
||||
}
|
||||
|
||||
public void setCenter( final TileQuantumBridge c )
|
||||
void setCenter( final TileQuantumBridge c )
|
||||
{
|
||||
this.registered = true;
|
||||
MinecraftForge.EVENT_BUS.register( this );
|
||||
this.center = c;
|
||||
}
|
||||
|
||||
private boolean isUpdateStatus()
|
||||
{
|
||||
return this.updateStatus;
|
||||
}
|
||||
|
||||
public void setUpdateStatus( final boolean updateStatus )
|
||||
{
|
||||
this.updateStatus = updateStatus;
|
||||
}
|
||||
|
||||
TileQuantumBridge[] getRing()
|
||||
{
|
||||
return this.Ring;
|
||||
}
|
||||
|
||||
private void setRing( final TileQuantumBridge[] ring )
|
||||
{
|
||||
this.Ring = ring;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -95,7 +95,7 @@ public class SpatialPylonCalculator extends MBCalculator
|
||||
{
|
||||
final TileSpatialPylon te = (TileSpatialPylon) w.getTileEntity( new BlockPos( x, y, z ) );
|
||||
te.updateStatus( c );
|
||||
c.line.add( ( te ) );
|
||||
c.getLine().add( ( te ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,43 +32,41 @@ import appeng.tile.spatial.TileSpatialPylon;
|
||||
public class SpatialPylonCluster implements IAECluster
|
||||
{
|
||||
|
||||
public final DimensionalCoord min;
|
||||
public final DimensionalCoord max;
|
||||
final List<TileSpatialPylon> line = new ArrayList<TileSpatialPylon>();
|
||||
public boolean isDestroyed = false;
|
||||
private final DimensionalCoord min;
|
||||
private final DimensionalCoord max;
|
||||
private final List<TileSpatialPylon> line = new ArrayList<TileSpatialPylon>();
|
||||
private boolean isDestroyed = false;
|
||||
|
||||
public Axis currentAxis = Axis.UNFORMED;
|
||||
public boolean isValid;
|
||||
public boolean hasPower;
|
||||
public boolean hasChannel;
|
||||
private Axis currentAxis = Axis.UNFORMED;
|
||||
private boolean isValid;
|
||||
|
||||
public SpatialPylonCluster( final DimensionalCoord min, final DimensionalCoord max )
|
||||
{
|
||||
this.min = min.copy();
|
||||
this.max = max.copy();
|
||||
|
||||
if( this.min.x != this.max.x )
|
||||
if( this.getMin().x != this.getMax().x )
|
||||
{
|
||||
this.currentAxis = Axis.X;
|
||||
this.setCurrentAxis( Axis.X );
|
||||
}
|
||||
else if( this.min.y != this.max.y )
|
||||
else if( this.getMin().y != this.getMax().y )
|
||||
{
|
||||
this.currentAxis = Axis.Y;
|
||||
this.setCurrentAxis( Axis.Y );
|
||||
}
|
||||
else if( this.min.z != this.max.z )
|
||||
else if( this.getMin().z != this.getMax().z )
|
||||
{
|
||||
this.currentAxis = Axis.Z;
|
||||
this.setCurrentAxis( Axis.Z );
|
||||
}
|
||||
else
|
||||
{
|
||||
this.currentAxis = Axis.UNFORMED;
|
||||
this.setCurrentAxis( Axis.UNFORMED );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateStatus( final boolean updateGrid )
|
||||
{
|
||||
for( final TileSpatialPylon r : this.line )
|
||||
for( final TileSpatialPylon r : this.getLine() )
|
||||
{
|
||||
r.recalculateDisplay();
|
||||
}
|
||||
@@ -84,7 +82,7 @@ public class SpatialPylonCluster implements IAECluster
|
||||
}
|
||||
this.isDestroyed = true;
|
||||
|
||||
for( final TileSpatialPylon r : this.line )
|
||||
for( final TileSpatialPylon r : this.getLine() )
|
||||
{
|
||||
r.updateStatus( null );
|
||||
}
|
||||
@@ -93,12 +91,47 @@ public class SpatialPylonCluster implements IAECluster
|
||||
@Override
|
||||
public Iterator<IGridHost> getTiles()
|
||||
{
|
||||
return (Iterator) this.line.iterator();
|
||||
return (Iterator) this.getLine().iterator();
|
||||
}
|
||||
|
||||
public int tileCount()
|
||||
{
|
||||
return this.line.size();
|
||||
return this.getLine().size();
|
||||
}
|
||||
|
||||
public Axis getCurrentAxis()
|
||||
{
|
||||
return this.currentAxis;
|
||||
}
|
||||
|
||||
private void setCurrentAxis( final Axis currentAxis )
|
||||
{
|
||||
this.currentAxis = currentAxis;
|
||||
}
|
||||
|
||||
public boolean isValid()
|
||||
{
|
||||
return this.isValid;
|
||||
}
|
||||
|
||||
public void setValid( final boolean isValid )
|
||||
{
|
||||
this.isValid = isValid;
|
||||
}
|
||||
|
||||
public DimensionalCoord getMax()
|
||||
{
|
||||
return this.max;
|
||||
}
|
||||
|
||||
public DimensionalCoord getMin()
|
||||
{
|
||||
return this.min;
|
||||
}
|
||||
|
||||
List<TileSpatialPylon> getLine()
|
||||
{
|
||||
return this.line;
|
||||
}
|
||||
|
||||
public enum Axis
|
||||
|
||||
@@ -26,18 +26,18 @@ import appeng.util.ItemSorters;
|
||||
public class EnergyThreshold implements Comparable<EnergyThreshold>
|
||||
{
|
||||
|
||||
public final double Limit;
|
||||
public final IEnergyWatcher watcher;
|
||||
final int hash;
|
||||
private final double Limit;
|
||||
private final IEnergyWatcher watcher;
|
||||
private final int hash;
|
||||
|
||||
public EnergyThreshold( final double lim, final IEnergyWatcher wat )
|
||||
{
|
||||
this.Limit = lim;
|
||||
this.watcher = wat;
|
||||
|
||||
if( this.watcher != null )
|
||||
if( this.getWatcher() != null )
|
||||
{
|
||||
this.hash = this.watcher.hashCode() ^ ( (Double) lim ).hashCode();
|
||||
this.hash = this.getWatcher().hashCode() ^ ( (Double) lim ).hashCode();
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -54,6 +54,16 @@ public class EnergyThreshold implements Comparable<EnergyThreshold>
|
||||
@Override
|
||||
public int compareTo( final EnergyThreshold o )
|
||||
{
|
||||
return ItemSorters.compareDouble( this.Limit, o.Limit );
|
||||
return ItemSorters.compareDouble( this.getLimit(), o.getLimit() );
|
||||
}
|
||||
|
||||
double getLimit()
|
||||
{
|
||||
return this.Limit;
|
||||
}
|
||||
|
||||
public IEnergyWatcher getWatcher()
|
||||
{
|
||||
return this.watcher;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,9 +34,9 @@ import appeng.me.cache.EnergyGridCache;
|
||||
public class EnergyWatcher implements IEnergyWatcher
|
||||
{
|
||||
|
||||
final EnergyGridCache gsc;
|
||||
final IEnergyWatcherHost myObject;
|
||||
final HashSet<EnergyThreshold> myInterests = new HashSet<EnergyThreshold>();
|
||||
private final EnergyGridCache gsc;
|
||||
private final IEnergyWatcherHost myObject;
|
||||
private final HashSet<EnergyThreshold> myInterests = new HashSet<EnergyThreshold>();
|
||||
|
||||
public EnergyWatcher( final EnergyGridCache cache, final IEnergyWatcherHost host )
|
||||
{
|
||||
@@ -99,14 +99,14 @@ public class EnergyWatcher implements IEnergyWatcher
|
||||
}
|
||||
|
||||
final EnergyThreshold eh = new EnergyThreshold( e, this );
|
||||
return this.gsc.interests.add( eh ) && this.myInterests.add( eh );
|
||||
return this.gsc.getInterests().add( eh ) && this.myInterests.add( eh );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean remove( final Object o )
|
||||
{
|
||||
final EnergyThreshold eh = new EnergyThreshold( (Double) o, this );
|
||||
return this.myInterests.remove( eh ) && this.gsc.interests.remove( eh );
|
||||
return this.myInterests.remove( eh ) && this.gsc.getInterests().remove( eh );
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -163,17 +163,17 @@ public class EnergyWatcher implements IEnergyWatcher
|
||||
final Iterator<EnergyThreshold> i = this.myInterests.iterator();
|
||||
while( i.hasNext() )
|
||||
{
|
||||
this.gsc.interests.remove( i.next() );
|
||||
this.gsc.getInterests().remove( i.next() );
|
||||
i.remove();
|
||||
}
|
||||
}
|
||||
|
||||
class EnergyWatcherIterator implements Iterator<Double>
|
||||
private class EnergyWatcherIterator implements Iterator<Double>
|
||||
{
|
||||
|
||||
final EnergyWatcher watcher;
|
||||
final Iterator<EnergyThreshold> interestIterator;
|
||||
EnergyThreshold myLast;
|
||||
private final EnergyWatcher watcher;
|
||||
private final Iterator<EnergyThreshold> interestIterator;
|
||||
private EnergyThreshold myLast;
|
||||
|
||||
public EnergyWatcherIterator( final EnergyWatcher parent, final Iterator<EnergyThreshold> i )
|
||||
{
|
||||
@@ -191,13 +191,13 @@ public class EnergyWatcher implements IEnergyWatcher
|
||||
public Double next()
|
||||
{
|
||||
this.myLast = this.interestIterator.next();
|
||||
return this.myLast.Limit;
|
||||
return this.myLast.getLimit();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove()
|
||||
{
|
||||
EnergyWatcher.this.gsc.interests.remove( this.myLast );
|
||||
EnergyWatcher.this.gsc.getInterests().remove( this.myLast );
|
||||
this.interestIterator.remove();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,8 +60,8 @@ public class AENetworkProxy implements IGridBlock
|
||||
private final IGridProxyable gp;
|
||||
private final boolean worldNode;
|
||||
private final String nbtName; // name
|
||||
public AEColor myColor = AEColor.Transparent;
|
||||
NBTTagCompound data = null; // input
|
||||
private AEColor myColor = AEColor.Transparent;
|
||||
private NBTTagCompound data = null; // input
|
||||
private ItemStack myRepInstance;
|
||||
private boolean isReady = false;
|
||||
private IGridNode node = null;
|
||||
@@ -322,7 +322,7 @@ public class AENetworkProxy implements IGridBlock
|
||||
@Override
|
||||
public AEColor getGridColor()
|
||||
{
|
||||
return this.myColor;
|
||||
return this.getColor();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -437,4 +437,14 @@ public class AENetworkProxy implements IGridBlock
|
||||
{
|
||||
this.owner = player;
|
||||
}
|
||||
|
||||
public AEColor getColor()
|
||||
{
|
||||
return this.myColor;
|
||||
}
|
||||
|
||||
public void setColor( final AEColor myColor )
|
||||
{
|
||||
this.myColor = myColor;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ public class AENetworkProxyMultiblock extends AENetworkProxy implements IGridMul
|
||||
return new ProxyNodeIterator( this.getCluster().getTiles() );
|
||||
}
|
||||
|
||||
IAECluster getCluster()
|
||||
private IAECluster getCluster()
|
||||
{
|
||||
return ( (IAEMultiBlock) this.getMachine() ).getCluster();
|
||||
}
|
||||
|
||||
@@ -28,8 +28,8 @@ import appeng.api.networking.energy.IEnergySource;
|
||||
public class ChannelPowerSrc implements IEnergySource
|
||||
{
|
||||
|
||||
final IGridNode node;
|
||||
final IEnergySource realSrc;
|
||||
private final IGridNode node;
|
||||
private final IEnergySource realSrc;
|
||||
|
||||
public ChannelPowerSrc( final IGridNode networkNode, final IEnergySource src )
|
||||
{
|
||||
|
||||
@@ -108,12 +108,12 @@ public class GenericInterestManager<T>
|
||||
return this.container.get( stack );
|
||||
}
|
||||
|
||||
class SavedTransactions
|
||||
private class SavedTransactions
|
||||
{
|
||||
|
||||
public final boolean put;
|
||||
public final IAEStack stack;
|
||||
public final T iw;
|
||||
private final boolean put;
|
||||
private final IAEStack stack;
|
||||
private final T iw;
|
||||
|
||||
public SavedTransactions( final boolean putOperation, final IAEStack myStack, final T watcher )
|
||||
{
|
||||
|
||||
@@ -29,14 +29,14 @@ import appeng.tile.networking.TileController;
|
||||
public class ControllerValidator implements IGridVisitor
|
||||
{
|
||||
|
||||
public boolean isValid = true;
|
||||
public int found = 0;
|
||||
int minX;
|
||||
int minY;
|
||||
int minZ;
|
||||
int maxX;
|
||||
int maxY;
|
||||
int maxZ;
|
||||
private boolean isValid = true;
|
||||
private int found = 0;
|
||||
private int minX;
|
||||
private int minY;
|
||||
private int minZ;
|
||||
private int maxX;
|
||||
private int maxY;
|
||||
private int maxZ;
|
||||
|
||||
public ControllerValidator( final int x, final int y, final int z )
|
||||
{
|
||||
@@ -52,7 +52,7 @@ public class ControllerValidator implements IGridVisitor
|
||||
public boolean visitNode( final IGridNode n )
|
||||
{
|
||||
final IGridHost host = n.getMachine();
|
||||
if( this.isValid && host instanceof TileController )
|
||||
if( this.isValid() && host instanceof TileController )
|
||||
{
|
||||
final TileController c = (TileController) host;
|
||||
|
||||
@@ -67,17 +67,37 @@ public class ControllerValidator implements IGridVisitor
|
||||
|
||||
if( this.maxX - this.minX < 7 && this.maxY - this.minY < 7 && this.maxZ - this.minZ < 7 )
|
||||
{
|
||||
this.found++;
|
||||
this.setFound( this.getFound() + 1 );
|
||||
return true;
|
||||
}
|
||||
|
||||
this.isValid = false;
|
||||
this.setValid( false );
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return this.isValid();
|
||||
}
|
||||
|
||||
public boolean isValid()
|
||||
{
|
||||
return this.isValid;
|
||||
}
|
||||
|
||||
private void setValid( final boolean isValid )
|
||||
{
|
||||
this.isValid = isValid;
|
||||
}
|
||||
|
||||
public int getFound()
|
||||
{
|
||||
return this.found;
|
||||
}
|
||||
|
||||
private void setFound( final int found )
|
||||
{
|
||||
this.found = found;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,11 +34,11 @@ import appeng.me.cache.PathGridCache;
|
||||
public class PathSegment
|
||||
{
|
||||
|
||||
final PathGridCache pgc;
|
||||
final Set<IPathItem> semiOpen;
|
||||
final Set<IPathItem> closed;
|
||||
public boolean isDead;
|
||||
List<IPathItem> open;
|
||||
private final PathGridCache pgc;
|
||||
private final Set<IPathItem> semiOpen;
|
||||
private final Set<IPathItem> closed;
|
||||
private boolean isDead;
|
||||
private List<IPathItem> open;
|
||||
|
||||
public PathSegment( final PathGridCache myPGC, final List<IPathItem> open, final Set<IPathItem> semiOpen, final Set<IPathItem> closed )
|
||||
{
|
||||
@@ -46,7 +46,7 @@ public class PathSegment
|
||||
this.semiOpen = semiOpen;
|
||||
this.closed = closed;
|
||||
this.pgc = myPGC;
|
||||
this.isDead = false;
|
||||
this.setDead( false );
|
||||
}
|
||||
|
||||
public boolean step()
|
||||
@@ -125,12 +125,12 @@ public class PathSegment
|
||||
pi = start;
|
||||
while( pi != null )
|
||||
{
|
||||
this.pgc.channelsByBlocks++;
|
||||
this.pgc.setChannelsByBlocks( this.pgc.getChannelsByBlocks() + 1 );
|
||||
pi.incrementChannelCount( 1 );
|
||||
pi = pi.getControllerRoute();
|
||||
}
|
||||
|
||||
this.pgc.channelsInUse++;
|
||||
this.pgc.setChannelsInUse( this.pgc.getChannelsInUse() + 1 );
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -150,12 +150,22 @@ public class PathSegment
|
||||
pi = start;
|
||||
while( pi != null )
|
||||
{
|
||||
this.pgc.channelsByBlocks++;
|
||||
this.pgc.setChannelsByBlocks( this.pgc.getChannelsByBlocks() + 1 );
|
||||
pi.incrementChannelCount( 1 );
|
||||
pi = pi.getControllerRoute();
|
||||
}
|
||||
|
||||
this.pgc.channelsInUse++;
|
||||
this.pgc.setChannelsInUse( this.pgc.getChannelsInUse() + 1 );
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean isDead()
|
||||
{
|
||||
return this.isDead;
|
||||
}
|
||||
|
||||
public void setDead( final boolean isDead )
|
||||
{
|
||||
this.isDead = isDead;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,25 +48,25 @@ import appeng.util.item.AEItemStack;
|
||||
public class CellInventory implements ICellInventory
|
||||
{
|
||||
|
||||
static final String ITEM_TYPE_TAG = "it";
|
||||
static final String ITEM_COUNT_TAG = "ic";
|
||||
static final String ITEM_SLOT = "#";
|
||||
static final String ITEM_SLOT_COUNT = "@";
|
||||
static final String ITEM_PRE_FORMATTED_COUNT = "PF";
|
||||
static final String ITEM_PRE_FORMATTED_SLOT = "PF#";
|
||||
static final String ITEM_PRE_FORMATTED_NAME = "PN";
|
||||
static final String ITEM_PRE_FORMATTED_FUZZY = "FP";
|
||||
private static final String ITEM_TYPE_TAG = "it";
|
||||
private static final String ITEM_COUNT_TAG = "ic";
|
||||
private static final String ITEM_SLOT = "#";
|
||||
private static final String ITEM_SLOT_COUNT = "@";
|
||||
private static final String ITEM_PRE_FORMATTED_COUNT = "PF";
|
||||
private static final String ITEM_PRE_FORMATTED_SLOT = "PF#";
|
||||
private static final String ITEM_PRE_FORMATTED_NAME = "PN";
|
||||
private static final String ITEM_PRE_FORMATTED_FUZZY = "FP";
|
||||
private static final HashSet<Integer> BLACK_LIST = new HashSet<Integer>();
|
||||
protected static String[] itemSlots;
|
||||
protected static String[] itemSlotCount;
|
||||
protected final NBTTagCompound tagCompound;
|
||||
protected final ISaveProvider container;
|
||||
protected int maxItemTypes = 63;
|
||||
protected short storedItems = 0;
|
||||
protected int storedItemCount = 0;
|
||||
protected IItemList<IAEItemStack> cellItems;
|
||||
protected ItemStack i;
|
||||
protected IStorageCell cellType;
|
||||
private static String[] itemSlots;
|
||||
private static String[] itemSlotCount;
|
||||
private final NBTTagCompound tagCompound;
|
||||
private final ISaveProvider container;
|
||||
private int maxItemTypes = 63;
|
||||
private short storedItems = 0;
|
||||
private int storedItemCount = 0;
|
||||
private IItemList<IAEItemStack> cellItems;
|
||||
private ItemStack i;
|
||||
private IStorageCell cellType;
|
||||
|
||||
protected CellInventory( final NBTTagCompound data, final ISaveProvider container )
|
||||
{
|
||||
@@ -74,7 +74,7 @@ public class CellInventory implements ICellInventory
|
||||
this.container = container;
|
||||
}
|
||||
|
||||
protected CellInventory( final ItemStack o, final ISaveProvider container ) throws AppEngException
|
||||
private CellInventory( final ItemStack o, final ISaveProvider container ) throws AppEngException
|
||||
{
|
||||
if( itemSlots == null )
|
||||
{
|
||||
@@ -185,7 +185,7 @@ public class CellInventory implements ICellInventory
|
||||
BLACK_LIST.add( ( meta << Platform.DEF_OFFSET ) | itemID );
|
||||
}
|
||||
|
||||
public static boolean isBlackListed( final IAEItemStack input )
|
||||
private static boolean isBlackListed( final IAEItemStack input )
|
||||
{
|
||||
if( BLACK_LIST.contains( ( OreDictionary.WILDCARD_VALUE << Platform.DEF_OFFSET ) | Item.getIdFromItem( input.getItem() ) ) )
|
||||
{
|
||||
|
||||
@@ -108,7 +108,7 @@ public class CellInventoryHandler extends MEInventoryHandler<IAEItemStack> imple
|
||||
@Override
|
||||
public ICellInventory getCellInv()
|
||||
{
|
||||
Object o = this.internal;
|
||||
Object o = this.getInternal();
|
||||
|
||||
if( o instanceof MEPassThrough )
|
||||
{
|
||||
|
||||
@@ -35,7 +35,7 @@ import appeng.util.item.AEItemStack;
|
||||
public class CreativeCellInventory implements IMEInventoryHandler<IAEItemStack>
|
||||
{
|
||||
|
||||
final IItemList<IAEItemStack> itemListCache = AEApi.instance().storage().createItemList();
|
||||
private final IItemList<IAEItemStack> itemListCache = AEApi.instance().storage().createItemList();
|
||||
|
||||
protected CreativeCellInventory( final ItemStack o )
|
||||
{
|
||||
|
||||
@@ -31,10 +31,10 @@ import appeng.api.storage.data.IAEStack;
|
||||
public class DriveWatcher<T extends IAEStack<T>> extends MEInventoryHandler<T>
|
||||
{
|
||||
|
||||
final int oldStatus = 0;
|
||||
final ItemStack is;
|
||||
final ICellHandler handler;
|
||||
final IChestOrDrive cord;
|
||||
private final int oldStatus = 0;
|
||||
private final ItemStack is;
|
||||
private final ICellHandler handler;
|
||||
private final IChestOrDrive cord;
|
||||
|
||||
public DriveWatcher( final IMEInventory<T> i, final ItemStack is, final ICellHandler han, final IChestOrDrive cod )
|
||||
{
|
||||
|
||||
@@ -35,9 +35,9 @@ import appeng.me.cache.GridStorageCache;
|
||||
public class ItemWatcher implements IStackWatcher
|
||||
{
|
||||
|
||||
final GridStorageCache gsc;
|
||||
final IStackWatcherHost myObject;
|
||||
final HashSet<IAEStack> myInterests = new HashSet<IAEStack>();
|
||||
private final GridStorageCache gsc;
|
||||
private final IStackWatcherHost myObject;
|
||||
private final HashSet<IAEStack> myInterests = new HashSet<IAEStack>();
|
||||
|
||||
public ItemWatcher( final GridStorageCache cache, final IStackWatcherHost host )
|
||||
{
|
||||
@@ -94,13 +94,13 @@ public class ItemWatcher implements IStackWatcher
|
||||
return false;
|
||||
}
|
||||
|
||||
return this.myInterests.add( e.copy() ) && this.gsc.interestManager.put( e, this );
|
||||
return this.myInterests.add( e.copy() ) && this.gsc.getInterestManager().put( e, this );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean remove( final Object o )
|
||||
{
|
||||
return this.myInterests.remove( o ) && this.gsc.interestManager.remove( (IAEStack) o, this );
|
||||
return this.myInterests.remove( o ) && this.gsc.getInterestManager().remove( (IAEStack) o, this );
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -157,17 +157,17 @@ public class ItemWatcher implements IStackWatcher
|
||||
final Iterator<IAEStack> i = this.myInterests.iterator();
|
||||
while( i.hasNext() )
|
||||
{
|
||||
this.gsc.interestManager.remove( i.next(), this );
|
||||
this.gsc.getInterestManager().remove( i.next(), this );
|
||||
i.remove();
|
||||
}
|
||||
}
|
||||
|
||||
class ItemWatcherIterator implements Iterator<IAEStack>
|
||||
private class ItemWatcherIterator implements Iterator<IAEStack>
|
||||
{
|
||||
|
||||
final ItemWatcher watcher;
|
||||
final Iterator<IAEStack> interestIterator;
|
||||
IAEStack myLast;
|
||||
private final ItemWatcher watcher;
|
||||
private final Iterator<IAEStack> interestIterator;
|
||||
private IAEStack myLast;
|
||||
|
||||
public ItemWatcherIterator( final ItemWatcher parent, final Iterator<IAEStack> i )
|
||||
{
|
||||
@@ -190,7 +190,7 @@ public class ItemWatcher implements IStackWatcher
|
||||
@Override
|
||||
public void remove()
|
||||
{
|
||||
ItemWatcher.this.gsc.interestManager.remove( this.myLast, this.watcher );
|
||||
ItemWatcher.this.gsc.getInterestManager().remove( this.myLast, this.watcher );
|
||||
this.interestIterator.remove();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,8 +35,8 @@ import appeng.util.item.AEItemStack;
|
||||
public class MEIInventoryWrapper implements IMEInventory<IAEItemStack>
|
||||
{
|
||||
|
||||
protected final IInventory target;
|
||||
protected final InventoryAdaptor adaptor;
|
||||
private final IInventory target;
|
||||
private final InventoryAdaptor adaptor;
|
||||
|
||||
public MEIInventoryWrapper( final IInventory m, final InventoryAdaptor ia )
|
||||
{
|
||||
|
||||
@@ -25,7 +25,6 @@ import appeng.api.config.IncludeExclude;
|
||||
import appeng.api.networking.security.BaseActionSource;
|
||||
import appeng.api.storage.IMEInventory;
|
||||
import appeng.api.storage.IMEInventoryHandler;
|
||||
import appeng.api.storage.IMEMonitor;
|
||||
import appeng.api.storage.StorageChannel;
|
||||
import appeng.api.storage.data.IAEStack;
|
||||
import appeng.api.storage.data.IItemList;
|
||||
@@ -36,9 +35,7 @@ import appeng.util.prioitylist.IPartitionList;
|
||||
public class MEInventoryHandler<T extends IAEStack<T>> implements IMEInventoryHandler<T>
|
||||
{
|
||||
|
||||
protected final IMEMonitor<T> monitor;
|
||||
protected final IMEInventoryHandler<T> internal;
|
||||
final StorageChannel channel;
|
||||
private final IMEInventoryHandler<T> internal;
|
||||
private int myPriority;
|
||||
private IncludeExclude myWhitelist;
|
||||
private AccessRestriction myAccess;
|
||||
@@ -50,8 +47,6 @@ public class MEInventoryHandler<T extends IAEStack<T>> implements IMEInventoryHa
|
||||
|
||||
public MEInventoryHandler( final IMEInventory<T> i, final StorageChannel channel )
|
||||
{
|
||||
this.channel = channel;
|
||||
|
||||
if( i instanceof IMEInventoryHandler )
|
||||
{
|
||||
this.internal = (IMEInventoryHandler<T>) i;
|
||||
@@ -61,15 +56,13 @@ public class MEInventoryHandler<T extends IAEStack<T>> implements IMEInventoryHa
|
||||
this.internal = new MEPassThrough<T>( i, channel );
|
||||
}
|
||||
|
||||
this.monitor = this.internal instanceof IMEMonitor ? (IMEMonitor<T>) this.internal : null;
|
||||
|
||||
this.myPriority = 0;
|
||||
this.myWhitelist = IncludeExclude.WHITELIST;
|
||||
this.setBaseAccess( AccessRestriction.READ_WRITE );
|
||||
this.myPartitionList = new DefaultPriorityList<T>();
|
||||
}
|
||||
|
||||
public IncludeExclude getWhitelist()
|
||||
IncludeExclude getWhitelist()
|
||||
{
|
||||
return this.myWhitelist;
|
||||
}
|
||||
@@ -92,7 +85,7 @@ public class MEInventoryHandler<T extends IAEStack<T>> implements IMEInventoryHa
|
||||
this.hasWriteAccess = this.cachedAccessRestriction.hasPermission( AccessRestriction.WRITE );
|
||||
}
|
||||
|
||||
public IPartitionList<T> getPartitionList()
|
||||
IPartitionList<T> getPartitionList()
|
||||
{
|
||||
return this.myPartitionList;
|
||||
}
|
||||
|
||||
@@ -46,12 +46,12 @@ import appeng.util.inv.ItemSlot;
|
||||
public class MEMonitorIInventory implements IMEMonitor<IAEItemStack>
|
||||
{
|
||||
|
||||
final InventoryAdaptor adaptor;
|
||||
final IItemList<IAEItemStack> list = AEApi.instance().storage().createItemList();
|
||||
final HashMap<IMEMonitorHandlerReceiver<IAEItemStack>, Object> listeners = new HashMap<IMEMonitorHandlerReceiver<IAEItemStack>, Object>();
|
||||
private final InventoryAdaptor adaptor;
|
||||
private final IItemList<IAEItemStack> list = AEApi.instance().storage().createItemList();
|
||||
private final HashMap<IMEMonitorHandlerReceiver<IAEItemStack>, Object> listeners = new HashMap<IMEMonitorHandlerReceiver<IAEItemStack>, Object>();
|
||||
private final NavigableMap<Integer, CachedItemStack> memory;
|
||||
public BaseActionSource mySource;
|
||||
public StorageFilter mode = StorageFilter.EXTRACTABLE_ONLY;
|
||||
private BaseActionSource mySource;
|
||||
private StorageFilter mode = StorageFilter.EXTRACTABLE_ONLY;
|
||||
|
||||
public MEMonitorIInventory( final InventoryAdaptor adaptor )
|
||||
{
|
||||
@@ -148,16 +148,16 @@ public class MEMonitorIInventory implements IMEMonitor<IAEItemStack>
|
||||
boolean changed = false;
|
||||
for( final ItemSlot is : this.adaptor )
|
||||
{
|
||||
final CachedItemStack old = this.memory.get( is.slot );
|
||||
high = Math.max( high, is.slot );
|
||||
final CachedItemStack old = this.memory.get( is.getSlot() );
|
||||
high = Math.max( high, is.getSlot() );
|
||||
|
||||
final ItemStack newIS = !is.isExtractable && this.mode == StorageFilter.EXTRACTABLE_ONLY ? null : is.getItemStack();
|
||||
final ItemStack newIS = !is.isExtractable() && this.getMode() == StorageFilter.EXTRACTABLE_ONLY ? null : is.getItemStack();
|
||||
final ItemStack oldIS = old == null ? null : old.itemStack;
|
||||
|
||||
if( this.isDifferent( newIS, oldIS ) )
|
||||
{
|
||||
final CachedItemStack cis = new CachedItemStack( is.getItemStack() );
|
||||
this.memory.put( is.slot, cis );
|
||||
this.memory.put( is.getSlot(), cis );
|
||||
|
||||
if( old != null && old.aeStack != null )
|
||||
{
|
||||
@@ -188,7 +188,7 @@ public class MEMonitorIInventory implements IMEMonitor<IAEItemStack>
|
||||
if( diff != 0 && stack != null )
|
||||
{
|
||||
final CachedItemStack cis = new CachedItemStack( is.getItemStack() );
|
||||
this.memory.put( is.slot, cis );
|
||||
this.memory.put( is.getSlot(), cis );
|
||||
|
||||
final IAEItemStack a = stack.copy();
|
||||
a.setStackSize( diff );
|
||||
@@ -250,7 +250,7 @@ public class MEMonitorIInventory implements IMEMonitor<IAEItemStack>
|
||||
final IMEMonitorHandlerReceiver<IAEItemStack> key = l.getKey();
|
||||
if( key.isValid( l.getValue() ) )
|
||||
{
|
||||
key.postChange( this, a, this.mySource );
|
||||
key.postChange( this, a, this.getActionSource() );
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -313,11 +313,31 @@ public class MEMonitorIInventory implements IMEMonitor<IAEItemStack>
|
||||
return this.list;
|
||||
}
|
||||
|
||||
static class CachedItemStack
|
||||
private StorageFilter getMode()
|
||||
{
|
||||
return this.mode;
|
||||
}
|
||||
|
||||
public void setMode( final StorageFilter mode )
|
||||
{
|
||||
this.mode = mode;
|
||||
}
|
||||
|
||||
private BaseActionSource getActionSource()
|
||||
{
|
||||
return this.mySource;
|
||||
}
|
||||
|
||||
public void setActionSource( final BaseActionSource mySource )
|
||||
{
|
||||
this.mySource = mySource;
|
||||
}
|
||||
|
||||
private static class CachedItemStack
|
||||
{
|
||||
|
||||
final ItemStack itemStack;
|
||||
final IAEItemStack aeStack;
|
||||
private final ItemStack itemStack;
|
||||
private final IAEItemStack aeStack;
|
||||
|
||||
public CachedItemStack( final ItemStack is )
|
||||
{
|
||||
|
||||
@@ -38,9 +38,9 @@ import appeng.util.inv.ItemListIgnoreCrafting;
|
||||
public class MEMonitorPassThrough<T extends IAEStack<T>> extends MEPassThrough<T> implements IMEMonitor<T>, IMEMonitorHandlerReceiver<T>
|
||||
{
|
||||
|
||||
final HashMap<IMEMonitorHandlerReceiver<T>, Object> listeners = new HashMap<IMEMonitorHandlerReceiver<T>, Object>();
|
||||
public BaseActionSource changeSource;
|
||||
IMEMonitor<T> monitor;
|
||||
private final HashMap<IMEMonitorHandlerReceiver<T>, Object> listeners = new HashMap<IMEMonitorHandlerReceiver<T>, Object>();
|
||||
private BaseActionSource changeSource;
|
||||
private IMEMonitor<T> monitor;
|
||||
|
||||
public MEMonitorPassThrough( final IMEInventory<T> i, final StorageChannel channel )
|
||||
{
|
||||
@@ -60,7 +60,7 @@ public class MEMonitorPassThrough<T extends IAEStack<T>> extends MEPassThrough<T
|
||||
}
|
||||
|
||||
this.monitor = null;
|
||||
final IItemList<T> before = this.getInternal() == null ? this.channel.createList() : this.getInternal().getAvailableItems( new ItemListIgnoreCrafting( this.channel.createList() ) );
|
||||
final IItemList<T> before = this.getInternal() == null ? this.getWrappedChannel().createList() : this.getInternal().getAvailableItems( new ItemListIgnoreCrafting( this.getWrappedChannel().createList() ) );
|
||||
|
||||
super.setInternal( i );
|
||||
if( i instanceof IMEMonitor )
|
||||
@@ -68,14 +68,14 @@ public class MEMonitorPassThrough<T extends IAEStack<T>> extends MEPassThrough<T
|
||||
this.monitor = (IMEMonitor<T>) i;
|
||||
}
|
||||
|
||||
final IItemList<T> after = this.getInternal() == null ? this.channel.createList() : this.getInternal().getAvailableItems( new ItemListIgnoreCrafting( this.channel.createList() ) );
|
||||
final IItemList<T> after = this.getInternal() == null ? this.getWrappedChannel().createList() : this.getInternal().getAvailableItems( new ItemListIgnoreCrafting( this.getWrappedChannel().createList() ) );
|
||||
|
||||
if( this.monitor != null )
|
||||
{
|
||||
this.monitor.addListener( this, this.monitor );
|
||||
}
|
||||
|
||||
Platform.postListChanges( before, after, this, this.changeSource );
|
||||
Platform.postListChanges( before, after, this, this.getChangeSource() );
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -102,7 +102,7 @@ public class MEMonitorPassThrough<T extends IAEStack<T>> extends MEPassThrough<T
|
||||
{
|
||||
if( this.monitor == null )
|
||||
{
|
||||
final IItemList<T> out = this.channel.createList();
|
||||
final IItemList<T> out = this.getWrappedChannel().createList();
|
||||
this.getInternal().getAvailableItems( new ItemListIgnoreCrafting( out ) );
|
||||
return out;
|
||||
}
|
||||
@@ -152,4 +152,14 @@ public class MEMonitorPassThrough<T extends IAEStack<T>> extends MEPassThrough<T
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private BaseActionSource getChangeSource()
|
||||
{
|
||||
return this.changeSource;
|
||||
}
|
||||
|
||||
public void setChangeSource( final BaseActionSource changeSource )
|
||||
{
|
||||
this.changeSource = changeSource;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,12 +32,12 @@ import appeng.api.storage.data.IItemList;
|
||||
public class MEPassThrough<T extends IAEStack<T>> implements IMEInventoryHandler<T>
|
||||
{
|
||||
|
||||
protected final StorageChannel channel;
|
||||
private final StorageChannel wrappedChannel;
|
||||
private IMEInventory<T> internal;
|
||||
|
||||
public MEPassThrough( final IMEInventory<T> i, final StorageChannel channel )
|
||||
{
|
||||
this.channel = channel;
|
||||
this.wrappedChannel = channel;
|
||||
this.setInternal( i );
|
||||
}
|
||||
|
||||
@@ -110,4 +110,9 @@ public class MEPassThrough<T extends IAEStack<T>> implements IMEInventoryHandler
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
StorageChannel getWrappedChannel()
|
||||
{
|
||||
return this.wrappedChannel;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,8 +47,8 @@ import appeng.util.ItemSorters;
|
||||
public class NetworkInventoryHandler<T extends IAEStack<T>> implements IMEInventoryHandler<T>
|
||||
{
|
||||
|
||||
static final ThreadLocal<LinkedList> DEPTH_MOD = new ThreadLocal<LinkedList>();
|
||||
static final ThreadLocal<LinkedList> DEPTH_SIM = new ThreadLocal<LinkedList>();
|
||||
private static final ThreadLocal<LinkedList> DEPTH_MOD = new ThreadLocal<LinkedList>();
|
||||
private static final ThreadLocal<LinkedList> DEPTH_SIM = new ThreadLocal<LinkedList>();
|
||||
private static final Comparator<Integer> PRIORITY_SORTER = new Comparator<Integer>()
|
||||
{
|
||||
|
||||
@@ -58,12 +58,12 @@ public class NetworkInventoryHandler<T extends IAEStack<T>> implements IMEInvent
|
||||
return ItemSorters.compareInt( o2, o1 );
|
||||
}
|
||||
};
|
||||
static int currentPass = 0;
|
||||
final StorageChannel myChannel;
|
||||
final SecurityCache security;
|
||||
private static int currentPass = 0;
|
||||
private final StorageChannel myChannel;
|
||||
private final SecurityCache security;
|
||||
// final TreeMultimap<Integer, IMEInventoryHandler<T>> priorityInventory;
|
||||
private final NavigableMap<Integer, List<IMEInventoryHandler<T>>> priorityInventory;
|
||||
int myPass = 0;
|
||||
private int myPass = 0;
|
||||
|
||||
public NetworkInventoryHandler( final StorageChannel chan, final SecurityCache security )
|
||||
{
|
||||
@@ -164,7 +164,7 @@ public class NetworkInventoryHandler<T extends IAEStack<T>> implements IMEInvent
|
||||
}
|
||||
|
||||
final IGrid gn = n.getGrid();
|
||||
if( gn != this.security.myGrid )
|
||||
if( gn != this.security.getGrid() )
|
||||
{
|
||||
|
||||
final ISecurityGrid sg = gn.getCache( ISecurityGrid.class );
|
||||
|
||||
@@ -39,8 +39,8 @@ import com.mojang.authlib.GameProfile;
|
||||
public class SecurityInventory implements IMEInventoryHandler<IAEItemStack>
|
||||
{
|
||||
|
||||
public final IItemList<IAEItemStack> storedItems = AEApi.instance().storage().createItemList();
|
||||
final TileSecurity securityTile;
|
||||
private final IItemList<IAEItemStack> storedItems = AEApi.instance().storage().createItemList();
|
||||
private final TileSecurity securityTile;
|
||||
|
||||
public SecurityInventory( final TileSecurity ts )
|
||||
{
|
||||
@@ -61,7 +61,7 @@ public class SecurityInventory implements IMEInventoryHandler<IAEItemStack>
|
||||
return null;
|
||||
}
|
||||
|
||||
this.storedItems.add( input );
|
||||
this.getStoredItems().add( input );
|
||||
this.securityTile.inventoryChanged();
|
||||
return null;
|
||||
}
|
||||
@@ -91,7 +91,7 @@ public class SecurityInventory implements IMEInventoryHandler<IAEItemStack>
|
||||
{
|
||||
if( this.hasPermission( src ) )
|
||||
{
|
||||
final IAEItemStack target = this.storedItems.findPrecise( request );
|
||||
final IAEItemStack target = this.getStoredItems().findPrecise( request );
|
||||
if( target != null )
|
||||
{
|
||||
final IAEItemStack output = target.copy();
|
||||
@@ -112,7 +112,7 @@ public class SecurityInventory implements IMEInventoryHandler<IAEItemStack>
|
||||
@Override
|
||||
public IItemList<IAEItemStack> getAvailableItems( final IItemList out )
|
||||
{
|
||||
for( final IAEItemStack ais : this.storedItems )
|
||||
for( final IAEItemStack ais : this.getStoredItems() )
|
||||
{
|
||||
out.add( ais );
|
||||
}
|
||||
@@ -152,7 +152,7 @@ public class SecurityInventory implements IMEInventoryHandler<IAEItemStack>
|
||||
return false;
|
||||
}
|
||||
|
||||
for( final IAEItemStack ais : this.storedItems )
|
||||
for( final IAEItemStack ais : this.getStoredItems() )
|
||||
{
|
||||
if( ais.isMeaningful() )
|
||||
{
|
||||
@@ -191,4 +191,9 @@ public class SecurityInventory implements IMEInventoryHandler<IAEItemStack>
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public IItemList<IAEItemStack> getStoredItems()
|
||||
{
|
||||
return this.storedItems;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ import appeng.tile.misc.TileCondenser;
|
||||
public class VoidFluidInventory implements IMEInventoryHandler<IAEFluidStack>
|
||||
{
|
||||
|
||||
final TileCondenser target;
|
||||
private final TileCondenser target;
|
||||
|
||||
public VoidFluidInventory( final TileCondenser te )
|
||||
{
|
||||
|
||||
@@ -32,7 +32,7 @@ import appeng.tile.misc.TileCondenser;
|
||||
public class VoidItemInventory implements IMEInventoryHandler<IAEItemStack>
|
||||
{
|
||||
|
||||
final TileCondenser target;
|
||||
private final TileCondenser target;
|
||||
|
||||
public VoidItemInventory( final TileCondenser te )
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user