public Packet getDescriptionPacket() { NBTTagCompound root = new NBTTagCompound(); NBTTagList nbttaglist = root.getTagList("contents"); for (ItemStack itemStack : contents) { nbttaglist.appendTag(itemStack == null ? new NBTTagCompound() : itemStack.writeToNBT(new NBTTagCompound())); } root.setTag("contents", nbttaglist); root.setString("username", username); root.setCompoundTag("holding", holding == null ? new NBTTagCompound() : holding.writeToNBT(new NBTTagCompound())); root.setString("text", BSConstants.TEXT_JOINER.join(text)); root.setInteger("age", age); return new Packet132TileEntityData(xCoord, yCoord, zCoord, 15, root); }
private void syncItems() { if(!worldObj.isRemote) { for(int a = 0; a < armour.length; a ++) { Packet packet = PacketManagerMF.getPacketItemStackArray(this, a, armour[a]); try { FMLCommonHandler.instance().getMinecraftServerInstance().getConfigurationManager().sendPacketToAllPlayers(packet); } catch(NullPointerException e) { System.out.println("MineFantasy: Client connection lost"); return; } } } }
public void func_96546_g(ScoreObjective par1ScoreObjective) { List list = this.func_96548_f(par1ScoreObjective); Iterator iterator = this.field_96555_a.getConfigurationManager().playerEntityList.iterator(); while (iterator.hasNext()) { EntityPlayerMP entityplayermp = (EntityPlayerMP)iterator.next(); Iterator iterator1 = list.iterator(); while (iterator1.hasNext()) { Packet packet = (Packet)iterator1.next(); entityplayermp.playerNetServerHandler.sendPacketToPlayer(packet); } } this.field_96553_b.remove(par1ScoreObjective); }
@SideOnly(Side.CLIENT) public static MerchantRecipeList func_77204_a(DataInputStream p_77204_0_) throws IOException { MerchantRecipeList var1 = new MerchantRecipeList(); int var2 = p_77204_0_.readByte() & 255; for(int var3 = 0; var3 < var2; ++var3) { ItemStack var4 = Packet.func_73276_c(p_77204_0_); ItemStack var5 = Packet.func_73276_c(p_77204_0_); ItemStack var6 = null; if(p_77204_0_.readBoolean()) { var6 = Packet.func_73276_c(p_77204_0_); } boolean var7 = p_77204_0_.readBoolean(); MerchantRecipe var8 = new MerchantRecipe(var4, var6, var5); if(var7) { var8.func_82785_h(); } var1.add(var8); } return var1; }
private void syncItems() { recipe = getNewRecipe(); maxProgress = this.getMaxTime(); if(!worldObj.isRemote) { for(int a = 0; a < inv.length; a ++) { Packet packet = PacketManagerMF.getPacketItemStackArray(this, a, inv[a]); try { FMLCommonHandler.instance().getMinecraftServerInstance().getConfigurationManager().sendPacketToAllPlayers(packet); } catch(NullPointerException e) { System.out.println("MineFantasy: Client connection lost"); return; } } } }
public void writeRecipiesToStream(DataOutputStream par1DataOutputStream) throws IOException { par1DataOutputStream.writeByte((byte)(this.size() & 255)); for (int i = 0; i < this.size(); ++i) { MerchantRecipe merchantrecipe = (MerchantRecipe)this.get(i); Packet.writeItemStack(merchantrecipe.getItemToBuy(), par1DataOutputStream); Packet.writeItemStack(merchantrecipe.getItemToSell(), par1DataOutputStream); ItemStack itemstack = merchantrecipe.getSecondItemToBuy(); par1DataOutputStream.writeBoolean(itemstack != null); if (itemstack != null) { Packet.writeItemStack(itemstack, par1DataOutputStream); } par1DataOutputStream.writeBoolean(merchantrecipe.func_82784_g()); } }
private void sendPacketToClients() { if (!worldObj.isRemote) { try { Packet packet = PacketManagerMF.getPacketIntegerArray(this, new int[] { (int)fuel, progress, direction, isBurning() ? 1 : 0, doorAngle }); FMLCommonHandler.instance().getMinecraftServerInstance() .getConfigurationManager() .sendPacketToAllPlayers(packet); } catch (Exception e) { e.printStackTrace(); } } }
public void syncItems() { if(!worldObj.isRemote) { for(int a = 0; a < items.length; a ++) { Packet packet = PacketManagerMF.getPacketItemStackArray(this, a, items[a]); try { FMLCommonHandler.instance().getMinecraftServerInstance().getConfigurationManager().sendPacketToAllPlayers(packet); } catch(NullPointerException e) { System.out.println("MineFantasy: Client connection lost"); return; } } } }
public void func_77200_a(DataOutputStream p_77200_1_) throws IOException { p_77200_1_.writeByte((byte)(this.size() & 255)); for(int var2 = 0; var2 < this.size(); ++var2) { MerchantRecipe var3 = (MerchantRecipe)this.get(var2); Packet.func_73270_a(var3.func_77394_a(), p_77200_1_); Packet.func_73270_a(var3.func_77397_d(), p_77200_1_); ItemStack var4 = var3.func_77396_b(); p_77200_1_.writeBoolean(var4 != null); if(var4 != null) { Packet.func_73270_a(var4, p_77200_1_); } p_77200_1_.writeBoolean(var3.func_82784_g()); } }
public void func_96546_g(ScoreObjective p_96546_1_) { List var2 = this.func_96548_f(p_96546_1_); Iterator var3 = this.field_96555_a.func_71203_ab().field_72404_b.iterator(); while(var3.hasNext()) { EntityPlayerMP var4 = (EntityPlayerMP)var3.next(); Iterator var5 = var2.iterator(); while(var5.hasNext()) { Packet var6 = (Packet)var5.next(); var4.field_71135_a.func_72567_b(var6); } } this.field_96553_b.remove(p_96546_1_); }
public void splashWater() { if(!isBurning())return; heat -= 100; if(heat < 0)heat = 0; worldObj.playSound(xCoord+0.5F, yCoord+0.4F, zCoord+0.5F, "random.fizz", 1.0F, 1.0F, true); worldObj.spawnParticle("smoke", xCoord+0.5F, yCoord+0.4F, zCoord+0.5F, 0, 0.05F, 0); if (!worldObj.isRemote) { try { Packet packet = PacketManagerMF.getPacketIntegerArray(this, new int[] {1, 0}); FMLCommonHandler.instance().getMinecraftServerInstance() .getConfigurationManager() .sendPacketToAllPlayers(packet); } catch (NullPointerException e) { e.printStackTrace(); } } }
/** * params: srcPlayer,x,y,z,d,dimension. The packet is not sent to the srcPlayer, but all other players where * dx*dx+dy*dy+dz*dz<d*d */ public void sendToAllNearExcept(EntityPlayer par1EntityPlayer, double par2, double par4, double par6, double par8, int par10, Packet par11Packet) { for (int j = 0; j < this.playerEntityList.size(); ++j) { EntityPlayerMP entityplayermp = (EntityPlayerMP)this.playerEntityList.get(j); if (entityplayermp != par1EntityPlayer && entityplayermp.dimension == par10) { double d4 = par2 - entityplayermp.posX; double d5 = par4 - entityplayermp.posY; double d6 = par6 - entityplayermp.posZ; if (d4 * d4 + d5 * d5 + d6 * d6 < par8 * par8) { entityplayermp.playerNetServerHandler.sendPacketToPlayer(par11Packet); } } } }
public static Packet getEntityPacketInteger(Entity entity, int dat) { ByteArrayOutputStream bos = new ByteArrayOutputStream(140); DataOutputStream dos = new DataOutputStream(bos); int id = entity.entityId; try { dos.writeInt(1); dos.writeInt(id); dos.writeInt(dat); } catch (IOException e) { System.out.println("Failed to send Entity packet"); } Packet250CustomPayload pkt = new Packet250CustomPayload(); pkt.channel = "MineFantasy"; pkt.data = bos.toByteArray(); pkt.length = bos.size(); pkt.isChunkDataPacket = true; return pkt; }
public static Packet getEntityPacketIntegerArray(Entity entity, int[] dat) { ByteArrayOutputStream bos = new ByteArrayOutputStream(140); DataOutputStream dos = new DataOutputStream(bos); int id = entity.entityId; try { dos.writeInt(1); dos.writeInt(id); for(int a = 0; a < dat.length; a ++) dos.writeInt(dat[a]); } catch (IOException e) { System.out.println("Failed to send Entity packet"); } Packet250CustomPayload pkt = new Packet250CustomPayload(); pkt.channel = "MineFantasy"; pkt.data = bos.toByteArray(); pkt.length = bos.size(); pkt.isChunkDataPacket = true; return pkt; }
public static Packet getEntityPacketMotionArray(Entity entity, int moveID, double[] dat) { ByteArrayOutputStream bos = new ByteArrayOutputStream(140); DataOutputStream dos = new DataOutputStream(bos); int id = entity.entityId; try { dos.writeInt(1); dos.writeInt(id); dos.writeInt(moveID); for(int a = 0; a < dat.length; a ++) dos.writeDouble(dat[a]); } catch (IOException e) { System.out.println("Failed to send Entity packet"); } Packet250CustomPayload pkt = new Packet250CustomPayload(); pkt.channel = "MineFantasy"; pkt.data = bos.toByteArray(); pkt.length = bos.size(); pkt.isChunkDataPacket = true; return pkt; }
public static Packet getEntityRenamePacket(INameableEntity namer, String dat) { ByteArrayOutputStream bos = new ByteArrayOutputStream(140); DataOutputStream dos = new DataOutputStream(bos); int id = namer.getEntityID(); try { dos.writeInt(3); dos.writeInt(id); dos.writeInt(dat.length()); dos.writeChars(dat); } catch (IOException e) { System.out.println("Failed to send Name packet"); } Packet250CustomPayload pkt = new Packet250CustomPayload(); pkt.channel = "MineFantasy"; pkt.data = bos.toByteArray(); pkt.length = bos.size(); pkt.isChunkDataPacket = true; return pkt; }
public static Packet getPacketItemStackArray(Entity entity, int slot, ItemStack item) { ByteArrayOutputStream bos = new ByteArrayOutputStream(140); DataOutputStream dos = new DataOutputStream(bos); try { dos.writeInt(4); dos.writeInt(entity.entityId); dos.writeInt(slot); writeItemStack(item, dos); } catch (IOException e) { System.out.println("Failed to send sync Item packet for entity"); } Packet250CustomPayload pkt = new Packet250CustomPayload(); pkt.channel = "MineFantasy"; pkt.data = bos.toByteArray(); pkt.length = bos.size(); pkt.isChunkDataPacket = true; return pkt; }
public Packet toPacket() { ByteArrayOutputStream bytes = new ByteArrayOutputStream(); DataOutputStream data = new DataOutputStream(bytes); Packet250CustomPayload pkt = new Packet250CustomPayload(); try { writeData(data); } catch (IOException e) { e.printStackTrace(); } pkt.channel = "Billund"; pkt.data = bytes.toByteArray(); pkt.length = pkt.data.length; return pkt; }
protected void func_96456_a(ServerScoreboard p_96456_1_, EntityPlayerMP p_96456_2_) { HashSet var3 = new HashSet(); Iterator var4 = p_96456_1_.func_96525_g().iterator(); while(var4.hasNext()) { ScorePlayerTeam var5 = (ScorePlayerTeam)var4.next(); p_96456_2_.field_71135_a.func_72567_b(new Packet209SetPlayerTeam(var5, 0)); } for(int var9 = 0; var9 < 3; ++var9) { ScoreObjective var10 = p_96456_1_.func_96539_a(var9); if(var10 != null && !var3.contains(var10)) { List var6 = p_96456_1_.func_96550_d(var10); Iterator var7 = var6.iterator(); while(var7.hasNext()) { Packet var8 = (Packet)var7.next(); p_96456_2_.field_71135_a.func_72567_b(var8); } var3.add(var10); } } }
public void func_74428_b() { int var1 = 2500; while(var1-- >= 0 && !this.field_74442_b.isEmpty()) { Packet var2 = (Packet)this.field_74442_b.remove(0); var2.func_73279_a(this.field_74440_d); } if(this.field_74442_b.size() > var1) { this.field_98214_c.func_98236_b("Memory connection overburdened; after processing 2500 packets, we still have " + this.field_74442_b.size() + " to go!"); } if(this.field_74441_e && this.field_74442_b.isEmpty()) { this.field_74440_d.func_72515_a(this.field_74438_f, this.field_74439_g); } }
protected void func_73875_a(GuiButton p_73875_1_) { if(p_73875_1_.field_73742_g) { if(p_73875_1_.field_73741_f == 1) { this.field_73882_e.func_71373_a((GuiScreen)null); } else if(p_73875_1_.field_73741_f == 0) { String var2 = "MC|AdvCdm"; ByteArrayOutputStream var3 = new ByteArrayOutputStream(); DataOutputStream var4 = new DataOutputStream(var3); try { var4.writeInt(this.field_82317_b.field_70329_l); var4.writeInt(this.field_82317_b.field_70330_m); var4.writeInt(this.field_82317_b.field_70327_n); Packet.func_73271_a(this.field_82318_a.func_73781_b(), var4); this.field_73882_e.func_71391_r().func_72552_c(new Packet250CustomPayload(var2, var3.toByteArray())); } catch (Exception var6) { var6.printStackTrace(); } this.field_73882_e.func_71373_a((GuiScreen)null); } } }
public final Packet makePacket() { ByteArrayDataOutput out = ByteStreams.newDataOutput(); out.writeByte( getPacketId() ); write( out ); return PacketDispatcher.getPacket( ModMetadata.CHANNEL_NAME, out.toByteArray() ); }
/** * called from onUpdate for all tileEntity in specific chunks */ private void sendTileEntityToPlayer(TileEntity par1TileEntity) { if (par1TileEntity != null) { Packet packet = par1TileEntity.getDescriptionPacket(); if (packet != null) { this.playerNetServerHandler.sendPacketToPlayer(packet); } } }
public void sendTrackerPacket() { try { Packet packet = PacketManagerMF.getEntityPacketDoubleArray(this, new double[]{posX, posY, posZ, motionX, motionY, motionZ, rotationPitch, rotationYaw, prevRotationPitch, prevRotationYaw}); FMLCommonHandler.instance().getMinecraftServerInstance() .getConfigurationManager() .sendPacketToAllPlayers(packet); } catch (NullPointerException e) { ; } }
private void sendQuickPackets() { try { Packet packet = PacketManagerMF.getEntityPacketIntegerArray(this, new int[]{1, attackMob ? 1 : 0, attackAnimal ? 1 : 0, attackPlayer ? 1 : 0, attackDefense ? 1 : 0 ,fightPvp ? 1 : 0 , leapAttack ? 1 : 0 , pickupItems ? 1 : 0 , boostStep ? 1 : 0, inPack ? 1 : 0, (int)trust, invertSpots}); FMLCommonHandler.instance().getMinecraftServerInstance() .getConfigurationManager() .sendPacketToAllPlayers(packet); } catch (NullPointerException e) { ; } }
/** * Sends a packet to all players in the specified Dimension */ public void sendPacketToAllPlayersInDimension(Packet par1Packet, int par2) { for (int j = 0; j < this.playerEntityList.size(); ++j) { EntityPlayerMP entityplayermp = (EntityPlayerMP)this.playerEntityList.get(j); if (entityplayermp.dimension == par2) { entityplayermp.playerNetServerHandler.sendPacketToPlayer(par1Packet); } } }
@SideOnly(Side.CLIENT) public void levelFromClient(int id) { try { Packet packet = PacketManagerMF.getEntityPacketIntegerArray(this, new int[]{4, id}); PacketDispatcher.sendPacketToServer(packet); FMLCommonHandler.instance().getMinecraftServerInstance() .getConfigurationManager() .sendPacketToAllPlayers(packet); } catch (NullPointerException e) { ; } }
@SideOnly(Side.CLIENT) public void usePower(int id) { try { Packet packet = PacketManagerMF.getEntityPacketIntegerArray(this, new int[]{3, id}); PacketDispatcher.sendPacketToServer(packet); FMLCommonHandler.instance().getMinecraftServerInstance() .getConfigurationManager() .sendPacketToAllPlayers(packet); } catch (NullPointerException e) { ; } }
public void unused() { int a1 = -1; int a2 = -1; int s1 = 1; int s2 = 1; int d1 = 0; int d2 = 0; if(armour[0] != null) { a1 = armour[0].itemID; s1 = armour[0].stackSize; d1 = armour[0].getItemDamage(); } if(armour[1] != null) { a2 = armour[1].itemID; s2 = armour[1].stackSize; d2 = armour[1].getItemDamage(); } try { Packet packet = PacketManagerMF.getEntityPacketIntegerArray(this, new int[]{5, a1, s1, d1, a2, s2, d2}); FMLCommonHandler.instance().getMinecraftServerInstance() .getConfigurationManager() .sendPacketToAllPlayers(packet); } catch (NullPointerException e) { ; } }
/** * Adds an arrow to an item for rendering arrow = null when taking it off * @param bow the bow used * @param arrow the arrow applied */ public static void loadArrow(EntityPlayer player, ItemStack bow, ItemStack arrow, boolean sendPacket) { NBTTagCompound nbt = getOrApplyNBT(bow); if(arrow == null) { nbt.removeTag("arrowID"); nbt.removeTag("arrowSub"); } else { nbt.setInteger("arrowID", arrow.itemID); nbt.setInteger("arrowSub", arrow.getItemDamage()); if(sendPacket) { try { Packet packet = PacketManagerMF.getArrowItemPacket(player, arrow.itemID, arrow.getItemDamage()); PacketDispatcher.sendPacketToAllAround(player.posX, player.posY, player.posZ, 16D, player.dimension, packet); } catch(Exception e) { System.err.println("MineFantasy: Failed to send arrow render packet to bow"); } } } }
@Override public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int i, float f, float f1, float f2) { TileEntitySpinningWheel tile = (TileEntitySpinningWheel) 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"); } } ItemStack held = player.getHeldItem(); if(held != null && held.itemID == Block.cloth.blockID) { return true; } return super.onBlockActivated(world, x, y, z, player, i, f, f1, f2); }
private void sendPacketToClients() { if(!worldObj.isRemote) { Packet packet = PacketManagerMF.getPacketIntegerArray(this, new int[]{0, progress, maxProgress, direction}); try { FMLCommonHandler.instance().getMinecraftServerInstance().getConfigurationManager().sendPacketToAllPlayers(packet); } catch(NullPointerException e) { System.out.println("MineFantasy: Client connection lost"); } } }
private void sendPacketToClients() { int id = 0; int meta = 0; int enc = 0; if(inv[0] != null) { id = inv[0].itemID; meta = inv[0].getItemDamage(); enc = inv[0].isItemEnchanted() ? 1 : 0; } int id2 = 0; int meta2 = 0; if(inv[1] != null) { id2 = inv[1].itemID; meta2 = inv[1].getItemDamage(); } if(!worldObj.isRemote || FMLCommonHandler.instance().getSide().isServer()) { try { Packet packet = PacketManagerMF.getPacketIntegerArray(this, new int[]{direction, id, meta, id2, meta2, enc, progBar}); FMLCommonHandler.instance().getMinecraftServerInstance().getConfigurationManager().sendPacketToAllPlayers(packet); } catch(NullPointerException e) { System.out.println("MineFantasy: Client connections lost"); } } }
public void func_72396_a(Packet p_72396_1_, int p_72396_2_) { for(int var3 = 0; var3 < this.field_72404_b.size(); ++var3) { EntityPlayerMP var4 = (EntityPlayerMP)this.field_72404_b.get(var3); if(var4.field_71093_bK == p_72396_2_) { var4.field_71135_a.func_72567_b(p_72396_1_); } } }
@Deprecated public static void serverSendPacket(NetServerHandler handler, Packet packet) { if (handler != null) { PacketDispatcher.sendPacketToPlayer(packet, (Player)handler.getPlayer()); } }
/** * Overriden in a sign to provide the text. */ public Packet getDescriptionPacket() { NBTTagCompound nbttagcompound = new NBTTagCompound(); this.writeToNBT(nbttagcompound); return new Packet132TileEntityData(this.xCoord, this.yCoord, this.zCoord, 2, nbttagcompound); }
public void sendPacketToServer() { if(worldObj.isRemote) { try { Packet packet = PacketManagerMF.getPacketIntegerArray(this, new int[]{direction, getItemID(0), getItemID(1), getItemID(2), getItemID(3), getItemID(4)}); PacketDispatcher.sendPacketToServer(packet); } catch(NullPointerException e) { e.printStackTrace(); } } }
/** * Adds the packet to the send queue */ public void addToSendQueue(Packet par1Packet) { if (!this.disconnected) { this.netManager.addToSendQueue(par1Packet); } }