Basic reformat, hit once, hope never again

This commit is contained in:
thatsIch
2015-04-03 08:54:31 +02:00
parent 4ff1631f89
commit d34c988c88
886 changed files with 31400 additions and 30990 deletions
@@ -18,23 +18,26 @@
package appeng.me.pathfinding;
import appeng.api.networking.IGridConnection;
import appeng.api.networking.IGridConnectionVisitor;
import appeng.api.networking.IGridNode;
import appeng.me.GridConnection;
import appeng.me.GridNode;
public class AdHocChannelUpdater implements IGridConnectionVisitor
{
final private int usedChannels;
public AdHocChannelUpdater(int used) {
public AdHocChannelUpdater( int used )
{
this.usedChannels = used;
}
@Override
public boolean visitNode(IGridNode n)
public boolean visitNode( IGridNode n )
{
GridNode gn = (GridNode) n;
gn.setControllerRoute( null, true );
@@ -44,7 +47,7 @@ public class AdHocChannelUpdater implements IGridConnectionVisitor
}
@Override
public void visitConnection(IGridConnection gcc)
public void visitConnection( IGridConnection gcc )
{
GridConnection gc = (GridConnection) gcc;
gc.setControllerRoute( null, true );
@@ -18,17 +18,19 @@
package appeng.me.pathfinding;
import appeng.api.networking.IGridConnection;
import appeng.api.networking.IGridConnectionVisitor;
import appeng.api.networking.IGridNode;
import appeng.me.GridConnection;
import appeng.me.GridNode;
public class ControllerChannelUpdater implements IGridConnectionVisitor
{
@Override
public boolean visitNode(IGridNode n)
public boolean visitNode( IGridNode n )
{
GridNode gn = (GridNode) n;
gn.finalizeChannels();
@@ -36,7 +38,7 @@ public class ControllerChannelUpdater implements IGridConnectionVisitor
}
@Override
public void visitConnection(IGridConnection gcc)
public void visitConnection( IGridConnection gcc )
{
GridConnection gc = (GridConnection) gcc;
gc.finalizeChannels();
@@ -18,26 +18,27 @@
package appeng.me.pathfinding;
import appeng.api.networking.IGridHost;
import appeng.api.networking.IGridNode;
import appeng.api.networking.IGridVisitor;
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;
public boolean isValid = true;
public int found = 0;
public ControllerValidator(int x, int y, int z) {
public ControllerValidator( int x, int y, int z )
{
this.minX = x;
this.minY = y;
this.minZ = z;
@@ -47,10 +48,10 @@ public class ControllerValidator implements IGridVisitor
}
@Override
public boolean visitNode(IGridNode n)
public boolean visitNode( IGridNode n )
{
IGridHost host = n.getMachine();
if ( this.isValid && host instanceof TileController )
if( this.isValid && host instanceof TileController )
{
TileController c = (TileController) host;
@@ -61,7 +62,7 @@ public class ControllerValidator implements IGridVisitor
this.minZ = Math.min( c.zCoord, this.minZ );
this.maxZ = Math.max( c.zCoord, this.maxZ );
if ( this.maxX - this.minX < 7 && this.maxY - this.minY < 7 && this.maxZ - this.minZ < 7 )
if( this.maxX - this.minX < 7 && this.maxY - this.minY < 7 && this.maxZ - this.minZ < 7 )
{
this.found++;
return true;
@@ -18,17 +18,19 @@
package appeng.me.pathfinding;
import java.util.EnumSet;
import appeng.api.networking.GridFlags;
import appeng.api.util.IReadOnlyCollection;
public interface IPathItem
{
IPathItem getControllerRoute();
void setControllerRoute(IPathItem fast, boolean zeroOut);
void setControllerRoute( IPathItem fast, boolean zeroOut );
/**
* used to determine if the finder can continue.
@@ -43,7 +45,7 @@ public interface IPathItem
/**
* add one to the channel count, this is mostly for cables.
*/
void incrementChannelCount(int usedChannels);
void incrementChannelCount( int usedChannels );
/**
* get the grid flags for this IPathItem.
@@ -56,5 +58,4 @@ public interface IPathItem
* channels are done, wrap it up.
*/
void finalizeChannels();
}
@@ -18,6 +18,7 @@
package appeng.me.pathfinding;
import java.util.EnumSet;
import java.util.Iterator;
import java.util.LinkedList;
@@ -29,14 +30,17 @@ import appeng.api.networking.IGridMultiblock;
import appeng.api.networking.IGridNode;
import appeng.me.cache.PathGridCache;
public class PathSegment
{
public boolean isDead;
final PathGridCache pgc;
final Set<IPathItem> semiOpen;
final Set<IPathItem> closed;
public boolean isDead;
List<IPathItem> open;
public PathSegment(PathGridCache myPGC, List<IPathItem> open, Set<IPathItem> semiOpen, Set<IPathItem> closed)
public PathSegment( PathGridCache myPGC, List<IPathItem> open, Set<IPathItem> semiOpen, Set<IPathItem> closed )
{
this.open = open;
this.semiOpen = semiOpen;
@@ -45,44 +49,40 @@ public class PathSegment
this.isDead = false;
}
List<IPathItem> open;
final Set<IPathItem> semiOpen;
final Set<IPathItem> closed;
public boolean step()
{
List<IPathItem> oldOpen = this.open;
this.open = new LinkedList<IPathItem>();
for (IPathItem i : oldOpen)
for( IPathItem i : oldOpen )
{
for (IPathItem pi : i.getPossibleOptions())
for( IPathItem pi : i.getPossibleOptions() )
{
EnumSet<GridFlags> flags = pi.getFlags();
if ( !this.closed.contains( pi ) )
if( !this.closed.contains( pi ) )
{
pi.setControllerRoute( i, true );
if ( flags.contains( GridFlags.REQUIRE_CHANNEL ) )
if( flags.contains( GridFlags.REQUIRE_CHANNEL ) )
{
// close the semi open.
if ( !this.semiOpen.contains( pi ) )
if( !this.semiOpen.contains( pi ) )
{
boolean worked;
if ( flags.contains( GridFlags.COMPRESSED_CHANNEL ) )
if( flags.contains( GridFlags.COMPRESSED_CHANNEL ) )
worked = this.useDenseChannel( pi );
else
worked = this.useChannel( pi );
if ( worked && flags.contains( GridFlags.MULTIBLOCK ) )
if( worked && flags.contains( GridFlags.MULTIBLOCK ) )
{
Iterator<IGridNode> oni = ((IGridMultiblock) ((IGridNode) pi).getGridBlock()).getMultiblockNodes();
while (oni.hasNext())
Iterator<IGridNode> oni = ( (IGridMultiblock) ( (IGridNode) pi ).getGridBlock() ).getMultiblockNodes();
while( oni.hasNext() )
{
IGridNode otherNodes = oni.next();
if ( otherNodes != pi )
if( otherNodes != pi )
this.semiOpen.add( (IPathItem) otherNodes );
}
}
@@ -103,19 +103,19 @@ public class PathSegment
return this.open.isEmpty();
}
private boolean useChannel(IPathItem start)
private boolean useDenseChannel( IPathItem start )
{
IPathItem pi = start;
while (pi != null)
while( pi != null )
{
if ( !pi.canSupportMoreChannels() )
if( !pi.canSupportMoreChannels() || pi.getFlags().contains( GridFlags.CANNOT_CARRY_COMPRESSED ) )
return false;
pi = pi.getControllerRoute();
}
pi = start;
while (pi != null)
while( pi != null )
{
this.pgc.channelsByBlocks++;
pi.incrementChannelCount( 1 );
@@ -126,19 +126,19 @@ public class PathSegment
return true;
}
private boolean useDenseChannel(IPathItem start)
private boolean useChannel( IPathItem start )
{
IPathItem pi = start;
while (pi != null)
while( pi != null )
{
if ( !pi.canSupportMoreChannels() || pi.getFlags().contains( GridFlags.CANNOT_CARRY_COMPRESSED ) )
if( !pi.canSupportMoreChannels() )
return false;
pi = pi.getControllerRoute();
}
pi = start;
while (pi != null)
while( pi != null )
{
this.pgc.channelsByBlocks++;
pi.incrementChannelCount( 1 );
@@ -148,5 +148,4 @@ public class PathSegment
this.pgc.channelsInUse++;
return true;
}
}