Search in sources :

Example 1 with IPowerNode

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;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) AMVector3(am2.api.math.AMVector3) ArrayList(java.util.ArrayList) IPowerNode(am2.api.power.IPowerNode)

Example 2 with IPowerNode

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));
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) AMVector3(am2.api.math.AMVector3) ChunkCoordIntPair(net.minecraft.world.ChunkCoordIntPair)

Example 3 with IPowerNode

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);
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) IPowerNode(am2.api.power.IPowerNode)

Example 4 with IPowerNode

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);
        }
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) AMVector3(am2.api.math.AMVector3) IPowerNode(am2.api.power.IPowerNode)

Example 5 with IPowerNode

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);
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) PowerNodeEntry(am2.power.PowerNodeEntry) IPowerNode(am2.api.power.IPowerNode)

Aggregations

IPowerNode (am2.api.power.IPowerNode)14 TileEntity (net.minecraft.tileentity.TileEntity)14 AMVector3 (am2.api.math.AMVector3)13 PowerTypes (am2.api.power.PowerTypes)5 PowerNodeEntry (am2.power.PowerNodeEntry)3 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)3 ChatComponentText (net.minecraft.util.ChatComponentText)3 ChunkCoordIntPair (net.minecraft.world.ChunkCoordIntPair)3 ArrayList (java.util.ArrayList)2 Block (net.minecraft.block.Block)2 Chunk (net.minecraft.world.chunk.Chunk)2 TileEntityCrystalMarker (am2.blocks.tileentities.TileEntityCrystalMarker)1 TileEntityParticleEmitter (am2.blocks.tileentities.TileEntityParticleEmitter)1 AMDataWriter (am2.network.AMDataWriter)1 AMLineArc (am2.particles.AMLineArc)1 KeyValuePair (am2.utility.KeyValuePair)1 LinkedList (java.util.LinkedList)1 ItemBlock (net.minecraft.item.ItemBlock)1 World (net.minecraft.world.World)1