RubixDev / Inventorio

Inventorio - an inventory enhancement mod for Minecraft (Fabric / (Neo)Forge)
https://modrinth.com/mod/inventorio
57 stars 22 forks source link

Stack size exploit: Ender Pearls can stack to 64, and higher if another mod changes the stack cap #190

Closed dehen closed 5 months ago

dehen commented 1 year ago

Love both these mods, posting this report to both because I don't know which side owns it.

There's a weird interaction between the way Inventorio is handling pickups, and BitsAndChisels is handling large stacks of bits. Basically, if Inventorio has a full stack of something in one of the offhand slots, or in a Deep Pocket slot and then picks up another drop of it, you can push your stack beyond 64. I made a 32k stack of sticks, lol.

The minimum modstack to trigger this seems to be: Fabric API Fabric Language Kotlin (inventorio dependency) Inventorio BitsAndChisels

Reproduction steps: single player cheats on give yourself 128 sticks put a stack in your Inventorio offhand throw the other stack on the ground pick it up 128 sticks

This feels like an Inventorio issue initially, but doesn't happen if BitsAndChisels is off. Likewise, it can't be reproduced with the Vanilla offhand, with Inventorio off. So it appears to be an interaction.

1.19.2/Fabric 14.10

mastery3 commented 1 year ago

Reproduced without BitsAndChisels Mods required:

Use ender pearls instead of sticks. Ender Pearls can normally stack to only 16, but can stack to 64 with this bug. They can stack to a higher amount with BitsAndChisels

dehen commented 1 year ago

Wow Mastery, you been working hard to figure this one out. I'll go ahead and close the BitsAndChisels side.

It looks like this is purely an Inventorio bug, where you can just push stacks to maximum stack size. BitsAndChisels just made it more obvious because it has huge stacks.

mastery3 commented 1 year ago

This line of the source code might have something to do with the bug, but I haven't compiled this mod:

val i = max(maxCountPerStack, targetStack.maxCount)

on line 102 in function transfer(sourceStack: ItemStack, targetStack: ItemStack) in common/src/main/kotlin/me/lizardofoz/inventorio/player/inventory/PlayerInventoryInjects.kt

Appears to be using whichever is higher of the highest possible maximum stack count of any item and the target stacks maximum stack count. Since the maximum stack count of any item is always higher or equal to the target stacks maximum, this means that this is effectively using the highest possible maximum stack count of any item. As a result, if this function is called when picking up an item, it will result in this bug. Might submit a PR later when I get my development environment ready.

mastery3 commented 1 year ago

Can't compile the mod due to some error about some file already existing, and deleting the loom-cache caused another error about some file not being compiled properly

RubixDev commented 5 months ago

This line of the source code might have something to do with the bug, but I haven't compiled this mod:

val i = max(maxCountPerStack, targetStack.maxCount)

on line 102 in function transfer(sourceStack: ItemStack, targetStack: ItemStack) in common/src/main/kotlin/me/lizardofoz/inventorio/player/inventory/PlayerInventoryInjects.kt

Appears to be using whichever is higher of the highest possible maximum stack count of any item and the target stacks maximum stack count. Since the maximum stack count of any item is always higher or equal to the target stacks maximum, this means that this is effectively using the highest possible maximum stack count of any item. As a result, if this function is called when picking up an item, it will result in this bug. Might submit a PR later when I get my development environment ready.

Thanks @mastery3. That was indeed what caused this bug.