Java 类cpw.mods.fml.common.network.PacketDispatcher 实例源码

项目:Rival-Rebels-Mod    文件:GuiLaptop.java   
@Override
protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3)
{
    GL11.glColor3f(1, 1, 1);
    Minecraft.getMinecraft().renderEngine.bindTexture(RivalRebels.guilaptopnuke);
    int x = (width - xSize) / 2;
    int y = (height - ySize) / 2;
    this.drawTexturedModalRect(x, y, 0, 0, xSize, ySize);
    if (lt.hasChips()) this.drawTexturedModalRect(x + 135, y + 79, 248, 0, 8, 8);
    Minecraft.getMinecraft().fontRenderer.drawString(StatCollector.translateToLocal("RivalRebels.controller.B83"), x + 118, y + 11, 0xffffff);
    Minecraft.getMinecraft().fontRenderer.drawString(StatCollector.translateToLocal("RivalRebels.controller.b2spirit"), x + 25, y + 11, 0xffffff);
    Minecraft.getMinecraft().fontRenderer.drawString(StatCollector.translateToLocal("x" + lt.b2spirit), x + 154, y + 96, 0xffffff);
    Minecraft.getMinecraft().fontRenderer.drawString(StatCollector.translateToLocal("x" + lt.b2carpet), x + 154, y + 85, 0xffffff);
    if (button.mousePressed(mc, par2, par3) && Mouse.isButtonDown(0) && !prevButtonDown)
    {
        PacketDispatcher.packetsys.sendToServer(new LaptopButtonPacket(lt.xCoord, lt.yCoord, lt.zCoord));
    }
    prevButtonDown = Mouse.isButtonDown(0);
}
项目:UniversalCoinsMod    文件:UCTileEntity.java   
public void dispatchPackage() { //packet server-to-player
    Packet250CustomPayload packet = new Packet250CustomPayload();
    ByteArrayOutputStream stream = new ByteArrayOutputStream(21);
    DataOutputStream outputStream = new DataOutputStream(stream);
    try {
        outputStream.writeInt(coinSum);
        outputStream.writeInt(xCoord);
        outputStream.writeInt(yCoord);
        outputStream.writeInt(zCoord);
        outputStream.writeInt(this.worldObj.getWorldInfo().getVanillaDimension());
        outputStream.writeBoolean(bypassActive);
    } catch (Exception ex) {
        ex.printStackTrace();
    }
    packet.channel = "UCTS_TileEntity";
    packet.data = stream.toByteArray();
    packet.length = stream.size();
    PacketDispatcher.sendPacketToAllPlayers(packet);
}
项目:UniversalCoinsMod    文件:UCTileEntity.java   
void requestCoinSumPackage(){
    Packet250CustomPayload packet = new Packet250CustomPayload();
    ByteArrayOutputStream stream = new ByteArrayOutputStream(16);
    DataOutputStream outputStream = new DataOutputStream(stream);
    try {
        outputStream.writeInt(xCoord);
        outputStream.writeInt(yCoord);
        outputStream.writeInt(zCoord);
        outputStream.writeInt(this.worldObj.getWorldInfo().getVanillaDimension());
    } catch (Exception ex) {
        ex.printStackTrace();
    }
    packet.channel = "UCTS_TE_Request";
    packet.data = stream.toByteArray();
    packet.length = stream.size();
    PacketDispatcher.sendPacketToServer(packet);
}
项目:MineFantasy    文件:BlockAnvilMF.java   
@Override
 public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int i, float f, float f1, float f2) 
 {
    TileEntityAnvil tile = (TileEntityAnvil) world.getBlockTileEntity(x, y, z);
     if(tile == null)
      {
        return super.onBlockActivated(world, x, y, z, player, i, f, f1, f2);
      }

    if(world.isRemote)
{
        int slot = tile.getSlotFor(f, f2);
         this.useInventory(world, x, y, z, tile, player, i, slot);

    Packet packet = PacketManagerMF.getPacketIntegerArray(tile, new int[]{1, player.entityId, i, slot});
    try
    {
        PacketDispatcher.sendPacketToServer(packet);
    } catch(NullPointerException e)
    {
        System.out.println("MineFantasy: Client connection lost");
    }
}

     return true;
 }
项目:MineFantasy    文件:BlockTailor.java   
@Override
 public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int i, float f, float f1, float f2)
 {
    TileEntityTailor tile = (TileEntityTailor) world.getBlockTileEntity(x, y, z);
     if(tile == null)
     {
        return super.onBlockActivated(world, x, y, z, player, i, f, f1, f2);
     }
     if(world.isRemote)
{
        int slot = tile.getSlotFor(f, f2);
         this.useInventory(world, x, y, z, tile, player, i, slot);

    Packet packet = PacketManagerMF.getPacketIntegerArray(tile, new int[]{1, player.entityId, i, slot});
    try
    {
        PacketDispatcher.sendPacketToServer(packet);
    } catch(NullPointerException e)
    {
        System.out.println("MineFantasy: Client connection lost");
    }
}

     return true;
 }
项目:MineFantasy    文件:BlockWeaponRack.java   
@Override
  public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int i, float f, float f1, float f2) 
  {
    TileEntityWeaponRack tile = (TileEntityWeaponRack)world.getBlockTileEntity(x, y, z);

if(world.isRemote)
    {
    int slot = tile.getSlotFor(f, f2);
    if(slot >= 0 && slot < 4)
    {
        tryPlaceItem(slot, world, tile, player);
    }

        Packet packet = PacketManagerMF.getPacketIntegerArray(tile, new int[]{1, player.entityId, i, slot});
        try
        {
            PacketDispatcher.sendPacketToServer(packet);
        } catch(NullPointerException e)
        {
            System.out.println("MineFantasy: Client connection lost");
        }
    }

      return true;
  }
项目:PeripheralsPlusPlus    文件:PeripheralBarrel.java   
private void updateAmount() {
    int amount = item == null ? 0 : item.stackSize;
    if (prevAmount != amount || prevMaxSize != maxSize) {
        World world = turtle.getWorld();
        Vec3 pos = turtle.getPosition();
        int x = (int)Math.floor(pos.xCoord);
        int y = (int)Math.floor(pos.yCoord);
        int z = (int)Math.floor(pos.zCoord);

        ByteArrayDataOutput os = ByteStreams.newDataOutput();
        os.writeInt(x);
        os.writeInt(y);
        os.writeInt(z);
        os.writeInt(amount);
        os.writeInt(maxSize);
        PacketDispatcher.sendPacketToAllAround(pos.xCoord + 0.5D, pos.yCoord + 0.5D, pos.zCoord + 0.5D, 64.0D, world.provider.dimensionId, PacketDispatcher.getTinyPacket(MiscPeripherals.instance, (short)5, os.toByteArray()));
    }
}
项目:RecipeIGE    文件:SmallButton.java   
@Override
public boolean mousePressed(Minecraft minecraft, int par2, int par3)
{
    if (renderID != 0)
        return super.mousePressed(minecraft, par2, par3);

    this.enabled = !super.mousePressed(minecraft, par2, par3);
    if (!this.enabled && this.renderID == 0)
    {
        Packet250CustomPayload packet = new Packet250CustomPayload();
        packet.length = 1;
        packet.data = new byte[] { 0 };
        packet.channel = Reference.CHANNEL;
        PacketDispatcher.sendPacketToServer(packet);
    }
    return !this.enabled;
}
项目:Billund    文件:GuiOrderForm.java   
private void order()
{
    if( !m_ordered )
    {
        // Send our orders to the server
        for( int i=0; i<NUM_SETS; ++i )
        {
            if( m_orders[i] )
            {
                BillundPacket packet = new BillundPacket();
                packet.packetType = BillundPacket.OrderSet;
                packet.dataInt = new int[] { i };
                PacketDispatcher.sendPacketToServer( packet.toPacket() );
            }
        }

        // Ensure we don't order again
        m_ordered = true;
    }
}
项目:AutoCrafter2000    文件:AutoCrafterOverlayHandler.java   
@Override
public void overlayRecipe(GuiContainer firstGui, IRecipeHandler recipe, int recipeIndex, boolean shift)
{
    List<PositionedStack> ingredients = recipe.getIngredientStacks(recipeIndex);

    NBTTagCompound root = new NBTTagCompound();
    for (PositionedStack stack : ingredients)
    {
        int x = (stack.relx - 25) / 18;
        int y = (stack.rely - 6) / 18;
        root.setCompoundTag(String.valueOf((x + y * 3)), stack.item.writeToNBT(new NBTTagCompound()));
    }
    PacketDispatcher.sendPacketToServer(NetworkHelper.makeNBTPacket(CHANNEL_NEI, root));

    ((AutoCrafterGui) firstGui).inventorySlots.getSlot(0).putStack(recipe.getResultStack(recipeIndex).item);
}
项目:Apocalyptic    文件:PacketHandler.java   
public static void LifePacketSender(double radiation, String name) {
    ByteArrayOutputStream bos = new ByteArrayOutputStream(8);
    DataOutputStream outputStream = new DataOutputStream(bos);
    try {
        outputStream.writeDouble(radiation);
    } catch (Exception ex) {
        ex.printStackTrace();
    }

    Packet250CustomPayload packet_sender = new Packet250CustomPayload();
    packet_sender.channel = "Apocalyptic-rad";
    packet_sender.data = bos.toByteArray();
    packet_sender.length = bos.size();

    if (side == Side.SERVER) {
        PacketDispatcher.sendPacketToPlayer(packet_sender, getPlayer(name));
    }
}
项目:Apocalyptic    文件:PacketHandler.java   
public static void BlockVisibilitySender(boolean result) {
    ByteArrayOutputStream bos = new ByteArrayOutputStream(8);
    DataOutputStream outputStream = new DataOutputStream(bos);
    try {
        outputStream.writeBoolean(result);
    } catch (Exception ex) {
        ex.printStackTrace();
    }

    Packet250CustomPayload packet_sender = new Packet250CustomPayload();
    packet_sender.channel = "Apocalyptic-bv";
    packet_sender.data = bos.toByteArray();
    packet_sender.length = bos.size();
    if (side == Side.SERVER) {
        PacketDispatcher.sendPacketToAllPlayers(packet_sender);
    }
}
项目:R0b0ts    文件:WindowIngameManual.java   
@Subscribe
public void onMouseClick(MouseClickEvent event)
{
    if (event.getComponent().getAction().equals(btnSit.getAction()))
    {
        bot.setSitting(!bot.isSitting());
        PacketDispatcher.sendPacketToServer(new PacketBuddyBotSit(bot.entityId).makePacket());
        btnSit.setText(bot.isSitting() ? LangHelper.translate("gui", "button.stand") : LangHelper.translate("gui", "button.sit"));
    }

    if (event.getComponent().getAction().equals(btnNext.getAction()))
    {
        if (currentPage < pages.size() - 1)
            setCurrentPage(currentPage + 1);
    }

    if (event.getComponent().getAction().equals(btnPrev.getAction()))
    {
        if (currentPage > 0)
            setCurrentPage(currentPage - 1);
    }
}
项目:ExtraCells1    文件:TileEntityTerminalFluid.java   
@Override
public void setGrid(IGridInterface gi)
{
    if (!worldObj.isRemote)
    {
        grid = gi;
        if (gi != null)
        {
            IMEInventoryHandler cellArray = gi.getCellArray();
            if (cellArray != null)
                updateFluids(cellArray.getAvailableItems());
        } else
        {
            setPowerStatus(false);
        }
        PacketDispatcher.sendPacketToAllPlayers(getDescriptionPacket());
    }
}
项目:ExtraCells1    文件:TileEntityTerminalFluid.java   
@ForgeSubscribe
public void onNetworkPatternChange(GridPatternUpdateEvent e)
{
    if (grid != null)
    {
        IMEInventoryHandler inventoryHandler = grid.getCraftableArray();
        if (inventoryHandler != null)
        {
            craftableFluidsInNetwork = new ArrayList<Fluid>();
            for (IAEItemStack stack : inventoryHandler.getAvailableItems())
            {
                if (stack.getItem() == FLUIDDISPLAY.getItemInstance())
                {
                    craftableFluidsInNetwork.add(FluidRegistry.getFluid(stack.getItemDamage()));
                }
            }
        }
    }
    PacketDispatcher.sendPacketToAllPlayers(getDescriptionPacket());
}
项目:Dota2Items    文件:ContainerShopBuy.java   
public void setResultItem(ItemStack stack) {
    if (stack != null) {
        if (stack.getItem() instanceof Dota2Item) {
            setResultItem((Dota2Item)stack.getItem());
        } else if (stack.itemID == Config.recipe.getID()) {
            invResult.setInventorySlotContents(0, ItemRecipe.copy(stack, false));
            if (invPlayer.player.worldObj.isRemote) {
                PacketDispatcher.sendPacketToServer(new ShopBuySetResultPacket(stack).makePacket());
            }
        }
    } else {
        invResult.setInventorySlotContents(0, null);
        if (invPlayer.player.worldObj.isRemote) {
            PacketDispatcher.sendPacketToServer(new ShopBuySetResultPacket(null).makePacket());
        }
    }
}
项目:secri    文件:GuiRenamePokemon.java   
protected void actionPerformed(GuiButton par1GuiButton) {
    if (!par1GuiButton.enabled) {
        return;
    }

    switch (par1GuiButton.id) {
    case 2:
        PacketDispatcher.sendPacketToServer(PacketCreator.createStringPacket(EnumPackets.RenamePokemon, targetPacket.pokemonID, ""));
        targetPacket.nickname = "";
        mc.displayGuiScreen(parentGuiScreen);
        break;
    case 1:
        mc.displayGuiScreen(parentGuiScreen);
    case 0:
            PacketDispatcher.sendPacketToServer(PacketCreator.createStringPacket(EnumPackets.RenamePokemon, targetPacket.pokemonID, theGuiTextField.getText()));
            targetPacket.nickname = theGuiTextField.getText();
        parentGuiScreen.initGui();
        mc.displayGuiScreen(parentGuiScreen);
    }
}
项目:secri    文件:GuiTrading.java   
protected void mouseClicked(int par1, int par2, int par3) {
    super.mouseClicked(par1, par2, par3);
    if (drawButtonReady(par1, par2) && selected >= 0) {
        if (ClientTradingManager.tradeTarget != null) {
            this.mc.sndManager.playSoundFX("random.click", 1.0F, 1.0F);
            ClientTradingManager.player1Ready = !ClientTradingManager.player1Ready;
            PacketDispatcher.sendPacketToServer(PacketCreator.createPacket(EnumPackets.SetTradingReady, ClientTradingManager.player1Ready ? 1 : 0));
        }
    }
    if (drawButtonTrade(par1, par2)) {
        if (ClientTradingManager.player1Ready && ClientTradingManager.player2Ready) {
            this.mc.sndManager.playSoundFX("random.click", 1.0F, 1.0F);
            PacketDispatcher.sendPacketToServer(PacketCreator.createPacket(EnumPackets.Trade, 0));
        }
    }
    if (drawPokemonSelection(par1, par2) != -1) {
        this.mc.sndManager.playSoundFX("random.click", 1.0F, 1.0F);
        this.selected = drawPokemonSelection(par1, par2);
        PacketDispatcher.sendPacketToServer(PacketCreator.createPacket(EnumPackets.SelectPokemonForTrade, selected));
    }
    if(drawButtonClose(par1, par2)){
        this.mc.sndManager.playSoundFX("random.click", 1.0F, 1.0F);
        mc.thePlayer.closeScreen();
    }
}
项目:WoodworkingTFC    文件:ContainerCarvingBase.java   
public void sendCarvingData(byte[] carvingData, Player player)
{
    try
    {
        ByteArrayOutputStream byteStream = new ByteArrayOutputStream(17);
        DataOutputStream dataStream = new DataOutputStream(byteStream);
        dataStream.writeByte(PacketHandler.CARVING_DATA);
        dataStream.writeInt(this.entityId);
        dataStream.writeInt(carvingData.length);
        dataStream.write(carvingData);

        Packet250CustomPayload packet = new Packet250CustomPayload();
        packet.channel = PacketHandler.CHANNEL_NAME;
        packet.data = byteStream.toByteArray();
        packet.length = packet.data.length;

        PacketDispatcher.sendPacketToPlayer(packet, player);
    }
    catch(Throwable tt)
    {
        tt.printStackTrace();
    }
}
项目:SimplePowerStorage    文件:TileEntityMachine.java   
public void rotate() {
    if (!worldObj.isRemote) {
        if (forwardDirection == ForgeDirection.DOWN) {
            forwardDirection = ForgeDirection.EAST;
        } else if (forwardDirection == ForgeDirection.EAST) {
            forwardDirection = ForgeDirection.SOUTH;
        } else if (forwardDirection == ForgeDirection.SOUTH) {
            forwardDirection = ForgeDirection.WEST;
        } else if (forwardDirection == ForgeDirection.WEST){
            forwardDirection = ForgeDirection.NORTH;
        } else if (forwardDirection == ForgeDirection.NORTH) {
            forwardDirection = ForgeDirection.UP;
        } else if (forwardDirection == ForgeDirection.UP) {
            forwardDirection = ForgeDirection.DOWN;
        } else {
            forwardDirection = ForgeDirection.NORTH;
        }

        worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
        PacketDispatcher.sendPacketToAllAround(xCoord, yCoord, zCoord, 50, worldObj.provider.dimensionId, getDescriptionPacket());
    }
}
项目:BL2    文件:NetworkHandlerClient.java   
@Override
public void sendReloaderPacket() {
    try {
        ByteArrayOutputStream baout = new ByteArrayOutputStream();
        DataOutputStream out = new DataOutputStream(baout);
        out.writeByte(reloadPacketID);
        out.close();
        Packet250CustomPayload packet = new Packet250CustomPayload();
        packet.channel = "bl2";
        packet.isChunkDataPacket = false;
        packet.data = baout.toByteArray();
        packet.length = baout.size();

        PacketDispatcher.sendPacketToServer(packet);
    } catch (Exception ex) {
        ex.printStackTrace();
    }
}
项目:spellbound    文件:SpellMeteor.java   
@Override
public void doSpellTargetEffect(World worldObj, int posX, int posY, int posZ, EntityLivingBase entityHit) 
{
    for (int i = 0; i < 3; i++)
    {
        final double nextX = SpellboundCore.modRandom.nextBoolean() ? SpellboundCore.modRandom.nextInt(15) + 10 : SpellboundCore.modRandom.nextInt(15) + 10 * -1;
        final double nextZ = SpellboundCore.modRandom.nextBoolean() ? SpellboundCore.modRandom.nextInt(15) + 10 : SpellboundCore.modRandom.nextInt(15) + 10 * -1;

        worldObj.spawnEntityInWorld(new EntityLightningBolt(worldObj, posX + nextX, posY, posZ + nextZ));
        PacketDispatcher.sendPacketToAllPlayers(PacketHandler.createLightningPacket(posX + nextX, posY, posZ + nextZ));
    }

    final EntityMeteor meteor = new EntityMeteor(caster, this);
    meteor.setPosition(posX + SpellboundCore.modRandom.nextGaussian(), 255, posZ + SpellboundCore.modRandom.nextGaussian());
    worldObj.spawnEntityInWorld(meteor);
}
项目:spellbound    文件:SpellLightningLvl2.java   
@Override
public void doSpellTargetEffect(World worldObj, int posX, int posY, int posZ, EntityLivingBase entityHit) 
{
    final double spawnX = entityHit == null ? posX : entityHit.posX;
    final double spawnY = entityHit == null ? posY : entityHit.posY;
    final double spawnZ = entityHit == null ? posZ : entityHit.posZ;

    if (entityHit instanceof EntityPlayer)
    {
        if (!SpellboundCore.getInstance().entityHasActiveSpell((EntityPlayer)entityHit, SpellShieldOfInvulnerability.class) && !SpellboundCore.getInstance().entityHasActiveSpell((EntityPlayer)entityHit, SpellLightningShield.class))
        {
            worldObj.spawnEntityInWorld(new EntityLightningBolt(worldObj, spawnX, spawnY, spawnZ));
            PacketDispatcher.sendPacketToAllPlayers(PacketHandler.createLightningPacket(spawnX, spawnY, spawnZ));
        }
    }

    else
    {
        worldObj.spawnEntityInWorld(new EntityLightningBolt(worldObj, spawnX, spawnY, spawnZ));
        PacketDispatcher.sendPacketToAllPlayers(PacketHandler.createLightningPacket(spawnX, spawnY, spawnZ));
    }
}
项目:spellbound    文件:SpellFlightLvl2.java   
@Override
public void doSpellCasterEffect(EntityPlayer caster) 
{
    caster.worldObj.playSoundAtEntity(caster, "mob.enderdragon.wings", 1.0F, 1.0F);

    if (caster.onGround)
    {
        caster.motionY += 1.0D;
    }

    caster.fallDistance = 0;
    caster.capabilities.allowFlying = true;
    caster.capabilities.isFlying = true;

    SpellboundCore.getInstance().addActiveSpellToEntity(caster, this, 400);
    PacketDispatcher.sendPacketToPlayer(PacketHandler.createFlightPacket(true), (Player) caster);
}
项目:spellbound    文件:SpellFlightLvl1.java   
@Override
public void doSpellCasterEffect(EntityPlayer caster) 
{
    caster.worldObj.playSoundAtEntity(caster, "mob.enderdragon.wings", 1.0F, 1.0F);

    if (caster.onGround)
    {
        caster.motionY += 1.0D;
    }

    caster.fallDistance = 0;
    caster.capabilities.allowFlying = true;
    caster.capabilities.isFlying = true;

    SpellboundCore.getInstance().addActiveSpellToEntity(caster, this, 20);
    PacketDispatcher.sendPacketToPlayer(PacketHandler.createFlightPacket(true), (Player) caster);
}
项目:spellbound    文件:AbstractSpellShield.java   
@Override
public final void doSpellCasterEffect(EntityPlayer caster) 
{
    this.caster = caster;

    if (this instanceof SpellShieldOfInvulnerability)
    {
        caster.worldObj.playSoundAtEntity(caster, "mob.wither.idle", 1.0F, 1.0F);
    }

    else
    {
        caster.worldObj.playSoundAtEntity(caster, "spellbound:shield", 1.0F, 1.0F);
    }

    SpellboundCore.getInstance().addActiveSpellToEntity(caster, this, getShieldDuration());
    PacketDispatcher.sendPacketToAllPlayers(PacketHandler.createShieldGFXPacket(this.getClass(), caster.posX, caster.posY, caster.posZ));
}
项目:ExtraCells1    文件:TileEntityMonitorStorageFluid.java   
@Override
public void onNetworkInventoryChange(IItemList iss)
{
    long lastAmount = fluidAmount;
    fluidAmount = 0;
    if (fluid != null)
    {
        for (IAEItemStack stack : iss)
        {
            if (stack != null && stack.getItem() == ItemEnum.FLUIDDISPLAY.getItemInstance() && stack.getItemDamage() == fluid.getID())
            {
                fluidAmount += stack.getStackSize();
            }
        }
    }
    if (lastAmount != fluidAmount)
    {
        lastAmount = fluidAmount;
        PacketDispatcher.sendPacketToAllPlayers(getDescriptionPacket());
    }
}
项目:ExtraCells1    文件:TileEntityTerminalFluid.java   
public void updateFluids(IItemList currentItems)
{
    fluidsInNetwork = new ArrayList<SpecialFluidStack>();

    if (grid != null)
    {
        for (IAEItemStack itemstack : currentItems)
        {
            if (itemstack.getItem() == FLUIDDISPLAY.getItemInstance() && itemstack.getStackSize() > 0)
            {
                fluidsInNetwork.add(new SpecialFluidStack(itemstack.getItemDamage(), itemstack.getStackSize()));
            }
        }
    }

    PacketDispatcher.sendPacketToAllPlayers(getDescriptionPacket());
}
项目:EnergyFromMatter    文件:NEIOverlayHandler.java   
@Override
public void overlayRecipe(GuiContainer gui, IRecipeHandler recipe,
        int recipeIndex, boolean shift)
{
    if (gui instanceof GuiMatterCreator)
    {
        ItemStack stack = recipe.getResultStack(recipeIndex).items[0];
        stack.stackSize = 1;
        if (EmcRegistry.hasEmcValue(stack))
        {
            TileMatterCreator tile = ((GuiMatterCreator) gui).tile;
            PacketDispatcher.sendPacketToServer(PacketTypeHandler
                    .populatePacket(new PacketSlotChange(tile.xCoord,
                            tile.yCoord, tile.zCoord, 0, stack)));
        }
    }
}
项目:Minecraft-VoiceChat    文件:CommandVoiceBase.java   
/**
 * {@inheritDoc}
 */
@Override
public void processCommand(final ICommandSender icommandsender,
        final String[] astring) {
    try {
        PacketCommandBase p = null;
        if (astring.length == 1) {
            p = createPacket(astring[0]);
        }
        if (p != null) {
            PacketDispatcher.sendPacketToPlayer(p.write(),
                    (Player) getCommandSenderAsPlayer(icommandsender));
        }
    } catch (final Exception e) {
        FMLLog.log(VoiceChat.MOD_ID, Level.SEVERE, e, "");
    }
}
项目:ExtraCells1    文件:TileEntityMonitorStorageFluid.java   
@Override
public void setGrid(IGridInterface gi)
{
    if (!worldObj.isRemote)
    {
        grid = gi;
        if (gi != null)
        {
            IMEInventoryHandler cellArray = gi.getCellArray();
            if (cellArray != null)
                onNetworkInventoryChange(cellArray.getAvailableItems());
        } else
        {
            setPowerStatus(false);
        }
        PacketDispatcher.sendPacketToAllPlayers(getDescriptionPacket());
    }
}
项目:ExtraCells1    文件:GuiBusFluidStorage.java   
@Override
protected void keyTyped(char key, int par2)
{
    if (textFieldPriority.isFocused())
    {
        textFieldPriority.textboxKeyTyped(key, par2);
        if (!textFieldPriority.getText().isEmpty())
        {
            try
            {
                int priority = Integer.valueOf(textFieldPriority.getText());
                PacketDispatcher.sendPacketToServer(new PacketBusFluidStorage(world, tileentity.xCoord, tileentity.yCoord, tileentity.zCoord, priority).makePacket());
            } catch (NumberFormatException e)
            {
            }

        }
    } else
    {
        super.keyTyped(key, par2);
    }
}
项目:StructureGenerationMod    文件:SGTPacketHandler.java   
public static final void sendPacketKeyPress(int keyCode)
{
    try {
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        DataOutputStream outputStream = new DataOutputStream(bos);

        try {
            outputStream.writeByte(SGTPacketHandler.PACKET_KEY_PRESS);
            outputStream.writeInt(keyCode);
        } finally {
            outputStream.close();
        }

        PacketDispatcher.sendPacketToServer(PacketDispatcher.getPacket(ModInfo.CHANNEL, bos.toByteArray()));

    } catch (Exception ex) {
        LogHelper.log(Level.SEVERE, "Failed to send key press packet.");
        ex.printStackTrace();
    }
}
项目:HudPlus    文件:HPHotbar.java   
protected void sendPacket(int selection) {
ByteArrayOutputStream bos = new ByteArrayOutputStream(8);
      DataOutputStream outputStream = new DataOutputStream(bos);
      try {
              outputStream.writeInt(selection);
              outputStream.writeInt(inv.currentItem);
      }
      catch (Exception ex) {
              ex.printStackTrace();
      }

      Packet250CustomPayload packet = new Packet250CustomPayload();
      packet.channel = HP_Ref.MOD_ID;
      packet.data = bos.toByteArray();
      packet.length = bos.size();
      PacketDispatcher.sendPacketToServer(packet);
      lastTick = 0;
  }
项目:Rival-Rebels-Mod    文件:GuiTray.java   
@Override
protected void keyTyped(char par1, int par2)
{
    if (par2 == 1)
    {
        this.mc.displayGuiScreen((GuiScreen) null);
        this.mc.setIngameFocus();
        PacketDispatcher.packetsys.sendToServer(new ADSClosePacket(r.xCoord, r.yCoord, r.zCoord, mobs.isPressed, chip.isPressed, players.isPressed, range.getDegree()*2));
    }
}
项目:MC-MineAPI.Java    文件:TileEntityPrefab.java   
/**
 * Sends base update packet for MadTileEntity containing position, progress, energy, fluids, textures, etc.
 */
private void sendUpdatePacket()
{
    // Send update to clients that require it.
    PacketDispatcher.sendPacketToAllAround( this.xCoord,
                                            this.yCoord,
                                            this.zCoord,
                                            ModLoader.PACKET_SEND_RADIUS,
                                            worldObj.provider.dimensionId,
                                            new TileTemplatePacket( this ).makePacket() );
}
项目:MC-MineAPI.Java    文件:PacketList.java   
public final Packet makePacket()
{
    ByteArrayDataOutput out = ByteStreams.newDataOutput();
    out.writeByte( getPacketId() );
    write( out );
    return PacketDispatcher.getPacket( ModMetadata.CHANNEL_NAME,
                                       out.toByteArray() );
}
项目:CcmBurialServicesInc    文件:GraveUpgradeGui.java   
public void onGuiClosed()
{
    Keyboard.enableRepeatEvents(false);
    NetClientHandler netclienthandler = this.mc.getNetHandler();

    if (MinecraftServer.getServer().isSinglePlayer())
    {
        MiscHelper.setPersistentDataTag(MinecraftServer.getServer().getConfigurationManager().getPlayerForUsername(MinecraftServer.getServer().getServerOwner()), BSConstants.NBT_PLAYER_GRAVE_DATA, data);
    }
    else if (netclienthandler != null)
    {
        PacketDispatcher.sendPacketToServer(NetworkHelper.makeNBTPacket(BSConstants.CHANNEL_GRAVE_UPGRADE, data));
    }
}
项目:CcmBurialServicesInc    文件:EventHandler.java   
/**
 * For catching interactions with the Undertaker
 */
@ForgeSubscribe
public void interactEvent(EntityInteractEvent event)
{
    if (event.target instanceof EntityVillager && ((EntityVillager) event.target).getProfession() == BurialServices.getConfig().villagerID)
    {
        if (FMLCommonHandler.instance().getSide().isServer())
        {
            PacketDispatcher.sendPacketToPlayer(NetworkHelper.makeNBTPacket(BSConstants.CHANNEL_GRAVE_UPGRADE, MiscHelper.getPersistentDataTag(event.entityPlayer, BSConstants.NBT_PLAYER_GRAVE_DATA)), (Player) event.entityPlayer);
        }
        event.setCanceled(MinecraftServer.getServer().isSinglePlayer());
        FMLNetworkHandler.openGui(event.entityPlayer, BurialServices.instance, GuiHandler.undertakerID, event.entityPlayer.worldObj, 0, 0, 0);
    }
}
项目:MineFantasy    文件:EntityThrownSpear.java   
public void syncSpear() 
   {
    if(!worldObj.isRemote)
    {
        try
        {
            Packet packet = PacketManagerMF.getPacketItemStackArray(this, 0, getSpear());
            PacketDispatcher.sendPacketToAllPlayers(packet);
        }catch(Exception e){}
    }
}