Mantle

Mantle

157M Downloads

`SmartItemHandlerSlot` ignores the stack size of the item itself, bypassing stack limit restrictions, allowing you to stack unstackable items up to 64

alcatrazEscapee opened this issue ยท 1 comments

commented

Reproduction steps:

  1. Place a crafting station (from Tinker's Construct) adjacent to a Chest
  2. Open the crafting station.
  3. Observe you can stack items up to 64 in the chest, even items that should not normally stack, and bypass all stack size restrictions:

ticon

Mods:

  • Minecraft 1.18.2
  • Forge 40.2.1
  • Mantle 1.9.43
  • Tinkers Construct 3.6.3.111

Logs: debug.log

Explanation

This method:

@Override
public int getMaxStackSize(ItemStack stack) {
return getItemHandler().getSlotLimit(getSlotIndex());
}

is an incomplete implementation. The vanilla implementation here takes the minimum of both the slot's stack size limit, and the item stack's size limit. This does not consider stack dependent slot restrictions, and as a result enables bypassing vanilla behavior using the crafting station.

What that should read, is:

@Override 
public int getMaxStackSize(ItemStack stack) { 
    return Math.min(stack.getMaxStackSize(), getItemHandler().getSlotLimit(getSlotIndex())); 
} 
commented

Fixed in 1.9.45