package common.item;

import common.entity.npc.EntityNPC;
import common.init.Blocks;
import common.init.SoundEvent;
import common.material.Material;
import common.util.BlockPos;
import common.util.Facing;
import common.world.World;

public class ItemFlintAndSteel extends Item
{
    public ItemFlintAndSteel()
    {
        this.maxStackSize = 1;
        this.setMaxDamage(64);
        this.setTab(CheatTab.tabTools);
    }

    /**
     * Called when a Block is right-clicked with this Item
     */
    public boolean onItemUse(ItemStack stack, EntityNPC playerIn, World worldIn, BlockPos pos, Facing side, float hitX, float hitY, float hitZ)
    {
        pos = pos.offset(side);

        if (!playerIn.canPlayerEdit(pos, side, stack))
        {
            return false;
        }
        else
        {
            if (worldIn.getState(pos).getBlock().getMaterial() == Material.air)
            {
                worldIn.playSound(SoundEvent.IGNITE, (double)pos.getX() + 0.5D, (double)pos.getY() + 0.5D, (double)pos.getZ() + 0.5D, 1.0F);
                worldIn.setState(pos, Blocks.fire.getState());
            }

            stack.damageItem(1, playerIn);
            return true;
        }
    }
    
    public boolean isMagnetic() {
    	return true;
    }
}
