ContainerPickup container = new ContainerPickup(ItemBackpackBase.getInventory(backpack, entityPlayer), new BackpackSave(backpack));
boolean hasPickedUp = false;
for(int i = 0; i < inventoryPickup.getSizeInventory(); i++) {
ItemStack pickupItemStack = inventoryPickup.getStackInSlot(i);
if(areStacksEqual(pickupItemStack, itemStack, true)) {
hasPickedUp = container.pickupItem(itemStack) || hasPickedUp;
}
}
if(hasPickedUp) {
container.onContainerClosed(entityPlayer);