final variables and parameters
seeing some methods it does actually help to enforce the parameters
This commit is contained in:
@@ -74,7 +74,7 @@ public class GridNode implements IGridNode, IPathItem
|
||||
private int usedChannels = 0;
|
||||
private int lastUsedChannels = 0;
|
||||
|
||||
public GridNode( IGridBlock what )
|
||||
public GridNode( final IGridBlock what )
|
||||
{
|
||||
this.gridProxy = what;
|
||||
}
|
||||
@@ -99,7 +99,7 @@ public class GridNode implements IGridNode, IPathItem
|
||||
return this.getMachine().getClass();
|
||||
}
|
||||
|
||||
public void addConnection( IGridConnection gridConnection )
|
||||
public void addConnection( final IGridConnection gridConnection )
|
||||
{
|
||||
this.connections.add( gridConnection );
|
||||
if( gridConnection.hasDirection() )
|
||||
@@ -112,7 +112,7 @@ public class GridNode implements IGridNode, IPathItem
|
||||
Collections.sort( this.connections, new ConnectionComparator( gn ) );
|
||||
}
|
||||
|
||||
public void removeConnection( IGridConnection gridConnection )
|
||||
public void removeConnection( final IGridConnection gridConnection )
|
||||
{
|
||||
this.connections.remove( gridConnection );
|
||||
if( gridConnection.hasDirection() )
|
||||
@@ -121,9 +121,9 @@ public class GridNode implements IGridNode, IPathItem
|
||||
}
|
||||
}
|
||||
|
||||
public boolean hasConnection( IGridNode otherSide )
|
||||
public boolean hasConnection( final IGridNode otherSide )
|
||||
{
|
||||
for( IGridConnection gc : this.connections )
|
||||
for( final IGridConnection gc : this.connections )
|
||||
{
|
||||
if( gc.a() == otherSide || gc.b() == otherSide )
|
||||
{
|
||||
@@ -135,11 +135,11 @@ public class GridNode implements IGridNode, IPathItem
|
||||
|
||||
public void validateGrid()
|
||||
{
|
||||
GridSplitDetector gsd = new GridSplitDetector( this.getInternalGrid().getPivot() );
|
||||
final GridSplitDetector gsd = new GridSplitDetector( this.getInternalGrid().getPivot() );
|
||||
this.beginVisit( gsd );
|
||||
if( !gsd.pivotFound )
|
||||
{
|
||||
IGridVisitor gp = new GridPropagator( new Grid( this ) );
|
||||
final IGridVisitor gp = new GridPropagator( new Grid( this ) );
|
||||
this.beginVisit( gp );
|
||||
}
|
||||
}
|
||||
@@ -155,9 +155,9 @@ public class GridNode implements IGridNode, IPathItem
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beginVisit( IGridVisitor g )
|
||||
public void beginVisit( final IGridVisitor g )
|
||||
{
|
||||
Object tracker = new Object();
|
||||
final Object tracker = new Object();
|
||||
|
||||
LinkedList<GridNode> nextRun = new LinkedList<GridNode>();
|
||||
nextRun.add( this );
|
||||
@@ -166,8 +166,8 @@ public class GridNode implements IGridNode, IPathItem
|
||||
|
||||
if( g instanceof IGridConnectionVisitor )
|
||||
{
|
||||
LinkedList<IGridConnection> nextConn = new LinkedList<IGridConnection>();
|
||||
IGridConnectionVisitor gcv = (IGridConnectionVisitor) g;
|
||||
final LinkedList<IGridConnection> nextConn = new LinkedList<IGridConnection>();
|
||||
final IGridConnectionVisitor gcv = (IGridConnectionVisitor) g;
|
||||
|
||||
while( !nextRun.isEmpty() )
|
||||
{
|
||||
@@ -176,10 +176,10 @@ public class GridNode implements IGridNode, IPathItem
|
||||
gcv.visitConnection( nextConn.poll() );
|
||||
}
|
||||
|
||||
Iterable<GridNode> thisRun = nextRun;
|
||||
final Iterable<GridNode> thisRun = nextRun;
|
||||
nextRun = new LinkedList<GridNode>();
|
||||
|
||||
for( GridNode n : thisRun )
|
||||
for( final GridNode n : thisRun )
|
||||
{
|
||||
n.visitorConnection( tracker, g, nextRun, nextConn );
|
||||
}
|
||||
@@ -189,10 +189,10 @@ public class GridNode implements IGridNode, IPathItem
|
||||
{
|
||||
while( !nextRun.isEmpty() )
|
||||
{
|
||||
Iterable<GridNode> thisRun = nextRun;
|
||||
final Iterable<GridNode> thisRun = nextRun;
|
||||
nextRun = new LinkedList<GridNode>();
|
||||
|
||||
for( GridNode n : thisRun )
|
||||
for( final GridNode n : thisRun )
|
||||
{
|
||||
n.visitorNode( tracker, g, nextRun );
|
||||
}
|
||||
@@ -203,13 +203,13 @@ public class GridNode implements IGridNode, IPathItem
|
||||
@Override
|
||||
public void updateState()
|
||||
{
|
||||
EnumSet<GridFlags> set = this.gridProxy.getFlags();
|
||||
final EnumSet<GridFlags> set = this.gridProxy.getFlags();
|
||||
|
||||
this.compressedData = set.contains( GridFlags.CANNOT_CARRY ) ? 0 : ( set.contains( GridFlags.DENSE_CAPACITY ) ? 2 : 1 );
|
||||
|
||||
this.compressedData |= ( this.gridProxy.getGridColor().ordinal() << 3 );
|
||||
|
||||
for( ForgeDirection dir : this.gridProxy.getConnectableSides() )
|
||||
for( final ForgeDirection dir : this.gridProxy.getConnectableSides() )
|
||||
{
|
||||
this.compressedData |= ( 1 << ( dir.ordinal() + 8 ) );
|
||||
}
|
||||
@@ -230,7 +230,7 @@ public class GridNode implements IGridNode, IPathItem
|
||||
return this.myGrid;
|
||||
}
|
||||
|
||||
public void setGrid( Grid grid )
|
||||
public void setGrid( final Grid grid )
|
||||
{
|
||||
if( this.myGrid == grid )
|
||||
{
|
||||
@@ -245,7 +245,7 @@ public class GridNode implements IGridNode, IPathItem
|
||||
{
|
||||
this.myGrid.saveState();
|
||||
|
||||
for( IGridCache c : grid.getCaches().values() )
|
||||
for( final IGridCache c : grid.getCaches().values() )
|
||||
{
|
||||
c.onJoin( this.myGrid.getMyStorage() );
|
||||
}
|
||||
@@ -267,8 +267,8 @@ public class GridNode implements IGridNode, IPathItem
|
||||
this.setGridStorage( null );
|
||||
}
|
||||
|
||||
IGridConnection c = this.connections.listIterator().next();
|
||||
GridNode otherSide = (GridNode) c.getOtherSide( this );
|
||||
final IGridConnection c = this.connections.listIterator().next();
|
||||
final GridNode otherSide = (GridNode) c.getOtherSide( this );
|
||||
otherSide.getInternalGrid().setPivot( otherSide );
|
||||
c.destroy();
|
||||
}
|
||||
@@ -288,8 +288,8 @@ public class GridNode implements IGridNode, IPathItem
|
||||
@Override
|
||||
public EnumSet<ForgeDirection> getConnectedSides()
|
||||
{
|
||||
EnumSet<ForgeDirection> set = EnumSet.noneOf( ForgeDirection.class );
|
||||
for( IGridConnection gc : this.connections )
|
||||
final EnumSet<ForgeDirection> set = EnumSet.noneOf( ForgeDirection.class );
|
||||
for( final IGridConnection gc : this.connections )
|
||||
{
|
||||
set.add( gc.getDirection( this ) );
|
||||
}
|
||||
@@ -311,22 +311,22 @@ public class GridNode implements IGridNode, IPathItem
|
||||
@Override
|
||||
public boolean isActive()
|
||||
{
|
||||
IGrid g = this.getGrid();
|
||||
final IGrid g = this.getGrid();
|
||||
if( g != null )
|
||||
{
|
||||
IPathingGrid pg = g.getCache( IPathingGrid.class );
|
||||
IEnergyGrid eg = g.getCache( IEnergyGrid.class );
|
||||
final IPathingGrid pg = g.getCache( IPathingGrid.class );
|
||||
final IEnergyGrid eg = g.getCache( IEnergyGrid.class );
|
||||
return this.meetsChannelRequirements() && eg.isNetworkPowered() && !pg.isNetworkBooting();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadFromNBT( String name, NBTTagCompound nodeData )
|
||||
public void loadFromNBT( final String name, final NBTTagCompound nodeData )
|
||||
{
|
||||
if( this.myGrid == null )
|
||||
{
|
||||
NBTTagCompound node = nodeData.getCompoundTag( name );
|
||||
final NBTTagCompound node = nodeData.getCompoundTag( name );
|
||||
this.playerID = node.getInteger( "p" );
|
||||
this.lastSecurityKey = node.getLong( "k" );
|
||||
|
||||
@@ -341,11 +341,11 @@ public class GridNode implements IGridNode, IPathItem
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveToNBT( String name, NBTTagCompound nodeData )
|
||||
public void saveToNBT( final String name, final NBTTagCompound nodeData )
|
||||
{
|
||||
if( this.myStorage != null )
|
||||
{
|
||||
NBTTagCompound node = new NBTTagCompound();
|
||||
final NBTTagCompound node = new NBTTagCompound();
|
||||
|
||||
node.setInteger( "p", this.playerID );
|
||||
node.setLong( "k", this.lastSecurityKey );
|
||||
@@ -366,7 +366,7 @@ public class GridNode implements IGridNode, IPathItem
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasFlag( GridFlags flag )
|
||||
public boolean hasFlag( final GridFlags flag )
|
||||
{
|
||||
return this.gridProxy.getFlags().contains( flag );
|
||||
}
|
||||
@@ -378,7 +378,7 @@ public class GridNode implements IGridNode, IPathItem
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerID( int playerID )
|
||||
public void setPlayerID( final int playerID )
|
||||
{
|
||||
if( playerID >= 0 )
|
||||
{
|
||||
@@ -398,25 +398,25 @@ public class GridNode implements IGridNode, IPathItem
|
||||
return;
|
||||
}
|
||||
|
||||
EnumSet<ForgeDirection> newSecurityConnections = EnumSet.noneOf( ForgeDirection.class );
|
||||
final EnumSet<ForgeDirection> newSecurityConnections = EnumSet.noneOf( ForgeDirection.class );
|
||||
|
||||
DimensionalCoord dc = this.gridProxy.getLocation();
|
||||
for( ForgeDirection f : ForgeDirection.VALID_DIRECTIONS )
|
||||
final DimensionalCoord dc = this.gridProxy.getLocation();
|
||||
for( final ForgeDirection f : ForgeDirection.VALID_DIRECTIONS )
|
||||
{
|
||||
IGridHost te = this.findGridHost( dc.getWorld(), dc.x + f.offsetX, dc.y + f.offsetY, dc.z + f.offsetZ );
|
||||
final IGridHost te = this.findGridHost( dc.getWorld(), dc.x + f.offsetX, dc.y + f.offsetY, dc.z + f.offsetZ );
|
||||
if( te != null )
|
||||
{
|
||||
GridNode node = (GridNode) te.getGridNode( f.getOpposite() );
|
||||
final GridNode node = (GridNode) te.getGridNode( f.getOpposite() );
|
||||
if( node == null )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
boolean isValidConnection = this.canConnect( node, f ) && node.canConnect( this, f.getOpposite() );
|
||||
final boolean isValidConnection = this.canConnect( node, f ) && node.canConnect( this, f.getOpposite() );
|
||||
|
||||
IGridConnection con = null; // find the connection for this
|
||||
// direction..
|
||||
for( IGridConnection c : this.getConnections() )
|
||||
for( final IGridConnection c : this.getConnections() )
|
||||
{
|
||||
if( c.getDirection( this ) == f )
|
||||
{
|
||||
@@ -427,7 +427,7 @@ public class GridNode implements IGridNode, IPathItem
|
||||
|
||||
if( con != null )
|
||||
{
|
||||
IGridNode os = con.getOtherSide( this );
|
||||
final IGridNode os = con.getOtherSide( this );
|
||||
if( os == node )
|
||||
{
|
||||
// if this connection is no longer valid, destroy it.
|
||||
@@ -455,7 +455,7 @@ public class GridNode implements IGridNode, IPathItem
|
||||
{
|
||||
new GridConnection( node, this, f.getOpposite() );
|
||||
}
|
||||
catch( FailedConnection e )
|
||||
catch( final FailedConnection e )
|
||||
{
|
||||
TickHandler.INSTANCE.addCallable( node.getWorld(), new MachineSecurityBreak( this ) );
|
||||
|
||||
@@ -466,12 +466,12 @@ public class GridNode implements IGridNode, IPathItem
|
||||
}
|
||||
}
|
||||
|
||||
for( ForgeDirection f : newSecurityConnections )
|
||||
for( final ForgeDirection f : newSecurityConnections )
|
||||
{
|
||||
IGridHost te = this.findGridHost( dc.getWorld(), dc.x + f.offsetX, dc.y + f.offsetY, dc.z + f.offsetZ );
|
||||
final IGridHost te = this.findGridHost( dc.getWorld(), dc.x + f.offsetX, dc.y + f.offsetY, dc.z + f.offsetZ );
|
||||
if( te != null )
|
||||
{
|
||||
GridNode node = (GridNode) te.getGridNode( f.getOpposite() );
|
||||
final GridNode node = (GridNode) te.getGridNode( f.getOpposite() );
|
||||
if( node == null )
|
||||
{
|
||||
continue;
|
||||
@@ -482,7 +482,7 @@ public class GridNode implements IGridNode, IPathItem
|
||||
{
|
||||
new GridConnection( node, this, f.getOpposite() );
|
||||
}
|
||||
catch( FailedConnection e )
|
||||
catch( final FailedConnection e )
|
||||
{
|
||||
TickHandler.INSTANCE.addCallable( node.getWorld(), new MachineSecurityBreak( this ) );
|
||||
|
||||
@@ -492,11 +492,11 @@ public class GridNode implements IGridNode, IPathItem
|
||||
}
|
||||
}
|
||||
|
||||
private IGridHost findGridHost( World world, int x, int y, int z )
|
||||
private IGridHost findGridHost( final World world, final int x, final int y, final int z )
|
||||
{
|
||||
if( world.blockExists( x, y, z ) )
|
||||
{
|
||||
TileEntity te = world.getTileEntity( x, y, z );
|
||||
final TileEntity te = world.getTileEntity( x, y, z );
|
||||
if( te instanceof IGridHost )
|
||||
{
|
||||
return (IGridHost) te;
|
||||
@@ -505,7 +505,7 @@ public class GridNode implements IGridNode, IPathItem
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean canConnect( GridNode from, ForgeDirection dir )
|
||||
public boolean canConnect( final GridNode from, final ForgeDirection dir )
|
||||
{
|
||||
if( !this.isValidDirection( dir ) )
|
||||
{
|
||||
@@ -520,7 +520,7 @@ public class GridNode implements IGridNode, IPathItem
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean isValidDirection( ForgeDirection dir )
|
||||
private boolean isValidDirection( final ForgeDirection dir )
|
||||
{
|
||||
return ( this.compressedData & ( 1 << ( 8 + dir.ordinal() ) ) ) > 0;
|
||||
}
|
||||
@@ -530,14 +530,14 @@ public class GridNode implements IGridNode, IPathItem
|
||||
return AEColor.values()[( this.compressedData >> 3 ) & 0x1F];
|
||||
}
|
||||
|
||||
private void visitorConnection( Object tracker, IGridVisitor g, Deque<GridNode> nextRun, Deque<IGridConnection> nextConnections )
|
||||
private void visitorConnection( final Object tracker, final IGridVisitor g, final Deque<GridNode> nextRun, final Deque<IGridConnection> nextConnections )
|
||||
{
|
||||
if( g.visitNode( this ) )
|
||||
{
|
||||
for( IGridConnection gc : this.getConnections() )
|
||||
for( final IGridConnection gc : this.getConnections() )
|
||||
{
|
||||
GridNode gn = (GridNode) gc.getOtherSide( this );
|
||||
GridConnection gcc = (GridConnection) gc;
|
||||
final GridNode gn = (GridNode) gc.getOtherSide( this );
|
||||
final GridConnection gcc = (GridConnection) gc;
|
||||
|
||||
if( gcc.visitorIterationNumber != tracker )
|
||||
{
|
||||
@@ -557,13 +557,13 @@ public class GridNode implements IGridNode, IPathItem
|
||||
}
|
||||
}
|
||||
|
||||
private void visitorNode( Object tracker, IGridVisitor g, Deque<GridNode> nextRun )
|
||||
private void visitorNode( final Object tracker, final IGridVisitor g, final Deque<GridNode> nextRun )
|
||||
{
|
||||
if( g.visitNode( this ) )
|
||||
{
|
||||
for( IGridConnection gc : this.getConnections() )
|
||||
for( final IGridConnection gc : this.getConnections() )
|
||||
{
|
||||
GridNode gn = (GridNode) gc.getOtherSide( this );
|
||||
final GridNode gn = (GridNode) gc.getOtherSide( this );
|
||||
|
||||
if( tracker == gn.visitorIterationNumber )
|
||||
{
|
||||
@@ -582,7 +582,7 @@ public class GridNode implements IGridNode, IPathItem
|
||||
return this.myStorage;
|
||||
}
|
||||
|
||||
public void setGridStorage( GridStorage s )
|
||||
public void setGridStorage( final GridStorage s )
|
||||
{
|
||||
this.myStorage = s;
|
||||
this.usedChannels = 0;
|
||||
@@ -601,14 +601,14 @@ public class GridNode implements IGridNode, IPathItem
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setControllerRoute( IPathItem fast, boolean zeroOut )
|
||||
public void setControllerRoute( final IPathItem fast, final boolean zeroOut )
|
||||
{
|
||||
if( zeroOut )
|
||||
{
|
||||
this.usedChannels = 0;
|
||||
}
|
||||
|
||||
int idx = this.connections.indexOf( fast );
|
||||
final int idx = this.connections.indexOf( fast );
|
||||
if( idx > 0 )
|
||||
{
|
||||
this.connections.remove( fast );
|
||||
@@ -634,7 +634,7 @@ public class GridNode implements IGridNode, IPathItem
|
||||
}
|
||||
|
||||
@Override
|
||||
public void incrementChannelCount( int usedChannels )
|
||||
public void incrementChannelCount( final int usedChannels )
|
||||
{
|
||||
this.usedChannels += usedChannels;
|
||||
}
|
||||
@@ -673,13 +673,13 @@ public class GridNode implements IGridNode, IPathItem
|
||||
{
|
||||
private final GridNode node;
|
||||
|
||||
public MachineSecurityBreak( GridNode node )
|
||||
public MachineSecurityBreak( final GridNode node )
|
||||
{
|
||||
this.node = node;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void call(World world) throws Exception
|
||||
public Void call( final World world) throws Exception
|
||||
{
|
||||
this.node.getMachine().securityBreak();
|
||||
|
||||
@@ -691,16 +691,16 @@ public class GridNode implements IGridNode, IPathItem
|
||||
{
|
||||
private final IGridNode gn;
|
||||
|
||||
public ConnectionComparator( IGridNode gn )
|
||||
public ConnectionComparator( final IGridNode gn )
|
||||
{
|
||||
this.gn = gn;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compare( IGridConnection o1, IGridConnection o2 )
|
||||
public int compare( final IGridConnection o1, final IGridConnection o2 )
|
||||
{
|
||||
boolean preferredA = o1.getOtherSide( this.gn ).hasFlag( GridFlags.PREFERRED );
|
||||
boolean preferredB = o2.getOtherSide( this.gn ).hasFlag( GridFlags.PREFERRED );
|
||||
final boolean preferredA = o1.getOtherSide( this.gn ).hasFlag( GridFlags.PREFERRED );
|
||||
final boolean preferredB = o2.getOtherSide( this.gn ).hasFlag( GridFlags.PREFERRED );
|
||||
|
||||
return preferredA == preferredB ? 0 : ( preferredA ? -1 : 1 );
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user