Ejemplo n.º 1
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);
      }
    }
  }
Ejemplo n.º 2
0
 @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);
   }
 }