Jump to content

Strange networking problem, packet sent is not the same as the packet received


Recommended Posts

Posted

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…

Posted

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • UPDATE: this seems to be an Arch-specific issue. Switching to Ubuntu server fixed EVERYTHING.
    • Yes, Attapoll offers a $20 Sign-up bonus for new users using a code (AOVCQ). Enter the Attapoll Referral Code “AOVCQ” and submit. Yes, Attapoll offers $20 Referral Code {AOVCQ} For New Customers. If you are who wish to join Attapoll, then you should use this exclusive Attapoll referral code $20 Signup Bonus Use this Code (AOVCQ) and get $20 Welcome Bonus. You can get a $20 Signup bonus use this referral code {AOVCQ}. You can get a $20 Attpoll Referral Code {AOVCQ}. This Attapoll $20 Referral code is specifically for existing customers and can be redeemed to receive a $20. Enter $20 Attapoll Referral Code {AOVCQ} at checkout. Enjoy $20Welcome Bonus. Use the best Attapoll referral code $20 (AOVCQ) to get up to $20 first time survey as a new user. Complete the survey and get $20 credited on your Attapoll account. Plus, refer your friend to earn 10% commission on their earning If you're on the hunt for a little extra cash or some cool rewards without too much hassle, you've landed in the right place. Today, we're diving into the world of Attapoll referral codes, a nifty way to boost your earnings while taking surveys. Use this Attapoll Referral Link or code {{AOVCQ}} to get a $20 sign up bonus.
    • Yes, Attapoll offers a $20 Sign-up bonus for new users using a code (AOVCQ). Enter the Attapoll Referral Code “AOVCQ” and submit. Yes, Attapoll offers $20 Referral Code {AOVCQ} For New Customers. If you are who wish to join Attapoll, then you should use this exclusive Attapoll referral code $20 Signup Bonus Use this Code (AOVCQ) and get $20 Welcome Bonus. You can get a $20 Signup bonus use this referral code {AOVCQ}. You can get a $20 Attpoll Referral Code {AOVCQ}. This Attapoll $20 Referral code is specifically for existing customers and can be redeemed to receive a $20. Enter $20 Attapoll Referral Code {AOVCQ} at checkout. Enjoy $20Welcome Bonus. Use the best Attapoll referral code $20 (AOVCQ) to get up to $20 first time survey as a new user. Complete the survey and get $20 credited on your Attapoll account. Plus, refer your friend to earn 10% commission on their earning If you're on the hunt for a little extra cash or some cool rewards without too much hassle, you've landed in the right place. Today, we're diving into the world of Attapoll referral codes, a nifty way to boost your earnings while taking surveys. Use this Attapoll Referral Link or code {{AOVCQ}} to get a $20 sign up bonus.
    • Yes, Attapoll offers a $20 Sign-up bonus for new users using a code (AOVCQ). Enter the Attapoll Referral Code “AOVCQ” and submit. Yes, Attapoll offers $20 Referral Code {AOVCQ} For New Customers. If you are who wish to join Attapoll, then you should use this exclusive Attapoll referral code $20 Signup Bonus Use this Code (AOVCQ) and get $20 Welcome Bonus. You can get a $20 Signup bonus use this referral code {AOVCQ}. You can get a $20 Attpoll Referral Code {AOVCQ}. This Attapoll $20 Referral code is specifically for existing customers and can be redeemed to receive a $20. Enter $20 Attapoll Referral Code {AOVCQ} at checkout. Enjoy $20Welcome Bonus. Use the best Attapoll referral code $20 (AOVCQ) to get up to $20 first time survey as a new user. Complete the survey and get $20 credited on your Attapoll account. Plus, refer your friend to earn 10% commission on their earning If you're on the hunt for a little extra cash or some cool rewards without too much hassle, you've landed in the right place. Today, we're diving into the world of Attapoll referral codes, a nifty way to boost your earnings while taking surveys. Use this Attapoll Referral Link or code {{AOVCQ}} to get a $20 sign up bonus.
    • Yes, Attapoll offers a $20 Sign-up bonus for new users using a code (AOVCQ). Enter the Attapoll Referral Code “AOVCQ” and submit. Yes, Attapoll offers $20 Referral Code {AOVCQ} For New Customers. If you are who wish to join Attapoll, then you should use this exclusive Attapoll referral code $20 Signup Bonus Use this Code (AOVCQ) and get $20 Welcome Bonus. You can get a $20 Signup bonus use this referral code {AOVCQ}. You can get a $20 Attpoll Referral Code {AOVCQ}. This Attapoll $20 Referral code is specifically for existing customers and can be redeemed to receive a $20. Enter $20 Attapoll Referral Code {AOVCQ} at checkout. Enjoy $20Welcome Bonus. Use the best Attapoll referral code $20 (AOVCQ) to get up to $20 first time survey as a new user. Complete the survey and get $20 credited on your Attapoll account. Plus, refer your friend to earn 10% commission on their earning If you're on the hunt for a little extra cash or some cool rewards without too much hassle, you've landed in the right place. Today, we're diving into the world of Attapoll referral codes, a nifty way to boost your earnings while taking surveys. Use this Attapoll Referral Link or code {{AOVCQ}} to get a $20 sign up bonus.
  • Topics

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.