use of forestry.storage.gui.ContainerBackpack in project ForestryMC by ForestryMC.
the class PickupHandlerStorage method onItemPickup.
@Override
public boolean onItemPickup(EntityPlayer player, EntityItem entityitem) {
ItemStack itemstack = entityitem.getItem();
if (itemstack.isEmpty()) {
return false;
}
// Do not pick up if a backpack is open
if (player.openContainer instanceof ContainerBackpack || player.openContainer instanceof ContainerNaturalistBackpack) {
return false;
}
// Make sure to top off manually placed itemstacks in player inventory first
topOffPlayerInventory(player, itemstack);
for (ItemStack pack : player.inventory.mainInventory) {
if (itemstack.isEmpty()) {
break;
}
if (pack.isEmpty() || !(pack.getItem() instanceof ItemBackpack)) {
continue;
}
ItemBackpack backpack = (ItemBackpack) pack.getItem();
IBackpackDefinition backpackDefinition = backpack.getDefinition();
if (backpackDefinition.getFilter().test(itemstack)) {
ItemBackpack.tryStowing(player, pack, itemstack);
}
}
return itemstack.isEmpty();
}
Aggregations