Java 类net.minecraftforge.fml.common.network.NetworkRegistry.TargetPoint 实例源码

项目:Adventurers-Toolbox    文件:WorldListener.java   
@Override
public void sendBlockBreakProgress(int breakerId, BlockPos pos, int progress) {
    EntityPlayerMP player = null;
    for (EntityPlayerMP entityplayermp : this.mcServer.getPlayerList().getPlayers()) {
        if (entityplayermp != null && entityplayermp.getEntityId() == breakerId) {
            player = entityplayermp;
        }
    }
    if (player == null) {
        return;
    }
    if (player.getHeldItemMainhand().getItem() == ModItems.hammer) {
        RayTraceResult rt = ModItems.hammer.rayTraceBlocks(world, player);
        List<BlockPos> positions = ModItems.hammer.getExtraBlocks(world, rt, player);

        PacketHandler.INSTANCE.sendToAllAround(new MessageExtraBlockBreak(player.getEntityId(), positions.toArray(new BlockPos[positions.size()]), progress - 1), new TargetPoint(player.dimension, player.posX, player.posY, player.posZ, 32D));
    }
}
项目:CustomWorldGen    文件:FMLOutboundHandler.java   
@Override
public List<NetworkDispatcher> selectNetworks(Object args, ChannelHandlerContext context, FMLProxyPacket packet)
{
    TargetPoint tp = (TargetPoint)args;
    ImmutableList.Builder<NetworkDispatcher> builder = ImmutableList.builder();
    for (EntityPlayerMP player : FMLCommonHandler.instance().getMinecraftServerInstance().getPlayerList().getPlayerList())
    {
        if (player.dimension == tp.dimension)
        {
            double d4 = tp.x - player.posX;
            double d5 = tp.y - player.posY;
            double d6 = tp.z - player.posZ;

            if (d4 * d4 + d5 * d5 + d6 * d6 < tp.range * tp.range)
            {
                NetworkDispatcher dispatcher = player.connection.netManager.channel().attr(NetworkDispatcher.FML_DISPATCHER).get();
                if (dispatcher != null) builder.add(dispatcher);
            }
        }
    }
    return builder.build();
}
项目:wolfarmor    文件:EntityAIWolfAutoEat.java   
@Override
public void updateTask() {
    --eatCooldown;
    if(eatingFood != ItemStack.EMPTY) {
        if (foodEatTime > 0) {
            if (--foodEatTime % 4 == 0) {
                PacketHandler.getChannel().sendToAllAround(
                    new WolfEatMessage(entity.getEntityId(), eatingFood),
                    new TargetPoint(entity.dimension, entity.posX, entity.posY, entity.posZ, 60));
                this.entity.playSound(SoundEvents.ENTITY_GENERIC_EAT,
                        0.5F,
                        (this.entity.getRNG().nextFloat() - this.entity.getRNG().nextFloat()) * 0.2F + 1);
            }
        } else if (!hasHealedSinceLastReset) {
            hasHealedSinceLastReset = true;
            PacketHandler.getChannel().sendToAllAround(
                new WolfHealMessage(entity.getEntityId()),
                new TargetPoint(entity.dimension, entity.posX, entity.posY, entity.posZ, 60));
            this.entity.heal((float) ((ItemFood) eatingFood.getItem()).getHealAmount(eatingFood));
            this.eatingFood.shrink(1);
        }
    }
}
项目:Attained-Drops-2    文件:BlockPlant.java   
@Override
public void grow(@Nonnull World world, @Nonnull Random rand, @Nonnull BlockPos pos, @Nonnull IBlockState state) {
    int age = getAge(state);
    if (age < getMaxAge()) {
        setAge(world, pos, getAge(state) + 1);
    }
    if (isMaxAge(state) && world.isAirBlock(pos.up())) {
        IBlockState place = BlockVitalized.getBulbFromState(world.getBlockState(pos.down()));
        if (place != null) {
            AttainedDrops2.NETWORK.sendToAllAround(new ParticleMessage(BlockBulb.getColorFromState(place), pos.up(), (byte) 1), new TargetPoint(world.provider.getDimension(), pos.getX(), pos.getY(), pos.getZ(), 30));
            world.setBlockState(pos.up(), place);
            int charge = state.getValue(CHARGE);
            world.setBlockState(pos, state.withProperty(CHARGE, charge + 1 > 4 ? 0 : charge + 1));
            if (charge > 0 && rand.nextInt(5 - charge) == 0) {
                world.setBlockState(pos.down(), world.getBlockState(pos.down()).getBlock().getDefaultState());
                world.setBlockState(pos, state.withProperty(CHARGE, 0));
                if (Config.revertToDirt && rand.nextInt(8 - charge) == 0) {
                    if (world.getBlockState(pos.up()).getBlock() == ModRegistry.BULB) world.destroyBlock(pos.up(), true);
                    world.setBlockState(pos.down(), Blocks.DIRT.getDefaultState());
                    AttainedDrops2.NETWORK.sendToAllAround(new ParticleMessage(EnumDyeColor.RED, pos.up(), (byte) 2), new TargetPoint(world.provider.getDimension(), pos.getX(), pos.getY(), pos.getZ(), 30));
                }
            }
        }
    }
}
项目:LightningCraft    文件:Effect.java   
/** summon enderman particles and play teleport sound (start / end configurable)*/
  public static void ender(World world, double x, double y, double z, double tx, double ty, double tz, boolean sound2x) {
    short nParticles = 64;
    float width = 1;
    float height = 2;
    int dim = world.provider.getDimension();

      for (int l = 0; l < nParticles; ++l)
      {
          double d6 = l / (nParticles - 1.0D);
          float f = (random.nextFloat() - 0.5F) * 0.2F;
          float f1 = (random.nextFloat() - 0.5F) * 0.2F;
          float f2 = (random.nextFloat() - 0.5F) * 0.2F;
          double d7 = tx + (x - tx) * d6 + (random.nextDouble() - 0.5D) * width * 2.0D;
          double d8 = ty + (y - ty) * d6 + random.nextDouble() * height;
          double d9 = tz + (z - tz) * d6 + (random.nextDouble() - 0.5D) * width * 2.0D;
          LCNetwork.net.sendToAllAround(new MessageSpawnParticle("portal", d7, d8, d9, f, f1, f2), new TargetPoint(dim, d7, d8, d9, 1024));
      }

float pitch = 0.9F + random.nextFloat() * 0.2F;
world.playSound(null, x , y, z, SoundEvents.ENTITY_ENDERMEN_TELEPORT, SoundCategory.PLAYERS, 1.0F, pitch);
if(sound2x) world.playSound(null, tx , ty, tz, SoundEvents.ENTITY_ENDERMEN_TELEPORT, SoundCategory.PLAYERS, 1.0F, pitch);

  }
项目:Project-Zed    文件:TileEntityNuclearIOPort.java   
@Override
public void update() {
    super.update();

    if (!worldObj.isRemote && worldObj.getTotalWorldTime() % 20L == 0) {
        byte current = (byte) this.getBlockMetadata();
        if (this.meta != current) setMetaOnUpdate(current);

        PacketHandler.INSTANCE.sendToAllAround(new MessageTileEntityNuclearIOPort(this),
                new TargetPoint(worldObj.provider.getDimension(), pos.getX(), pos.getY(), pos.getZ(), 0x10));
    }

    else if (worldObj.isRemote && burnTime > 0) {
        burnTime--; // On client side, we can predict that burn time will be decreased each tick, and will be corrected via messages 1/sec.
    }
}
项目:EnderIO    文件:LiquidConduit.java   
@Override
public void updateEntity(@Nonnull World world) {
  super.updateEntity(world);
  if (world.isRemote) {
    return;
  }
  // filledFromThisTick.clear();
  updateStartPushDir();
  doExtract();

  if (stateDirty) {
    getBundle().dirty();
    stateDirty = false;
    lastSyncRatio = tank.getFilledRatio();

  } else if ((lastSyncRatio != tank.getFilledRatio() && world.getTotalWorldTime() % 2 == 0)) {

    // need to send a custom packet as we don't want want to trigger a full chunk update, just
    // need to get the required values to the entity renderer
    BlockPos pos = getBundle().getLocation();
    PacketHandler.INSTANCE.sendToAllAround(new PacketConduitFluidLevel(this),
        new TargetPoint(world.provider.getDimension(), pos.getX(), pos.getY(), pos.getZ(), 64));
    lastSyncRatio = tank.getFilledRatio();
  }
}
项目:VillagerTweaks    文件:NetworkHelper.java   
/**
 * Send info about the golems (iron and snow) to all players around a certain radius of them.
 * 
 * Server -> Client
 * 
 */
public static void sendEnchantedGolemInfoMessage(EntityLiving golem, ExtendedGolem properties) {
    if (golem != null && properties != null) {
        int[] ids = GolemEnchantment.convert(properties.getEnchantments());

        if (ids.length > 0) {
            MessageGolemEnchantments message = new MessageGolemEnchantments(golem.getEntityId(), ids);
            TargetPoint target = new TargetPoint(golem.dimension, golem.posX, golem.posY, golem.posZ, 64.0D);

            // Debug
            LogHelper.info("~~Sending Message - Enchanted Iron Golem info~~");
            LogHelper.info("    target: " + target);
            LogHelper.info("    " + message.toString());

            // Sends a message to the player, with the golem extra info
            ModVillagerTweaks.NetworkWrapper.sendToAllAround(message, target);
        }
    }
}
项目:VoidApi    文件:VoidNetwork.java   
public static void sendDataToAllAround(PacketType type, NBTTagCompound toSend, TargetPoint pt)
{
    if (MC.getSide() == Side.CLIENT)
    {
        VCLoggers.loggerErrors.log(LogLevel.Error, "A mod attempted to send a packet to a client while being on a client side already! [packet - %s:%d]", type.registryName, type.internalID);
        return;
    }

    sendData(type, toSend, null, pt);
}
项目:VoidApi    文件:VoidNetwork.java   
public static void send(Packet packet, EntityPlayerMP to, TargetPoint point)
{
    Side s = MC.getSide();
    if (s == Side.CLIENT)
    {
        if (packet.id == PacketType.Request.internalID)
        {
            packet.data.setString("requester", VoidApi.proxy.getClientPlayerName());
        }

        networkManager.sendToServer(packet);
    }
    else
    {
        if (to != null)
        {
            networkManager.sendTo(packet, to);
        }
        else
        {
            if (point != null)
            {
                networkManager.sendToAllAround(packet, point);
            }
            else
            {
                networkManager.sendToAll(packet);
            }
        }
    }
}
项目:Solar    文件:PacketHelper.java   
public static void sendPhenomenaPacket(TilePhenomena phenomena) {
    NBTTagCompound tag = new NBTTagCompound();
    BlockPos pos = phenomena.getPos();
    tag.setInteger("x", pos.getX());
    tag.setInteger("y", pos.getY());
    tag.setInteger("z", pos.getZ());
    TargetPoint point = fromTileEntity(phenomena, 25);
    PacketHandler.NETWORK.sendToAllAround(new ServerToClientPacket(PacketHandler.PHENOMENA, tag), point);
}
项目:Solar    文件:PacketHelper.java   
public static void sendQuartzEffectPacket(EntityCrystalQuartzItem item, Vector3 from, Vector3 to) {
    TargetPoint point = fromEntity(item, 25);
    NBTTagCompound tag = new NBTTagCompound();
    tag.setTag("from", from.writeToNBT(new NBTTagCompound()));
    tag.setTag("to", to.writeToNBT(new NBTTagCompound()));
    PacketHandler.NETWORK.sendToAllAround(new ServerToClientPacket(PacketHandler.QUARTZ_EFFECT, tag), point);
}
项目:CustomWorldGen    文件:FMLOutboundHandler.java   
@Override
public void validateArgs(Object args)
{
    if (!(args instanceof TargetPoint))
    {
        throw new RuntimeException("ALLAROUNDPOINT expects a TargetPoint argument");
    }
}
项目:ExPetrum    文件:ExPFarmland.java   
@Override
public void setDirty()
{
    NBTTagCompound sent = new NBTTagCompound();
    sent.setTag("tileData", this.getContainer().serializeNBT());
    sent.setTag("blockPosData", new DimBlockPos(this.getContainer().getPos(), this.getContainer().getWorld().provider.getDimension()).serializeNBT());
    VoidNetwork.sendDataToAllAround(PacketType.TileData, sent, new TargetPoint(this.getContainer().getWorld().provider.getDimension(), this.getContainer().getPos().getX(), this.getContainer().getPos().getY(), this.getContainer().getPos().getZ(), 96));
}
项目:ExPetrum    文件:ExPCrop.java   
public void sendUpdatePacket()
{
    NBTTagCompound sent = new NBTTagCompound();
    sent.setTag("tileData", this.getContainer().serializeNBT());
    sent.setTag("blockPosData", new DimBlockPos(this.getContainer().getPos(), this.getContainer().getWorld().provider.getDimension()).serializeNBT());
    VoidNetwork.sendDataToAllAround(PacketType.TileData, sent, new TargetPoint(this.getContainer().getWorld().provider.getDimension(), this.getContainer().getPos().getX(), this.getContainer().getPos().getY(), this.getContainer().getPos().getZ(), 96));
}
项目:ExPetrum    文件:ItemSeeds.java   
@Override
public EnumActionResult onItemUse(EntityPlayer player, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ)
{
    if (worldIn.isRemote)
    {
        return EnumActionResult.FAIL;
    }

    TileEntity tile = worldIn.getTileEntity(pos);
    if (tile != null && tile.hasCapability(ExPFarmlandCapability.farmlandCap, EnumFacing.UP))
    {
        if (worldIn.isAirBlock(pos.up()))
        {
            // FIXME fix packet pipeline render issues!
            try
            {
                ItemStack held = player.getHeldItem(hand);
                CapabilityExPSeeds seedsCap = (CapabilityExPSeeds) held.getCapability(ExPSeedsCapability.seedsCap, null);
                CropStats stats = new CropStats(seedsCap.getOrCreateStats());
                worldIn.setBlockState(pos.up(), ExPBlocks.crop.getDefaultState());
                TileCrop cropTile = (TileCrop) worldIn.getTileEntity(pos.up());
                ExPCrop cropCap = (ExPCrop) IExPCrop.of(cropTile);
                cropCap.stats = stats;
                cropCap.timeKeeper = new Calendar(IExPWorld.of(worldIn).today().getTime());
                NBTTagCompound sent = new NBTTagCompound();
                sent.setTag("tileData", cropTile.serializeNBT());
                sent.setTag("blockPosData", new DimBlockPos(pos.up(), worldIn.provider.getDimension()).serializeNBT());
                VoidNetwork.sendDataToAllAround(PacketType.TileData, sent, new TargetPoint(worldIn.provider.getDimension(), pos.getX(), pos.up().getY(), pos.getZ(), 96));
                held.shrink(1);
                return EnumActionResult.SUCCESS;
            }
            catch (Exception ex)
            {
                ExPMisc.modLogger.log(LogLevel.Error, "Unable to place seeds at %s!", ex, pos.toString());
            }
        }
    }

    return super.onItemUse(player, worldIn, pos, hand, facing, hitX, hitY, hitZ);
}
项目:CraftStudioAPI    文件:CSNetworkHelper.java   
/**
 * Send the given message through the network.
 * 
 * @param message
 *            The message to send.
 */
public static void sendIAnimatedEvent(IAnimatedEventMessage message) {
    if (message.animated.isWorldRemote())
        // If we are on client, we send a server message to the server.
        CraftStudioApi.NETWORK.sendToServer(new ServerIAnimatedEventMessage(message));
    else
        // If we are on server, we send a client message to the clients in
        // range.
        CraftStudioApi.NETWORK.sendToAllAround(new ClientIAnimatedEventMessage(message), new TargetPoint(message.animated.getDimension(),
                message.animated.getX(), message.animated.getY(), message.animated.getZ(), CSNetworkHelper.EVENT_RANGE));
}
项目:Attained-Drops-2    文件:BlockCreator.java   
private void genNewSoil(World world, BlockPos pos, IBlockState state, Random rand) {
    int radius = Config.creatorRadius;
    BlockPos pos2 = pos.add(MathHelper.getInt(rand, radius * -1, radius), 0, MathHelper.getInt(rand, radius * -1, radius));
    if (world.getBlockState(pos2).getBlock().canSustainPlant(world.getBlockState(pos2), world, pos2, EnumFacing.UP, Blocks.YELLOW_FLOWER)) {
        world.setBlockState(pos2, ModRegistry.SOIL.getDefaultState());
        if (rand.nextBoolean()) {
            if (state.getValue(CHARGE) - 1 <= 0) {
                world.setBlockState(pos, Blocks.DIRT.getDefaultState());
                AttainedDrops2.NETWORK.sendToAllAround(new ParticleMessage(EnumDyeColor.RED, pos.up(), (byte) 2), new TargetPoint(world.provider.getDimension(), pos.getX(), pos.getY(), pos.getZ(), 30));
            } else world.setBlockState(pos, state.withProperty(CHARGE, state.getValue(CHARGE) - 1));
        }
        AttainedDrops2.NETWORK.sendToAllAround(new ParticleMessage(EnumDyeColor.GREEN, pos2), new TargetPoint(world.provider.getDimension(), pos.getX(), pos.getY(), pos.getZ(), 30));

    }
}
项目:Factorization    文件:NotifyNetwork.java   
static void broadcast(FMLProxyPacket packet, EntityPlayer player, TargetPoint area) {
    if (player == null) {
        NotifyNetwork.channel.sendToAll(packet);
    } else if (player instanceof EntityPlayerMP) {
        NotifyNetwork.channel.sendTo(packet, (EntityPlayerMP) player);
    }
}
项目:LightningCraft    文件:EntityLCTNTPrimed.java   
/**
 * Called to update the entity's position/logic.
 */
@Override
public void onUpdate() {
    if(!worldObj.isRemote && !firstTick) {
        LCNetwork.net.sendToAllAround(new MessageSyncTNT(this), 
                new TargetPoint(this.dimension, this.posX, this.posY, this.posZ, 1024));
        firstTick = true;
    }

    this.prevPosX = this.posX;
    this.prevPosY = this.posY;
    this.prevPosZ = this.posZ;
    this.motionY -= 0.03999999910593033D;
    this.moveEntity(this.motionX, this.motionY, this.motionZ);
    this.motionX *= 0.9800000190734863D;
    this.motionY *= 0.9800000190734863D;
    this.motionZ *= 0.9800000190734863D;

    if (this.onGround)
    {
        this.motionX *= 0.699999988079071D;
        this.motionZ *= 0.699999988079071D;
        this.motionY *= -0.5D;
    }

    if (this.fuse-- <= 0)
    {
        this.setDead();

        if (!this.worldObj.isRemote)
        {
            this.explode();
        }
    }
    else
    {
        this.worldObj.spawnParticle(EnumParticleTypes.SMOKE_LARGE, this.posX, this.posY + 0.5D, this.posZ, 0.0D, 0.0D, 0.0D);
    }
}
项目:LightningCraft    文件:Effect.java   
/** special sword particle effect */
  public static void specialSword(String name, World world, double x, double y, double z) {
    int dim = world.provider.getDimension();
    for(int i = 0; i < LCParticles.swordParticleCount; i++) {
    float xoff = (random.nextFloat() - 0.5F) * LCParticles.swordParticleSpread;
    float yoff = (random.nextFloat() + 0.0F)  * LCParticles.swordParticleSpread;
    float zoff = (random.nextFloat() - 0.5F)  * LCParticles.swordParticleSpread;
    LCNetwork.net.sendToAllAround(new MessageSpawnParticle(name, x + xoff, y + yoff, z + zoff, 0, 0, 0), new TargetPoint(dim, x, y, z, 1024));
}
  }
项目:vintagetg    文件:NetworkTileEntity.java   
public void broadcastPacketInRange() {
    int dim = worldObj.provider.getDimensionId();
    if(worldObj.isRemote) {
        VintageTG.packetPipeline.sendToServer(this.createDataPacket());
    } else {
        VintageTG.packetPipeline.sendToAllAround(this.createDataPacket(), 
                new TargetPoint(dim, pos.getX(), pos.getY(), pos.getZ(), broadcastRange));
    }
}
项目:vintagetg    文件:NetworkTileEntity.java   
public void broadcastPacketInRange(AbstractPacket packet) {
    if(worldObj.isRemote) {
        VintageTG.packetPipeline.sendToServer(packet);
    } else {
        VintageTG.packetPipeline.sendToAllAround(packet, 
                new TargetPoint(worldObj.provider.getDimensionId(), pos.getX(), pos.getY(), pos.getZ(), broadcastRange));
    }
}
项目:TechStack-s-HeavyMachineryMod    文件:ModNetwork.java   
public static void sendPacketToAllAround(IMessage packet, TargetPoint tp) {
    for (EntityPlayerMP player : (List<EntityPlayerMP>) FMLCommonHandler.instance().getMinecraftServerInstance().getPlayerList().getPlayers()) {
        if (player.dimension == tp.dimension) {
            double d4 = tp.x - player.posX;
            double d6 = tp.z - player.posZ;

            // base distance only on the x & Z axis so you can see machines way above / below you. (blast a machine up and you'll understand why
            if (d4 * d4 + d6 * d6 < tp.range * tp.range) {

                ModNetwork.simpleNetworkWrapper.sendTo(packet, player);

            }
        }
    }
}
项目:Extra-Food    文件:WailaProviderJuiceBlender.java   
@Override
public NBTTagCompound getNBTData(EntityPlayerMP entityPlayerMP, TileEntity te, NBTTagCompound tag, World world, BlockPos blockPos) {
       if (te != null){
        TileEntityJuiceBlender tileEntity = (TileEntityJuiceBlender) te;
        if(tileEntity.tank.getFluid() != null){
            ChannelHandler.EFchannel.sendToAllAround(new PacketJBTank(tileEntity.tank.getFluidAmount(), tileEntity.tank.getFluid().tag, tileEntity.tank.getFluid().getFluid(), tileEntity.getPos().getX(), tileEntity.getPos().getY(), tileEntity.getPos().getZ()), new TargetPoint(tileEntity.getWorld().provider.getDimension(), tileEntity.getPos().getX(), tileEntity.getPos().getY(), tileEntity.getPos().getZ(), 10));
        }
       }
       return tag;
}
项目:Project-Zed    文件:SidedInfo.java   
/**
 * @param side Side to send to.
 * @param packet EnumClientPacket containing info on where to send packets.
 */
public SidedInfo(Side side, EnumClientPacket packet, TargetPoint targetPoint, EntityPlayer player) {
    this.side = side;
    this.packet = packet;
    packet.targetPoint = targetPoint;
    packet.player = player;
}
项目:pnc-repressurized    文件:TileEntityAirCannon.java   
private synchronized boolean fire() {
    Entity itemShot = getCloseEntityIfUpgraded();
    if (getPressure() >= PneumaticValues.MIN_PRESSURE_AIR_CANNON && (itemShot != null || !inventory.getStackInSlot(CANNON_SLOT).isEmpty())) {
        double[] velocity = getVelocityVector(heightAngle, rotationAngle, getForce());
        addAir((int) (-500 * getForce()));
        boolean shootingInventory = false;
        if (itemShot == null) {
            shootingInventory = true;
            itemShot = getPayloadEntity();
            if (itemShot instanceof EntityItem) {
                inventory.setStackInSlot(CANNON_SLOT, ItemStack.EMPTY);
                if (getUpgrades(EnumUpgrade.BLOCK_TRACKER) > 0) {
                    trackedItems.add((EntityItem) itemShot);
                }
            } else {
                inventory.extractItem(CANNON_SLOT, 1, false);
            }
        } else if (itemShot instanceof EntityPlayer) {
            EntityPlayerMP entityplayermp = (EntityPlayerMP) itemShot;
            if (entityplayermp.connection.getNetworkManager().isChannelOpen()) {

                //This is a nasty hack to get around "player moved wrongly!" messages, which can be caused if player movement
                // triggers a player teleport (e.g. player moves onto pressure plate, triggers air cannon with an entity tracker).
                entityplayermp.invulnerableDimensionChange = true;

                entityplayermp.setPositionAndUpdate(getPos().getX() + 0.5D, getPos().getY() + 1.8D, getPos().getZ() + 0.5D);
            }
        }

        if (itemShot.isRiding()) {
            itemShot.dismountRidingEntity();
        }

        itemShot.setPosition(getPos().getX() + 0.5D, getPos().getY() + 1.8D, getPos().getZ() + 0.5D);
        NetworkHandler.sendToAllAround(new PacketSetEntityMotion(itemShot, velocity[0], velocity[1], velocity[2]),
                new TargetPoint(getWorld().provider.getDimension(), getPos().getX(), getPos().getY(), getPos().getZ(), 64));

        if (itemShot instanceof EntityFireball) {
            velocity[0] *= 0.05D;
            velocity[1] *= 0.05D;
            velocity[2] *= 0.05D;
        }

        itemShot.motionX = velocity[0];
        itemShot.motionY = velocity[1];
        itemShot.motionZ = velocity[2];

        itemShot.onGround = false;
        itemShot.collided = false;
        itemShot.collidedHorizontally = false;
        itemShot.collidedVertically = false;
        if (itemShot instanceof EntityLivingBase) ((EntityLivingBase) itemShot).setJumping(true);

        if (shootingInventory && !getWorld().isRemote) getWorld().spawnEntity(itemShot);

        for (int i = 0; i < 10; i++) {
            double velX = velocity[0] * 0.4D + (rand.nextGaussian() - 0.5D) * 0.05D;
            double velY = velocity[1] * 0.4D + (rand.nextGaussian() - 0.5D) * 0.05D;
            double velZ = velocity[2] * 0.4D + (rand.nextGaussian() - 0.5D) * 0.05D;
            NetworkHandler.sendToAllAround(new PacketSpawnParticle(EnumParticleTypes.SMOKE_LARGE, getPos().getX() + 0.5D, getPos().getY() + 0.7D, getPos().getZ() + 0.5D, velX, velY, velZ), getWorld());
        }
        NetworkHandler.sendToAllAround(new PacketPlaySound(Sounds.CANNON_SOUND, SoundCategory.BLOCKS, getPos().getX(), getPos().getY(), getPos().getZ(), 1.0F, rand.nextFloat() / 4F + 0.75F, true), getWorld());
        return true;
    } else {
        return false;
    }
}
项目:VoidApi    文件:VoidNetwork.java   
public static void sendRequestToAllAround(PacketType toRequest, TargetPoint pt)
{
    sendDataToAllAround(PacketType.Request, NBTChain.startChain().withShort("requestID", toRequest.internalID).endChain(), pt);
}
项目:VoidApi    文件:VoidNetwork.java   
public static void sendRequest(PacketType toRequest, EntityPlayerMP to, TargetPoint point)
{
    sendData(PacketType.Request, NBTChain.startChain().withShort("requestID", toRequest.internalID).endChain(), to, point);
}
项目:VoidApi    文件:VoidNetwork.java   
public static void sendData(PacketType type, NBTTagCompound toSend, EntityPlayerMP to, TargetPoint point)
{
    Packet p = new Packet(type, toSend);
    send(p, to, point);
}
项目:Solar    文件:PacketHelper.java   
public static TargetPoint fromWorldPos(World world, BlockPos pos, int range) {
    return new TargetPoint(world.provider.getDimension(), pos.getX(), pos.getY(), pos.getZ(), range);
}
项目:Solar    文件:PacketHelper.java   
public static TargetPoint fromTileEntity(TileEntity te, int range) {
    return new TargetPoint(te.getWorld().provider.getDimension(), te.getPos().getX(), te.getPos().getY(), te.getPos().getZ(), range);
}
项目:Solar    文件:PacketHelper.java   
public static TargetPoint fromEntity(Entity entity, int range) {
    return new TargetPoint(entity.world.provider.getDimension(), entity.posX, entity.posY, entity.posZ, range);
}
项目:ToroChess    文件:TileEntityChessControl.java   
private void sendTurnChangeMessage() {
  TargetPoint p = new TargetPoint(world.provider.getDimension(), a8.getX() + 4, a8.getY(), a8.getZ() + 4, 40);
  ToroChess.NETWORK.sendToAllAround(new MessageTurnChangeEvent(turn, gameId), p);
}
项目:ToroChess    文件:TileEntityChessControl.java   
private void sendControlBlockUpdatePacket() {
  TargetPoint p = new TargetPoint(world.provider.getDimension(), a8.getX() + 4, a8.getY(), a8.getZ() + 4, 100);
  ToroChess.NETWORK.sendToAllAround(new MessageUpdateControlBlock(pos, writeToNBT(new NBTTagCompound())), p);
}
项目:Toms-Mod    文件:NetworkHandler.java   
public static void sendToAllAround(IMessage message, TargetPoint point) {
    INSTANCE.sendToAllAround(message, point);
}
项目:ExNihiloAdscensio    文件:PacketHandler.java   
public static void sendToAllAround(IMessage message, TileEntity te, int range) 
{
    BlockPos pos = te.getPos();
       INSTANCE.sendToAllAround(message, new TargetPoint(te.getWorld().provider.getDimension(), pos.getX(), pos.getY(), pos.getZ(), range));
   }
项目:How-Bout-That-Furniture    文件:PacketDispatcher.java   
public static final void sendToAllAround(IMessage message, NetworkRegistry.TargetPoint point)
{
  dispatcher.sendToAllAround(message, point);
}
项目:How-Bout-That-Furniture    文件:PacketDispatcher.java   
public static final void sendToAllAround(IMessage message, int dimension, double x, double y, double z, double range)
{
  sendToAllAround(message, new NetworkRegistry.TargetPoint(dimension, x, y, z, range));
}
项目:LightningCraft    文件:ItemMaterial.java   
/** Right-click the item on a block */
@Override
public EnumActionResult onItemUse(ItemStack stack, EntityPlayer player, World world, BlockPos pos,
        EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
    switch(stack.getItemDamage()) {

    // Cell Upgrade usage
    case Material.UPGRADE:
        // upgrade an upgradable tile entity
        TileEntity tile = world.getTileEntity(pos);
        if(LCConfig.upgradeEnabled && tile != null && tile.hasCapability(LCCapabilities.LIGHTNING_UPGRADABLE, null) && 
                !tile.getCapability(LCCapabilities.LIGHTNING_UPGRADABLE, null).isUpgraded()) {
            EnumActionResult r = tile.getCapability(LCCapabilities.LIGHTNING_UPGRADABLE, null)
                    .onLightningUpgrade(stack, player, world, pos, hand, facing, hitX, hitY, hitZ);
            if(r == EnumActionResult.SUCCESS && !world.isRemote) {
                --stack.stackSize; // transfer the upgrade to the tile entity on success
                tile.markDirty();

                player.addStat(LCAchievements.upgradeMachine, 1); // give out the achievement

                // send a message to nearby clients to update the upgraded status
                LCNetwork.net.sendToAllAround(new MessageLightningUpgrade(pos), 
                        new TargetPoint(world.provider.getDimension(), pos.getX(), pos.getY(), pos.getZ(), 1024));
            }
            return r;
        } else {
            return EnumActionResult.FAIL;
        }

    // Underworld Charge usage
    case Material.UNDER_CHARGE:

        if(!world.isRemote) {
            if(PortalUnderworld.ignitePortal(world, pos.up())) {
                if(player.capabilities.isCreativeMode == false) stack.stackSize--;
                Effect.lightning(world, pos.getX(), pos.getY() + 1, pos.getZ());
                if(stack.stackSize <= 0) stack = null;
            }
        }
        return EnumActionResult.SUCCESS;

    // Default usage
    default:
        return super.onItemUse(stack, player, world, pos, hand, facing, hitX, hitY, hitZ);
    }
}