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); }
@Override public void onPacketData(INetworkManager manager, Packet250CustomPayload packet, Player player) { try { if (packet.channel.equals(CHANNEL_GRAVE_UPGRADE)) { if (FMLCommonHandler.instance().getEffectiveSide().isClient()) { if (Minecraft.getMinecraft().currentScreen instanceof GraveUpgradeGui) { ((GraveUpgradeGui) (Minecraft.getMinecraft().currentScreen)).updateInfoFromPacket(NetworkHelper.byteArrayToNBT(packet.data)); } } else { MiscHelper.setPersistentDataTag((EntityPlayer) player, BSConstants.NBT_PLAYER_GRAVE_DATA, NetworkHelper.byteArrayToNBT(packet.data)); } } } catch (Exception e) { e.printStackTrace(); } }
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 getEntityPacketDoubleArray(Entity entity, double[] 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.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 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 getPacketInteger(TileEntity tile, int data) { ByteArrayOutputStream bos = new ByteArrayOutputStream(140); DataOutputStream dos = new DataOutputStream(bos); int x = tile.xCoord; int y = tile.yCoord; int z = tile.zCoord; int dat = data; try { dos.writeInt(0); dos.writeInt(x); dos.writeInt(y); dos.writeInt(z); dos.writeInt(dat); } catch (IOException e) { System.out.println("Failed to send tile Entity packet for tile entity"); } Packet250CustomPayload pkt = new Packet250CustomPayload(); pkt.channel = "MineFantasy"; pkt.data = bos.toByteArray(); pkt.length = bos.size(); pkt.isChunkDataPacket = true; return pkt; }
public static Packet getPacketMFResult(TileEntity tile, ItemStack item) { ByteArrayOutputStream bos = new ByteArrayOutputStream(140); DataOutputStream dos = new DataOutputStream(bos); int x = tile.xCoord; int y = tile.yCoord; int z = tile.zCoord; try { dos.writeInt(6); dos.writeInt(x); dos.writeInt(y); dos.writeInt(z); writeItemStack(item, dos); } catch (IOException e) { System.out.println("Failed to send tile Entity packet for tile entity"); } Packet250CustomPayload pkt = new Packet250CustomPayload(); pkt.channel = "MineFantasy"; pkt.data = bos.toByteArray(); pkt.length = bos.size(); pkt.isChunkDataPacket = true; return pkt; }
public static Packet getPacketIntegerArray(TileEntity tile, int[] data) { ByteArrayOutputStream bos = new ByteArrayOutputStream(140); DataOutputStream dos = new DataOutputStream(bos); int x = tile.xCoord; int y = tile.yCoord; int z = tile.zCoord; try { dos.writeInt(0); dos.writeInt(x); dos.writeInt(y); dos.writeInt(z); for(int i = 0; i < data.length ; i ++) dos.writeInt(data[i]); } catch (IOException e) { System.out.println("Failed to send tile Entity packet for tile entity"); } 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 getArrowItemPacket(EntityPlayer player, int ID, int Meta) { ByteArrayOutputStream bos = new ByteArrayOutputStream(140); DataOutputStream dos = new DataOutputStream(bos); int playerID = player.entityId; try { dos.writeInt(5); dos.writeInt(playerID); dos.writeInt(ID); dos.writeInt(Meta); } catch (IOException e) { System.out.println("Failed to send Load Arrow 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(TileEntity tile, int slot, ItemStack item) { ByteArrayOutputStream bos = new ByteArrayOutputStream(140); DataOutputStream dos = new DataOutputStream(bos); int x = tile.xCoord; int y = tile.yCoord; int z = tile.zCoord; try { dos.writeInt(2); dos.writeInt(x); dos.writeInt(y); dos.writeInt(z); dos.writeInt(slot); writeItemStack(item, dos); } catch (IOException e) { System.out.println("Failed to send tile Entity packet for tile entity"); } 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; }
@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; }
@Override public void onPacketData(INetworkManager manager, Packet250CustomPayload packet, Player player) { if (player instanceof EntityPlayerMP) { EntityPlayerMP playerMP = (EntityPlayerMP) player; RemoteKey rk = new RemoteKey(packet); Map<String, Boolean> playerKeyMap; if (!playerKeys.containsKey(playerMP.username)) { playerKeyMap = new HashMap<String, Boolean>(); playerKeys.put(playerMP.username, playerKeyMap); } else { playerKeyMap = playerKeys.get(playerMP.username); } playerKeyMap.put(rk.getName(), rk.isDown()); } }
public static void onPacketData(INetworkManager manager, Packet250CustomPayload packet, EntityPlayer player) { if (!packet.channel.equals(channel)) return; packet.channel=channelDummy; DataInputStream inputStream = new DataInputStream(new ByteArrayInputStream(packet.data)); try { byte index = inputStream.readByte(); if (index >= items.size()) { return; } items.get(index).onData(inputStream, player); } catch (IOException e) { e.printStackTrace(); } }
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; }
private void handleStats(Packet250CustomPayload packet, Player player, DataInputStream inputStream){ FCraftJobCore props = FCraftJobCore.get((EntityPlayer) player); float[] newStats = new float[4]; try { for(int i=0;i<4;i++){ newStats[i] = inputStream.readFloat(); } props.setStats(newStats[0], newStats[1], newStats[2], newStats[3]); props.setLevelUpPoints(inputStream.readInt()); props.setLevel(inputStream.readInt()); props.setMaxExperience(inputStream.readInt()); props.setCurrentMateria(inputStream.readInt()); } catch (IOException e) { e.printStackTrace(); } }
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)); } }
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); } }
public void handlePacket(Packet250CustomPayload packet){ DataInputStream inputStream = new DataInputStream(new ByteArrayInputStream(packet.data)); int randomInt1; int randomInt2; try{ randomInt1 = inputStream.readInt(); randomInt2 = inputStream.readInt(); }catch(IOException e){ e.printStackTrace(); return; } System.out.println(randomInt1 + "" + randomInt2); }
@Override public void onPacketData(INetworkManager manager, Packet250CustomPayload packet, Player player) { EntityPlayer sender = (EntityPlayer) player; if (packet.channel.equals(Resources.PACKET_CHANNEL)) { DataInputStream data = new DataInputStream(new ByteArrayInputStream(packet.data)); int id = -1; try { id = data.readInt(); } catch (IOException e) { e.printStackTrace(); } } }
@Override public void onPacketData(INetworkManager manager, Packet250CustomPayload packet, Player player) { if (packet.channel.equals(Resources.PACKET_CHANNEL)) { DataInputStream data = new DataInputStream(new ByteArrayInputStream(packet.data)); try { int id = -1; id = data.readInt(); EntityPlayer p = (EntityPlayer) player; } catch (IOException e) { e.printStackTrace(); } } }
public void func_71030_a(IMerchant p_71030_1_, String p_71030_2_) { this.func_71117_bO(); this.field_71070_bA = new ContainerMerchant(this.field_71071_by, p_71030_1_, this.field_70170_p); this.field_71070_bA.field_75152_c = this.field_71139_cq; this.field_71070_bA.func_75132_a(this); InventoryMerchant var3 = ((ContainerMerchant)this.field_71070_bA).func_75174_d(); this.field_71135_a.func_72567_b(new Packet100OpenWindow(this.field_71139_cq, 6, p_71030_2_ == null?"":p_71030_2_, var3.func_70302_i_(), p_71030_2_ != null)); MerchantRecipeList var4 = p_71030_1_.func_70934_b(this); if(var4 != null) { try { ByteArrayOutputStream var5 = new ByteArrayOutputStream(); DataOutputStream var6 = new DataOutputStream(var5); var6.writeInt(this.field_71139_cq); var4.func_77200_a(var6); this.field_71135_a.func_72567_b(new Packet250CustomPayload("MC|TrList", var5.toByteArray())); } catch (IOException var7) { var7.printStackTrace(); } } }
public void func_72501_a(Packet250CustomPayload p_72501_1_) { if("MC|TrList".equals(p_72501_1_.field_73630_a)) { DataInputStream var2 = new DataInputStream(new ByteArrayInputStream(p_72501_1_.field_73629_c)); try { int var3 = var2.readInt(); GuiScreen var4 = this.field_72563_h.field_71462_r; if(var4 != null && var4 instanceof GuiMerchant && var3 == this.field_72563_h.field_71439_g.field_71070_bA.field_75152_c) { IMerchant var5 = ((GuiMerchant)var4).func_74199_h(); MerchantRecipeList var6 = MerchantRecipeList.func_77204_a(var2); var5.func_70930_a(var6); } } catch (IOException var7) { var7.printStackTrace(); } } else if("MC|Brand".equals(p_72501_1_.field_73630_a)) { this.field_72563_h.field_71439_g.func_142020_c(new String(p_72501_1_.field_73629_c, Charsets.UTF_8)); } }
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 Packet getPacket() { ByteArrayOutputStream bytes = new ByteArrayOutputStream(); DataOutputStream data = new DataOutputStream(bytes); try { data.writeByte(getID()); writeData(data); } catch (IOException e) { e.printStackTrace(); } Packet250CustomPayload packet = new Packet250CustomPayload(); packet.channel = channel; packet.data = bytes.toByteArray(); packet.length = packet.data.length; packet.isChunkDataPacket = this.isChunkDataPacket; return packet; }
public void displayGUIMerchant(IMerchant par1IMerchant, String par2Str) { this.incrementWindowID(); this.openContainer = new ContainerMerchant(this.inventory, par1IMerchant, this.worldObj); this.openContainer.windowId = this.currentWindowId; this.openContainer.addCraftingToCrafters(this); InventoryMerchant inventorymerchant = ((ContainerMerchant)this.openContainer).getMerchantInventory(); this.playerNetServerHandler.sendPacketToPlayer(new Packet100OpenWindow(this.currentWindowId, 6, par2Str == null ? "" : par2Str, inventorymerchant.getSizeInventory(), par2Str != null)); MerchantRecipeList merchantrecipelist = par1IMerchant.getRecipes(this); if (merchantrecipelist != null) { try { ByteArrayOutputStream bytearrayoutputstream = new ByteArrayOutputStream(); DataOutputStream dataoutputstream = new DataOutputStream(bytearrayoutputstream); dataoutputstream.writeInt(this.currentWindowId); merchantrecipelist.writeRecipiesToStream(dataoutputstream); this.playerNetServerHandler.sendPacketToPlayer(new Packet250CustomPayload("MC|TrList", bytearrayoutputstream.toByteArray())); } catch (IOException ioexception) { ioexception.printStackTrace(); } } }
public void handleLogin(Packet1Login par1Packet1Login) { this.mc.playerController = new PlayerControllerMP(this.mc, this); this.mc.statFileWriter.readStat(StatList.joinMultiplayerStat, 1); this.worldClient = new WorldClient(this, new WorldSettings(0L, par1Packet1Login.gameType, false, par1Packet1Login.hardcoreMode, par1Packet1Login.terrainType), par1Packet1Login.dimension, par1Packet1Login.difficultySetting, this.mc.mcProfiler, this.mc.getLogAgent()); this.worldClient.isRemote = true; this.mc.loadWorld(this.worldClient); this.mc.thePlayer.dimension = par1Packet1Login.dimension; this.mc.displayGuiScreen(new GuiDownloadTerrain(this)); this.mc.thePlayer.entityId = par1Packet1Login.clientEntityId; this.currentServerMaxPlayers = par1Packet1Login.maxPlayers; this.mc.playerController.setGameType(par1Packet1Login.gameType); FMLNetworkHandler.onConnectionEstablishedToServer(this, netManager, par1Packet1Login); this.mc.gameSettings.sendSettingsToServer(); this.netManager.addToSendQueue(new Packet250CustomPayload("MC|Brand", ClientBrandRetriever.getClientModName().getBytes(Charsets.UTF_8))); }
@Override public void onPacketData(INetworkManager network, Packet250CustomPayload packet, Player player) { ForgePacket pkt = ForgePacket.readPacket(network, packet.data); // Part of an incomplete multipart packet if (pkt == null) { return; } pkt.execute(network, (EntityPlayer)player); }
@Override public void onPacketData(INetworkManager manager, Packet250CustomPayload packet, Player player) { if (packet.channel.equals("UCTS_TileEntity")) { handleTEPacket(manager, packet, player); } else if (packet.channel.equals("UCTS_Buttons")) { handleButtonsPacket(manager, packet, player); } else if (packet.channel.equals("UCTS_TE_Request")){ handleTERequest(manager, packet, player); } }
private void handleTEPacket(INetworkManager manager, Packet250CustomPayload packet, Player player) { // Packet always server-to-player. EntityPlayer entityPlayer = (EntityPlayer) player; World world = entityPlayer.worldObj; if (!world.isRemote) { Minecraft.getMinecraft().getLogAgent() .logWarning("UniversalCoins: TileEntity packet received by server."); } int coinSum, x = 0, y = 0, z = 0, dimension; boolean bypass; DataInputStream stream = new DataInputStream(new ByteArrayInputStream( packet.data)); try { coinSum = stream.readInt(); x = stream.readInt(); y = stream.readInt(); z = stream.readInt(); dimension = stream.readInt(); bypass = stream.readBoolean(); } catch (Exception ex) { ex.printStackTrace(); return; } if (world.getWorldInfo().getVanillaDimension() != dimension) { return; } TileEntity tEntity = world.getBlockTileEntity(x, y, z); if (tEntity != null && tEntity instanceof UCTileEntity) { UCTileEntity ucTileEntity = (UCTileEntity) tEntity; ucTileEntity.coinSum = coinSum; ucTileEntity.bypassActive = bypass; ucTileEntity.onInventoryChanged(); } }
private void handleTERequest(INetworkManager manager, Packet250CustomPayload packet, Player player) { // Packet always player-to-server EntityPlayer entityPlayer = (EntityPlayer) player; World world = entityPlayer.worldObj; if (world.isRemote) { Minecraft.getMinecraft().getLogAgent() .logWarning("UniversalCoins: TE Request packet received by client."); } int x = 0, y = 0, z = 0, dimension; DataInputStream stream = new DataInputStream(new ByteArrayInputStream( packet.data)); try { x = stream.readInt(); y = stream.readInt(); z = stream.readInt(); dimension = stream.readInt(); } catch (Exception ex) { ex.printStackTrace(); return; } if (world.getWorldInfo().getVanillaDimension() != dimension) { return; } TileEntity tEntity = world.getBlockTileEntity(x, y, z); if (tEntity != null && tEntity instanceof UCTileEntity) { UCTileEntity ucTileEntity = (UCTileEntity) tEntity; ucTileEntity.dispatchPackage(); } }
protected void keyTyped(char key, int num) { if (this.field.textboxKeyTyped(key, num)) { this.mc.thePlayer.sendQueue.addToSendQueue(new Packet250CustomPayload("MC|ItemName", this.field.getText().getBytes())); } else { super.keyTyped(key, num); } }
@Override public void onPacketData(INetworkManager manager, Packet250CustomPayload packet, Player player) { switch (packet.data[0]) { case 0: EntityPlayerMP playerMP = (EntityPlayerMP) player; playerMP.openGui(RecipeIGE.instance, 0, playerMP.worldObj, 0, 0, 0); break; } }
private void sendPacket(KeyBinding kb) { // don't send packets when not riding dragons if (mc.thePlayer == null || !(mc.thePlayer.ridingEntity instanceof EntityJakanPrime)) { return; } // don't send packets if the GUI is active if (mc.currentScreen != null) { return; } RemoteKey rk = new RemoteKey(kb); Packet250CustomPayload packet = new Packet250CustomPayload(RemoteKeyPacketHandler.CHANNEL, rk.write()); PacketDispatcher.sendPacketToServer(packet); }
public void sendToPlayer(EntityPlayerMP player,PacketData data) { if (FMLCommonHandler.instance().getEffectiveSide() != Side.SERVER) return; data.packetIndex = (byte) index; ByteArrayOutputStream stream = data.getData(); Packet250CustomPayload packet = new Packet250CustomPayload(); packet.channel = channel; packet.data = stream.toByteArray(); packet.length = stream.size(); player.playerNetServerHandler.sendPacketToPlayer(packet); }
public void sendToServer(PacketData data) { if (FMLCommonHandler.instance().getEffectiveSide() != Side.CLIENT) return; data.packetIndex = (byte) index; ByteArrayOutputStream stream = data.getData(); Packet250CustomPayload packet = new Packet250CustomPayload(); packet.channel = channel; packet.data = stream.toByteArray(); packet.length = stream.size(); PacketHandlerClient.send(packet); }
@Override public void onPacketData(INetworkManager manager, Packet250CustomPayload _packet, Player player) { try { BillundPacket packet = BillundPacket.parse( _packet.data ); Billund.handlePacket( packet, player ); } catch( Exception e ) { // Something failed, ignore it //e.printStackTrace(); } }