use of com.bluepowermod.container.ContainerSeedBag in project BluePower by Qmunity.
the class BPEventHandler method itemPickUp.
@SubscribeEvent
public void itemPickUp(EntityItemPickupEvent event) {
EntityPlayer player = event.entityPlayer;
ItemStack pickUp = event.item.getEntityItem();
if (!(player.openContainer instanceof ContainerSeedBag)) {
for (ItemStack is : player.inventory.mainInventory) {
if (is != null && is.getItem() instanceof ItemSeedBag) {
ItemStack seedType = ItemSeedBag.getSeedType(is);
if (seedType != null && seedType.isItemEqual(pickUp)) {
InventoryItem inventory = InventoryItem.getItemInventory(is, "Seed Bag", 9);
inventory.openInventory();
ItemStack pickedUp = TileEntityHopper.func_145889_a(inventory, pickUp, -1);
inventory.closeInventory(is);
if (pickedUp == null) {
event.setResult(Result.ALLOW);
event.item.setDead();
return;
} else {
event.item.setEntityItemStack(pickedUp);
}
}
}
}
}
if (pickUp.getItem().equals(Item.getItemFromBlock(BPBlocks.tungsten_ore))) {
player.addStat(Achievements.tungstenAchievement, 1);
}
}
Aggregations