@Override
  public boolean generate(World par1World, Random par2Random, int par3, int par4, int par5) {
    if (par1World.getBlockMaterial(par3, par4, par5) != Material.water) return false;
    else {
      int var6 = par2Random.nextInt(radius - 2) + 2;
      byte var7 = 2;

      for (int var8 = par3 - var6; var8 <= par3 + var6; ++var8) {
        for (int var9 = par5 - var6; var9 <= par5 + var6; ++var9) {
          int var10 = var8 - par3;
          int var11 = var9 - par5;

          if (var10 * var10 + var11 * var11 <= var6 * var6) {
            for (int var12 = par4 - var7; var12 <= par4 + var7; ++var12) {
              int var13 = par1World.getBlockId(var8, var12, var9);

              if (var13 == Block.sand.blockID) {
                par1World.setBlock(var8, var12, var9, sandID);
              }
            }
          }
        }
      }

      return true;
    }
  }
  @Override
  public boolean generate(World par1World, Random par2Random, int par3, int par4, int par5) {
    for (int i = 0;
        ((i = par1World.getBlockId(par3, par4, par5)) == 0 || i == Block.leaves.blockID)
            && par4 > 0;
        par4--) {}

    for (int j = 0; j < 128; j++) {
      int k = (par3 + par2Random.nextInt(8)) - par2Random.nextInt(8);
      int l = (par4 + par2Random.nextInt(4)) - par2Random.nextInt(4);
      int i1 = (par5 + par2Random.nextInt(8)) - par2Random.nextInt(8);

      boolean old =
          ODNBXlite.MapFeatures < ODNBXlite.FEATURES_13
              || ODNBXlite.Generator < ODNBXlite.GEN_NEWBIOMES;
      boolean oldc =
          ((BlockFlower) Block.blocksList[tallGrassID]).canBlockStay(par1World, k, l, i1);
      boolean newc = Block.blocksList[tallGrassID].canBlockStay(par1World, k, l, i1);
      if (par1World.isAirBlock(k, l, i1) && ((oldc && old) || (!old && newc))) {
        par1World.setBlock(k, l, i1, tallGrassID, tallGrassMetadata, 0);
      }
    }

    return true;
  }
  @Override
  public void decorate(World par1World, Random par2Random, int par3, int par4) {
    super.decorate(par1World, par2Random, par3, par4);
    int var5 = 3 + par2Random.nextInt(6);

    for (int var6 = 0; var6 < var5; ++var6) {
      int var7 = par3 + par2Random.nextInt(16);
      int var8 = par2Random.nextInt(28) + 4;
      int var9 = par4 + par2Random.nextInt(16);
      int var10 = par1World.getBlockId(var7, var8, var9);

      if (var10 == Block.stone.blockID) {
        int var11 = 0;

        if (var8 <= 48 + par1World.rand.nextInt(2)) {
          byte var12 = 1;

          if (var8 <= 24 + par1World.rand.nextInt(2)) {
            var12 = 2;
          }

          var11 = Block.oreEmerald.GetMetadataConversionForStrataLevel(var12, 0);
        }

        par1World.setBlock(var7, var8, var9, Block.oreEmerald.blockID, var11, 2);
      }
    }
  }
  @Override
  public void tick() {
    this.ticks++;
    int currentBlocksChanged = 0;
    boolean continueFlag = true;
    World world = player.worldObj;

    // Only store the X and Z, since we're considering columns only.
    int x = this.currentPos.x;
    int z = this.currentPos.z;
    int y = 0;
    int blockID;

    while (continueFlag) {
      // Find the y coord of the first exposed, non-air block.
      y = world.getActualHeight();
      while (world.isAirBlock(x, y, z) && y >= 0) {
        y--;
      }

      // If Y goes under the world base, skip this column. (The End, I'm looking at you.)
      if (0 <= y && y <= world.getActualHeight()) {
        blockID = world.getBlockId(x, y, z);

        switch (this.effectMode) {
          case THAW:
            if (blockID == Block.ice.blockID) {
              // Replace ice with water.
              backup.before.add(new BlockSaveable(world, x, y, z));
              world.setBlock(x, y, z, Block.waterMoving.blockID);
              backup.after.add(new BlockSaveable(world, x, y, z));
              currentBlocksChanged++;
            } else if (blockID == Block.snow.blockID) {
              // Remove snow.
              backup.before.add(new BlockSaveable(world, x, y, z));
              world.setBlock(x, y, z, 0);
              backup.after.add(new BlockSaveable(world, x, y, z));
              currentBlocksChanged++;
            }
            break;
          case FREEZE:
            if (blockID == Block.waterMoving.blockID || blockID == Block.waterStill.blockID) {
              // Both water types become ice.
              backup.before.add(new BlockSaveable(world, x, y, z));
              world.setBlock(x, y, z, Block.ice.blockID);
              backup.after.add(new BlockSaveable(world, x, y, z));
              currentBlocksChanged++;
            }
            break;
          case SNOW:
            if (Block.isNormalCube(world.getBlockId(x, y, z))) {
              // Add snow covering to the block above.
              backup.before.add(new BlockSaveable(world, x, y + 1, z));
              world.setBlock(x, y + 1, z, Block.snow.blockID);
              backup.after.add(new BlockSaveable(world, x, y + 1, z));
              currentBlocksChanged++;
            }
            break;
          case TILL:
            if (blockID == Block.dirt.blockID || blockID == Block.grass.blockID) {
              backup.before.add(new BlockSaveable(world, x, y, z));
              world.setBlock(x, y, z, Block.tilledField.blockID);
              backup.after.add(new BlockSaveable(world, x, y, z));
              currentBlocksChanged++;
            }
            break;
          case UNTILL:
            if (blockID == Block.tilledField.blockID) {
              backup.before.add(new BlockSaveable(world, x, y, z));
              world.setBlock(x, y, z, Block.dirt.blockID);
              backup.after.add(new BlockSaveable(world, x, y, z));
              currentBlocksChanged++;
            }
            break;
        }
      }

      z++;

      if (z > (this.effectOrigin.z + this.effectRadius)) {
        x++;
        z = this.effectOrigin.z - this.effectRadius;
        if (x > (this.effectOrigin.x + this.effectRadius)) {
          this.isComplete = true;
        }
      }

      if (this.isComplete || currentBlocksChanged >= ModuleWorldControl.WCblocksPerTick) {
        this.changed += currentBlocksChanged;
        this.currentPos = new Point(x, 0, z);
        continueFlag = false;
      }
    }
  }
예제 #5
0
  public boolean generateRandomTree(World world, Random random, int i, int j, int k) {
    int l = random.nextInt(5) + 8;
    boolean flag = true;
    if (j < 1 || j + l + 1 > 256) {
      return false;
    }
    for (int i1 = j; i1 <= j + 1 + l; i1++) {
      byte byte0 = 1;
      if (i1 == j) {
        byte0 = 0;
      }
      if (i1 >= (j + 1 + l) - 2) {
        byte0 = 2;
      }
      label0:
      for (int l1 = i - byte0; l1 <= i + byte0 && flag; l1++) {
        int j2 = k - byte0;
        do {
          if (j2 > k + byte0 || !flag) {
            continue label0;
          }
          if (i1 >= 0 && i1 < 256) {
            int k2 = world.getBlockId(l1, i1, j2);
            if (k2 != 0 && k2 != FloraTrees.floraLeaves.blockID) {
              flag = false;
              continue label0;
            }
          } else {
            flag = false;
            continue label0;
          }
          j2++;
        } while (true);
      }
    }

    if (!flag) {
      return false;
    }
    int j1 = world.getBlockId(i, j - 1, k);
    if (j1 != Block.netherrack.blockID && j1 != Block.slowSand.blockID || j >= 256 - l - 1) {
      return false;
    }
    world.setBlock(i, j - 1, k, Block.slowSand.blockID);
    world.setBlock(i + 1, j - 1, k, Block.slowSand.blockID);
    world.setBlock(i, j - 1, k + 1, Block.slowSand.blockID);
    world.setBlock(i + 1, j - 1, k + 1, Block.slowSand.blockID);
    for (int k1 = 0; k1 < l; k1++) {
      int i2 = world.getBlockId(i, j + k1, k);
      if (i2 == 0 || i2 == FloraTrees.floraLeaves.blockID) {
        setBlockAndMetadata(world, i, j + k1, k, FloraTrees.redwood.blockID, mdWood);
        setBlockAndMetadata(world, i + 1, j + k1, k, FloraTrees.redwood.blockID, mdWood);
        setBlockAndMetadata(world, i, j + k1, k + 1, FloraTrees.redwood.blockID, mdWood);
        setBlockAndMetadata(world, i + 1, j + k1, k + 1, FloraTrees.redwood.blockID, mdWood);
      }
    }

    genBranch(world, random, i, j, k, l, 1);
    genBranch(world, random, i + 1, j, k, l, 2);
    genBranch(world, random, i, j, k + 1, l, 3);
    genBranch(world, random, i + 1, j, k + 1, l, 4);
    genStraightBranch(world, random, i, j, k, l, 1);
    genStraightBranch(world, random, i + 1, j, k, l, 2);
    genStraightBranch(world, random, i, j, k + 1, l, 3);
    genStraightBranch(world, random, i + 1, j, k + 1, l, 4);
    return true;
  }
예제 #6
0
  @Override
  public boolean generate(World var1, Random var2, int var3, int var4, int var5) {
    while (var1.isAirBlock(var3, var4, var5) && var4 > 2) {
      --var4;
    }

    int var6 = var1.getBlockId(var3, var4, var5);

    if (var6 != Block.grass.blockID) return false;
    else {
      for (int var7 = -2; var7 <= 2; ++var7) {
        for (int var8 = -2; var8 <= 2; ++var8) {
          if (var1.isAirBlock(var3 + var7, var4 - 1, var5 + var8)
              && var1.isAirBlock(var3 + var7, var4 - 2, var5 + var8)) return false;
        }
      }

      var1.setBlock(var3, var4, var5, Block.dirt.blockID);
      var1.setBlock(var3, var4 + 1, var5, Block.wood.blockID);
      var1.setBlock(var3, var4 + 2, var5, Block.wood.blockID);
      var1.setBlock(var3, var4 + 3, var5, Block.wood.blockID);
      var1.setBlock(var3, var4 + 4, var5, Block.wood.blockID);
      var1.setBlock(var3, var4 + 5, var5, Block.wood.blockID);
      var1.setBlock(var3, var4 + 6, var5, Block.wood.blockID);
      var1.setBlock(var3, var4 + 7, var5, Block.wood.blockID);
      var1.setBlock(var3 + 1, var4 + 7, var5, Block.leaves.blockID);
      var1.setBlock(var3 - 1, var4 + 7, var5, Block.leaves.blockID);
      var1.setBlock(var3, var4 + 7, var5 + 1, Block.leaves.blockID);
      var1.setBlock(var3, var4 + 7, var5 - 1, Block.leaves.blockID);

      var1.setBlock(var3 + 1, var4 + 8, var5, Block.leaves.blockID);
      var1.setBlock(var3 - 1, var4 + 8, var5, Block.leaves.blockID);
      var1.setBlock(var3, var4 + 8, var5 + 1, Block.leaves.blockID);
      var1.setBlock(var3, var4 + 8, var5 - 1, Block.leaves.blockID);

      var1.setBlock(var3 + 1, var4 + 8, var5 + 1, Block.leaves.blockID);
      var1.setBlock(var3 + 1, var4 + 8, var5 - 1, Block.leaves.blockID);
      var1.setBlock(var3 - 1, var4 + 8, var5 + 1, Block.leaves.blockID);
      var1.setBlock(var3 - 1, var4 + 8, var5 - 1, Block.leaves.blockID);
      var1.setBlock(var3, var4 + 8, var5, Block.leaves.blockID);

      var1.setBlock(var3, var4 + 9, var5, Block.leaves.blockID);
      return true;
    }
  }