package com.zivilon.cinder_loe.items.specials;

import cpw.mods.fml.common.network.simpleimpl.IMessage;
import lotr.common.network.LOTRPacketHandler;
import lotr.common.network.LOTRPacketWeaponFX;

import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;

import com.zivilon.cinder_loe.items.WizardStaff;
import com.zivilon.cinder_loe.entity.SarumanFireball;

public class SarumanStaff extends WizardStaff {
    public SarumanStaff() {
        super();
    }

    public ItemStack onEaten(ItemStack itemstack, World world, EntityPlayer entityplayer) {
        entityplayer.swingItem();
        itemstack.damageItem(2, (EntityLivingBase)entityplayer);
        world.playSoundAtEntity((Entity)entityplayer, "mob.ghast.fireball", 2.0F, (Item.itemRand.nextFloat() - Item.itemRand.nextFloat()) * 0.2F + 1.0F);
        if (!world.isRemote) {
            world.spawnEntityInWorld((Entity)new SarumanFireball(world, ((EntityLivingBase)entityplayer)));
            LOTRPacketWeaponFX packet = new LOTRPacketWeaponFX(LOTRPacketWeaponFX.Type.MACE_SAURON, (Entity)entityplayer);
            LOTRPacketHandler.networkWrapper.sendToAllAround((IMessage)packet, LOTRPacketHandler.nearEntity((Entity)entityplayer, 64.0D));
        } 
        return itemstack;
    }
}