McJtyMods / XNet

Advanced item/liquid/energy/... networking
MIT License
91 stars 49 forks source link

XNet Controller large NBT data size can cause Invalid PacketBuffer when opening GUIs #499

Open Raidobw2 opened 2 years ago

Raidobw2 commented 2 years ago

Issue description

Hello McJty. One of our users is playing FTB OceanBlock v1.7.0 and encountered a problem opening a gui with the method openGui when right-clicking a Tempered Jar (FTB Jar Mod, it's new), which is basically some kind of container with crafting logic. Here is what the game showed them in the server console: Invalid PacketBuffer for openGui, found 109288 bytes. After investigation, it looks like they had a XNet Controller in their inventory, which weights about 85KB in NBT data. Removing the XNet Controller from their inventory allowed them to open the container.

I have not filed a report yet to my main modder who made FTB Jar Mod, but I suspect some logic could maybe be added on our side too to prevent these kind of issues in the future. Anyways, this is sort of a bug/request about if you see optimization that could be done for the XNet Controller data tags.

This issue is relayed from FTBTeam/FTB-Modpack-Issues#278.

Steps to reproduce

Create a FTB OceanBlock 1.7.0 server. Play FTB OceanBlock v1.7.0 and connect to that same server. Place down a Tempered Jar from the FTB Jar Mod. Place down a command block. Use the command block to give yourself the XNet Controller with a lot of NBT data. Try to open the Tempered Jar with right-click while having the XNet Controller in your inventory.

Versions

Possibly incompatible mods and versions

N/A

Logs

  1. latest.log of server: https://paste.feed-the-beast.com/view/dfc9f958
  2. (! Important) NBT Data of the Controller in inventory: https://paste.feed-the-beast.com/view/72e37f3b
    [08Nov2021 22:00:10.610] [Server thread/FATAL] [net.minecraft.util.concurrent.ThreadTaskExecutor/]: Error executing task on Server
    java.lang.IllegalArgumentException: Invalid PacketBuffer for openGui, found 109288 bytes
        at net.minecraftforge.fml.network.NetworkHooks.openGui(NetworkHooks.java:224) ~[forge:?]
        at dev.ftb.mods.ftbjarmod.block.TemperedJarBlock.func_225533_a_(TemperedJarBlock.java:90) ~[ftbjarmod:1605.1.0-build.31]
        at net.minecraft.block.AbstractBlock$AbstractBlockState.func_227031_a_(AbstractBlock.java:640) ~[?:?]
        at net.minecraft.server.management.PlayerInteractionManager.func_219441_a(PlayerInteractionManager.java:338) ~[?:?]
        at net.minecraft.network.play.ServerPlayNetHandler.func_184337_a(ServerPlayNetHandler.java:958) ~[?:?]
        at net.minecraft.network.play.client.CPlayerTryUseItemOnBlockPacket.func_148833_a(SourceFile:36) ~[?:?]
        at net.minecraft.network.play.client.CPlayerTryUseItemOnBlockPacket.func_148833_a(SourceFile:10) ~[?:?]
        at net.minecraft.network.PacketThreadUtil.func_225383_a(SourceFile:21) ~[?:?]
        at net.minecraft.util.concurrent.TickDelayedTask.run(SourceFile:18) ~[?:?]
        at net.minecraft.util.concurrent.ThreadTaskExecutor.func_213166_h(SourceFile:144) ~[?:?]
        at net.minecraft.util.concurrent.RecursiveEventLoop.func_213166_h(SourceFile:23) ~[?:?]
        at net.minecraft.server.MinecraftServer.func_213166_h(MinecraftServer.java:734) ~[?:?]
        at net.minecraft.server.MinecraftServer.func_213166_h(MinecraftServer.java:159) ~[?:?]
        at net.minecraft.util.concurrent.ThreadTaskExecutor.func_213168_p(SourceFile:118) ~[?:?]
        at net.minecraft.server.MinecraftServer.func_213205_aW(MinecraftServer.java:717) ~[?:?]
        at net.minecraft.server.MinecraftServer.func_213168_p(MinecraftServer.java:711) ~[?:?]
        at net.minecraft.util.concurrent.ThreadTaskExecutor.func_213160_bf(SourceFile:103) ~[?:?]
        at net.minecraft.server.MinecraftServer.func_213202_o(MinecraftServer.java:696) ~[?:?]
        at net.minecraft.server.MinecraftServer.func_240802_v_(MinecraftServer.java:646) ~[?:?]
        at net.minecraft.server.MinecraftServer.func_240783_a_(MinecraftServer.java:232) ~[?:?]
        at java.lang.Thread.run(Unknown Source) [?:1.8.0_191]

    Other

    Thank you for making this mod!

McJty commented 2 years ago

Sorry for the slow response. I'll check it out

Raidobw2 commented 2 years ago

No worries, thanks for the response!

I believe this was fixed on our modder's side with FTB Jar Mod, he probably does the check differently. Probably by removing this: https://github.com/FTBTeam/FTB-Jar-Mod/commit/f88742b02b61eb51cc305dc6745c3febce0defac#diff-7a0107a74c12307e6e053d279138f7753d7564c66f56f941e8edcfb3e6fde85cL46

Some backpack mods solved that "issue" with IDs as one NBT tag I believe, but that might require changing the system, so yeah. I can close this if you want, your mod works well and this could be translated into a feature/optimization rather than a bug. Lmk. And thanks a bunch in any case!