    001    package net.minecraft.dispenser;
    002
    003    import net.minecraft.block.material.Material;
    004    import net.minecraft.item.Item;
    005    import net.minecraft.item.ItemStack;
    006    import net.minecraft.server.MinecraftServer;
    007    import net.minecraft.tileentity.TileEntityDispenser;
    008    import net.minecraft.util.EnumFacing;
    009    import net.minecraft.world.World;
    010
    011    public class BehaviorBucketEmptyDispense extends BehaviorDefaultDispenseItem
    012    {
    013        private final BehaviorDefaultDispenseItem field_92018_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_92018_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.func_82600_a(par1IBlockSource.func_82620_h());
    030            World var4 = par1IBlockSource.getWorld();
    031            int var5 = par1IBlockSource.getXInt() + var3.func_82601_c();
    032            int var6 = par1IBlockSource.getYInt();
    033            int var7 = par1IBlockSource.getZInt() + var3.func_82599_e();
    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.shiftedIndex;
    057                par2ItemStack.stackSize = 1;
    058            }
    059            else if (((TileEntityDispenser)par1IBlockSource.func_82619_j()).func_70360_a(new ItemStack(var10)) < 0)
    060            {
    061                this.field_92018_c.dispense(par1IBlockSource, new ItemStack(var10));
    062            }
    063
    064            return par2ItemStack;
    065        }
    066    }