Lumby Posted October 6, 2018 Share Posted October 6, 2018 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 Quote Link to comment Share on other sites More sharing options...
V0idWa1k3r Posted October 6, 2018 Share Posted October 6, 2018 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. 1 Quote Link to comment Share on other sites More sharing options...
Lumby Posted October 6, 2018 Author Share Posted October 6, 2018 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? Quote Link to comment Share on other sites More sharing options...
V0idWa1k3r Posted October 6, 2018 Share Posted October 6, 2018 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. 1 Quote Link to comment Share on other sites More sharing options...
Cadiboo Posted October 6, 2018 Share Posted October 6, 2018 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! 1 Quote About Me Spoiler My Discord - Cadiboo#8887 My Website - Cadiboo.github.io My Mods - Cadiboo.github.io/projects My Tutorials - Cadiboo.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) Link to comment Share on other sites More sharing options...
quadraxis Posted October 6, 2018 Share Posted October 6, 2018 Forge deliberately does not split client -> server packets, only server -> client. 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.