Java Code Examples for cpw.mods.fml.common.network.NetworkRegistry#TargetPoint

The following examples show how to use cpw.mods.fml.common.network.NetworkRegistry#TargetPoint . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BlockEssentiaCompressor.java    From Gadomancy with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int these, float are, float some, float variables) { //LUL side, hitx, hity, hitz
    if(world.isRemote) return false;
    TileEntity te = world.getTileEntity(x, y, z);
    if(te == null || !(te instanceof TileEssentiaCompressor)) return false;
    if(((TileEssentiaCompressor) te).isMultiblockFormed()) {
        if(!((TileEssentiaCompressor) te).isMasterTile()) {
            int yOffset = ((TileEssentiaCompressor) te).getMultiblockYIndex();
            return RegisteredBlocks.blockEssentiaCompressor.onBlockActivated(world, x, y - yOffset, z, player, these, are, some, variables);
        }
    } else {
        ItemStack heldItem = player.getHeldItem();
        if(heldItem != null && heldItem.getItem() instanceof ItemWandCasting &&
                ResearchManager.isResearchComplete(player.getCommandSenderName(), SimpleResearchItem.getFullName("ESSENTIA_COMPRESSOR"))) {
            ChunkCoordinates lowest = findLowestCompressorBlock(world, x, y, z);
            boolean canForm = lowest != null && isMuliblockPossible(world, lowest);
            if(canForm && ThaumcraftApiHelper.consumeVisFromWandCrafting(player.getCurrentEquippedItem(), player, RegisteredRecipes.costsCompressorMultiblock, true)) {
                int multiblockID = TileEssentiaCompressor.getAndIncrementNewMultiblockId();
                TileEssentiaCompressor compressor = (TileEssentiaCompressor) world.getTileEntity(lowest.posX, lowest.posY, lowest.posZ);
                compressor.setInMultiblock(true, 0, multiblockID);
                PacketStartAnimation pkt = new PacketStartAnimation(PacketStartAnimation.ID_SPARKLE_SPREAD, lowest.posX, lowest.posY, lowest.posZ);
                NetworkRegistry.TargetPoint point = new NetworkRegistry.TargetPoint(world.provider.dimensionId, lowest.posX, lowest.posY, lowest.posZ, 32);
                PacketHandler.INSTANCE.sendToAllAround(pkt, point);
                compressor = (TileEssentiaCompressor) world.getTileEntity(lowest.posX, lowest.posY + 1, lowest.posZ);
                compressor.setInMultiblock(false, 1, multiblockID);
                pkt = new PacketStartAnimation(PacketStartAnimation.ID_SPARKLE_SPREAD, lowest.posX, lowest.posY + 1, lowest.posZ);
                point = new NetworkRegistry.TargetPoint(world.provider.dimensionId, lowest.posX, lowest.posY + 1, lowest.posZ, 32);
                PacketHandler.INSTANCE.sendToAllAround(pkt, point);
                compressor = (TileEssentiaCompressor) world.getTileEntity(lowest.posX, lowest.posY + 2, lowest.posZ);
                compressor.setInMultiblock(false, 2, multiblockID);
                pkt = new PacketStartAnimation(PacketStartAnimation.ID_SPARKLE_SPREAD, lowest.posX, lowest.posY + 2, lowest.posZ);
                point = new NetworkRegistry.TargetPoint(world.provider.dimensionId, lowest.posX, lowest.posY + 2, lowest.posZ, 32);
                PacketHandler.INSTANCE.sendToAllAround(pkt, point);
            }
        }
    }
    return false;
}
 
Example 2
Source File: BlockAuraPylon.java    From Gadomancy with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float par7, float par8, float par9) {
    if(world.getBlockMetadata(x, y, z) != 1) {
        Block up = world.getBlock(x, y + 1, z);
        return up != null && up instanceof BlockAuraPylon && up.onBlockActivated(world, x, y + 1, z, player, side, par7, par8, par9);
    }
    ItemStack heldItem = player.getHeldItem();
    if(!world.isRemote && heldItem != null && heldItem.getItem() instanceof ItemWandCasting &&
            ResearchManager.isResearchComplete(player.getCommandSenderName(), Gadomancy.MODID.toUpperCase() + ".AURA_PYLON")) {
        TileAuraPylon tileAuraPylon = (TileAuraPylon) world.getTileEntity(x, y - 1, z);
        if(MultiblockHelper.isMultiblockPresent(world, x, y, z, RegisteredMultiblocks.auraPylonPattern) &&
                !tileAuraPylon.isPartOfMultiblock() &&
                ThaumcraftApiHelper.consumeVisFromWandCrafting(player.getCurrentEquippedItem(), player, RegisteredRecipes.costsAuraPylonMultiblock, true)) {
            PacketStartAnimation pkt = new PacketStartAnimation(PacketStartAnimation.ID_SPARKLE_SPREAD, x, y, z);
            NetworkRegistry.TargetPoint point = new NetworkRegistry.TargetPoint(world.provider.dimensionId, x, y, z, 32);
            PacketHandler.INSTANCE.sendToAllAround(pkt, point);
            TileAuraPylon ta = (TileAuraPylon) world.getTileEntity(x, y - 1, z);
            ta.setTileInformation(true, false);
            ta = (TileAuraPylon) world.getTileEntity(x, y - 3, z);
            ta.setTileInformation(false, true);
            int count = 1;
            TileEntity iter = world.getTileEntity(x, y - count, z);
            while(iter != null && iter instanceof TileAuraPylon) {
                ((TileAuraPylon) iter).setPartOfMultiblock(true);
                world.markBlockForUpdate(x, y - count, z);
                iter.markDirty();
                pkt = new PacketStartAnimation(PacketStartAnimation.ID_SPARKLE_SPREAD, x, y - count, z);
                PacketHandler.INSTANCE.sendToAllAround(pkt, point);
                count++;
                iter = world.getTileEntity(x, y - count, z);
            }
        }
    }
    return false;
}
 
Example 3
Source File: TileNodeManipulator.java    From Gadomancy with GNU Lesser General Public License v3.0 5 votes vote down vote up
private void playAspectDrainFromWand(Aspect drained) {
    if(drained == null) return;
    NetworkRegistry.TargetPoint point = getTargetPoint(32);
    PacketTCWispyLine line = new PacketTCWispyLine(worldObj.provider.dimensionId, xCoord + 0.5, yCoord + 0.8, zCoord + 0.5,
            xCoord + 0.5, yCoord + 1.4 + (((double) worldObj.rand.nextInt(4)) / 10D), zCoord + 0.5, 40, drained.getColor());
    PacketHandler.INSTANCE.sendToAllAround(line, point);
}
 
Example 4
Source File: TileNodeManipulator.java    From Gadomancy with GNU Lesser General Public License v3.0 4 votes vote down vote up
public void formMultiblock() {
    MultiblockHelper.MultiblockPattern toBuild;
    if(multiblockType == null) return;
    switch (multiblockType) {
        case NODE_MANIPULATOR:
            toBuild = RegisteredMultiblocks.completeNodeManipulatorMultiblock;
            break;
        case E_PORTAL_CREATOR:
            toBuild = RegisteredMultiblocks.completeEldritchPortalCreator;
            break;
        default:
            return;
    }
    for(MultiblockHelper.IntVec3 v : toBuild.keySet()) {
        MultiblockHelper.BlockInfo info = toBuild.get(v);
        if(info.block == RegisteredBlocks.blockNode || (info.block == RegisteredBlocks.blockStoneMachine && (info.meta == 0 || info.meta == 1 || info.meta == 3))
                || info.block == Blocks.air || info.block == RegisteredBlocks.blockNodeManipulator) continue;
        int absX = v.x + xCoord;
        int absY = v.y + yCoord;
        int absZ = v.z + zCoord;
        worldObj.setBlock(absX, absY, absZ, Blocks.air, 0, 0);
        worldObj.setBlock(absX, absY, absZ, info.block, info.meta, 0);
        worldObj.markBlockForUpdate(absX, absY, absZ);
    }
    NetworkRegistry.TargetPoint target = getTargetPoint(32);
    TileManipulatorPillar pillar = (TileManipulatorPillar) worldObj.getTileEntity(xCoord + 1, yCoord, zCoord + 1); //wrong
    pillar.setOrientation((byte) 5);
    PacketStartAnimation animation = new PacketStartAnimation(PacketStartAnimation.ID_RUNES, pillar.xCoord, pillar.yCoord, pillar.zCoord);
    PacketHandler.INSTANCE.sendToAllAround(animation, target);
    TileManipulatorPillar pillar2 = (TileManipulatorPillar) worldObj.getTileEntity(xCoord - 1, yCoord, zCoord + 1);
    pillar2.setOrientation((byte) 3);
    animation = new PacketStartAnimation(PacketStartAnimation.ID_RUNES, pillar2.xCoord, pillar2.yCoord, pillar2.zCoord);
    PacketHandler.INSTANCE.sendToAllAround(animation, target);
    TileManipulatorPillar pillar3 = (TileManipulatorPillar) worldObj.getTileEntity(xCoord + 1, yCoord, zCoord - 1); //wrong
    pillar3.setOrientation((byte) 4);
    animation = new PacketStartAnimation(PacketStartAnimation.ID_RUNES, pillar3.xCoord, pillar3.yCoord, pillar3.zCoord);
    PacketHandler.INSTANCE.sendToAllAround(animation, target);
    animation = new PacketStartAnimation(PacketStartAnimation.ID_RUNES, xCoord - 1, yCoord, zCoord - 1);
    PacketHandler.INSTANCE.sendToAllAround(animation, target);
    worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
    markDirty();
    this.isMultiblock = true;
}
 
Example 5
Source File: LocationIntPacket.java    From PneumaticCraft with GNU General Public License v3.0 4 votes vote down vote up
public NetworkRegistry.TargetPoint getTargetPoint(World world, double updateDistance){
    return new NetworkRegistry.TargetPoint(world.provider.dimensionId, x, y, z, updateDistance);
}
 
Example 6
Source File: LocationIntPacket.java    From PneumaticCraft with GNU General Public License v3.0 4 votes vote down vote up
public NetworkRegistry.TargetPoint getTargetPoint(World world){
    return getTargetPoint(world, TileEntityConstants.PACKET_UPDATE_DISTANCE);
}
 
Example 7
Source File: LocationDoublePacket.java    From PneumaticCraft with GNU General Public License v3.0 4 votes vote down vote up
public NetworkRegistry.TargetPoint getTargetPoint(World world, double updateDistance){
    return new NetworkRegistry.TargetPoint(world.provider.dimensionId, x, y, z, updateDistance);
}
 
Example 8
Source File: LocationDoublePacket.java    From PneumaticCraft with GNU General Public License v3.0 4 votes vote down vote up
public NetworkRegistry.TargetPoint getTargetPoint(World world){
    return getTargetPoint(world, TileEntityConstants.PACKET_UPDATE_DISTANCE);
}
 
Example 9
Source File: NetworkHandler.java    From PneumaticCraft with GNU General Public License v3.0 4 votes vote down vote up
public static void sendToAllAround(IMessage message, NetworkRegistry.TargetPoint point){
    INSTANCE.sendToAllAround(message, point);
}
 
Example 10
Source File: TileKnowledgeBook.java    From Gadomancy with GNU Lesser General Public License v3.0 4 votes vote down vote up
private NetworkRegistry.TargetPoint getTargetPoint(double radius) {
    return new NetworkRegistry.TargetPoint(worldObj.provider.dimensionId, xCoord, yCoord, zCoord, radius);
}
 
Example 11
Source File: TileNodeManipulator.java    From Gadomancy with GNU Lesser General Public License v3.0 4 votes vote down vote up
public NetworkRegistry.TargetPoint getTargetPoint(double radius) {
    return new NetworkRegistry.TargetPoint(worldObj.provider.dimensionId, xCoord, yCoord, zCoord, radius);
}
 
Example 12
Source File: BW_Network.java    From bartworks with MIT License 4 votes vote down vote up
public void sendToAllAround(@Nonnull GT_Packet aPacket, NetworkRegistry.TargetPoint aPosition) {
    ((FMLEmbeddedChannel) this.mChannel.get(Side.SERVER)).attr(FMLOutboundHandler.FML_MESSAGETARGET).set(FMLOutboundHandler.OutboundTarget.ALLAROUNDPOINT);
    ((FMLEmbeddedChannel) this.mChannel.get(Side.SERVER)).attr(FMLOutboundHandler.FML_MESSAGETARGETARGS).set(aPosition);
    ((FMLEmbeddedChannel) this.mChannel.get(Side.SERVER)).writeAndFlush(aPacket);
}
 
Example 13
Source File: ExplosionHelper.java    From Gadomancy with GNU Lesser General Public License v3.0 4 votes vote down vote up
private void sendRandomVortexLightningPacket(World world, int x, int y, int z) {
    PacketStartAnimation animationPacket = new PacketStartAnimation(PacketStartAnimation.ID_EX_VORTEX, x, y, z);
    NetworkRegistry.TargetPoint point = new NetworkRegistry.TargetPoint(world.provider.dimensionId, x, y, z, 32.0D);
    PacketHandler.INSTANCE.sendToAllAround(animationPacket, point);
}
 
Example 14
Source File: MiscUtils.java    From Gadomancy with GNU Lesser General Public License v3.0 4 votes vote down vote up
public static NetworkRegistry.TargetPoint getTargetPoint(World world, double range, Vector3 target) {
    return new NetworkRegistry.TargetPoint(world.provider.dimensionId, target.getX(), target.getY(), target.getZ(), range);
}
 
Example 15
Source File: MiscUtils.java    From Gadomancy with GNU Lesser General Public License v3.0 4 votes vote down vote up
public static NetworkRegistry.TargetPoint getTargetPoint(World world, TileEntity tileEntity, double range) {
    return getTargetPoint(world, range, new Vector3(tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord));
}
 
Example 16
Source File: MiscUtils.java    From Gadomancy with GNU Lesser General Public License v3.0 4 votes vote down vote up
public static NetworkRegistry.TargetPoint getTargetPoint(World world, Entity entity, double range) {
    return getTargetPoint(world, range, getPositionVector(entity));
}
 
Example 17
Source File: MCNetworkManager.java    From NOVA-Core with GNU Lesser General Public License v3.0 4 votes vote down vote up
public void sendToAllAround(PacketAbstract message, NetworkRegistry.TargetPoint point) {
	this.channelEnumMap.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGET).set(FMLOutboundHandler.OutboundTarget.ALLAROUNDPOINT);
	this.channelEnumMap.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGETARGS).set(point);
	this.channelEnumMap.get(Side.SERVER).writeAndFlush(message);
}
 
Example 18
Source File: ASMessagePipeline.java    From archimedes-ships with MIT License 3 votes vote down vote up
/**
 * Send this message to everyone within a certain range of a point.
 * <p/>
 * Adapted from CPW's code in cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper
 * 
 * @param message
 *            The message to send
 * @param point
 *            The {@link cpw.mods.fml.common.network.NetworkRegistry.TargetPoint} around which to send
 */
public void sendToAllAround(ASMessage message, NetworkRegistry.TargetPoint point)
{
	channels.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGET).set(FMLOutboundHandler.OutboundTarget.ALLAROUNDPOINT);
	channels.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGETARGS).set(point);
	channels.get(Side.SERVER).writeAndFlush(message);
}
 
Example 19
Source File: PacketPipeline.java    From NBTEdit with GNU General Public License v3.0 2 votes vote down vote up
/**
 * Send this message to everyone within a certain range of a point.
 * <p/>
 * Adapted from CPW's code in cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper
 *
 * @param message The message to send
 * @param point   The {@link cpw.mods.fml.common.network.NetworkRegistry.TargetPoint} around which to send
 */
public void sendToAllAround(AbstractPacket message, NetworkRegistry.TargetPoint point) {
    this.channels.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGET).set(FMLOutboundHandler.OutboundTarget.ALLAROUNDPOINT);
    this.channels.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGETARGS).set(point);
    this.channels.get(Side.SERVER).writeAndFlush(message);
}