Jump to content

Recommended Posts

Posted

Hi, I want to send the nbt data of an item block to the server through a packet. From my understanding, NBTTagCompounds are already converted to byte streams since the way I accessed it was:

NBTTagCompound nbt = this.inventorySlots.inventorySlots.get(0).getStack().serializeNBT();

hence I can send it through my packet. However, I read somewhere that there is a limit to how much data you can send to the server through a packet. Is this still true as of the 1.12.2? If so, what is the size, and how do I make sure I don't go over the limit? Thanks in advance

Posted
1 hour ago, Lumby said:

NBTTagCompounds are already converted to byte streams since the way I accessed it was:


NBTTagCompound nbt = this.inventorySlots.inventorySlots.get(0).getStack().serializeNBT();

This makes no sense. You've just accessed the NBTTagCompound that contains the serialized item data. Nothing about this says anything about a ByteStream.

 

1 hour ago, Lumby said:

However, I read somewhere that there is a limit to how much data you can send to the server through a packet. Is this still true as of the 1.12.2? 

Yes, it is true.

 

1 hour ago, Lumby said:

what is the size

32767 bytes.

 

1 hour ago, Lumby said:

how do I make sure I don't go over the limit?

Don't have insanely large NBTTagCompounds. In pretty much all cases you won't have the tag bigger than the limit. If it is it is likely not your fault and you need to complain to whomever caused this issue.

  • Thanks 1
Posted
3 minutes ago, V0idWa1k3r said:

This makes no sense. You've just accessed the NBTTagCompound that contains the serialized item data. Nothing about this says anything about a ByteStream.

Thanks for the response. My goal is to get the nbt data of a shulker box in its item form and pass it to a custom tileEntity. From my understanding all I have to do is call that line and add these lines into my packet:

in #toBytes

ByteBufUtils.writeTag(buf, nbt);

and #fromBytes

nbt = ByteBufUtils.readTag(buf);

 

I feel like the Shulker box with its many items holding their own nbt data, however, would cause the packet to be over the limit? Is there a way to know the size of the packet when I'm sending it somehow?

Posted
9 minutes ago, Lumby said:

I feel like the Shulker box with its many items holding their own nbt data, however, would cause the packet to be over the limit?

It is not quite as easy to reach that limit. In one of my mods I have items that can hold items that can be nested inside of other such items. Even a very big invenroty(100+) slots filled with those items each of which also holds items inside doesn't go near the packet limit.

 

9 minutes ago, Lumby said:

Is there a way to know the size of the packet when I'm sending it somehow?

You can use CompressedStreamTools.write to write an NBTTagCompound to anything that implements a DataOutput, for example a DataOutputStream or a ByteBufOutputStream(this is the one that the game uses anyway), then get the length of that stream.

  • Thanks 1
Posted
5 hours ago, V0idWa1k3r said:

packet limit

Correct me if I’m wrong, but I believe Forge just splits packets that are too big and reconstructs them on the other side

 

6 hours ago, Lumby said:

Hi, I want to send the nbt data of an item block to the server through a packet.

Remember: The client is always lying, do any logic, item creation/modification etc. on the server!

  • Thanks 1

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

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



×
×
  • Create New...

Important Information

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