Пример #1
0
  public boolean genHive(World world, Random rand, int chunkX, int chunkZ, Hive hive) {
    if (hive.genChance() * Config.getBeehivesRate() < rand.nextFloat() * 100.0f) {
      return false;
    }

    int worldX = chunkX * 16;
    int worldZ = chunkZ * 16;

    BiomeGenBase biome = world.getBiomeGenForCoords(worldX, worldZ);
    EnumHumidity humidity = EnumHumidity.getFromValue(biome.rainfall);

    if (!hive.isGoodBiome(biome) || !hive.isGoodHumidity(humidity)) {
      return false;
    }

    for (int tries = 0; tries < 4; tries++) {
      int x = worldX + rand.nextInt(16);
      int z = worldZ + rand.nextInt(16);

      if (tryGenHive(world, x, z, hive)) {
        return true;
      }
    }

    return false;
  }
Пример #2
0
  private void decorateHivesDebug(World world, int chunkX, int chunkZ, List<Hive> hives) {
    int worldX = chunkX * 16;
    int worldZ = chunkZ * 16;
    BiomeGenBase biome = world.getBiomeGenForCoords(worldX, worldZ);
    EnumHumidity humidity = EnumHumidity.getFromValue(biome.rainfall);

    for (int x = 0; x < 16; x++) {
      for (int z = 0; z < 16; z++) {
        Collections.shuffle(hives, world.rand);
        for (Hive hive : hives) {
          if (!hive.isGoodBiome(biome) || !hive.isGoodHumidity(humidity)) {
            continue;
          }

          tryGenHive(world, worldX + x, worldZ + z, hive);
        }
      }
    }
  }