Posted July 14, 201312 yr Okay, so, I must be doing something incredibly wrong, because I just have no idea why it's doing what it's doing. I send a packet from the server like this: NBTTagCompound tagToSend = new NBTTagCompound("MWGGetSchem"); tagToSend.setInteger("x1", x1); tagToSend.setInteger("y1", y1); tagToSend.setInteger("z1", z1); tagToSend.setInteger("x2", x2); tagToSend.setInteger("y2", y2); tagToSend.setInteger("z2", z2); tagToSend.setTag("entities", Schematic.getEntities(playerMP.worldObj, x1, y1, z1, x2, y2, z2)); tagToSend.setTag("tileEntities", Schematic.getTileEntities(playerMP.worldObj, x1, y1, z1, x2, y2, z2)); ByteArrayOutputStream bos = new ByteArrayOutputStream(); DataOutputStream outputStream = new DataOutputStream(bos); try { NBTBase.writeNamedTag(tagToSend, outputStream); } catch (IOException exc) { exc.printStackTrace(); return; } Packet250CustomPayload packetToSend = new Packet250CustomPayload("MWGGetSchem", bos.toByteArray()); // debug output System.out.println("PacketDispatcher.sendPacketToPlayer"); for (int i = 0; i < packetToSend.data.length; i++) { System.out.printf("%02X ", packetToSend.data[i]); } System.out.println(""); System.out.println(tagToSend.toString()); PacketDispatcher.sendPacketToPlayer(packet, player); and process it on the client like this: DataInputStream inputStream = new DataInputStream( new ByteArrayInputStream(packet.data)); NBTBase packetTag; try { packetTag = NBTBase.readNamedTag(inputStream); assert (packetTag instanceof NBTTagCompound); } catch (IOException e) { e.printStackTrace(); return; } // debug output System.out.println("onPacketData client"); for (int i = 0; i < packet.data.length; i++) { System.out.printf("%02X ", packet.data[i]); } System.out.println(""); System.out.println(packetTag.toString()); The console output is then: [iNFO] [sTDOUT] PacketDispatcher.sendPacketToPlayer [iNFO] [sTDOUT] 0A 00 0B 4D 57 47 47 65 74 53 63 68 65 6D 03 00 02 7A 31 FF FF FF ... [iNFO] [sTDOUT] MWGGetSchem:[z1:-147,tileEntities:1 entries of type TAG_Compound,y1:71,y2:73,z2:-143,x2:-138,entities:2 entries of type TAG_Compound,x1:-142,] [iNFO] [sTDOUT] onPacketData client [iNFO] [sTDOUT] 0A 00 00 03 00 02 7A 31 FF FF FF ... [iNFO] [sTDOUT] :[z1:-147,y1:71,y2:73,z2:-143,x2:-138,x1:-142,] I don't get it. Where did the two TAG_Lists go!? What about the tag name? I didn't do anything with them! I looked through the Minecraft/Forge networking code and I can't seem to find anything that modifies packet NBT data, and I have no idea what to google to find the resolution to my problem. Is there some kind of packet corruption going on? The same problem occurs if the server and client are separate. I'm on Forge 1.6.2-9.10.0.789. I apologize if I'm in the wrong forum, or if I'm missing something really stupid. The boatcake is coming for you…
July 16, 201312 yr Author Well, I changed it to use CompressedStreamTools, and it didn't make a difference, so I guess it must be something to do with the NBT. I still don't get why the packet data is different, though. Still looking for answers. Edit: Fixed it. PacketDispatcher.sendPacketToPlayer(packet, player); was supposed to be PacketDispatcher.sendPacketToPlayer(packetToSend, player); The boatcake is coming for you…
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.