public int func_76629_c(int p_76629_1_, int p_76629_2_, int p_76629_3_, int p_76629_4_) {
    ExtendedBlockStorage var5 = this.field_76652_q[p_76629_2_ >> 4];
    if (var5 == null) {
      return !this.field_76637_e.field_73011_w.field_76576_e
              && p_76629_4_ < EnumSkyBlock.Sky.field_77198_c
          ? EnumSkyBlock.Sky.field_77198_c - p_76629_4_
          : 0;
    } else {
      int var6 =
          this.field_76637_e.field_73011_w.field_76576_e
              ? 0
              : var5.func_76670_c(p_76629_1_, p_76629_2_ & 15, p_76629_3_);
      if (var6 > 0) {
        field_76640_a = true;
      }

      var6 -= p_76629_4_;
      int var7 = var5.func_76674_d(p_76629_1_, p_76629_2_ & 15, p_76629_3_);
      if (var7 > var6) {
        var6 = var7;
      }

      return var6;
    }
  }
 public int func_76628_c(int p_76628_1_, int p_76628_2_, int p_76628_3_) {
   if (p_76628_2_ >> 4 >= this.field_76652_q.length) {
     return 0;
   } else {
     ExtendedBlockStorage var4 = this.field_76652_q[p_76628_2_ >> 4];
     return var4 != null ? var4.func_76665_b(p_76628_1_, p_76628_2_ & 15, p_76628_3_) : 0;
   }
 }
 public int func_76614_a(EnumSkyBlock p_76614_1_, int p_76614_2_, int p_76614_3_, int p_76614_4_) {
   ExtendedBlockStorage var5 = this.field_76652_q[p_76614_3_ >> 4];
   return var5 == null
       ? (this.func_76619_d(p_76614_2_, p_76614_3_, p_76614_4_) ? p_76614_1_.field_77198_c : 0)
       : (p_76614_1_ == EnumSkyBlock.Sky
           ? var5.func_76670_c(p_76614_2_, p_76614_3_ & 15, p_76614_4_)
           : (p_76614_1_ == EnumSkyBlock.Block
               ? var5.func_76674_d(p_76614_2_, p_76614_3_ & 15, p_76614_4_)
               : p_76614_1_.field_77198_c));
 }
  public void func_76603_b() {
    int var1 = this.func_76625_h();

    int var2;
    int var3;
    for (var2 = 0; var2 < 16; ++var2) {
      var3 = 0;

      while (var3 < 16) {
        this.field_76638_b[var2 + (var3 << 4)] = -999;
        int var4 = var1 + 16 - 1;

        while (true) {
          if (var4 > 0) {
            if (this.func_76596_b(var2, var4 - 1, var3) == 0) {
              --var4;
              continue;
            }

            this.field_76634_f[var3 << 4 | var2] = var4;
          }

          if (!this.field_76637_e.field_73011_w.field_76576_e) {
            var4 = 15;
            int var5 = var1 + 16 - 1;

            do {
              var4 -= this.func_76596_b(var2, var5, var3);
              if (var4 > 0) {
                ExtendedBlockStorage var6 = this.field_76652_q[var5 >> 4];
                if (var6 != null) {
                  var6.func_76657_c(var2, var5 & 15, var3, var4);
                  this.field_76637_e.func_72902_n(
                      (this.field_76635_g << 4) + var2, var5, (this.field_76647_h << 4) + var3);
                }
              }

              --var5;
            } while (var5 > 0 && var4 > 0);
          }

          ++var3;
          break;
        }
      }
    }

    this.field_76643_l = true;

    for (var2 = 0; var2 < 16; ++var2) {
      for (var3 = 0; var3 < 16; ++var3) {
        this.func_76595_e(var2, var3);
      }
    }
  }
  public void func_76633_a(
      EnumSkyBlock p_76633_1_, int p_76633_2_, int p_76633_3_, int p_76633_4_, int p_76633_5_) {
    ExtendedBlockStorage var6 = this.field_76652_q[p_76633_3_ >> 4];
    if (var6 == null) {
      var6 = this.field_76652_q[p_76633_3_ >> 4] = new ExtendedBlockStorage(p_76633_3_ >> 4 << 4);
      this.func_76603_b();
    }

    this.field_76643_l = true;
    if (p_76633_1_ == EnumSkyBlock.Sky) {
      if (!this.field_76637_e.field_73011_w.field_76576_e) {
        var6.func_76657_c(p_76633_2_, p_76633_3_ & 15, p_76633_4_, p_76633_5_);
      }
    } else if (p_76633_1_ == EnumSkyBlock.Block) {
      var6.func_76677_d(p_76633_2_, p_76633_3_ & 15, p_76633_4_, p_76633_5_);
    }
  }
  public boolean func_76606_c(int p_76606_1_, int p_76606_2_) {
    if (p_76606_1_ < 0) {
      p_76606_1_ = 0;
    }

    if (p_76606_2_ >= 256) {
      p_76606_2_ = 255;
    }

    for (int var3 = p_76606_1_; var3 <= p_76606_2_; var3 += 16) {
      ExtendedBlockStorage var4 = this.field_76652_q[var3 >> 4];
      if (var4 != null && !var4.func_76663_a()) {
        return false;
      }
    }

    return true;
  }
  public boolean func_76589_b(int p_76589_1_, int p_76589_2_, int p_76589_3_, int p_76589_4_) {
    ExtendedBlockStorage var5 = this.field_76652_q[p_76589_2_ >> 4];
    if (var5 == null) {
      return false;
    } else {
      int var6 = var5.func_76665_b(p_76589_1_, p_76589_2_ & 15, p_76589_3_);
      if (var6 == p_76589_4_) {
        return false;
      } else {
        this.field_76643_l = true;
        var5.func_76654_b(p_76589_1_, p_76589_2_ & 15, p_76589_3_, p_76589_4_);
        int var7 = var5.func_76656_a(p_76589_1_, p_76589_2_ & 15, p_76589_3_);
        if (var7 > 0 && Block.field_71973_m[var7] instanceof BlockContainer) {
          TileEntity var8 = this.func_76597_e(p_76589_1_, p_76589_2_, p_76589_3_);
          if (var8 != null) {
            var8.func_70321_h();
            var8.field_70325_p = p_76589_4_;
          }
        }

        return true;
      }
    }
  }
  public boolean func_76592_a(
      int p_76592_1_, int p_76592_2_, int p_76592_3_, int p_76592_4_, int p_76592_5_) {
    int var6 = p_76592_3_ << 4 | p_76592_1_;
    if (p_76592_2_ >= this.field_76638_b[var6] - 1) {
      this.field_76638_b[var6] = -999;
    }

    int var7 = this.field_76634_f[var6];
    int var8 = this.func_76610_a(p_76592_1_, p_76592_2_, p_76592_3_);
    int var9 = this.func_76628_c(p_76592_1_, p_76592_2_, p_76592_3_);
    if (var8 == p_76592_4_ && var9 == p_76592_5_) {
      return false;
    } else {
      ExtendedBlockStorage var10 = this.field_76652_q[p_76592_2_ >> 4];
      boolean var11 = false;
      if (var10 == null) {
        if (p_76592_4_ == 0) {
          return false;
        }

        var10 =
            this.field_76652_q[p_76592_2_ >> 4] = new ExtendedBlockStorage(p_76592_2_ >> 4 << 4);
        var11 = p_76592_2_ >= var7;
      }

      int var12 = this.field_76635_g * 16 + p_76592_1_;
      int var13 = this.field_76647_h * 16 + p_76592_3_;
      if (var8 != 0 && !this.field_76637_e.field_72995_K) {
        Block.field_71973_m[var8].func_71927_h(this.field_76637_e, var12, p_76592_2_, var13, var9);
      }

      var10.func_76655_a(p_76592_1_, p_76592_2_ & 15, p_76592_3_, p_76592_4_);
      if (var8 != 0) {
        if (!this.field_76637_e.field_72995_K) {
          Block.field_71973_m[var8].func_71852_a(
              this.field_76637_e, var12, p_76592_2_, var13, var8, var9);
        } else if (Block.field_71973_m[var8] instanceof BlockContainer && var8 != p_76592_4_) {
          this.field_76637_e.func_72932_q(var12, p_76592_2_, var13);
        }
      }

      if (var10.func_76656_a(p_76592_1_, p_76592_2_ & 15, p_76592_3_) != p_76592_4_) {
        return false;
      } else {
        var10.func_76654_b(p_76592_1_, p_76592_2_ & 15, p_76592_3_, p_76592_5_);
        if (var11) {
          this.func_76603_b();
        } else {
          if (Block.field_71971_o[p_76592_4_ & 4095] > 0) {
            if (p_76592_2_ >= var7) {
              this.func_76615_h(p_76592_1_, p_76592_2_ + 1, p_76592_3_);
            }
          } else if (p_76592_2_ == var7 - 1) {
            this.func_76615_h(p_76592_1_, p_76592_2_, p_76592_3_);
          }

          this.func_76595_e(p_76592_1_, p_76592_3_);
        }

        TileEntity var14;
        if (p_76592_4_ != 0) {
          if (!this.field_76637_e.field_72995_K) {
            Block.field_71973_m[p_76592_4_].func_71861_g(
                this.field_76637_e, var12, p_76592_2_, var13);
          }

          if (Block.field_71973_m[p_76592_4_] instanceof BlockContainer) {
            var14 = this.func_76597_e(p_76592_1_, p_76592_2_, p_76592_3_);
            if (var14 == null) {
              var14 =
                  ((BlockContainer) Block.field_71973_m[p_76592_4_])
                      .func_72274_a(this.field_76637_e);
              this.field_76637_e.func_72837_a(var12, p_76592_2_, var13, var14);
            }

            if (var14 != null) {
              var14.func_70321_h();
            }
          }
        } else if (var8 > 0 && Block.field_71973_m[var8] instanceof BlockContainer) {
          var14 = this.func_76597_e(p_76592_1_, p_76592_2_, p_76592_3_);
          if (var14 != null) {
            var14.func_70321_h();
          }
        }

        this.field_76643_l = true;
        return true;
      }
    }
  }
  private void func_76615_h(int p_76615_1_, int p_76615_2_, int p_76615_3_) {
    int var4 = this.field_76634_f[p_76615_3_ << 4 | p_76615_1_] & 255;
    int var5 = var4;
    if (p_76615_2_ > var4) {
      var5 = p_76615_2_;
    }

    while (var5 > 0 && this.func_76596_b(p_76615_1_, var5 - 1, p_76615_3_) == 0) {
      --var5;
    }

    if (var5 != var4) {
      this.field_76637_e.func_72975_g(
          p_76615_1_ + this.field_76635_g * 16, p_76615_3_ + this.field_76647_h * 16, var5, var4);
      this.field_76634_f[p_76615_3_ << 4 | p_76615_1_] = var5;
      int var6 = this.field_76635_g * 16 + p_76615_1_;
      int var7 = this.field_76647_h * 16 + p_76615_3_;
      int var8;
      int var12;
      if (!this.field_76637_e.field_73011_w.field_76576_e) {
        ExtendedBlockStorage var9;
        if (var5 < var4) {
          for (var8 = var5; var8 < var4; ++var8) {
            var9 = this.field_76652_q[var8 >> 4];
            if (var9 != null) {
              var9.func_76657_c(p_76615_1_, var8 & 15, p_76615_3_, 15);
              this.field_76637_e.func_72902_n(
                  (this.field_76635_g << 4) + p_76615_1_,
                  var8,
                  (this.field_76647_h << 4) + p_76615_3_);
            }
          }
        } else {
          for (var8 = var4; var8 < var5; ++var8) {
            var9 = this.field_76652_q[var8 >> 4];
            if (var9 != null) {
              var9.func_76657_c(p_76615_1_, var8 & 15, p_76615_3_, 0);
              this.field_76637_e.func_72902_n(
                  (this.field_76635_g << 4) + p_76615_1_,
                  var8,
                  (this.field_76647_h << 4) + p_76615_3_);
            }
          }
        }

        var8 = 15;

        while (var5 > 0 && var8 > 0) {
          --var5;
          var12 = this.func_76596_b(p_76615_1_, var5, p_76615_3_);
          if (var12 == 0) {
            var12 = 1;
          }

          var8 -= var12;
          if (var8 < 0) {
            var8 = 0;
          }

          ExtendedBlockStorage var10 = this.field_76652_q[var5 >> 4];
          if (var10 != null) {
            var10.func_76657_c(p_76615_1_, var5 & 15, p_76615_3_, var8);
          }
        }
      }

      var8 = this.field_76634_f[p_76615_3_ << 4 | p_76615_1_];
      var12 = var4;
      int var13 = var8;
      if (var8 < var4) {
        var12 = var8;
        var13 = var4;
      }

      if (!this.field_76637_e.field_73011_w.field_76576_e) {
        this.func_76609_d(var6 - 1, var7, var12, var13);
        this.func_76609_d(var6 + 1, var7, var12, var13);
        this.func_76609_d(var6, var7 - 1, var12, var13);
        this.func_76609_d(var6, var7 + 1, var12, var13);
        this.func_76609_d(var6, var7, var12, var13);
      }

      this.field_76643_l = true;
    }
  }