IronBackpacks icon indicating copy to clipboard operation
IronBackpacks copied to clipboard

Fix Crash With Huge Packet Data

Open Claycorp opened this issue 8 years ago • 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):

  1. Fill RS drives with tons of NBT stuff and stuff em in a bag?
  2. Let the bag to continue to exist.
  3. 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

Claycorp avatar Jan 27 '17 06:01 Claycorp

@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 avatar Jan 27 '17 07:01 TehNut

@TehNut That is not the solution. You're supposed to send the NBT share tag, a feature that Forge has.

raoulvdberge avatar Feb 04 '17 09:02 raoulvdberge

Moving this to fix for 1.12, ignoring for 1.10, as it would take too much internal rewriting to fix it to be worth it.

Just don't go crazy with items full of data in your backpack in 1.10 and you'll be fine.

gr8pefish avatar Jan 11 '18 20:01 gr8pefish