Пример #1
0
    public DataPoint2D generateHumidityAt(int x, int z) {
      /* Rasterize the coordinates */
      x =
          MathHelper.floor((float) x / DefaultWorldProvider.SAMPLE_RATE_HORIZONTAL)
              * DefaultWorldProvider.SAMPLE_RATE_HORIZONTAL;
      z =
          MathHelper.floor((float) z / DefaultWorldProvider.SAMPLE_RATE_HORIZONTAL)
              * DefaultWorldProvider.SAMPLE_RATE_HORIZONTAL;

      DataResults dr = gatherDataAround(_humidities, x, z, 40);

      if (dr.count == 0) {
        DataPoint2D data = new DataPoint2D(x, z, _random.randomInt(60, 80));
        _humidities.add(data);
        return data;
      } else {
        float diff = _random.exponentialRandom(100.0f, 4);
        diff = _random.randomBoolean() ? diff : -diff;
        DataPoint2D data =
            new DataPoint2D(x, z, (int) MathHelper.clamp(dr.avg + diff, 30.0f, 95.0f));
        _humidities.add(data);
        if (DEBUG_WOLRD_PROVIDER)
          System.out.println("Humidity (" + x + ", " + z + ") = " + data.getData());
        return data;
      }
    }
Пример #2
0
    public DataPoint2D generateTemperatureAt(int x, int z) {
      /* Rasterize the coordinates */
      x =
          MathHelper.floorDivision(x, DefaultWorldProvider.SAMPLE_RATE_TEMPERATURE)
              * DefaultWorldProvider.SAMPLE_RATE_TEMPERATURE;
      z =
          MathHelper.floorDivision(z, DefaultWorldProvider.SAMPLE_RATE_TEMPERATURE)
              * DefaultWorldProvider.SAMPLE_RATE_TEMPERATURE;

      DataResults dr = gatherDataAround(_temperatures, x, z, 50);

      if (dr.count == 0) {
        DataPoint2D data = new DataPoint2D(x, z, _random.randomInt(25, 32));
        _temperatures.add(data);
        return data;
      } else {
        float diff = _random.exponentialRandom(16.0f, 2);
        diff = _random.randomBoolean() ? diff : -diff;
        DataPoint2D data =
            new DataPoint2D(x, z, (int) MathHelper.clamp(dr.avg + diff, 10.0f, 50.0f));
        _temperatures.add(data);
        if (DEBUG_WOLRD_PROVIDER)
          System.out.println("Temp (" + x + ", " + z + ") = " + data.getData());
        return data;
      }
    }
Пример #3
0
  private void generateSpawnPoint() {
    SmartRandom random = new SmartRandom(new Random());
    for (int i = 1; i <= 15; ++i) {
      int x = random.randomInt(-5 * i, 5 * i);
      int z = random.randomInt(-5 * i, 5 * i);
      int y = getHeightAt(x, z);

      _spawnPoint = new Vec3f(x + 0.5f, y + 1.5f, z + 0.5f);
      byte spawnPointBlock = 0;
      while (spawnPointBlock <= 0) {
        spawnPointBlock = _world.getChunkManager().getBlock(x, y, z, true, true, true);
        try {
          Thread.sleep(100);
        } catch (Exception e) {
        }
      }
      if (BlockManager.getInstance().getBlockType(spawnPointBlock).getName().equals("grass")) {
        byte above = _world.getChunkManager().getBlock(x, y + 1, z, true, true, true);
        if (above == 0) {
          above = _world.getChunkManager().getBlock(x, y + 2, z, true, true, true);
          if (above == 0) {
            break;
          }
        }
      }
    }
  }