Esempio n. 1
0
  public void updateTick(World world, int x, int y, int z, Random random) {
    if (!world.isRemote) {
      int meta = world.getBlockMetadata(x, y, z);

      if ((meta & 4) == 0) {
        boolean nearbyTree = false;
        byte range = 4;
        for (int posX = x - range; posX <= x + range; posX++) {
          for (int posY = y - range; posY <= y + range; posY++) {
            for (int posZ = z - range; posZ <= z + range; posZ++) {
              Block block = Block.blocksList[world.getBlockId(posX, posY, posZ)];
              if (block != null && block.canSustainLeaves(world, posX, posY, posZ))
                nearbyTree = true;
            }
          }
        }

        if (!nearbyTree) this.removeLeaves(world, x, y, z);
      }
    }
  }
Esempio n. 2
0
  @Override
  public void updateTick(World world, int x, int y, int z, Random random) {
    if (world.isRemote) return;

    int meta = world.getBlockMetadata(x, y, z);

    if ((meta & 8) != 0 /* && (meta & 4) == 0*/) {
      byte b0 = 4;
      int i1 = b0 + 1;
      byte b1 = 32;
      int j1 = b1 * b1;
      int k1 = b1 / 2;

      if (adjacentTreeBlocks == null) {
        adjacentTreeBlocks = new int[b1 * b1 * b1];
      }

      int l1;

      if (world.checkChunksExist(x - i1, y - i1, z - i1, x + i1, y + i1, z + i1)) {
        int i2;
        int j2;
        int k2;

        for (l1 = -b0; l1 <= b0; ++l1) {
          for (i2 = -b0; i2 <= b0; ++i2) {
            for (j2 = -b0; j2 <= b0; ++j2) {
              k2 = world.getBlockId(x + l1, y + i2, z + j2);

              Block block = Block.blocksList[k2];

              if (block != null && block.canSustainLeaves(world, x + l1, y + i2, z + j2)) {
                adjacentTreeBlocks[(l1 + k1) * j1 + (i2 + k1) * b1 + j2 + k1] = 0;
              } else if (block != null && block.isLeaves(world, x + l1, y + i2, z + j2)) {
                adjacentTreeBlocks[(l1 + k1) * j1 + (i2 + k1) * b1 + j2 + k1] = -2;
              } else {
                adjacentTreeBlocks[(l1 + k1) * j1 + (i2 + k1) * b1 + j2 + k1] = -1;
              }
            }
          }
        }

        for (l1 = 1; l1 <= 4; ++l1) {
          for (i2 = -b0; i2 <= b0; ++i2) {
            for (j2 = -b0; j2 <= b0; ++j2) {
              for (k2 = -b0; k2 <= b0; ++k2) {
                if (adjacentTreeBlocks[(i2 + k1) * j1 + (j2 + k1) * b1 + k2 + k1] == l1 - 1) {
                  if (adjacentTreeBlocks[(i2 + k1 - 1) * j1 + (j2 + k1) * b1 + k2 + k1] == -2) {
                    adjacentTreeBlocks[(i2 + k1 - 1) * j1 + (j2 + k1) * b1 + k2 + k1] = l1;
                  }

                  if (adjacentTreeBlocks[(i2 + k1 + 1) * j1 + (j2 + k1) * b1 + k2 + k1] == -2) {
                    adjacentTreeBlocks[(i2 + k1 + 1) * j1 + (j2 + k1) * b1 + k2 + k1] = l1;
                  }

                  if (adjacentTreeBlocks[(i2 + k1) * j1 + (j2 + k1 - 1) * b1 + k2 + k1] == -2) {
                    adjacentTreeBlocks[(i2 + k1) * j1 + (j2 + k1 - 1) * b1 + k2 + k1] = l1;
                  }

                  if (adjacentTreeBlocks[(i2 + k1) * j1 + (j2 + k1 + 1) * b1 + k2 + k1] == -2) {
                    adjacentTreeBlocks[(i2 + k1) * j1 + (j2 + k1 + 1) * b1 + k2 + k1] = l1;
                  }

                  if (adjacentTreeBlocks[(i2 + k1) * j1 + (j2 + k1) * b1 + (k2 + k1 - 1)] == -2) {
                    adjacentTreeBlocks[(i2 + k1) * j1 + (j2 + k1) * b1 + (k2 + k1 - 1)] = l1;
                  }

                  if (adjacentTreeBlocks[(i2 + k1) * j1 + (j2 + k1) * b1 + k2 + k1 + 1] == -2) {
                    adjacentTreeBlocks[(i2 + k1) * j1 + (j2 + k1) * b1 + k2 + k1 + 1] = l1;
                  }
                }
              }
            }
          }
        }
      }

      l1 = adjacentTreeBlocks[k1 * j1 + k1 * b1 + k1];

      if (l1 >= 0) {
        world.setBlockMetadataWithNotify(x, y, z, meta & -9, 4);
      } else {
        this.removeLeaves(world, x, y, z);
      }
    }
  }
Esempio n. 3
0
  /** Ticks the block if it's been scheduled */
  public void updateTick(World var1, int var2, int var3, int var4, Random var5) {
    if (!var1.isRemote) {
      int var6 = var1.getBlockMetadata(var2, var3, var4);

      if ((var6 & 8) != 0 && (var6 & 4) == 0) {
        byte var7 = 4;
        int var8 = var7 + 1;
        byte var9 = 32;
        int var10 = var9 * var9;
        int var11 = var9 / 2;

        if (this.adjacentTreeBlocks == null) {
          this.adjacentTreeBlocks = new int[var9 * var9 * var9];
        }

        int var12;

        if (var1.checkChunksExist(
            var2 - var8, var3 - var8, var4 - var8, var2 + var8, var3 + var8, var4 + var8)) {
          int var13;
          int var14;
          int var15;

          for (var12 = -var7; var12 <= var7; ++var12) {
            for (var13 = -var7; var13 <= var7; ++var13) {
              for (var14 = -var7; var14 <= var7; ++var14) {
                var15 = var1.getBlockId(var2 + var12, var3 + var13, var4 + var14);
                Block var16 = Block.blocksList[var15];

                if (var16 != null
                    && var16.canSustainLeaves(var1, var2 + var12, var3 + var13, var4 + var14)) {
                  this.adjacentTreeBlocks[
                          (var12 + var11) * var10 + (var13 + var11) * var9 + var14 + var11] =
                      0;
                } else if (var16 != null
                    && var16.isLeaves(var1, var2 + var12, var3 + var13, var4 + var14)) {
                  this.adjacentTreeBlocks[
                          (var12 + var11) * var10 + (var13 + var11) * var9 + var14 + var11] =
                      -2;
                } else {
                  this.adjacentTreeBlocks[
                          (var12 + var11) * var10 + (var13 + var11) * var9 + var14 + var11] =
                      -1;
                }
              }
            }
          }

          for (var12 = 1; var12 <= 4; ++var12) {
            for (var13 = -var7; var13 <= var7; ++var13) {
              for (var14 = -var7; var14 <= var7; ++var14) {
                for (var15 = -var7; var15 <= var7; ++var15) {
                  if (this.adjacentTreeBlocks[
                          (var13 + var11) * var10 + (var14 + var11) * var9 + var15 + var11]
                      == var12 - 1) {
                    if (this.adjacentTreeBlocks[
                            (var13 + var11 - 1) * var10 + (var14 + var11) * var9 + var15 + var11]
                        == -2) {
                      this.adjacentTreeBlocks[
                              (var13 + var11 - 1) * var10
                                  + (var14 + var11) * var9
                                  + var15
                                  + var11] =
                          var12;
                    }

                    if (this.adjacentTreeBlocks[
                            (var13 + var11 + 1) * var10 + (var14 + var11) * var9 + var15 + var11]
                        == -2) {
                      this.adjacentTreeBlocks[
                              (var13 + var11 + 1) * var10
                                  + (var14 + var11) * var9
                                  + var15
                                  + var11] =
                          var12;
                    }

                    if (this.adjacentTreeBlocks[
                            (var13 + var11) * var10 + (var14 + var11 - 1) * var9 + var15 + var11]
                        == -2) {
                      this.adjacentTreeBlocks[
                              (var13 + var11) * var10
                                  + (var14 + var11 - 1) * var9
                                  + var15
                                  + var11] =
                          var12;
                    }

                    if (this.adjacentTreeBlocks[
                            (var13 + var11) * var10 + (var14 + var11 + 1) * var9 + var15 + var11]
                        == -2) {
                      this.adjacentTreeBlocks[
                              (var13 + var11) * var10
                                  + (var14 + var11 + 1) * var9
                                  + var15
                                  + var11] =
                          var12;
                    }

                    if (this.adjacentTreeBlocks[
                            (var13 + var11) * var10 + (var14 + var11) * var9 + (var15 + var11 - 1)]
                        == -2) {
                      this.adjacentTreeBlocks[
                              (var13 + var11) * var10
                                  + (var14 + var11) * var9
                                  + (var15 + var11 - 1)] =
                          var12;
                    }

                    if (this.adjacentTreeBlocks[
                            (var13 + var11) * var10 + (var14 + var11) * var9 + var15 + var11 + 1]
                        == -2) {
                      this.adjacentTreeBlocks[
                              (var13 + var11) * var10
                                  + (var14 + var11) * var9
                                  + var15
                                  + var11
                                  + 1] =
                          var12;
                    }
                  }
                }
              }
            }
          }
        }

        var12 = this.adjacentTreeBlocks[var11 * var10 + var11 * var9 + var11];

        if (var12 >= 0) {
          var1.setBlockMetadata(var2, var3, var4, var6 & -9);
        } else {
          this.removeLeaves(var1, var2, var3, var4);
        }
      }
    }
  }
Esempio n. 4
0
  /** Ticks the block if it's been scheduled */
  public void updateTick(World par1World, int par2, int par3, int par4, Random par5Random) {
    if (!par1World.isRemote) {
      int l = par1World.getBlockMetadata(par2, par3, par4);

      if ((l & 8) != 0 && (l & 4) == 0) {
        byte b0 = 4;
        int i1 = b0 + 1;
        byte b1 = 32;
        int j1 = b1 * b1;
        int k1 = b1 / 2;

        if (this.adjacentTreeBlocks == null) {
          this.adjacentTreeBlocks = new int[b1 * b1 * b1];
        }

        int l1;

        if (par1World.checkChunksExist(
            par2 - i1, par3 - i1, par4 - i1, par2 + i1, par3 + i1, par4 + i1)) {
          int i2;
          int j2;
          int k2;

          for (l1 = -b0; l1 <= b0; ++l1) {
            for (i2 = -b0; i2 <= b0; ++i2) {
              for (j2 = -b0; j2 <= b0; ++j2) {
                k2 = par1World.getBlockId(par2 + l1, par3 + i2, par4 + j2);

                Block block = Block.blocksList[k2];

                if (block != null
                    && block.canSustainLeaves(par1World, par2 + l1, par3 + i2, par4 + j2)) {
                  this.adjacentTreeBlocks[(l1 + k1) * j1 + (i2 + k1) * b1 + j2 + k1] = 0;
                } else if (block != null
                    && block.isLeaves(par1World, par2 + l1, par3 + i2, par4 + j2)) {
                  this.adjacentTreeBlocks[(l1 + k1) * j1 + (i2 + k1) * b1 + j2 + k1] = -2;
                } else {
                  this.adjacentTreeBlocks[(l1 + k1) * j1 + (i2 + k1) * b1 + j2 + k1] = -1;
                }
              }
            }
          }

          for (l1 = 1; l1 <= 4; ++l1) {
            for (i2 = -b0; i2 <= b0; ++i2) {
              for (j2 = -b0; j2 <= b0; ++j2) {
                for (k2 = -b0; k2 <= b0; ++k2) {
                  if (this.adjacentTreeBlocks[(i2 + k1) * j1 + (j2 + k1) * b1 + k2 + k1]
                      == l1 - 1) {
                    if (this.adjacentTreeBlocks[(i2 + k1 - 1) * j1 + (j2 + k1) * b1 + k2 + k1]
                        == -2) {
                      this.adjacentTreeBlocks[(i2 + k1 - 1) * j1 + (j2 + k1) * b1 + k2 + k1] = l1;
                    }

                    if (this.adjacentTreeBlocks[(i2 + k1 + 1) * j1 + (j2 + k1) * b1 + k2 + k1]
                        == -2) {
                      this.adjacentTreeBlocks[(i2 + k1 + 1) * j1 + (j2 + k1) * b1 + k2 + k1] = l1;
                    }

                    if (this.adjacentTreeBlocks[(i2 + k1) * j1 + (j2 + k1 - 1) * b1 + k2 + k1]
                        == -2) {
                      this.adjacentTreeBlocks[(i2 + k1) * j1 + (j2 + k1 - 1) * b1 + k2 + k1] = l1;
                    }

                    if (this.adjacentTreeBlocks[(i2 + k1) * j1 + (j2 + k1 + 1) * b1 + k2 + k1]
                        == -2) {
                      this.adjacentTreeBlocks[(i2 + k1) * j1 + (j2 + k1 + 1) * b1 + k2 + k1] = l1;
                    }

                    if (this.adjacentTreeBlocks[(i2 + k1) * j1 + (j2 + k1) * b1 + (k2 + k1 - 1)]
                        == -2) {
                      this.adjacentTreeBlocks[(i2 + k1) * j1 + (j2 + k1) * b1 + (k2 + k1 - 1)] = l1;
                    }

                    if (this.adjacentTreeBlocks[(i2 + k1) * j1 + (j2 + k1) * b1 + k2 + k1 + 1]
                        == -2) {
                      this.adjacentTreeBlocks[(i2 + k1) * j1 + (j2 + k1) * b1 + k2 + k1 + 1] = l1;
                    }
                  }
                }
              }
            }
          }
        }

        l1 = this.adjacentTreeBlocks[k1 * j1 + k1 * b1 + k1];

        if (l1 >= 0) {
          par1World.setBlockMetadataWithNotify(par2, par3, par4, l & -9, 4);
        } else {
          this.removeLeaves(par1World, par2, par3, par4);
        }
      }
    }
  }