Relocate Source to proper directory.
This commit is contained in:
@@ -0,0 +1,123 @@
|
||||
package appeng.me.cluster.implementations;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import appeng.api.networking.IGrid;
|
||||
import appeng.api.networking.IGridHost;
|
||||
import appeng.api.networking.IGridNode;
|
||||
import appeng.api.networking.events.MENetworkCraftingCpuChange;
|
||||
import appeng.api.util.WorldCoord;
|
||||
import appeng.me.cluster.IAECluster;
|
||||
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) {
|
||||
super( t );
|
||||
tqb = (TileCraftingTile) t;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValidTile(TileEntity te)
|
||||
{
|
||||
return te instanceof TileCraftingTile;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkMultiblockScale(WorldCoord min, WorldCoord max)
|
||||
{
|
||||
if ( max.x - min.x > 16 )
|
||||
return false;
|
||||
|
||||
if ( max.y - min.y > 16 )
|
||||
return false;
|
||||
|
||||
if ( max.z - min.z > 16 )
|
||||
return false;
|
||||
|
||||
return 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 y = min.y; y <= max.y; y++)
|
||||
{
|
||||
for (int z = min.z; z <= max.z; z++)
|
||||
{
|
||||
TileCraftingTile te = (TileCraftingTile) w.getTileEntity( x, y, z );
|
||||
te.updateStatus( c );
|
||||
c.addTile( te );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
c.done();
|
||||
|
||||
Iterator<IGridHost> i = c.getTiles();
|
||||
while (i.hasNext())
|
||||
{
|
||||
IGridHost gh = i.next();
|
||||
IGridNode n = gh.getGridNode( ForgeDirection.UNKNOWN );
|
||||
if ( n != null )
|
||||
{
|
||||
IGrid g = n.getGrid();
|
||||
if ( g != null )
|
||||
{
|
||||
g.postEvent( new MENetworkCraftingCpuChange( n ) );
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAECluster createCluster(World w, WorldCoord min, WorldCoord max)
|
||||
{
|
||||
return new CraftingCPUCluster( min, max );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disconnect()
|
||||
{
|
||||
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
@@ -0,0 +1,130 @@
|
||||
package appeng.me.cluster.implementations;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.util.WorldCoord;
|
||||
import appeng.me.cluster.IAECluster;
|
||||
import appeng.me.cluster.IAEMultiBlock;
|
||||
import appeng.me.cluster.MBCalculator;
|
||||
import appeng.tile.qnb.TileQuantumBridge;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class QuantumCalculator extends MBCalculator
|
||||
{
|
||||
|
||||
final private TileQuantumBridge tqb;
|
||||
|
||||
public QuantumCalculator(IAEMultiBlock t) {
|
||||
super( t );
|
||||
tqb = (TileQuantumBridge) t;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValidTile(TileEntity te)
|
||||
{
|
||||
return te instanceof TileQuantumBridge;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkMultiblockScale(WorldCoord min, WorldCoord max)
|
||||
{
|
||||
|
||||
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 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;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@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 = 0;
|
||||
|
||||
num++;
|
||||
if ( num == 5 )
|
||||
{
|
||||
flags = (byte) (num);
|
||||
c.setCenter( te );
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( num == 1 || num == 3 || num == 7 || num == 9 )
|
||||
flags = (byte) (tqb.corner | num);
|
||||
else
|
||||
flags = (byte) (num);
|
||||
c.Ring[ringNum++] = te;
|
||||
}
|
||||
|
||||
te.updateStatus( c, flags, true );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAECluster createCluster(World w, WorldCoord min, WorldCoord max)
|
||||
{
|
||||
return new QuantumCluster( min, max );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disconnect()
|
||||
{
|
||||
tqb.disconnect(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean verifyInternalStructure(World w, WorldCoord min, WorldCoord max)
|
||||
{
|
||||
|
||||
byte num = 0;
|
||||
|
||||
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;
|
||||
|
||||
num++;
|
||||
if ( num == 5 )
|
||||
{
|
||||
if ( !Platform.blockAtLocationIs( w, x, y, z, AEApi.instance().blocks().blockQuantumLink ) )
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( !Platform.blockAtLocationIs( w, x, y, z, AEApi.instance().blocks().blockQuantumRing ) )
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,259 @@
|
||||
package appeng.me.cluster.implementations;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
import net.minecraftforge.common.DimensionManager;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraftforge.event.world.WorldEvent;
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.events.LocatableEventAnnounce;
|
||||
import appeng.api.events.LocatableEventAnnounce.LocatableEvent;
|
||||
import appeng.api.exceptions.FailedConnection;
|
||||
import appeng.api.features.ILocatable;
|
||||
import appeng.api.networking.IGridHost;
|
||||
import appeng.api.networking.IGridNode;
|
||||
import appeng.api.util.WorldCoord;
|
||||
import appeng.me.cache.helpers.ConnectionWrapper;
|
||||
import appeng.me.cluster.IAECluster;
|
||||
import appeng.tile.qnb.TileQuantumBridge;
|
||||
import appeng.util.iterators.ChainedIterator;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
|
||||
public class QuantumCluster implements ILocatable, IAECluster
|
||||
{
|
||||
|
||||
final public WorldCoord min;
|
||||
final public WorldCoord max;
|
||||
public boolean isDestroyed = false;
|
||||
public boolean updateStatus = true;
|
||||
|
||||
boolean registered = false;
|
||||
private long thisSide;
|
||||
private long otherSide;
|
||||
|
||||
ConnectionWrapper connection;
|
||||
|
||||
public TileQuantumBridge Ring[];
|
||||
private TileQuantumBridge center;
|
||||
|
||||
@Override
|
||||
public Iterator<IGridHost> getTiles()
|
||||
{
|
||||
return new ChainedIterator<IGridHost>( Ring[0], Ring[1], Ring[2], Ring[3], Ring[4], Ring[5], Ring[6], Ring[7], center );
|
||||
}
|
||||
|
||||
public void setCenter(TileQuantumBridge c)
|
||||
{
|
||||
registered = true;
|
||||
MinecraftForge.EVENT_BUS.register( this );
|
||||
center = c;
|
||||
}
|
||||
|
||||
public QuantumCluster(WorldCoord _min, WorldCoord _max) {
|
||||
min = _min;
|
||||
max = _max;
|
||||
Ring = new TileQuantumBridge[8];
|
||||
}
|
||||
|
||||
public boolean canUseNode(long qe)
|
||||
{
|
||||
QuantumCluster qc = (QuantumCluster) AEApi.instance().registries().locatable().findLocatableBySerial( qe );
|
||||
if ( qc != null && qc.center instanceof TileQuantumBridge )
|
||||
{
|
||||
World theWorld = qc.getCenter().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)
|
||||
{
|
||||
if ( center.getWorldObj() == e.world )
|
||||
{
|
||||
updateStatus = false;
|
||||
destroy();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateStatus(boolean updateGrid)
|
||||
{
|
||||
long qe;
|
||||
|
||||
qe = center.getQEDest();
|
||||
|
||||
if ( thisSide != qe && thisSide != -qe )
|
||||
{
|
||||
if ( qe != 0 )
|
||||
{
|
||||
if ( thisSide != 0 )
|
||||
MinecraftForge.EVENT_BUS.post( new LocatableEventAnnounce( this, LocatableEvent.Unregister ) );
|
||||
|
||||
if ( canUseNode( -qe ) )
|
||||
{
|
||||
otherSide = qe;
|
||||
thisSide = -qe;
|
||||
}
|
||||
else if ( canUseNode( qe ) )
|
||||
{
|
||||
thisSide = qe;
|
||||
otherSide = -qe;
|
||||
}
|
||||
|
||||
MinecraftForge.EVENT_BUS.post( new LocatableEventAnnounce( this, LocatableEvent.Register ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
MinecraftForge.EVENT_BUS.post( new LocatableEventAnnounce( this, LocatableEvent.Unregister ) );
|
||||
|
||||
otherSide = 0;
|
||||
thisSide = 0;
|
||||
}
|
||||
}
|
||||
|
||||
Object myOtherSide = otherSide == 0 ? null : AEApi.instance().registries().locatable().findLocatableBySerial( otherSide );
|
||||
|
||||
boolean shutdown = false;
|
||||
|
||||
if ( myOtherSide instanceof QuantumCluster )
|
||||
{
|
||||
QuantumCluster sideA = (QuantumCluster) this;
|
||||
QuantumCluster sideB = (QuantumCluster) myOtherSide;
|
||||
|
||||
if ( sideA.isActive() && sideB.isActive() )
|
||||
{
|
||||
if ( connection != null && connection.connection != null )
|
||||
{
|
||||
IGridNode a = connection.connection.a();
|
||||
IGridNode b = connection.connection.b();
|
||||
IGridNode sa = sideA.getNode();
|
||||
IGridNode sb = sideB.getNode();
|
||||
if ( (a == sa || b == sa) && (a == sb || b == sb) )
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
if ( sideA.connection != null )
|
||||
{
|
||||
if ( sideA.connection.connection != null )
|
||||
{
|
||||
sideA.connection.connection.destroy();
|
||||
sideA.connection = new ConnectionWrapper( null );
|
||||
}
|
||||
}
|
||||
|
||||
if ( sideB.connection != null )
|
||||
{
|
||||
if ( sideB.connection.connection != null )
|
||||
{
|
||||
sideB.connection.connection.destroy();
|
||||
sideB.connection = new ConnectionWrapper( null );
|
||||
}
|
||||
}
|
||||
|
||||
sideA.connection = sideB.connection = new ConnectionWrapper( AEApi.instance().createGridConnection( sideA.getNode(), sideB.getNode() ) );
|
||||
}
|
||||
catch (FailedConnection e)
|
||||
{
|
||||
// :(
|
||||
}
|
||||
}
|
||||
else
|
||||
shutdown = true;
|
||||
}
|
||||
else
|
||||
shutdown = true;
|
||||
|
||||
if ( shutdown && connection != null )
|
||||
{
|
||||
if ( connection.connection != null )
|
||||
{
|
||||
connection.connection.destroy();
|
||||
connection.connection = null;
|
||||
connection = new ConnectionWrapper( null );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy()
|
||||
{
|
||||
if ( isDestroyed )
|
||||
return;
|
||||
isDestroyed = true;
|
||||
|
||||
if ( registered )
|
||||
{
|
||||
MinecraftForge.EVENT_BUS.unregister( this );
|
||||
registered = false;
|
||||
}
|
||||
|
||||
if ( getLocatableSerial() != 0 )
|
||||
{
|
||||
updateStatus( true );
|
||||
MinecraftForge.EVENT_BUS.post( new LocatableEventAnnounce( this, LocatableEvent.Unregister ) );
|
||||
}
|
||||
|
||||
center.updateStatus( null, (byte) -1, updateStatus );
|
||||
|
||||
for (TileQuantumBridge r : Ring)
|
||||
{
|
||||
r.updateStatus( null, (byte) -1, updateStatus );
|
||||
}
|
||||
|
||||
center = null;
|
||||
Ring = new TileQuantumBridge[8];
|
||||
}
|
||||
|
||||
public boolean isCorner(TileQuantumBridge tileQuantumBridge)
|
||||
{
|
||||
return Ring[0] == tileQuantumBridge || Ring[2] == tileQuantumBridge || Ring[4] == tileQuantumBridge || Ring[6] == tileQuantumBridge;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getLocatableSerial()
|
||||
{
|
||||
return thisSide;
|
||||
}
|
||||
|
||||
public TileQuantumBridge getCenter()
|
||||
{
|
||||
return center;
|
||||
}
|
||||
|
||||
public boolean hasQES()
|
||||
{
|
||||
return getLocatableSerial() != 0;
|
||||
}
|
||||
|
||||
private IGridNode getNode()
|
||||
{
|
||||
return center.getGridNode( ForgeDirection.UNKNOWN );
|
||||
}
|
||||
|
||||
private boolean isActive()
|
||||
{
|
||||
if ( isDestroyed || !registered )
|
||||
return false;
|
||||
|
||||
return center.isPowered() && hasQES();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
package appeng.me.cluster.implementations;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import appeng.api.util.DimensionalCoord;
|
||||
import appeng.api.util.WorldCoord;
|
||||
import appeng.me.cluster.IAECluster;
|
||||
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) {
|
||||
super( t );
|
||||
tqb = (TileSpatialPylon) t;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValidTile(TileEntity te)
|
||||
{
|
||||
return te instanceof TileSpatialPylon;
|
||||
}
|
||||
|
||||
@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)
|
||||
{
|
||||
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()
|
||||
{
|
||||
tqb.disconnect(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean verifyInternalStructure(World w, WorldCoord min, WorldCoord max)
|
||||
{
|
||||
|
||||
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;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
package appeng.me.cluster.implementations;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import appeng.api.networking.IGridHost;
|
||||
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;
|
||||
public boolean isDestroyed = false;
|
||||
|
||||
public Axis currentAxis = Axis.UNFORMED;
|
||||
|
||||
final List<TileSpatialPylon> line = new ArrayList();
|
||||
public boolean isValid;
|
||||
public boolean hasPower;
|
||||
public boolean hasChannel;
|
||||
|
||||
public SpatialPylonCluster(DimensionalCoord _min, DimensionalCoord _max) {
|
||||
min = _min.copy();
|
||||
max = _max.copy();
|
||||
|
||||
if ( min.x != max.x )
|
||||
currentAxis = Axis.X;
|
||||
else if ( min.y != max.y )
|
||||
currentAxis = Axis.Y;
|
||||
else if ( min.z != max.z )
|
||||
currentAxis = Axis.Z;
|
||||
else
|
||||
currentAxis = Axis.UNFORMED;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateStatus(boolean updateGrid)
|
||||
{
|
||||
for (TileSpatialPylon r : line)
|
||||
{
|
||||
r.recalculateDisplay();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy()
|
||||
{
|
||||
|
||||
if ( isDestroyed )
|
||||
return;
|
||||
isDestroyed = true;
|
||||
|
||||
for (TileSpatialPylon r : line)
|
||||
{
|
||||
r.updateStatus( null );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public int tileCount()
|
||||
{
|
||||
return line.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<IGridHost> getTiles()
|
||||
{
|
||||
return (Iterator) line.iterator();
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user