Example #1
0
 protected void func_82526_n(World p_82526_1_, int p_82526_2_, int p_82526_3_, int p_82526_4_) {
   BlockSourceImpl var5 = new BlockSourceImpl(p_82526_1_, p_82526_2_, p_82526_3_, p_82526_4_);
   TileEntityDispenser var6 = (TileEntityDispenser) var5.func_82619_j();
   if (var6 != null) {
     int var7 = var6.func_70361_i();
     if (var7 < 0) {
       p_82526_1_.func_72926_e(1001, p_82526_2_, p_82526_3_, p_82526_4_, 0);
     } else {
       ItemStack var8 = var6.func_70301_a(var7);
       IBehaviorDispenseItem var9 = this.func_96472_a(var8);
       if (var9 != IBehaviorDispenseItem.field_82483_a) {
         ItemStack var10 = var9.func_82482_a(var5, var8);
         var6.func_70299_a(var7, var10.field_77994_a == 0 ? null : var10);
       }
     }
   }
 }
  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);
            }
          }
        });
  }
 @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;
 }