private int func_70452_e(ItemStack p_70452_1_) {
    int var2 = p_70452_1_.field_77993_c;
    int var3 = p_70452_1_.field_77994_a;
    int var4;
    if (p_70452_1_.func_77976_d() == 1) {
      var4 = this.func_70447_i();
      if (var4 < 0) {
        return var3;
      } else {
        if (this.field_70462_a[var4] == null) {
          this.field_70462_a[var4] = ItemStack.func_77944_b(p_70452_1_);
        }

        return 0;
      }
    } else {
      var4 = this.func_70432_d(p_70452_1_);
      if (var4 < 0) {
        var4 = this.func_70447_i();
      }

      if (var4 < 0) {
        return var3;
      } else {
        if (this.field_70462_a[var4] == null) {
          this.field_70462_a[var4] = new ItemStack(var2, 0, p_70452_1_.func_77960_j());
          if (p_70452_1_.func_77942_o()) {
            this.field_70462_a[var4].func_77982_d(
                (NBTTagCompound) p_70452_1_.func_77978_p().func_74737_b());
          }
        }

        int var5 = var3;
        if (var3
            > this.field_70462_a[var4].func_77976_d() - this.field_70462_a[var4].field_77994_a) {
          var5 = this.field_70462_a[var4].func_77976_d() - this.field_70462_a[var4].field_77994_a;
        }

        if (var5 > this.func_70297_j_() - this.field_70462_a[var4].field_77994_a) {
          var5 = this.func_70297_j_() - this.field_70462_a[var4].field_77994_a;
        }

        if (var5 == 0) {
          return var3;
        } else {
          var3 -= var5;
          this.field_70462_a[var4].field_77994_a += var5;
          this.field_70462_a[var4].field_77992_b = 5;
          return var3;
        }
      }
    }
  }
  public void func_71852_a(
      World p_71852_1_,
      int p_71852_2_,
      int p_71852_3_,
      int p_71852_4_,
      int p_71852_5_,
      int p_71852_6_) {
    TileEntityChest var7 =
        (TileEntityChest) p_71852_1_.func_72796_p(p_71852_2_, p_71852_3_, p_71852_4_);
    if (var7 != null) {
      for (int var8 = 0; var8 < var7.func_70302_i_(); ++var8) {
        ItemStack var9 = var7.func_70301_a(var8);
        if (var9 != null) {
          float var10 = this.field_72293_a.nextFloat() * 0.8F + 0.1F;
          float var11 = this.field_72293_a.nextFloat() * 0.8F + 0.1F;

          EntityItem var14;
          for (float var12 = this.field_72293_a.nextFloat() * 0.8F + 0.1F;
              var9.field_77994_a > 0;
              p_71852_1_.func_72838_d(var14)) {
            int var13 = this.field_72293_a.nextInt(21) + 10;
            if (var13 > var9.field_77994_a) {
              var13 = var9.field_77994_a;
            }

            var9.field_77994_a -= var13;
            var14 =
                new EntityItem(
                    p_71852_1_,
                    (double) ((float) p_71852_2_ + var10),
                    (double) ((float) p_71852_3_ + var11),
                    (double) ((float) p_71852_4_ + var12),
                    new ItemStack(var9.field_77993_c, var13, var9.func_77960_j()));
            float var15 = 0.05F;
            var14.field_70159_w = (double) ((float) this.field_72293_a.nextGaussian() * var15);
            var14.field_70181_x =
                (double) ((float) this.field_72293_a.nextGaussian() * var15 + 0.2F);
            var14.field_70179_y = (double) ((float) this.field_72293_a.nextGaussian() * var15);
            if (var9.func_77942_o()) {
              var14
                  .func_92059_d()
                  .func_77982_d((NBTTagCompound) var9.func_77978_p().func_74737_b());
            }
          }
        }
      }
    }

    super.func_71852_a(p_71852_1_, p_71852_2_, p_71852_3_, p_71852_4_, p_71852_5_, p_71852_6_);
  }