    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        /** Reference to the MinecraftServer object. */
    016        final MinecraftServer mcServer;
    017
    018        public BehaviorDispenseBoat(MinecraftServer par1MinecraftServer)
    019        {
    020            this.mcServer = par1MinecraftServer;
    021            this.defaultItemDispenseBehavior = 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            double var5 = par1IBlockSource.getX() + (double)((float)var3.func_82601_c() * 1.125F);
    032            double var7 = par1IBlockSource.getY();
    033            double var9 = par1IBlockSource.getZ() + (double)((float)var3.func_82599_e() * 1.125F);
    034            int var11 = par1IBlockSource.getXInt() + var3.func_82601_c();
    035            int var12 = par1IBlockSource.getYInt();
    036            int var13 = par1IBlockSource.getZInt() + var3.func_82599_e();
    037            Material var14 = var4.getBlockMaterial(var11, var12, var13);
    038            double var15;
    039
    040            if (Material.water.equals(var14))
    041            {
    042                var15 = 1.0D;
    043            }
    044            else
    045            {
    046                if (!Material.air.equals(var14) || !Material.water.equals(var4.getBlockMaterial(var11, var12 - 1, var13)))
    047                {
    048                    return this.defaultItemDispenseBehavior.dispense(par1IBlockSource, par2ItemStack);
    049                }
    050
    051                var15 = 0.0D;
    052            }
    053
    054            EntityBoat var17 = new EntityBoat(var4, var5, var7 + var15, var9);
    055            var4.spawnEntityInWorld(var17);
    056            par2ItemStack.splitStack(1);
    057            return par2ItemStack;
    058        }
    059
    060        /**
    061         * Play the dispense sound from the specified block.
    062         */
    063        protected void playDispenseSound(IBlockSource par1IBlockSource)
    064        {
    065            par1IBlockSource.getWorld().playAuxSFX(1000, par1IBlockSource.getXInt(), par1IBlockSource.getYInt(), par1IBlockSource.getZInt(), 0);
    066        }
    067    }