use of am2.api.power.IPowerNode in project ArsMagica2 by Mithion.
the class PowerNodePathfinder method generateSuccessors.
@Override
protected List<AMVector3> generateSuccessors(AMVector3 node) {
IPowerNode powerNode = getPowerNode(world, node);
if (powerNode == null)
return new ArrayList<AMVector3>();
IPowerNode[] candidates = PowerNodeRegistry.For(world).getAllNearbyNodes(world, node, powerType);
ArrayList<AMVector3> prunedCandidates = new ArrayList<AMVector3>();
for (IPowerNode candidate : candidates) {
if (verifyCandidate(candidate)) {
prunedCandidates.add(new AMVector3((TileEntity) candidate));
}
}
return prunedCandidates;
}
use of am2.api.power.IPowerNode in project ArsMagica2 by Mithion.
the class PowerNodeRegistry method removePowerNode.
public void removePowerNode(IPowerNode node) {
ChunkCoordIntPair chunk = getChunkFromNode(node);
removePowerNode(chunk, new AMVector3((TileEntity) node));
}
use of am2.api.power.IPowerNode in project ArsMagica2 by Mithion.
the class PoweredBlock method onBlockPlacedBy.
@Override
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase elb, ItemStack stack) {
super.onBlockPlacedBy(world, x, y, z, elb, stack);
TileEntity te = world.getTileEntity(x, y, z);
if (te instanceof IPowerNode) {
PowerNodeRegistry.For(world).registerPowerNode((IPowerNode) te);
}
}
use of am2.api.power.IPowerNode in project ArsMagica2 by Mithion.
the class AMPacketProcessorServer method handlePowerPathSync.
private void handlePowerPathSync(byte[] data, EntityPlayerMP player) {
AMDataReader rdr = new AMDataReader(data, false);
byte nom = rdr.getByte();
if (nom == 1) {
AMVector3 loc = new AMVector3(rdr.getFloat(), rdr.getFloat(), rdr.getFloat());
TileEntity te = player.worldObj.getTileEntity((int) loc.x, (int) loc.y, (int) loc.z);
if (te != null && te instanceof IPowerNode) {
AMNetHandler.INSTANCE.sendPowerResponseToClient(PowerNodeRegistry.For(player.worldObj).getDataCompoundForNode((IPowerNode) te), player, te);
}
}
}
use of am2.api.power.IPowerNode in project ArsMagica2 by Mithion.
the class AMPacketProcessorClient method handleRcvPowerPaths.
private void handleRcvPowerPaths(byte[] data) {
AMDataReader rdr = new AMDataReader(data, false);
byte bite = rdr.getByte();
NBTTagCompound compound = rdr.getNBTTagCompound();
if (bite == 0) {
PowerNodeEntry pnd = PowerNodeRegistry.For(Minecraft.getMinecraft().theWorld).parseFromNBT(compound);
AMCore.proxy.receivePowerPathVisuals(pnd.getNodePaths());
} else if (bite == 1) {
int x = rdr.getInt();
int y = rdr.getInt();
int z = rdr.getInt();
AMCore.proxy.setTrackedPowerCompound((NBTTagCompound) compound.copy());
TileEntity te = Minecraft.getMinecraft().theWorld.getTileEntity(x, y, z);
if (te != null && te instanceof IPowerNode)
PowerNodeRegistry.For(Minecraft.getMinecraft().theWorld).setDataCompoundForNode((IPowerNode) te, compound);
}
}
Aggregations