reformatted all src files (#141)

This commit is contained in:
YoungOnion
2022-09-17 05:08:02 -06:00
committed by GitHub
parent 3328bfcda2
commit 9011273229
1056 changed files with 88127 additions and 110597 deletions
@@ -26,32 +26,28 @@ import appeng.me.GridConnection;
import appeng.me.GridNode;
public class AdHocChannelUpdater implements IGridConnectionVisitor
{
public class AdHocChannelUpdater implements IGridConnectionVisitor {
private final int usedChannels;
private final int usedChannels;
public AdHocChannelUpdater( final int used )
{
this.usedChannels = used;
}
public AdHocChannelUpdater(final int used) {
this.usedChannels = used;
}
@Override
public boolean visitNode( final IGridNode n )
{
final GridNode gn = (GridNode) n;
gn.setControllerRoute( null, true );
gn.incrementChannelCount( this.usedChannels );
gn.finalizeChannels();
return true;
}
@Override
public boolean visitNode(final IGridNode n) {
final GridNode gn = (GridNode) n;
gn.setControllerRoute(null, true);
gn.incrementChannelCount(this.usedChannels);
gn.finalizeChannels();
return true;
}
@Override
public void visitConnection( final IGridConnection gcc )
{
final GridConnection gc = (GridConnection) gcc;
gc.setControllerRoute( null, true );
gc.incrementChannelCount( this.usedChannels );
gc.finalizeChannels();
}
@Override
public void visitConnection(final IGridConnection gcc) {
final GridConnection gc = (GridConnection) gcc;
gc.setControllerRoute(null, true);
gc.incrementChannelCount(this.usedChannels);
gc.finalizeChannels();
}
}
@@ -26,21 +26,18 @@ import appeng.me.GridConnection;
import appeng.me.GridNode;
public class ControllerChannelUpdater implements IGridConnectionVisitor
{
public class ControllerChannelUpdater implements IGridConnectionVisitor {
@Override
public boolean visitNode( final IGridNode n )
{
final GridNode gn = (GridNode) n;
gn.finalizeChannels();
return true;
}
@Override
public boolean visitNode(final IGridNode n) {
final GridNode gn = (GridNode) n;
gn.finalizeChannels();
return true;
}
@Override
public void visitConnection( final IGridConnection gcc )
{
final GridConnection gc = (GridConnection) gcc;
gc.finalizeChannels();
}
@Override
public void visitConnection(final IGridConnection gcc) {
final GridConnection gc = (GridConnection) gcc;
gc.finalizeChannels();
}
}
@@ -19,87 +19,75 @@
package appeng.me.pathfinding;
import appeng.core.AEConfig;
import net.minecraft.util.math.BlockPos;
import appeng.api.networking.IGridHost;
import appeng.api.networking.IGridNode;
import appeng.api.networking.IGridVisitor;
import appeng.core.AEConfig;
import appeng.tile.networking.TileController;
import net.minecraft.util.math.BlockPos;
public class ControllerValidator implements IGridVisitor
{
public class ControllerValidator implements IGridVisitor {
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;
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 )
{
this.minX = x;
this.maxX = x;
this.minY = y;
this.maxY = y;
this.minZ = z;
this.maxZ = z;
}
public ControllerValidator(final int x, final int y, final int z) {
this.minX = x;
this.maxX = x;
this.minY = y;
this.maxY = y;
this.minZ = z;
this.maxZ = z;
}
@Override
public boolean visitNode( final IGridNode n )
{
final IGridHost host = n.getMachine();
if( this.isValid() && host instanceof TileController )
{
final TileController c = (TileController) host;
@Override
public boolean visitNode(final IGridNode n) {
final IGridHost host = n.getMachine();
if (this.isValid() && host instanceof TileController) {
final TileController c = (TileController) host;
final BlockPos pos = c.getPos();
final BlockPos pos = c.getPos();
this.minX = Math.min( pos.getX(), this.minX );
this.maxX = Math.max( pos.getX(), this.maxX );
this.minY = Math.min( pos.getY(), this.minY );
this.maxY = Math.max( pos.getY(), this.maxY );
this.minZ = Math.min( pos.getZ(), this.minZ );
this.maxZ = Math.max( pos.getZ(), this.maxZ );
this.minX = Math.min(pos.getX(), this.minX);
this.maxX = Math.max(pos.getX(), this.maxX);
this.minY = Math.min(pos.getY(), this.minY);
this.maxY = Math.max(pos.getY(), this.maxY);
this.minZ = Math.min(pos.getZ(), this.minZ);
this.maxZ = Math.max(pos.getZ(), this.maxZ);
if( this.maxX - this.minX < AEConfig.instance().getMaxControllerSizeX() && this.maxY - this.minY < AEConfig.instance().getMaxControllerSizeY() && this.maxZ - this.minZ < AEConfig.instance().getMaxControllerSizeZ() )
{
this.setFound( this.getFound() + 1 );
return true;
}
if (this.maxX - this.minX < AEConfig.instance().getMaxControllerSizeX() && this.maxY - this.minY < AEConfig.instance().getMaxControllerSizeY() && this.maxZ - this.minZ < AEConfig.instance().getMaxControllerSizeZ()) {
this.setFound(this.getFound() + 1);
return true;
}
this.setValid( false );
}
else
{
return false;
}
this.setValid(false);
} else {
return false;
}
return this.isValid();
}
return this.isValid();
}
public boolean isValid()
{
return this.isValid;
}
public boolean isValid() {
return this.isValid;
}
private void setValid( final boolean isValid )
{
this.isValid = isValid;
}
private void setValid(final boolean isValid) {
this.isValid = isValid;
}
public int getFound()
{
return this.found;
}
public int getFound() {
return this.found;
}
private void setFound( final int found )
{
this.found = found;
}
private void setFound(final int found) {
this.found = found;
}
}
@@ -19,43 +19,42 @@
package appeng.me.pathfinding;
import java.util.EnumSet;
import appeng.api.networking.GridFlags;
import appeng.api.util.IReadOnlyCollection;
import java.util.EnumSet;
public interface IPathItem
{
IPathItem getControllerRoute();
public interface IPathItem {
void setControllerRoute( IPathItem fast, boolean zeroOut );
IPathItem getControllerRoute();
/**
* used to determine if the finder can continue.
*/
boolean canSupportMoreChannels();
void setControllerRoute(IPathItem fast, boolean zeroOut);
/**
* find possible choices for other pathing.
*/
IReadOnlyCollection<IPathItem> getPossibleOptions();
/**
* used to determine if the finder can continue.
*/
boolean canSupportMoreChannels();
/**
* add one to the channel count, this is mostly for cables.
*/
void incrementChannelCount( int usedChannels );
/**
* find possible choices for other pathing.
*/
IReadOnlyCollection<IPathItem> getPossibleOptions();
/**
* get the grid flags for this IPathItem.
*
* @return the flag set.
*/
EnumSet<GridFlags> getFlags();
/**
* add one to the channel count, this is mostly for cables.
*/
void incrementChannelCount(int usedChannels);
/**
* channels are done, wrap it up.
*/
void finalizeChannels();
/**
* get the grid flags for this IPathItem.
*
* @return the flag set.
*/
EnumSet<GridFlags> getFlags();
/**
* channels are done, wrap it up.
*/
void finalizeChannels();
}
@@ -19,153 +19,123 @@
package appeng.me.pathfinding;
import java.util.ArrayList;
import java.util.EnumSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import appeng.api.networking.GridFlags;
import appeng.api.networking.IGridMultiblock;
import appeng.api.networking.IGridNode;
import appeng.me.cache.PathGridCache;
import java.util.*;
public class PathSegment
{
private final PathGridCache pgc;
private final Set<IPathItem> semiOpen;
private final Set<IPathItem> closed;
private boolean isDead;
private List<IPathItem> open;
public class PathSegment {
public PathSegment( final PathGridCache myPGC, final List<IPathItem> open, final Set<IPathItem> semiOpen, final Set<IPathItem> closed )
{
this.open = open;
this.semiOpen = semiOpen;
this.closed = closed;
this.pgc = myPGC;
this.setDead( false );
}
private final PathGridCache pgc;
private final Set<IPathItem> semiOpen;
private final Set<IPathItem> closed;
private boolean isDead;
private List<IPathItem> open;
public boolean step()
{
final List<IPathItem> oldOpen = this.open;
this.open = new ArrayList<>();
public PathSegment(final PathGridCache myPGC, final List<IPathItem> open, final Set<IPathItem> semiOpen, final Set<IPathItem> closed) {
this.open = open;
this.semiOpen = semiOpen;
this.closed = closed;
this.pgc = myPGC;
this.setDead(false);
}
for( final IPathItem i : oldOpen )
{
for( final IPathItem pi : i.getPossibleOptions() )
{
final EnumSet<GridFlags> flags = pi.getFlags();
public boolean step() {
final List<IPathItem> oldOpen = this.open;
this.open = new ArrayList<>();
if( !this.closed.contains( pi ) )
{
pi.setControllerRoute( i, true );
for (final IPathItem i : oldOpen) {
for (final IPathItem pi : i.getPossibleOptions()) {
final EnumSet<GridFlags> flags = pi.getFlags();
if( flags.contains( GridFlags.REQUIRE_CHANNEL ) )
{
// close the semi open.
if( !this.semiOpen.contains( pi ) )
{
final boolean worked;
if (!this.closed.contains(pi)) {
pi.setControllerRoute(i, true);
if( flags.contains( GridFlags.COMPRESSED_CHANNEL ) )
{
worked = this.useDenseChannel( pi );
}
else
{
worked = this.useChannel( pi );
}
if (flags.contains(GridFlags.REQUIRE_CHANNEL)) {
// close the semi open.
if (!this.semiOpen.contains(pi)) {
final boolean worked;
if( worked && flags.contains( GridFlags.MULTIBLOCK ) )
{
final Iterator<IGridNode> oni = ( (IGridMultiblock) ( (IGridNode) pi ).getGridBlock() ).getMultiblockNodes();
while( oni.hasNext() )
{
final IGridNode otherNodes = oni.next();
if( otherNodes != pi )
{
this.semiOpen.add( (IPathItem) otherNodes );
}
}
}
}
else
{
pi.incrementChannelCount( 1 ); // give a channel.
this.semiOpen.remove( pi );
}
}
if (flags.contains(GridFlags.COMPRESSED_CHANNEL)) {
worked = this.useDenseChannel(pi);
} else {
worked = this.useChannel(pi);
}
this.closed.add( pi );
this.open.add( pi );
}
}
}
if (worked && flags.contains(GridFlags.MULTIBLOCK)) {
final Iterator<IGridNode> oni = ((IGridMultiblock) ((IGridNode) pi).getGridBlock()).getMultiblockNodes();
while (oni.hasNext()) {
final IGridNode otherNodes = oni.next();
if (otherNodes != pi) {
this.semiOpen.add((IPathItem) otherNodes);
}
}
}
} else {
pi.incrementChannelCount(1); // give a channel.
this.semiOpen.remove(pi);
}
}
return this.open.isEmpty();
}
this.closed.add(pi);
this.open.add(pi);
}
}
}
private boolean useDenseChannel( final IPathItem start )
{
IPathItem pi = start;
while( pi != null )
{
if( !pi.canSupportMoreChannels() || pi.getFlags().contains( GridFlags.CANNOT_CARRY_COMPRESSED ) )
{
return false;
}
return this.open.isEmpty();
}
pi = pi.getControllerRoute();
}
private boolean useDenseChannel(final IPathItem start) {
IPathItem pi = start;
while (pi != null) {
if (!pi.canSupportMoreChannels() || pi.getFlags().contains(GridFlags.CANNOT_CARRY_COMPRESSED)) {
return false;
}
pi = start;
while( pi != null )
{
this.pgc.setChannelsByBlocks( this.pgc.getChannelsByBlocks() + 1 );
pi.incrementChannelCount( 1 );
pi = pi.getControllerRoute();
}
pi = pi.getControllerRoute();
}
this.pgc.setChannelsInUse( this.pgc.getChannelsInUse() + 1 );
return true;
}
pi = start;
while (pi != null) {
this.pgc.setChannelsByBlocks(this.pgc.getChannelsByBlocks() + 1);
pi.incrementChannelCount(1);
pi = pi.getControllerRoute();
}
private boolean useChannel( final IPathItem start )
{
IPathItem pi = start;
while( pi != null )
{
if( !pi.canSupportMoreChannels() )
{
return false;
}
this.pgc.setChannelsInUse(this.pgc.getChannelsInUse() + 1);
return true;
}
pi = pi.getControllerRoute();
}
private boolean useChannel(final IPathItem start) {
IPathItem pi = start;
while (pi != null) {
if (!pi.canSupportMoreChannels()) {
return false;
}
pi = start;
while( pi != null )
{
this.pgc.setChannelsByBlocks( this.pgc.getChannelsByBlocks() + 1 );
pi.incrementChannelCount( 1 );
pi = pi.getControllerRoute();
}
pi = pi.getControllerRoute();
}
this.pgc.setChannelsInUse( this.pgc.getChannelsInUse() + 1 );
return true;
}
pi = start;
while (pi != null) {
this.pgc.setChannelsByBlocks(this.pgc.getChannelsByBlocks() + 1);
pi.incrementChannelCount(1);
pi = pi.getControllerRoute();
}
public boolean isDead()
{
return this.isDead;
}
this.pgc.setChannelsInUse(this.pgc.getChannelsInUse() + 1);
return true;
}
public void setDead( final boolean isDead )
{
this.isDead = isDead;
}
public boolean isDead() {
return this.isDead;
}
public void setDead(final boolean isDead) {
this.isDead = isDead;
}
}