witchica / compact-storage

Upgradable storage for Fabric and NeoForge
https://www.curseforge.com/minecraft/mc-mods/compactstorage
GNU General Public License v3.0
8 stars 16 forks source link

java.lang.IllegalArgumentException: Got 276 items, but maximum is 256 #175

Closed Paulem79 closed 3 months ago

Paulem79 commented 4 months ago

Describe the bug When the amount of slots is above 256, the client is kicked of the server

To Reproduce

  1. Have a chest of 256+ slots
  2. Open it
  3. You'll crash

Expected behavior I wanted my chest to... open

Log files [Server thread/ERROR]: Failed to handle packet class_2873[slotNum=39, itemStack=1 compact_storage:oak_compact_chest], suppressing error java.lang.IllegalArgumentException: Got 276 items, but maximum is 256 at net.minecraft.class_9288.(class_9288.java:33) ~[server-intermediary.jar:?] at net.minecraft.class_9288.(class_9288.java:40) ~[server-intermediary.jar:?] at net.minecraft.class_9288.method_57493(class_9288.java:69) ~[server-intermediary.jar:?] at net.minecraft.class_2624.method_57567(class_2624.java:169) ~[server-intermediary.jar:?] at net.minecraft.class_2621.method_57567(class_2621.java:106) ~[server-intermediary.jar:?] at com.witchica.compactstorage.common.block.entity.CompactChestBlockEntity.method_57567(CompactChestBlockEntity.java:175) ~[compact_storage-1.21-fabric-8.0.74.jar:?] at net.minecraft.class_2586.method_57590(class_2586.java:327) ~[server-intermediary.jar:?] at com.witchica.compactstorage.common.block.entity.CompactChestBlockEntity.method_38240(CompactChestBlockEntity.java:170) ~[compact_storage-1.21-fabric-8.0.74.jar:?] at net.minecraft.class_3244.method_12070(class_3244.java:1791) ~[server-intermediary.jar:?] at net.minecraft.class_2873.method_12480(class_2873.java:31) ~[server-intermediary.jar:?] at net.minecraft.class_2873.method_11054(class_2873.java:10) ~[server-intermediary.jar:?] at net.minecraft.class_2600.method_11072(class_2600.java:27) ~[server-intermediary.jar:?] at net.minecraft.class_3738.run(class_3738.java:18) ~[server-intermediary.jar:?] at net.minecraft.class_1255.method_18859(class_1255.java:162) ~[server-intermediary.jar:?] at net.minecraft.class_4093.method_18859(class_4093.java:23) ~[server-intermediary.jar:?] at net.minecraft.server.MinecraftServer.method_24306(MinecraftServer.java:864) ~[server-intermediary.jar:?] at net.minecraft.server.MinecraftServer.method_18859(MinecraftServer.java:173) ~[server-intermediary.jar:?] at net.minecraft.class_1255.method_16075(class_1255.java:136) ~[server-intermediary.jar:?] at net.minecraft.server.MinecraftServer.method_20415(MinecraftServer.java:846) ~[server-intermediary.jar:?] at net.minecraft.server.MinecraftServer.method_16075(MinecraftServer.java:840) ~[server-intermediary.jar:?] at net.minecraft.class_1255.method_5383(class_1255.java:121) ~[server-intermediary.jar:?] at net.minecraft.server.MinecraftServer.method_16208(MinecraftServer.java:814) ~[server-intermediary.jar:?] at net.minecraft.server.MinecraftServer.method_29741(MinecraftServer.java:702) ~[server-intermediary.jar:?] at net.minecraft.server.MinecraftServer.method_29739(MinecraftServer.java:281) ~[server-intermediary.jar:?] at java.base/java.lang.Thread.run(Thread.java:1583) [?:?]

Additional context It's on a modded server, with other mods, but I don't think it's related to the other mods but here is the full list if you want https://github.com/Paulem79/Launcher/blob/updater/mods_list.json

witchica commented 4 months ago

Okay interesting, seems to be an issue with 1.20.6 and 1.21 specifically. I shall take a look

Paulem79 commented 3 months ago

So, did you checked ?

Paulem79 commented 3 months ago

In ItemContainerContents :

    private ItemContainerContents(NonNullList<ItemStack> items) {
        if (items.size() > 256) {
            throw new IllegalArgumentException("Got " + items.size() + " items, but maximum is 256");
        } else {
            this.items = items;
            this.hashCode = ItemStack.hashStackList(items);
        }
    }

I'll do a PR to mixin this and remove this annoying condition

witchica commented 3 months ago

You would have to mixin in a lot of places in that file, I have a solution in the works right now :)

witchica commented 3 months ago

I'm going to chuck a temporary solution in, I am planning a big upgrade to storage that this will fit nicely with anyways. For now, maxing out at 21x12 https://github.com/witchica/compact-storage/commit/9c42d0058f2591a9ba09fcd145b4469c22df2997 https://github.com/witchica/compact-storage/commit/68a62f0c585ab2269dc760565853146d44d6c557