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,6 +18,7 @@
package appeng.me.cluster.implementations;
import java.util.Iterator;
import net.minecraft.tileentity.TileEntity;
@@ -34,47 +35,80 @@ import appeng.me.cluster.IAEMultiBlock;
import appeng.me.cluster.MBCalculator;
import appeng.tile.crafting.TileCraftingTile;
public class CraftingCPUCalculator extends MBCalculator
{
final TileCraftingTile tqb;
public CraftingCPUCalculator(IAEMultiBlock t) {
public CraftingCPUCalculator( IAEMultiBlock t )
{
super( t );
this.tqb = (TileCraftingTile) t;
}
@Override
public boolean isValidTile(TileEntity te)
public boolean checkMultiblockScale( WorldCoord min, WorldCoord max )
{
return te instanceof TileCraftingTile;
}
@Override
public boolean checkMultiblockScale(WorldCoord min, WorldCoord max)
{
if ( max.x - min.x > 16 )
if( max.x - min.x > 16 )
return false;
if ( max.y - min.y > 16 )
if( max.y - min.y > 16 )
return false;
if ( max.z - min.z > 16 )
if( max.z - min.z > 16 )
return false;
return true;
}
@Override
public void updateTiles(IAECluster cl, World w, WorldCoord min, WorldCoord max)
public IAECluster createCluster( World w, WorldCoord min, WorldCoord max )
{
return new CraftingCPUCluster( min, max );
}
@Override
public boolean verifyInternalStructure( World w, WorldCoord min, WorldCoord max )
{
boolean storage = false;
for( int x = min.x; x <= max.x; x++ )
{
for( int y = min.y; y <= max.y; y++ )
{
for( int z = min.z; z <= max.z; z++ )
{
IAEMultiBlock te = (IAEMultiBlock) w.getTileEntity( x, y, z );
if( !te.isValid() )
return false;
if( !storage && te instanceof TileCraftingTile )
storage = ( (TileCraftingTile) te ).getStorageBytes() > 0;
}
}
}
return storage;
}
@Override
public void disconnect()
{
this.tqb.disconnect( true );
}
@Override
public void updateTiles( IAECluster cl, World w, WorldCoord min, WorldCoord max )
{
CraftingCPUCluster c = (CraftingCPUCluster) cl;
for (int x = min.x; x <= max.x; x++)
for( int x = min.x; x <= max.x; x++ )
{
for (int y = min.y; y <= max.y; y++)
for( int y = min.y; y <= max.y; y++ )
{
for (int z = min.z; z <= max.z; z++)
for( int z = min.z; z <= max.z; z++ )
{
TileCraftingTile te = (TileCraftingTile) w.getTileEntity( x, y, z );
te.updateStatus( c );
@@ -86,14 +120,14 @@ public class CraftingCPUCalculator extends MBCalculator
c.done();
Iterator<IGridHost> i = c.getTiles();
while (i.hasNext())
while( i.hasNext() )
{
IGridHost gh = i.next();
IGridNode n = gh.getGridNode( ForgeDirection.UNKNOWN );
if ( n != null )
if( n != null )
{
IGrid g = n.getGrid();
if ( g != null )
if( g != null )
{
g.postEvent( new MENetworkCraftingCpuChange( n ) );
return;
@@ -103,40 +137,8 @@ public class CraftingCPUCalculator extends MBCalculator
}
@Override
public IAECluster createCluster(World w, WorldCoord min, WorldCoord max)
public boolean isValidTile( TileEntity te )
{
return new CraftingCPUCluster( min, max );
return te instanceof TileCraftingTile;
}
@Override
public void disconnect()
{
this.tqb.disconnect( true );
}
@Override
public boolean verifyInternalStructure(World w, WorldCoord min, WorldCoord max)
{
boolean storage = false;
for (int x = min.x; x <= max.x; x++)
{
for (int y = min.y; y <= max.y; y++)
{
for (int z = min.z; z <= max.z; z++)
{
IAEMultiBlock te = (IAEMultiBlock) w.getTileEntity( x, y, z );
if ( !te.isValid() )
return false;
if ( !storage && te instanceof TileCraftingTile )
storage = ((TileCraftingTile) te).getStorageBytes() > 0;
}
}
}
return storage;
}
}
File diff suppressed because it is too large Load Diff
@@ -18,6 +18,7 @@
package appeng.me.cluster.implementations;
import net.minecraft.block.Block;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.IBlockAccess;
@@ -32,31 +33,27 @@ import appeng.me.cluster.IAEMultiBlock;
import appeng.me.cluster.MBCalculator;
import appeng.tile.qnb.TileQuantumBridge;
public class QuantumCalculator extends MBCalculator
{
final private TileQuantumBridge tqb;
public QuantumCalculator(IAEMultiBlock t) {
public QuantumCalculator( IAEMultiBlock t )
{
super( t );
this.tqb = (TileQuantumBridge) t;
}
@Override
public boolean isValidTile(TileEntity te)
{
return te instanceof TileQuantumBridge;
}
@Override
public boolean checkMultiblockScale(WorldCoord min, WorldCoord max)
public boolean checkMultiblockScale( WorldCoord min, WorldCoord max )
{
if ( (max.x - min.x + 1) * (max.y - min.y + 1) * (max.z - min.z + 1) == 9 )
if( ( max.x - min.x + 1 ) * ( max.y - min.y + 1 ) * ( max.z - min.z + 1 ) == 9 )
{
int ones = ((max.x - min.x) == 0 ? 1 : 0) + ((max.y - min.y) == 0 ? 1 : 0) + ((max.z - min.z) == 0 ? 1 : 0);
int ones = ( ( max.x - min.x ) == 0 ? 1 : 0 ) + ( ( max.y - min.y ) == 0 ? 1 : 0 ) + ( ( max.z - min.z ) == 0 ? 1 : 0 );
int threes = ((max.x - min.x) == 2 ? 1 : 0) + ((max.y - min.y) == 2 ? 1 : 0) + ((max.z - min.z) == 2 ? 1 : 0);
int threes = ( ( max.x - min.x ) == 2 ? 1 : 0 ) + ( ( max.y - min.y ) == 2 ? 1 : 0 ) + ( ( max.z - min.z ) == 2 ? 1 : 0 );
return ones == 1 && threes == 2;
}
@@ -64,86 +61,40 @@ public class QuantumCalculator extends MBCalculator
}
@Override
public void updateTiles(IAECluster cl, World w, WorldCoord min, WorldCoord max)
{
byte num = 0;
byte ringNum = 0;
QuantumCluster c = (QuantumCluster) cl;
for (int x = min.x; x <= max.x; x++)
{
for (int y = min.y; y <= max.y; y++)
{
for (int z = min.z; z <= max.z; z++)
{
TileQuantumBridge te = (TileQuantumBridge) w.getTileEntity( x, y, z );
byte flags;
num++;
if ( num == 5 )
{
flags = num;
c.setCenter( te );
}
else
{
if ( num == 1 || num == 3 || num == 7 || num == 9 )
flags = (byte) (this.tqb.corner | num);
else
flags = num;
c.Ring[ringNum] = te;
ringNum++;
}
te.updateStatus( c, flags, true );
}
}
}
}
@Override
public IAECluster createCluster(World w, WorldCoord min, WorldCoord max)
public IAECluster createCluster( World w, WorldCoord min, WorldCoord max )
{
return new QuantumCluster( min, max );
}
@Override
public void disconnect()
{
this.tqb.disconnect(true);
}
@Override
public boolean verifyInternalStructure(World w, WorldCoord min, WorldCoord max)
public boolean verifyInternalStructure( World w, WorldCoord min, WorldCoord max )
{
byte num = 0;
for (int x = min.x; x <= max.x; x++)
for( int x = min.x; x <= max.x; x++ )
{
for (int y = min.y; y <= max.y; y++)
for( int y = min.y; y <= max.y; y++ )
{
for (int z = min.z; z <= max.z; z++)
for( int z = min.z; z <= max.z; z++ )
{
IAEMultiBlock te = (IAEMultiBlock) w.getTileEntity( x, y, z );
if ( !te.isValid() )
if( !te.isValid() )
return false;
num++;
final IBlocks blocks = AEApi.instance().definitions().blocks();
if ( num == 5 )
if( num == 5 )
{
if ( !this.isBlockAtLocation( w, x, y, z, blocks.quantumLink() ) )
if( !this.isBlockAtLocation( w, x, y, z, blocks.quantumLink() ) )
{
return false;
}
}
else
{
if ( !this.isBlockAtLocation( w, x, y, z, blocks.quantumRing() ) )
if( !this.isBlockAtLocation( w, x, y, z, blocks.quantumRing() ) )
{
return false;
}
@@ -154,9 +105,60 @@ public class QuantumCalculator extends MBCalculator
return true;
}
@Override
public void disconnect()
{
this.tqb.disconnect( true );
}
@Override
public void updateTiles( IAECluster cl, World w, WorldCoord min, WorldCoord max )
{
byte num = 0;
byte ringNum = 0;
QuantumCluster c = (QuantumCluster) cl;
for( int x = min.x; x <= max.x; x++ )
{
for( int y = min.y; y <= max.y; y++ )
{
for( int z = min.z; z <= max.z; z++ )
{
TileQuantumBridge te = (TileQuantumBridge) w.getTileEntity( x, y, z );
byte flags;
num++;
if( num == 5 )
{
flags = num;
c.setCenter( te );
}
else
{
if( num == 1 || num == 3 || num == 7 || num == 9 )
flags = (byte) ( this.tqb.corner | num );
else
flags = num;
c.Ring[ringNum] = te;
ringNum++;
}
te.updateStatus( c, flags, true );
}
}
}
}
@Override
public boolean isValidTile( TileEntity te )
{
return te instanceof TileQuantumBridge;
}
private boolean isBlockAtLocation( IBlockAccess w, int x, int y, int z, IBlockDefinition def )
{
for ( Block block : def.maybeBlock().asSet() )
for( Block block : def.maybeBlock().asSet() )
{
return block == w.getBlock( x, y, z );
}
@@ -18,6 +18,7 @@
package appeng.me.cluster.implementations;
import java.util.Iterator;
import net.minecraft.tileentity.TileEntity;
@@ -43,6 +44,7 @@ import appeng.me.cluster.IAECluster;
import appeng.tile.qnb.TileQuantumBridge;
import appeng.util.iterators.ChainedIterator;
public class QuantumCluster implements ILocatable, IAECluster
{
@@ -50,61 +52,24 @@ public class QuantumCluster implements ILocatable, IAECluster
final public WorldCoord max;
public boolean isDestroyed = false;
public boolean updateStatus = true;
public TileQuantumBridge[] Ring;
boolean registered = false;
ConnectionWrapper connection;
private long thisSide;
private long otherSide;
ConnectionWrapper connection;
public TileQuantumBridge[] Ring;
private TileQuantumBridge center;
@Override
public Iterator<IGridHost> getTiles()
public QuantumCluster( WorldCoord _min, WorldCoord _max )
{
return new ChainedIterator<IGridHost>( this.Ring[0], this.Ring[1], this.Ring[2], this.Ring[3], this.Ring[4], this.Ring[5], this.Ring[6], this.Ring[7], this.center );
}
public void setCenter(TileQuantumBridge c)
{
this.registered = true;
MinecraftForge.EVENT_BUS.register( this );
this.center = c;
}
public QuantumCluster(WorldCoord _min, WorldCoord _max) {
this.min = _min;
this.max = _max;
this.Ring = new TileQuantumBridge[8];
}
public boolean canUseNode(long qe)
{
QuantumCluster qc = (QuantumCluster) AEApi.instance().registries().locatable().getLocatableBy( qe );
if ( qc != null )
{
World theWorld = qc.center.getWorldObj();
if ( !qc.isDestroyed )
{
Chunk c = theWorld.getChunkFromBlockCoords( qc.center.xCoord, qc.center.zCoord );
if ( c.isChunkLoaded )
{
int id = theWorld.provider.dimensionId;
World cur = DimensionManager.getWorld( id );
TileEntity te = theWorld.getTileEntity( qc.center.xCoord, qc.center.yCoord, qc.center.zCoord );
return te != qc.center || theWorld != cur;
}
}
}
return true;
}
@SubscribeEvent
public void onUnload(WorldEvent.Unload e)
public void onUnload( WorldEvent.Unload e )
{
if ( this.center.getWorldObj() == e.world )
if( this.center.getWorldObj() == e.world )
{
this.updateStatus = false;
this.destroy();
@@ -112,25 +77,25 @@ public class QuantumCluster implements ILocatable, IAECluster
}
@Override
public void updateStatus(boolean updateGrid)
public void updateStatus( boolean updateGrid )
{
long qe;
qe = this.center.getQEFrequency();
if ( this.thisSide != qe && this.thisSide != -qe )
if( this.thisSide != qe && this.thisSide != -qe )
{
if ( qe != 0 )
if( qe != 0 )
{
if ( this.thisSide != 0 )
if( this.thisSide != 0 )
MinecraftForge.EVENT_BUS.post( new LocatableEventAnnounce( this, LocatableEvent.Unregister ) );
if ( this.canUseNode( -qe ) )
if( this.canUseNode( -qe ) )
{
this.otherSide = qe;
this.thisSide = -qe;
}
else if ( this.canUseNode( qe ) )
else if( this.canUseNode( qe ) )
{
this.thisSide = qe;
this.otherSide = -qe;
@@ -151,37 +116,37 @@ public class QuantumCluster implements ILocatable, IAECluster
boolean shutdown = false;
if ( myOtherSide instanceof QuantumCluster )
if( myOtherSide instanceof QuantumCluster )
{
QuantumCluster sideA = this;
QuantumCluster sideB = (QuantumCluster) myOtherSide;
if ( sideA.isActive() && sideB.isActive() )
if( sideA.isActive() && sideB.isActive() )
{
if ( this.connection != null && this.connection.connection != null )
if( this.connection != null && this.connection.connection != null )
{
IGridNode a = this.connection.connection.a();
IGridNode b = this.connection.connection.b();
IGridNode sa = sideA.getNode();
IGridNode sb = sideB.getNode();
if ( (a == sa || b == sa) && (a == sb || b == sb) )
if( ( a == sa || b == sa ) && ( a == sb || b == sb ) )
return;
}
try
{
if ( sideA.connection != null )
if( sideA.connection != null )
{
if ( sideA.connection.connection != null )
if( sideA.connection.connection != null )
{
sideA.connection.connection.destroy();
sideA.connection = new ConnectionWrapper( null );
}
}
if ( sideB.connection != null )
if( sideB.connection != null )
{
if ( sideB.connection.connection != null )
if( sideB.connection.connection != null )
{
sideB.connection.connection.destroy();
sideB.connection = new ConnectionWrapper( null );
@@ -190,7 +155,7 @@ public class QuantumCluster implements ILocatable, IAECluster
sideA.connection = sideB.connection = new ConnectionWrapper( AEApi.instance().createGridConnection( sideA.getNode(), sideB.getNode() ) );
}
catch (FailedConnection e)
catch( FailedConnection e )
{
// :(
}
@@ -201,9 +166,9 @@ public class QuantumCluster implements ILocatable, IAECluster
else
shutdown = true;
if ( shutdown && this.connection != null )
if( shutdown && this.connection != null )
{
if ( this.connection.connection != null )
if( this.connection.connection != null )
{
this.connection.connection.destroy();
this.connection.connection = null;
@@ -212,20 +177,60 @@ public class QuantumCluster implements ILocatable, IAECluster
}
}
public boolean canUseNode( long qe )
{
QuantumCluster qc = (QuantumCluster) AEApi.instance().registries().locatable().getLocatableBy( qe );
if( qc != null )
{
World theWorld = qc.center.getWorldObj();
if( !qc.isDestroyed )
{
Chunk c = theWorld.getChunkFromBlockCoords( qc.center.xCoord, qc.center.zCoord );
if( c.isChunkLoaded )
{
int id = theWorld.provider.dimensionId;
World cur = DimensionManager.getWorld( id );
TileEntity te = theWorld.getTileEntity( qc.center.xCoord, qc.center.yCoord, qc.center.zCoord );
return te != qc.center || theWorld != cur;
}
}
}
return true;
}
private boolean isActive()
{
if( this.isDestroyed || !this.registered )
return false;
return this.center.isPowered() && this.hasQES();
}
private IGridNode getNode()
{
return this.center.getGridNode( ForgeDirection.UNKNOWN );
}
public boolean hasQES()
{
return this.thisSide != 0;
}
@Override
public void destroy()
{
if ( this.isDestroyed )
if( this.isDestroyed )
return;
this.isDestroyed = true;
if ( this.registered )
if( this.registered )
{
MinecraftForge.EVENT_BUS.unregister( this );
this.registered = false;
}
if ( this.thisSide != 0 )
if( this.thisSide != 0 )
{
this.updateStatus( true );
MinecraftForge.EVENT_BUS.post( new LocatableEventAnnounce( this, LocatableEvent.Unregister ) );
@@ -233,7 +238,7 @@ public class QuantumCluster implements ILocatable, IAECluster
this.center.updateStatus( null, (byte) -1, this.updateStatus );
for (TileQuantumBridge r : this.Ring)
for( TileQuantumBridge r : this.Ring )
{
r.updateStatus( null, (byte) -1, this.updateStatus );
}
@@ -242,7 +247,13 @@ public class QuantumCluster implements ILocatable, IAECluster
this.Ring = new TileQuantumBridge[8];
}
public boolean isCorner(TileQuantumBridge tileQuantumBridge)
@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 );
}
public boolean isCorner( TileQuantumBridge tileQuantumBridge )
{
return this.Ring[0] == tileQuantumBridge || this.Ring[2] == tileQuantumBridge || this.Ring[4] == tileQuantumBridge || this.Ring[6] == tileQuantumBridge;
}
@@ -258,22 +269,10 @@ public class QuantumCluster implements ILocatable, IAECluster
return this.center;
}
public boolean hasQES()
public void setCenter( TileQuantumBridge c )
{
return this.thisSide != 0;
this.registered = true;
MinecraftForge.EVENT_BUS.register( this );
this.center = c;
}
private IGridNode getNode()
{
return this.center.getGridNode( ForgeDirection.UNKNOWN );
}
private boolean isActive()
{
if ( this.isDestroyed || !this.registered )
return false;
return this.center.isPowered() && this.hasQES();
}
}
@@ -18,6 +18,7 @@
package appeng.me.cluster.implementations;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
@@ -28,75 +29,44 @@ import appeng.me.cluster.IAEMultiBlock;
import appeng.me.cluster.MBCalculator;
import appeng.tile.spatial.TileSpatialPylon;
public class SpatialPylonCalculator extends MBCalculator
{
private final TileSpatialPylon tqb;
public SpatialPylonCalculator(IAEMultiBlock t) {
public SpatialPylonCalculator( IAEMultiBlock t )
{
super( t );
this.tqb = (TileSpatialPylon) t;
}
@Override
public boolean isValidTile(TileEntity te)
public boolean checkMultiblockScale( WorldCoord min, WorldCoord max )
{
return te instanceof TileSpatialPylon;
return ( min.x == max.x && min.y == max.y && min.z != max.z ) || ( min.x == max.x && min.y != max.y && min.z == max.z ) || ( min.x != max.x && min.y == max.y && min.z == max.z );
}
@Override
public boolean checkMultiblockScale(WorldCoord min, WorldCoord max)
{
return (min.x == max.x && min.y == max.y && min.z != max.z) || (min.x == max.x && min.y != max.y && min.z == max.z) || (min.x != max.x && min.y == max.y && min.z == max.z);
}
@Override
public void updateTiles(IAECluster cl, World w, WorldCoord min, WorldCoord max)
{
SpatialPylonCluster c = (SpatialPylonCluster) cl;
for (int x = min.x; x <= max.x; x++)
{
for (int y = min.y; y <= max.y; y++)
{
for (int z = min.z; z <= max.z; z++)
{
TileSpatialPylon te = (TileSpatialPylon) w.getTileEntity( x, y, z );
te.updateStatus( c );
c.line.add( (te) );
}
}
}
}
@Override
public IAECluster createCluster(World w, WorldCoord min, WorldCoord max)
public IAECluster createCluster( World w, WorldCoord min, WorldCoord max )
{
return new SpatialPylonCluster( new DimensionalCoord( w, min.x, min.y, min.z ), new DimensionalCoord( w, max.x, max.y, max.z ) );
}
@Override
public void disconnect()
{
this.tqb.disconnect(true);
}
@Override
public boolean verifyInternalStructure(World w, WorldCoord min, WorldCoord max)
public boolean verifyInternalStructure( World w, WorldCoord min, WorldCoord max )
{
for (int x = min.x; x <= max.x; x++)
for( int x = min.x; x <= max.x; x++ )
{
for (int y = min.y; y <= max.y; y++)
for( int y = min.y; y <= max.y; y++ )
{
for (int z = min.z; z <= max.z; z++)
for( int z = min.z; z <= max.z; z++ )
{
IAEMultiBlock te = (IAEMultiBlock) w.getTileEntity( x, y, z );
if ( !te.isValid() )
if( !te.isValid() )
return false;
}
}
}
@@ -104,4 +74,34 @@ public class SpatialPylonCalculator extends MBCalculator
return true;
}
@Override
public void disconnect()
{
this.tqb.disconnect( true );
}
@Override
public void updateTiles( IAECluster cl, World w, WorldCoord min, WorldCoord max )
{
SpatialPylonCluster c = (SpatialPylonCluster) cl;
for( int x = min.x; x <= max.x; x++ )
{
for( int y = min.y; y <= max.y; y++ )
{
for( int z = min.z; z <= max.z; z++ )
{
TileSpatialPylon te = (TileSpatialPylon) w.getTileEntity( x, y, z );
te.updateStatus( c );
c.line.add( ( te ) );
}
}
}
}
@Override
public boolean isValidTile( TileEntity te )
{
return te instanceof TileSpatialPylon;
}
}
@@ -18,6 +18,7 @@
package appeng.me.cluster.implementations;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
@@ -27,43 +28,39 @@ import appeng.api.util.DimensionalCoord;
import appeng.me.cluster.IAECluster;
import appeng.tile.spatial.TileSpatialPylon;
public class SpatialPylonCluster implements IAECluster
{
public enum Axis
{
X, Y, Z, UNFORMED
}
final public DimensionalCoord min;
final public DimensionalCoord max;
final List<TileSpatialPylon> line = new ArrayList<TileSpatialPylon>();
public boolean isDestroyed = false;
public Axis currentAxis = Axis.UNFORMED;
final List<TileSpatialPylon> line = new ArrayList<TileSpatialPylon>();
public boolean isValid;
public boolean hasPower;
public boolean hasChannel;
public SpatialPylonCluster(DimensionalCoord _min, DimensionalCoord _max) {
public SpatialPylonCluster( DimensionalCoord _min, DimensionalCoord _max )
{
this.min = _min.copy();
this.max = _max.copy();
if ( this.min.x != this.max.x )
if( this.min.x != this.max.x )
this.currentAxis = Axis.X;
else if ( this.min.y != this.max.y )
else if( this.min.y != this.max.y )
this.currentAxis = Axis.Y;
else if ( this.min.z != this.max.z )
else if( this.min.z != this.max.z )
this.currentAxis = Axis.Z;
else
this.currentAxis = Axis.UNFORMED;
}
@Override
public void updateStatus(boolean updateGrid)
public void updateStatus( boolean updateGrid )
{
for (TileSpatialPylon r : this.line)
for( TileSpatialPylon r : this.line )
{
r.recalculateDisplay();
}
@@ -73,20 +70,14 @@ public class SpatialPylonCluster implements IAECluster
public void destroy()
{
if ( this.isDestroyed )
if( this.isDestroyed )
return;
this.isDestroyed = true;
for (TileSpatialPylon r : this.line)
for( TileSpatialPylon r : this.line )
{
r.updateStatus( null );
}
}
public int tileCount()
{
return this.line.size();
}
@Override
@@ -95,4 +86,13 @@ public class SpatialPylonCluster implements IAECluster
return (Iterator) this.line.iterator();
}
public int tileCount()
{
return this.line.size();
}
public enum Axis
{
X, Y, Z, UNFORMED
}
}