    001package net.minecraft.dispenser;
    002
    003import java.util.Random;
    004import net.minecraft.block.BlockDispenser;
    005import net.minecraft.entity.projectile.EntitySmallFireball;
    006import net.minecraft.item.ItemStack;
    007import net.minecraft.server.MinecraftServer;
    008import net.minecraft.util.EnumFacing;
    009import net.minecraft.world.World;
    010
    011public class BehaviorDispenseFireball extends BehaviorDefaultDispenseItem
    012{
    013    final MinecraftServer mcServer;
    014
    015    public BehaviorDispenseFireball(MinecraftServer par1MinecraftServer)
    016    {
    017        this.mcServer = par1MinecraftServer;
    018    }
    019
    020    /**
    021     * Dispense the specified stack, play the dispense sound and spawn particles.
    022     */
    023    public ItemStack dispenseStack(IBlockSource par1IBlockSource, ItemStack par2ItemStack)
    024    {
    025        EnumFacing var3 = EnumFacing.getFront(par1IBlockSource.func_82620_h());
    026        IPosition var4 = BlockDispenser.func_82525_a(par1IBlockSource);
    027        double var5 = var4.getX() + (double)((float)var3.getFrontOffsetX() * 0.3F);
    028        double var7 = var4.getY();
    029        double var9 = var4.getZ() + (double)((float)var3.getFrontOffsetZ() * 0.3F);
    030        World var11 = par1IBlockSource.getWorld();
    031        Random var12 = var11.rand;
    032        double var13 = var12.nextGaussian() * 0.05D + (double)var3.getFrontOffsetX();
    033        double var15 = var12.nextGaussian() * 0.05D;
    034        double var17 = var12.nextGaussian() * 0.05D + (double)var3.getFrontOffsetZ();
    035        var11.spawnEntityInWorld(new EntitySmallFireball(var11, var5, var7, var9, var13, var15, var17));
    036        par2ItemStack.splitStack(1);
    037        return par2ItemStack;
    038    }
    039
    040    /**
    041     * Play the dispense sound from the specified block.
    042     */
    043    protected void playDispenseSound(IBlockSource par1IBlockSource)
    044    {
    045        par1IBlockSource.getWorld().playAuxSFX(1009, par1IBlockSource.getXInt(), par1IBlockSource.getYInt(), par1IBlockSource.getZInt(), 0);
    046    }
    047}