AE2 First Commit, the dawn of 1.7 hast arrived.
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
package appeng.me.cluster.implementations;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
import appeng.api.networking.IGridHost;
|
||||
import appeng.me.cluster.IAECluster;
|
||||
|
||||
public class IAssemblerCluster implements IAECluster
|
||||
{
|
||||
|
||||
@Override
|
||||
public void updateStatus(boolean updateGrid)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<IGridHost> getTiles()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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
|
||||
{
|
||||
|
||||
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.getBlockTileEntity( x, y, z );
|
||||
|
||||
byte Fish = 0;
|
||||
|
||||
num++;
|
||||
if ( num == 5 )
|
||||
{
|
||||
Fish = (byte) (num);
|
||||
c.setCenter( te );
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( num == 1 || num == 3 || num == 7 || num == 9 )
|
||||
Fish = (byte) (tqb.corner | num);
|
||||
else
|
||||
Fish = (byte) (num);
|
||||
c.Ring[ringNum++] = te;
|
||||
}
|
||||
|
||||
te.updateStatus( c, Fish );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAECluster createCluster(World w, WorldCoord min, WorldCoord max)
|
||||
{
|
||||
return new QuantumCluster( min, max );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disconnect()
|
||||
{
|
||||
tqb.disconnect();
|
||||
}
|
||||
|
||||
@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.getBlockTileEntity( 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,224 @@
|
||||
package appeng.me.cluster.implementations;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.ForgeSubscribe;
|
||||
import net.minecraftforge.event.world.WorldEvent;
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.events.LocatableEventAnnounce;
|
||||
import appeng.api.events.LocatableEventAnnounce.LocatableEvent;
|
||||
import appeng.api.features.ILocatable;
|
||||
import appeng.api.networking.IGridHost;
|
||||
import appeng.api.util.DimensionalCoord;
|
||||
import appeng.api.util.WorldCoord;
|
||||
import appeng.me.cluster.IAECluster;
|
||||
import appeng.tile.qnb.TileQuantumBridge;
|
||||
import appeng.util.iterators.ChainedIterator;
|
||||
|
||||
public class QuantumCluster implements ILocatable, IAECluster
|
||||
{
|
||||
|
||||
public WorldCoord min;
|
||||
public WorldCoord max;
|
||||
public boolean isDestroyed = false;
|
||||
|
||||
boolean registered = false;
|
||||
private long thisSide;
|
||||
private long otherSide;
|
||||
|
||||
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().locateable().findLocateableBySerial( qe );
|
||||
if ( qc.center instanceof TileQuantumBridge )
|
||||
{
|
||||
if ( !qc.isDestroyed )
|
||||
{
|
||||
Chunk c = qc.center.worldObj.getChunkFromBlockCoords( qc.center.xCoord, qc.center.zCoord );
|
||||
if ( c.isChunkLoaded )
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@ForgeSubscribe
|
||||
public void onUnload(WorldEvent.Unload e)
|
||||
{
|
||||
if ( center.worldObj == e.world )
|
||||
{
|
||||
destroy();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateStatus(boolean updateGrid)
|
||||
{
|
||||
long oldOtherSide = otherSide;
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
if ( updateGrid )
|
||||
{
|
||||
updateGrid( this );
|
||||
Object myOtherSide = otherSide == 0 ? null : AEApi.instance().registries().locateable().findLocateableBySerial( otherSide );
|
||||
Object oldMyOtherSide = oldOtherSide == 0 ? null : AEApi.instance().registries().locateable().findLocateableBySerial( oldOtherSide );
|
||||
if ( myOtherSide instanceof QuantumCluster )
|
||||
updateGrid( (QuantumCluster) myOtherSide );
|
||||
if ( oldMyOtherSide instanceof QuantumCluster )
|
||||
updateGrid( (QuantumCluster) oldMyOtherSide );
|
||||
}
|
||||
}
|
||||
|
||||
public void updateRender()
|
||||
{
|
||||
for (int x = 0; x < Ring.length; x++)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void updateGrid(QuantumCluster c)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy()
|
||||
{
|
||||
if ( isDestroyed )
|
||||
return;
|
||||
isDestroyed = true;
|
||||
|
||||
if ( registered )
|
||||
{
|
||||
MinecraftForge.EVENT_BUS.unregister( this );
|
||||
registered = false;
|
||||
}
|
||||
|
||||
if ( getLocatableSerial() != 0 )
|
||||
{
|
||||
updateGrid( this );
|
||||
Object myOtherSide = otherSide == 0 ? null : AEApi.instance().registries().locateable().findLocateableBySerial( otherSide );
|
||||
if ( myOtherSide instanceof QuantumCluster )
|
||||
updateGrid( (QuantumCluster) myOtherSide );
|
||||
|
||||
MinecraftForge.EVENT_BUS.post( new LocatableEventAnnounce( this, LocatableEvent.Unregister ) );
|
||||
}
|
||||
|
||||
// updateStatus( true );
|
||||
|
||||
center.updateStatus( null, (byte) -1 );
|
||||
|
||||
for (TileQuantumBridge r : Ring)
|
||||
{
|
||||
r.updateStatus( null, (byte) -1 );
|
||||
}
|
||||
|
||||
center = null;
|
||||
Ring = new TileQuantumBridge[8];
|
||||
}
|
||||
|
||||
public boolean isCorner(TileQuantumBridge tileQuantumBridge)
|
||||
{
|
||||
return Ring[0] == tileQuantumBridge || Ring[2] == tileQuantumBridge || Ring[4] == tileQuantumBridge || Ring[6] == tileQuantumBridge;
|
||||
|
||||
}
|
||||
|
||||
public DimensionalCoord[] getOtherSide()
|
||||
{
|
||||
Object myOtherSide = AEApi.instance().registries().locateable().findLocateableBySerial( otherSide );
|
||||
if ( myOtherSide != null )
|
||||
{
|
||||
try
|
||||
{
|
||||
QuantumCluster qc = (QuantumCluster) myOtherSide;
|
||||
DimensionalCoord[] out = new DimensionalCoord[4];
|
||||
out[0] = new DimensionalCoord( qc.Ring[1] );
|
||||
out[1] = new DimensionalCoord( qc.Ring[3] );
|
||||
out[2] = new DimensionalCoord( qc.Ring[4] );
|
||||
out[3] = new DimensionalCoord( qc.Ring[6] );
|
||||
return out;
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
}
|
||||
}
|
||||
return new DimensionalCoord[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getLocatableSerial()
|
||||
{
|
||||
return thisSide;
|
||||
}
|
||||
|
||||
public boolean hasPower()
|
||||
{
|
||||
return center.bridgePowered;
|
||||
}
|
||||
|
||||
public TileQuantumBridge getCenter()
|
||||
{
|
||||
return center;
|
||||
}
|
||||
|
||||
public boolean hasQES()
|
||||
{
|
||||
return getLocatableSerial() != 0;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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
|
||||
{
|
||||
|
||||
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.getBlockTileEntity( 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();
|
||||
}
|
||||
|
||||
@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.getBlockTileEntity( 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
|
||||
};
|
||||
|
||||
public DimensionalCoord min;
|
||||
public DimensionalCoord max;
|
||||
public boolean isDestroyed = false;
|
||||
|
||||
public Axis currentAxis = Axis.UNFORMED;
|
||||
|
||||
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