Пример #1
0
 @Override
 public void populate(Chunk chunk, Random random) {
   if (chunk.getY() != 4) {
     return;
   }
   final World world = chunk.getWorld();
   if (random.nextInt(WATER_ODD) == 0) {
     final int x = chunk.getBlockX(random);
     final int z = chunk.getBlockZ(random);
     final int y = random.nextInt(128);
     WATER_POND.setRandom(random);
     WATER_POND.randomize();
     if (WATER_POND.canPlaceObject(world, x, y, z)) {
       WATER_POND.placeObject(world, x, y, z);
     }
   }
   if (random.nextInt(LAVA_ODD) == 0) {
     final int x = chunk.getBlockX(random);
     final int z = chunk.getBlockZ(random);
     final int y = random.nextInt(120) + 8;
     if (y >= 63 && random.nextInt(LAVA_SURFACE_ODD) != 0) {
       return;
     }
     LAVA_POND.setRandom(random);
     LAVA_POND.randomize();
     if (LAVA_POND.canPlaceObject(world, x, y, z)) {
       LAVA_POND.placeObject(world, x, y, z);
     }
   }
 }
Пример #2
0
 @Override
 public void populate(Chunk chunk, Random random) {
   if (chunk.getY() != 4) {
     return;
   }
   final World world = chunk.getWorld();
   final OreObject[] ores =
       new OreObject[] {
         new OreObject(OreType.DIRT),
         new OreObject(OreType.GRAVEL),
         new OreObject(OreType.COAL),
         new OreObject(OreType.IRON),
         new OreObject(OreType.REDSTONE),
         new OreObject(OreType.GOLD),
         new OreObject(OreType.LAPIS_LAZULI),
         new OreObject(OreType.DIAMOND)
       };
   for (OreObject ore : ores) {
     ore.setRandom(random);
     for (byte i = 0; i < ore.getAmount(); i++) {
       final int x = chunk.getBlockX(random);
       final int y = random.nextInt(ore.getMaxHeight());
       final int z = chunk.getBlockZ(random);
       if (ore.canPlaceObject(world, x, y, z)) {
         ore.placeObject(world, x, y, z);
       }
     }
   }
 }
Пример #3
0
  @Override
  public void populate(Chunk source, Random random) {
    if (source.getY() < 4) {
      return;
    }
    if (random.nextInt(100) > chance) {
      return;
    }

    int x = source.getBlockX();
    int z = source.getBlockZ();
    int y;
    int numSteps = random.nextInt(maxSteps - minSteps + 1) + minSteps;
    for (int i = 0; i < numSteps; i++) {
      x += random.nextInt(3) - 1;
      z += random.nextInt(3) - 1;
      y = source.getBlockY() + 15;
      Block b = source.getWorld().getBlock(x, y, z);
      while (b.getMaterial() == VanillaMaterials.AIR) {
        b = b.translate(BlockFace.BOTTOM);
        if (--y < 0) {
          return;
        }
      }
      if (b.getMaterial() == VanillaMaterials.GRASS) {
        b = b.translate(BlockFace.TOP).setMaterial(VanillaMaterials.TALL_GRASS);
      }
    }
  }
 @Override
 public void populate(Chunk chunk, Random random) {
   if (chunk.getY() != 4) {
     return;
   }
   if (random.nextInt(odd) != 0) {
     return;
   }
   final World world = chunk.getWorld();
   final int amount = getAmount(random);
   for (byte count = 0; count < amount; count++) {
     final int x = chunk.getBlockX(random);
     final int y = random.nextInt(NetherGenerator.HEIGHT);
     final int z = chunk.getBlockZ(random);
     final Mushroom mushroom =
         random.nextInt(4) == 0 ? VanillaMaterials.RED_MUSHROOM : VanillaMaterials.BROWN_MUSHROOM;
     for (byte size = 6; size > 0; size--) {
       final int xx = x - 7 + random.nextInt(15);
       final int zz = z - 7 + random.nextInt(15);
       final int yy = getHighestWorkableBlock(world, xx, y, zz);
       if (yy != -1
           && world.getBlockMaterial(xx, yy, zz) == VanillaMaterials.AIR
           && mushroom.isValidPosition(world.getBlock(xx, yy, zz), BlockFace.BOTTOM, false)) {
         world.setBlockMaterial(xx, yy, zz, mushroom, (short) 0, null);
       }
     }
   }
 }
 @Override
 public void updateBlock(Chunk chunk, int x, int y, int z, BlockMaterial material, short data) {
   short id = getMinecraftId(material);
   x += chunk.getBlockX();
   y += chunk.getBlockY();
   z += chunk.getBlockZ();
   BlockChangeMessage BCM =
       new BlockChangeMessage(
           x, y, z, id, getMinecraftData(material, data), getRepositionManager());
   session.send(false, BCM);
 }
 @Override
 public void updateBlock(Chunk chunk, int x, int y, int z, BlockMaterial material, short data) {
   short id = getMinecraftId(material);
   x += chunk.getBlockX();
   y += chunk.getBlockY();
   z += chunk.getBlockZ();
   if (y >= 0 && y < chunk.getWorld().getHeight()) {
     BlockChangeMessage BCM =
         new BlockChangeMessage(x, y, z, id, getMinecraftData(material, data));
     session.send(false, BCM);
   }
 }
Пример #7
0
 @Override
 public void populate(Chunk chunk, Random random) {
   if (chunk.getY() != 4) {
     return;
   }
   final World world = chunk.getWorld();
   for (OreObject object : ORES) {
     object.setRandom(random);
     for (byte i = 0; i < object.getCount(); i++) {
       final int x = chunk.getBlockX(random);
       final int y = random.nextInt(object.getMaxHeight());
       final int z = chunk.getBlockZ(random);
       object.placeObject(world, x, y, z);
     }
   }
 }
Пример #8
0
 @Override
 public void populate(Chunk chunk, Random random) {
   if (chunk.getY() != 4) {
     return;
   }
   if (random.nextInt(ODD) != 0) {
     return;
   }
   final World world = chunk.getWorld();
   final int x = chunk.getBlockX(random);
   final int z = chunk.getBlockZ(random);
   final int y = getHighestWorkableBlock(world, x, z);
   if (y == -1) {
     return;
   }
   if (well.canPlaceObject(world, x, y, z)) {
     well.placeObject(world, x, y, z);
   }
 }
Пример #9
0
 @Override
 public void populate(Chunk chunk, Random random) {
   if (chunk.getY() != 4) {
     return;
   }
   final World world = chunk.getWorld();
   for (byte count = 0; count < amount; count++) {
     final int x = chunk.getBlockX(random);
     final int z = chunk.getBlockZ(random);
     for (byte size = 5; size > 0; size--) {
       final int xx = x - 7 + random.nextInt(15);
       final int zz = z - 7 + random.nextInt(15);
       final int yy = getHighestWorkableBlock(world, xx, zz);
       if (yy != -1
           && world.getBlockMaterial(xx, yy, zz) == VanillaMaterials.AIR
           && VanillaMaterials.LILY_PAD.canAttachTo(
               world.getBlock(xx, yy - 1, zz, world), BlockFace.TOP)) {
         world.setBlockMaterial(xx, yy, zz, VanillaMaterials.LILY_PAD, (short) 0, world);
       }
     }
   }
 }
Пример #10
0
 @Override
 public void populate(Chunk chunk, Random random) {
   if (chunk.getY() != 4) {
     return;
   }
   final int size = Chunk.BLOCKS.SIZE;
   final int x = chunk.getBlockX();
   final int z = chunk.getBlockZ();
   final World world = chunk.getWorld();
   final int seed = (int) (world.getSeed() * 73);
   SHIELD_BASE.setSeed(seed);
   SHIELD.setSeed(seed);
   final double[][] noise = WorldGeneratorUtils.fastNoise(SHIELD, size, size, 4, x, 63, z);
   for (int xx = 0; xx < size; xx++) {
     for (int zz = 0; zz < size; zz++) {
       if (noise[xx][zz] > 0.92) {
         final int y = world.getSurfaceHeight(x + xx, z + zz);
         for (int yy = 0; yy >= -7; yy--) {
           if (yy == 0) {
             final Block block = world.getBlock(x + xx, y + yy, z + zz, world);
             if (!canReplace(block.getMaterial())) {
               continue;
             }
             block.setMaterial(
                 block.getY() <= NormalGenerator.SEA_LEVEL
                     ? VanillaMaterials.STATIONARY_WATER
                     : VanillaMaterials.AIR);
           } else {
             if (canReplace(world.getBlockMaterial(x + xx, y + yy, z + zz))) {
               world.setBlockMaterial(
                   x + xx, y + yy, z + zz, VanillaMaterials.STONE, (short) 0, world);
             }
           }
         }
       }
     }
   }
 }