continue;
}
// Load their inventory
ItemBackpack packItem = ((ItemBackpack) backpack.getItem());
ItemInventory backpackinventory = new ItemInventory(ItemBackpack.class, packItem.getBackpackSize(), backpack);
Event event = new BackpackResupplyEvent(player, packItem.getDefinition(), backpackinventory);
MinecraftForge.EVENT_BUS.post(event);
if (event.isCanceled())
continue;
boolean inventoryChanged = false;
// Cycle through their contents
for (int i = 0; i < backpackinventory.getSizeInventory(); i++) {
ItemStack packstack = backpackinventory.getStackInSlot(i);
if (packstack == null)
continue;
if (packstack.stackSize <= 0)
continue;
// Try to add it to the player's inventory and note any change
boolean change = topOffPlayerInventory(player, packstack);
if (!inventoryChanged)
inventoryChanged = change;
// Clear consumed stacks
if (packstack.stackSize <= 0)
backpackinventory.setInventorySlotContents(i, null);
}
// Save the backpack inventory if it changed
if (inventoryChanged)
backpackinventory.onGuiSaved(player);
}
}