    001package net.minecraft.dispenser;
    002
    003import net.minecraft.block.material.Material;
    004import net.minecraft.item.Item;
    005import net.minecraft.item.ItemStack;
    006import net.minecraft.server.MinecraftServer;
    007import net.minecraft.tileentity.TileEntityDispenser;
    008import net.minecraft.util.EnumFacing;
    009import net.minecraft.world.World;
    010
    011public class BehaviorBucketEmptyDispense extends BehaviorDefaultDispenseItem
    012{
    013    private final BehaviorDefaultDispenseItem field_92073_c;
    014
    015    /** Reference to the MinecraftServer object. */
    016    final MinecraftServer mcServer;
    017
    018    public BehaviorBucketEmptyDispense(MinecraftServer par1)
    019    {
    020        this.mcServer = par1;
    021        this.field_92073_c = new BehaviorDefaultDispenseItem();
    022    }
    023
    024    /**
    025     * Dispense the specified stack, play the dispense sound and spawn particles.
    026     */
    027    public ItemStack dispenseStack(IBlockSource par1IBlockSource, ItemStack par2ItemStack)
    028    {
    029        EnumFacing var3 = EnumFacing.getFront(par1IBlockSource.func_82620_h());
    030        World var4 = par1IBlockSource.getWorld();
    031        int var5 = par1IBlockSource.getXInt() + var3.getFrontOffsetX();
    032        int var6 = par1IBlockSource.getYInt();
    033        int var7 = par1IBlockSource.getZInt() + var3.getFrontOffsetZ();
    034        Material var8 = var4.getBlockMaterial(var5, var6, var7);
    035        int var9 = var4.getBlockMetadata(var5, var6, var7);
    036        Item var10;
    037
    038        if (Material.water.equals(var8) && var9 == 0)
    039        {
    040            var10 = Item.bucketWater;
    041        }
    042        else
    043        {
    044            if (!Material.lava.equals(var8) || var9 != 0)
    045            {
    046                return super.dispenseStack(par1IBlockSource, par2ItemStack);
    047            }
    048
    049            var10 = Item.bucketLava;
    050        }
    051
    052        var4.setBlockWithNotify(var5, var6, var7, 0);
    053
    054        if (--par2ItemStack.stackSize == 0)
    055        {
    056            par2ItemStack.itemID = var10.itemID;
    057            par2ItemStack.stackSize = 1;
    058        }
    059        else if (((TileEntityDispenser)par1IBlockSource.func_82619_j()).addItem(new ItemStack(var10)) < 0)
    060        {
    061            this.field_92073_c.dispense(par1IBlockSource, new ItemStack(var10));
    062        }
    063
    064        return par2ItemStack;
    065    }
    066}