public void generate(
      Random random, int i, int k, World world, IChunkProvider provider, IChunkProvider provider2) {
    int x = i * 16;
    int z = k * 16;

    try {
      if (world.getBlockId(x + 4, 0, z) == Block.bedrock.blockID
          && world.getWorldInfo().getTerrainType() != WorldType.FLAT) {
        if (world.getBlockMetadata(x + 4, 0, z) == 0) {
          for (int it = 0; it < 1; it++) {

            world.setBlockMetadataWithNotify(x + 4, 0, z, 0x1, 2);

            x = i * 16;
            z = k * 16;

            int y = EmasherGas.flatBedrockTop;
            if (!EmasherGas.flatBedrock) y = random.nextInt(2) + 3;

            x += random.nextInt(16);
            z += random.nextInt(16);

            if (world.provider.dimensionId != -1) {
              if (random.nextInt(8) == 0) {
                world.setBlock(x, y, z, EmasherGas.shaleResource.blockID, 0, 2);
                // System.out.println("Gen: " + x + ", " + y + ", " + z);

              } else if (Loader.isModLoaded("BuildCraft|Energy") && random.nextInt(12) == 0) {
                world.setBlock(x, y, z, EmasherGas.shaleResource.blockID, 1, 2);
              }
            } else {
              if (random.nextInt(6) == 0)
                world.setBlock(x, y, z, EmasherGas.shaleResource.blockID, 2, 2);
            }
          }
        }
      }
    } catch (Exception e) {
      System.out.println("[GasCraft] Error generating shale resorces for chunk @" + i + ", " + k);
    }
  }
Ejemplo n.º 2
0
  private boolean moveToBlock(World world, int x, int y, int z, int x2, int y2, int z2) {
    int blockID2 = world.getBlockId(x2, y2, z2);
    int originMeta = world.getBlockMetadata(x, y, z);
    int destMeta = world.getBlockMetadata(x2, y2, z2);
    if (blockID2 == this.blockID) {
      if (destMeta > originMeta || y > y2) {
        if (originMeta < 7 && destMeta > 0) {
          world.setBlockMetadata(x, y, z, originMeta + 1);
          world.markBlockForUpdate(x, y, z);
          world.setBlockMetadata(x2, y2, z2, destMeta - 1);
          world.markBlockForUpdate(x2, y2, z2);
          return true;
        } else if (destMeta > 0) {
          world.setBlockWithNotify(x, y, z, 0);
          world.markBlockForUpdate(x, y, z);
          world.setBlockMetadata(x2, y2, z2, destMeta - 1);
          world.markBlockForUpdate(x2, y2, z2);
          return true;
        } else {
          return false;
        }
      } else {
        return false;
      }
    } else if (liquidCanDisplaceBlock(world, x2, y2, z2)) {
      if (blockID2 > 0) {
        if (this.blockMaterial == Material.lava) {
          this.triggerLavaMixEffects(world, x2, y2, z2);
        } else if (blockID2 == Block.waterMoving.blockID || blockID2 == Block.waterStill.blockID) {
          if (originMeta < 7) {
            world.setBlockMetadataWithNotify(x, y, z, originMeta + 1);
            world.markBlockForUpdate(x, y, z);
            return true;
          } else {
            world.setBlockWithNotify(x, y, z, 0);
            world.markBlockForUpdate(x, y, z);
            return true;
          }
        } else {
          Block.blocksList[blockID2].dropBlockAsItem(
              world, x2, y2, z2, world.getBlockMetadata(x2, y2, z2), 0);
        }
      }

      if (y2 < y) {
        world.setBlockWithNotify(x, y, z, 0);
        world.markBlockForUpdate(x, y, z);
        world.setBlockAndMetadataWithNotify(x2, y2, z2, blockID, originMeta);
        world.markBlockForUpdate(x2, y2, z2);
        return true;
      }
      if (originMeta < 7) {
        world.setBlockMetadataWithNotify(x, y, z, originMeta + 1);
        world.markBlockForUpdate(x, y, z);
        world.setBlockAndMetadataWithNotify(x2, y2, z2, blockID, 7);
        world.markBlockForUpdate(x2, y2, z2);
        return true;
      } else if (world.getBlockId(x - 1, y, z) != this.blockID
          && world.getBlockId(x + 1, y, z) != this.blockID
          && world.getBlockId(x, y + 1, z) != this.blockID
          && world.getBlockId(x, y, z - 1) != this.blockID
          && world.getBlockId(x, y, z + 1) != this.blockID) {
        world.setBlockWithNotify(x, y, z, 0);
        return true;
      } else {
        world.setBlockWithNotify(x, y, z, 0);
        world.markBlockForUpdate(x, y, z);
        world.setBlockAndMetadataWithNotify(x2, y2, z2, blockID, 7);
        world.markBlockForUpdate(x2, y2, z2);
        return true;
      }
    } else {
      return false;
    }
  }