ItemBackpack backpack = ((ItemBackpack) backpackStack.getItem());
ItemInventory inventory = new ItemInventory(ItemBackpack.class, backpack.getBackpackSize(), backpackStack);
if (backpackStack.getItemDamage() == 1)
return stack;
Event event = new BackpackStowEvent(player, backpack.getDefinition(), inventory, stack);
MinecraftForge.EVENT_BUS.post(event);
if (stack.stackSize <= 0)
return null;
if (event.isCanceled())
return stack;
ItemStack remainder = InvTools.moveItemStack(stack, inventory);
stack.stackSize = remainder == null ? 0 : remainder.stackSize;