/** Get the position where the dispenser at the given Coordinates should dispense to. */
 public static IPosition getDispensePosition(IBlockSource coords) {
   EnumDirection var1 = getFacing(coords.getBlockMetadata());
   double var2 = coords.getX() + 0.7D * var1.getOffsetX();
   double var4 = coords.getY() + 0.7D * var1.getOffsetY();
   double var6 = coords.getZ() + 0.7D * var1.getOffsetZ();
   return new PositionImpl(var2, var4, var6);
 }
 protected ItemStack dispenseStack(IBlockSource source, ItemStack stack) {
   EnumFacing var3 = BlockDispenser.getFacing(source.getBlockMetadata());
   IPosition var4 = BlockDispenser.getDispensePosition(source);
   ItemStack var5 = stack.splitStack(1);
   doDispense(source.getWorld(), var5, 6, var3, var4);
   return stack;
 }
 /** Play the dispense sound from the specified block. */
 protected void playDispenseSound(IBlockSource par1IBlockSource) {
   par1IBlockSource
       .getWorld()
       .playAuxSFX(
           1000,
           par1IBlockSource.getXInt(),
           par1IBlockSource.getYInt(),
           par1IBlockSource.getZInt(),
           0);
 }
  /** Dispense the specified stack, play the dispense sound and spawn particles. */
  public ItemStack dispenseStack(IBlockSource par1IBlockSource, ItemStack par2ItemStack) {
    EnumFacing enumfacing = BlockDispenser.getFacing(par1IBlockSource.getBlockMetadata());
    World world = par1IBlockSource.getWorld();
    double d0 = par1IBlockSource.getX() + (double) ((float) enumfacing.getFrontOffsetX() * 1.125F);
    double d1 = par1IBlockSource.getY() + (double) ((float) enumfacing.getFrontOffsetY() * 1.125F);
    double d2 = par1IBlockSource.getZ() + (double) ((float) enumfacing.getFrontOffsetZ() * 1.125F);
    int i = par1IBlockSource.getXInt() + enumfacing.getFrontOffsetX();
    int j = par1IBlockSource.getYInt() + enumfacing.getFrontOffsetY();
    int k = par1IBlockSource.getZInt() + enumfacing.getFrontOffsetZ();
    Material material = world.getBlockMaterial(i, j, k);
    double d3;

    if (Material.water.equals(material)) {
      d3 = 1.0D;
    } else {
      if (!Material.air.equals(material)
          || !Material.water.equals(world.getBlockMaterial(i, j - 1, k))) {
        return this.defaultDispenserItemBehavior.dispense(par1IBlockSource, par2ItemStack);
      }

      d3 = 0.0D;
    }

    EntityBoat entityboat = new EntityBoat(world, d0, d1 + d3, d2);
    world.spawnEntityInWorld(entityboat);
    par2ItemStack.splitStack(1);
    return par2ItemStack;
  }
  /** Dispense the specified stack, play the dispense sound and spawn particles. */
  public ItemStack dispenseStack(IBlockSource par1IBlockSource, ItemStack par2ItemStack) {
    EnumFacing var3 = EnumFacing.func_82600_a(par1IBlockSource.func_82620_h());
    World var4 = par1IBlockSource.getWorld();
    double var5 = par1IBlockSource.getX() + (double) ((float) var3.func_82601_c() * 1.125F);
    double var7 = par1IBlockSource.getY();
    double var9 = par1IBlockSource.getZ() + (double) ((float) var3.func_82599_e() * 1.125F);
    int var11 = par1IBlockSource.getXInt() + var3.func_82601_c();
    int var12 = par1IBlockSource.getYInt();
    int var13 = par1IBlockSource.getZInt() + var3.func_82599_e();
    Material var14 = var4.getBlockMaterial(var11, var12, var13);
    double var15;

    if (Material.water.equals(var14)) {
      var15 = 1.0D;
    } else {
      if (!Material.air.equals(var14)
          || !Material.water.equals(var4.getBlockMaterial(var11, var12 - 1, var13))) {
        return this.defaultItemDispenseBehavior.dispense(par1IBlockSource, par2ItemStack);
      }

      var15 = 0.0D;
    }

    EntityBoat var17 = new EntityBoat(var4, var5, var7 + var15, var9);
    var4.spawnEntityInWorld(var17);
    par2ItemStack.splitStack(1);
    return par2ItemStack;
  }
  /** Dispense the specified stack, play the dispense sound and spawn particles. */
  public ItemStack dispenseStack(IBlockSource par1IBlockSource, ItemStack par2ItemStack) {
    EnumFacing var3 = BlockDispenser.getFacing(par1IBlockSource.getBlockMetadata());
    double var4 = par1IBlockSource.getX() + (double) var3.getFrontOffsetX();
    double var6 = (double) ((float) par1IBlockSource.getYInt() + 0.2F);
    double var8 = par1IBlockSource.getZ() + (double) var3.getFrontOffsetZ();
    Entity var10 =
        ItemMonsterPlacer.spawnCreature(
            par1IBlockSource.getWorld(), par2ItemStack.getItemDamage(), var4, var6, var8);

    if (var10 instanceof EntityLiving && par2ItemStack.hasDisplayName()) {
      ((EntityLiving) var10).func_94058_c(par2ItemStack.getDisplayName());
    }

    par2ItemStack.splitStack(1);
    return par2ItemStack;
  }
 /** Dispense the specified stack, play the dispense sound and spawn particles. */
 protected ItemStack dispenseStack(IBlockSource par1IBlockSource, ItemStack par2ItemStack) {
   EnumFacing enumfacing = BlockDispenser.getFacing(par1IBlockSource.getBlockMetadata());
   World world = par1IBlockSource.getWorld();
   int i = par1IBlockSource.getXInt() + enumfacing.getFrontOffsetX();
   int j = par1IBlockSource.getYInt() + enumfacing.getFrontOffsetY();
   int k = par1IBlockSource.getZInt() + enumfacing.getFrontOffsetZ();
   EntityTNTPrimed entitytntprimed =
       new EntityTNTPrimed(
           world,
           (double) ((float) i + 0.5F),
           (double) ((float) j + 0.5F),
           (double) ((float) k + 0.5F),
           (EntityLivingBase) null);
   world.spawnEntityInWorld(entitytntprimed);
   --par2ItemStack.stackSize;
   return par2ItemStack;
 }
  public ItemStack b(IBlockSource iblocksource, ItemStack itemstack) {
    EnumFacing enumfacing = BlockDispenser.j_(iblocksource.h());
    World world = iblocksource.k();
    double d0 = iblocksource.a() + (double) ((float) enumfacing.c() * 1.125F);
    double d1 = iblocksource.b() + (double) ((float) enumfacing.d() * 1.125F);
    double d2 = iblocksource.c() + (double) ((float) enumfacing.e() * 1.125F);
    int i0 = iblocksource.d() + enumfacing.c();
    int i1 = iblocksource.e() + enumfacing.d();
    int i2 = iblocksource.f() + enumfacing.e();
    int i3 = world.a(i0, i1, i2);
    double d3;

    if (BlockRailBase.d_(i3)) {
      d3 = 0.0D;
    } else {
      if (i3 != 0 || !BlockRailBase.d_(world.a(i0, i1 - 1, i2))) {
        return this.b.a(iblocksource, itemstack);
      }

      d3 = -1.0D;
    }

    EntityMinecart entityminecart =
        EntityMinecart.a(world, d0, d1 + d3, d2, ((ItemMinecart) itemstack.b()).a);

    // CanaryMod: Dispense
    DispenseHook hook =
        new DispenseHook(
            ((TileEntityDispenser) iblocksource.j()).getCanaryDispenser(),
            entityminecart.getCanaryEntity());

    Canary.hooks().callHook(hook);
    if (!hook.isCanceled()) {
      world.d((Entity) entityminecart);
      itemstack.a(1);
    }
    //
    return itemstack;
  }
  public ItemStack b(IBlockSource iblocksource, ItemStack itemstack) {
    EnumFacing enumfacing = BlockDispenser.j_(iblocksource.h());
    World world = iblocksource.k();
    int i0 = iblocksource.d() + enumfacing.c();
    int i1 = iblocksource.e() + enumfacing.d();
    int i2 = iblocksource.f() + enumfacing.e();
    Material material = world.g(i0, i1, i2);
    int i3 = world.h(i0, i1, i2);
    Item item;

    if (Material.h.equals(material) && i3 == 0) {
      item = Item.ay;
    } else {
      if (!Material.i.equals(material) || i3 != 0) {
        return super.b(iblocksource, itemstack);
      }

      item = Item.az;
    }

    world.i(i0, i1, i2);
    if (--itemstack.a == 0) {
      // CanaryMod: Dispense
      DispenseHook hook =
          new DispenseHook(((TileEntityDispenser) iblocksource.j()).getCanaryDispenser(), null);

      Canary.hooks().callHook(hook);
      if (!hook.isCanceled()) {
        itemstack.c = item.cp;
        itemstack.a = 1;
      }
      //
    } else if (((TileEntityDispenser) iblocksource.j()).a(new ItemStack(item)) < 0) {
      this.b.a(iblocksource, new ItemStack(item));
    }

    return itemstack;
  }
 protected void spawnDispenseParticles(IBlockSource source, EnumFacing facingIn) {
   source.getWorld().playAuxSFX(2000, source.getBlockPos(), this.func_82488_a(facingIn));
 }
 protected void playDispenseSound(IBlockSource source) {
   source.getWorld().playAuxSFX(1000, source.getBlockPos(), 0);
 }
 public final ItemStack dispense(IBlockSource source, ItemStack stack) {
   ItemStack var3 = this.dispenseStack(source, stack);
   this.playDispenseSound(source);
   this.spawnDispenseParticles(source, BlockDispenser.getFacing(source.getBlockMetadata()));
   return var3;
 }
 protected void a(IBlockSource iblocksource) {
   iblocksource.k().e(1000, iblocksource.d(), iblocksource.e(), iblocksource.f(), 0);
 }