@Override
 public ItemStack dispense(IBlockSource blockSource, ItemStack itemstack) {
   ItemStack result = dispenseStack(blockSource, itemstack);
   if (result == null) {
     System.out.println("Not processed. Chain to Vanilla.");
     return chain.dispense(blockSource, itemstack);
   }
   if (result.stackSize <= 0) {
     // The result was empty.
   } else if (addResultToInventory((TileEntityDispenser) blockSource.func_82619_j(), result)) {
     // The result was placed in inventory.
   } else if (itemstack.stackSize <= 0) {
     itemstack.itemID = result.itemID;
     itemstack.setItemDamage(result.getItemDamage());
     itemstack.stackSize = result.stackSize;
   } else {
     defaultDispenseBehavior.dispense(blockSource, result);
   }
   playDispenseSound(blockSource);
   spawnDispenseParticles(blockSource);
   return itemstack;
 }
  protected void dispenseItem(World world, BlockPos pos) {
    world.withTileEntity(
        pos,
        TileEntityDispenser.class,
        var4 -> {
          int var5 = var4.func_146017_i();

          if (var5 < 0) {
            world.playSound(1001, pos, 0);
          } else {
            ItemStack var6 = var4.get(var5);
            IBehaviorDispenseItem var7 = this.getDispenserLogic(var6);

            if (var7 != IBehaviorDispenseItem.itemDispenseBehaviorProvider) {
              ItemStack var8 = var7.dispense(new BlockSource(world, pos), var6);
              var4.set(var5, var8.stackSize == 0 ? null : var8);
            }
          }
        });
  }