    001    package net.minecraft.dispenser;
    002
    003    import net.minecraft.block.material.Material;
    004    import net.minecraft.entity.item.EntityBoat;
    005    import net.minecraft.item.ItemStack;
    006    import net.minecraft.server.MinecraftServer;
    007    import net.minecraft.util.EnumFacing;
    008    import net.minecraft.world.World;
    009
    010    public class BehaviorDispenseBoat extends BehaviorDefaultDispenseItem
    011    {
    012        /** Reference to the BehaviorDefaultDispenseItem object. */
    013        private final BehaviorDefaultDispenseItem defaultItemDispenseBehavior;
    014
    015        final MinecraftServer mcServer;
    016
    017        public BehaviorDispenseBoat(MinecraftServer par1MinecraftServer)
    018        {
    019            this.mcServer = par1MinecraftServer;
    020            this.defaultItemDispenseBehavior = new BehaviorDefaultDispenseItem();
    021        }
    022
    023        /**
    024         * Dispense the specified stack, play the dispense sound and spawn particles.
    025         */
    026        public ItemStack dispenseStack(IBlockSource par1IBlockSource, ItemStack par2ItemStack)
    027        {
    028            EnumFacing var3 = EnumFacing.func_82600_a(par1IBlockSource.func_82620_h());
    029            World var4 = par1IBlockSource.getWorld();
    030            double var5 = par1IBlockSource.getX() + (double)((float)var3.func_82601_c() * 1.125F);
    031            double var7 = par1IBlockSource.getY();
    032            double var9 = par1IBlockSource.getZ() + (double)((float)var3.func_82599_e() * 1.125F);
    033            int var11 = par1IBlockSource.getXInt() + var3.func_82601_c();
    034            int var12 = par1IBlockSource.getYInt();
    035            int var13 = par1IBlockSource.getZInt() + var3.func_82599_e();
    036            Material var14 = var4.getBlockMaterial(var11, var12, var13);
    037            double var15;
    038
    039            if (Material.water.equals(var14))
    040            {
    041                var15 = 1.0D;
    042            }
    043            else
    044            {
    045                if (!Material.air.equals(var14) || !Material.water.equals(var4.getBlockMaterial(var11, var12 - 1, var13)))
    046                {
    047                    return this.defaultItemDispenseBehavior.dispense(par1IBlockSource, par2ItemStack);
    048                }
    049
    050                var15 = 0.0D;
    051            }
    052
    053            EntityBoat var17 = new EntityBoat(var4, var5, var7 + var15, var9);
    054            var4.spawnEntityInWorld(var17);
    055            par2ItemStack.splitStack(1);
    056            return par2ItemStack;
    057        }
    058
    059        /**
    060         * Play the dispense sound from the specified block.
    061         */
    062        protected void playDispenseSound(IBlockSource par1IBlockSource)
    063        {
    064            par1IBlockSource.getWorld().playAuxSFX(1000, par1IBlockSource.getXInt(), par1IBlockSource.getYInt(), par1IBlockSource.getZInt(), 0);
    065        }
    066    }