package common.item;

import java.util.Map;
import java.util.Set;

import common.attributes.Attribute;
import common.attributes.AttributeModifier;
import common.attributes.Attributes;
import common.collect.Sets;
import common.entity.npc.EntityNPC;
import common.init.Items;
import common.world.World;

public class ItemBucketMilk extends Item
{
    public ItemBucketMilk()
    {
        this.setMaxStackSize(1);
        this.setTab(CheatTab.tabTools);
    }

    /**
     * Called when the player finishes using this Item (E.g. finishes eating.). Not called when the player stops using
     * the Item before the action is complete.
     */
    public ItemStack onItemUseFinish(ItemStack stack, World worldIn, EntityNPC playerIn)
    {
//        if (!playerIn.creative)
//        {
        --stack.stackSize;
//        }

        if (!worldIn.client)
        {
            playerIn.clearEffects(false);
        }

//        playerIn.triggerAchievement(StatRegistry.objectUseStats[ItemRegistry.getIdFromItem(this)]);
        return stack.stackSize <= 0 ? new ItemStack(Items.bucket) : stack;
    }

    /**
     * How long it takes to use or consume an item
     */
    public int getMaxItemUseDuration(ItemStack stack)
    {
        return 32;
    }

    /**
     * returns the action that specifies what animation to play when the items is being used
     */
    public ItemAction getItemUseAction(ItemStack stack)
    {
        return ItemAction.DRINK;
    }

    /**
     * Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer
     */
    public ItemStack onItemRightClick(ItemStack itemStackIn, World worldIn, EntityNPC playerIn)
    {
        playerIn.setItemInUse(itemStackIn, this.getMaxItemUseDuration(itemStackIn));
        return itemStackIn;
    }

    public Map<Attribute, Set<AttributeModifier>> getItemInventoryModifiers()
    {
    	Map<Attribute, Set<AttributeModifier>> multimap = super.getItemInventoryModifiers();
        multimap.put(Attributes.RADIATION, Sets.newHashSet(new AttributeModifier(Attributes.ITEM_VAL_ID, "Milk modifier", -5.0, false, true, true)));
        return multimap;
    }
    
    public boolean isMagnetic() {
    	return true;
    }
}
