001package net.minecraft.item;
002
003import net.minecraft.block.Block;
004import net.minecraft.creativetab.CreativeTabs;
005import net.minecraft.entity.player.EntityPlayer;
006import net.minecraft.world.World;
007
008public class ItemFireball extends Item
009{
010    public ItemFireball(int par1)
011    {
012        super(par1);
013        this.setCreativeTab(CreativeTabs.tabMisc);
014    }
015
016    /**
017     * Callback for item usage. If the item does something special on right clicking, he will have one of those. Return
018     * True if something happen and false if it don't. This is for ITEMS, not BLOCKS
019     */
020    public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10)
021    {
022        if (par3World.isRemote)
023        {
024            return true;
025        }
026        else
027        {
028            if (par7 == 0)
029            {
030                --par5;
031            }
032
033            if (par7 == 1)
034            {
035                ++par5;
036            }
037
038            if (par7 == 2)
039            {
040                --par6;
041            }
042
043            if (par7 == 3)
044            {
045                ++par6;
046            }
047
048            if (par7 == 4)
049            {
050                --par4;
051            }
052
053            if (par7 == 5)
054            {
055                ++par4;
056            }
057
058            if (!par2EntityPlayer.canPlayerEdit(par4, par5, par6, par7, par1ItemStack))
059            {
060                return false;
061            }
062            else
063            {
064                int i1 = par3World.getBlockId(par4, par5, par6);
065
066                if (i1 == 0)
067                {
068                    par3World.playSoundEffect((double)par4 + 0.5D, (double)par5 + 0.5D, (double)par6 + 0.5D, "fire.ignite", 1.0F, itemRand.nextFloat() * 0.4F + 0.8F);
069                    par3World.setBlock(par4, par5, par6, Block.fire.blockID);
070                }
071
072                if (!par2EntityPlayer.capabilities.isCreativeMode)
073                {
074                    --par1ItemStack.stackSize;
075                }
076
077                return true;
078            }
079        }
080    }
081}