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