Fix Crash With Huge Packet Data
Claycorp opened this issue ยท 5 comments
Issue Description:
Currently there is an issue going around with Refined storage drives and packets being too large because mods are not expecting this.
What happens:
Place a special recipe of 7 herbs and drives in a backpack and tada! Mass RIP! Then whenever this person connects to a server it will disconnect people around them. Including thierself.
http://pastebin.com/A5cmSPji <--- The magic at work!
What you expected to happen:
Not to nuke the connection of anyone in the range of the monster bag.
Steps to reproduce (important):
- Fill RS drives with tons of NBT stuff and stuff em in a bag?
- Let the bag to continue to exist.
- Log in after getting Fataled and REK someone's day!
...
Affected Versions (Do not use "latest"):
- IronBackpacks: 2.2.22
- Minecraft: 1.10.2
- Forge: 2215
- Other Conflicting Mods (may be irrelevant to your issue): Refined storage
@gr8pefish This is caused by the large amount of NBT (>2mb worth of data in large networks) saved in RS drives. To solve this issue, you can use custom writing/reading for the ItemStack and ByteBuf.
Something like
@Override
public void fromBytes(ByteBuf buf) {
ResourceLocation id = new ResourceLocation(ByteBufUtils.readUTF8String(buf)); // To save even more data, the integer ID could be used, though that's prone to breakage when mods are added/removed.
int amount = buf.readInt();
int meta = buf.readInt();
NBTTagCompound tagCompound;
try {
tagCompound = CompressedStreamTools.readCompressed(new ByteBufInputStream(buf));
} catch (Exception e) {
tagCompound = null;
}
stack = new ItemStack(ForgeRegistries.ITEMS.getValue(id), amount, meta);
if (tagCompound != null && tagCompound.getSize() != 0)
stack.setTagCompound(tagCompound);
}
@Override
public void toBytes(ByteBuf buf) {
ItemStack stack = new ItemStack(Items.ARROW);
ByteBufUtils.writeUTF8String(buf, stack.getItem().getRegistryName().toString());
buf.writeInt(stack.stackSize);
buf.writeInt(stack.getItemDamage());
ByteBufUtils.writeTag(buf, stack.hasTagCompound() ? stack.getTagCompound() : new NBTTagCompound());
}
@TehNut That is not the solution. You're supposed to send the NBT share tag, a feature that Forge has.