The_Fireplace Posted February 25, 2017 Posted February 25, 2017 So, I send a packet that contains one NBTTagCompound containing a lot of data(Mostly inventories within a tile entity). Unfortunately, it seems to be too large, since I get the following crash upon sending. http://paste.ubuntu.com/24062837/ My question to you is, how do you suggest I redesign the system to reduce the packet size? My current way of doing things involves sending the packet to the client just before the GUI opens. This packet contains all of the entity's data, including inventory, which the client needs or else it will crash upon opening the GUI. The creation of the NBT Tag Compound The packet If anyone knows of a way to reduce packet size or simply split this in to as many smaller packets as needed, it would be greatly appreciated. Quote If I helped please press the Thank You button. Check out my mods at http://www.curse.com/users/The_Fireplace/projects
Animefan8888 Posted February 25, 2017 Posted February 25, 2017 I would suggest looking at the code for writing a NBTTagCompound to a ByteBuf and find the limitation or you could just send multiple packets for each inventory. Quote VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect. Forge and vanilla BlockState generator.
Choonster Posted February 25, 2017 Posted February 25, 2017 (edited) This exception is caused by a client-to-server message (which Forge limits to a single CPacketCustomPayload, i.e. 32,767 bytes), not a server-to-client message.(which Forge splits into a a maximum of 255 SPacketCustomPayloads, i.e. 267,366,480 bytes). Do you need to send all of that data to the server at once? Can you send individual parts that have changed, possibly through the Container? You shouldn't be storing mutable game data in a field of your @Mod class (Caterpillar#mainContainers), since it's shared between logical sides in single player. You should be using World Capabilities or World Saved Data (if storing the data directly in the TileEntity isn't an option). Iterating through a server's World's to find a block at a specific position is very unreliable, what happens when two dimensions have a drill at the same position? Edited February 25, 2017 by Choonster Quote Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.
The_Fireplace Posted February 25, 2017 Author Posted February 25, 2017 On 2/25/2017 at 5:48 AM, Choonster said: This exception is caused by a client-to-server message (which Forge limits to a single CPacketCustomPayload, i.e. 32,767 bytes), not a server-to-client message.(which Forge splits into a a maximum of 255 SPacketCustomPayloads, i.e. 267,366,480 bytes). Do you need to send all of that data to the server at once? Can you send individual parts that have changed, possibly through the Container? You shouldn't be storing mutable game data in a field of your @Mod class (Caterpillar#mainContainers), since it's shared between logical sides in single player. You should be using World Capabilities or World Saved Data (if storing the data directly in the TileEntity isn't an option). Iterating through a server's World's to find a block at a specific position is very unreliable, what happens when two dimensions have a drill at the same position? Expand Ah, I see. Thanks for the explanation, it should be somewhat easy to fix now, since the client shouldn't have any reason in this mod to need to send that much data to the server. Thanks for the suggestions, I will work on them today. You've pointed out several problems and ways to fix them that I wouldn't have caught. As for the why of all of that bad design, that was the original author's doing, and I have been working on fixing it for a while now. Quote If I helped please press the Thank You button. Check out my mods at http://www.curse.com/users/The_Fireplace/projects
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.