Search in sources :

Example 1 with ContainerSeedBag

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);
    }
}
Also used : InventoryItem(com.bluepowermod.container.inventory.InventoryItem) EntityPlayer(net.minecraft.entity.player.EntityPlayer) ItemStack(net.minecraft.item.ItemStack) ItemSeedBag(com.bluepowermod.item.ItemSeedBag) ContainerSeedBag(com.bluepowermod.container.ContainerSeedBag) SubscribeEvent(cpw.mods.fml.common.eventhandler.SubscribeEvent)

Aggregations

ContainerSeedBag (com.bluepowermod.container.ContainerSeedBag)1 InventoryItem (com.bluepowermod.container.inventory.InventoryItem)1 ItemSeedBag (com.bluepowermod.item.ItemSeedBag)1 SubscribeEvent (cpw.mods.fml.common.eventhandler.SubscribeEvent)1 EntityPlayer (net.minecraft.entity.player.EntityPlayer)1 ItemStack (net.minecraft.item.ItemStack)1