Ejemplo n.º 1
0
  public boolean canSpawn(World world, int x, int y, int z) {

    if (world.getActualHeight() <= 200) {
      return true;
    }
    return false;
  }
Ejemplo n.º 2
0
  // Adapted from BCs oilspout gen code
  @Override
  public boolean generate(World world, Random random, int x, int y, int z) {
    // Find ground level
    int groundLevel = this.getTopBlock(world, x, z);
    if (groundLevel < 5) {
      return false;
    }

    int wellX = x;
    int wellZ = z;
    int wellHeight = 6 + random.nextInt(3);
    int maxHeight = groundLevel + wellHeight;
    if (maxHeight >= (world.getActualHeight() - 1)) {
      return false;
    }

    new WorldGenLakes(this.block).generate(world, random, x, y, z);

    int wellY = 50 + random.nextInt(10);

    for (int i = wellY + 1; i <= maxHeight; ++i) {
      world.setBlock(wellX, i, wellZ, this.block, 0, 3);
    }
    for (int i = wellY; i <= (maxHeight - (wellHeight / 2)); ++i) {
      world.setBlock(wellX + 1, i, wellZ, this.block, 0, 3);
      world.setBlock(wellX - 1, i, wellZ, this.block, 0, 3);
      world.setBlock(wellX, i, wellZ + 1, this.block, 0, 3);
      world.setBlock(wellX, i, wellZ - 1, this.block, 0, 3);
    }
    return true;
  }
  @Override
  public boolean onBlockActivated(
      World world,
      int x,
      int y,
      int z,
      EntityPlayer player,
      int side,
      float xOffset,
      float yOffset,
      float zOffset) {

    ItemStack ci = player.inventory.mainInventory[player.inventory.currentItem];
    if (ci != null && Block.getBlockFromItem(ci.getItem()).equals(this)) {
      for (int i = y + 1, e = world.getActualHeight(); i < e; ++i) {
        Block block = world.getBlock(x, i, z);
        if (block.isAir(world, x, i, z) || block.isReplaceable(world, x, i, z)) {
          if (!world.isRemote && world.setBlock(x, i, z, this, 0, 3)) {
            world.playAuxSFXAtEntity(null, 2001, x, i, z, Block.getIdFromBlock(this));
            if (!player.capabilities.isCreativeMode) {
              ci.stackSize--;
              if (ci.stackSize == 0) {
                player.inventory.mainInventory[player.inventory.currentItem] = null;
              }
            }
          }
          return true;
        } else if (!block.equals(this)) {
          return false;
        }
      }
    }
    return false;
  }
  @Override
  public void trigger(World world, int x, int y, int z, EntityPlayer player) {
    int xChange = ((world.rand.nextInt(50) + 20) + x) - 35;
    int zChange = ((world.rand.nextInt(50) + 20) + z) - 35;

    int yChange = -1;

    for (int yy = 0; yy <= world.getActualHeight(); yy++) {
      if (world.getBlock(xChange, yy, zChange).isAir(world, xChange, yy, zChange)
          && world.getBlock(xChange, yy + 1, zChange).isAir(world, xChange, yy + 1, zChange)) {
        yChange = yy;
        break;
      }
    }
    if (yChange == -1) return;

    player.setPositionAndUpdate(xChange, yChange, zChange);
  }
  @Override
  public boolean generate(World world, Random rand, int x, int retries, int z) {
    for (int c = 0; c < retries; c++) {
      int y = world.getActualHeight() - 1;
      Block block = Block.blocksList[world.getBlockId(x, y, z)];
      while ((block == null || block.isAirBlock(world, x, y, z)) && y > 0) {
        y--;
      }

      if (!growTree(world, rand, x, y + 1, z)) {
        retries--;
      }

      x += rand.nextInt(16) - 8;
      z += rand.nextInt(16) - 8;
    }

    return true;
  }
  @Override
  public void onNeighborBlockChange(World world, int x, int y, int z, Block block) {

    if (!canBlockStay(world, x, y, z)) {
      for (int e = world.getActualHeight(); y < e; ++y) {
        block = world.getBlock(x, y, z);
        if (!block.equals(this)) break;
        dropBlockAsItem(world, x, y, z, world.getBlockMetadata(x, y, z), 0);
        world.setBlock(x, y, z, Blocks.air, 0, 2);
        for (ForgeDirection d : _attachDirections) {
          BlockPosition bp = new BlockPosition(x, y, z, d);
          for (int i = 0; i < _attachDistance; i++) {
            bp.moveForwards(1);
            block = world.getBlock(bp.x, bp.y, bp.z);
            if (block.equals(this)) {
              world.func_147446_b(bp.x, bp.y, bp.z, block, 0, 0);
            } else break;
          }
        }
      }
    }
  }
Ejemplo n.º 7
0
 public static int getFirstNonAirBlockFromTop(World world, int x, int z) {
   int y;
   for (y = world.getActualHeight(); world.isAirBlock(x, y - 1, z) && y > 0; y--) {}
   return y;
 }