// canSpawnStructureAtCoords
  @Override
  protected boolean a(int chunkX, int chunkZ) {
    Random rand = b;
    World worldMC = c;
    if (rand.nextInt(80) < Math.max(Math.abs(chunkX), Math.abs(chunkZ))) {
      LocalWorld world = WorldHelper.toLocalWorld(worldMC);
      LocalBiome biome = world.getBiome(chunkX * 16 + 8, chunkZ * 16 + 8);
      if (rand.nextDouble() * 100.0 < biome.getBiomeConfig().mineshaftsRarity) {
        return true;
      }
    }

    return false;
  }
  @Override
  public boolean onCommand(CommandSender sender, List<String> args) {
    Location location = this.getLocation(sender);
    int x = location.getBlockX();
    int y = location.getBlockY();
    int z = location.getBlockZ();

    LocalWorld world = this.getWorld(sender, "");

    if (world == null) {
      sender.sendMessage(ERROR_COLOR + "Plugin is not enabled for this world.");
      return true;
    }

    LocalBiome biome = world.getCalculatedBiome(x, z);
    BiomeIds biomeIds = biome.getIds();

    sender.sendMessage(
        MESSAGE_COLOR
            + "According to the biome generator, you are in the "
            + VALUE_COLOR
            + biome.getName()
            + MESSAGE_COLOR
            + " biome, with id "
            + VALUE_COLOR
            + biomeIds.getGenerationId());

    if (args.contains("-f")) {
      sender.sendMessage(
          MESSAGE_COLOR
              + "The base temperature of this biome is "
              + VALUE_COLOR
              + biome.getBiomeConfig().biomeTemperature
              + MESSAGE_COLOR
              + ", \nat your height it is "
              + VALUE_COLOR
              + biome.getTemperatureAt(x, y, z));
    }

    if (args.contains("-s")) {
      LocalBiome savedBiome = world.getBiome(x, z);
      BiomeIds savedIds = savedBiome.getIds();
      sender.sendMessage(
          MESSAGE_COLOR
              + "According to the world save files, you are in the "
              + VALUE_COLOR
              + savedBiome.getName()
              + MESSAGE_COLOR
              + " biome, with id "
              + VALUE_COLOR
              + savedIds.getSavedId());
    }

    return true;
  }
  @SuppressWarnings({"unchecked", "rawtypes"})
  public TXRareBuildingGen(ServerConfigProvider configs) {
    biomeList = new ArrayList<Biome>();

    for (LocalBiome biome : configs.getBiomeArray()) {
      if (biome == null) continue;
      if (biome.getBiomeConfig().rareBuildingType != RareBuildingType.disabled) {
        biomeList.add(((ForgeBiome) biome).getHandle());
      }
    }

    this.scatteredFeatureSpawnList = new ArrayList();
    this.maxDistanceBetweenScatteredFeatures =
        configs.getWorldConfig().maximumDistanceBetweenRareBuildings;
    // Minecraft's internal minimum distance is one lower than TC's value
    this.minDistanceBetweenScatteredFeatures =
        configs.getWorldConfig().minimumDistanceBetweenRareBuildings - 1;
    this.scatteredFeatureSpawnList.add(new SpawnListEntry(EntityWitch.class, 1, 1, 1));
  }
  public WorldConfig(File settingsDir, LocalWorld world, boolean checkOnly) {
    this.SettingsDir = settingsDir;
    this.WorldName = world.getName();

    File settingsFile = new File(this.SettingsDir, TCDefaultValues.WorldSettingsName.stringValue());

    this.ReadSettingsFile(settingsFile);
    this.RenameOldSettings();
    this.ReadConfigSettings();

    this.CorrectSettings();

    ReadWorldCustomObjects();

    // Check biome ids

    for (String biomeName : CustomBiomes)
      if (CustomBiomeIds.get(biomeName) == -1)
        CustomBiomeIds.put(biomeName, world.getFreeBiomeId());

    // Need add check to clashes
    if (this.SettingsMode != ConfigMode.WriteDisable)
      this.WriteSettingsFile(settingsFile, (this.SettingsMode == ConfigMode.WriteAll));

    world.setHeightBits(this.worldHeightBits);

    File BiomeFolder =
        new File(SettingsDir, TCDefaultValues.WorldBiomeConfigDirectoryName.stringValue());
    if (!BiomeFolder.exists()) {
      if (!BiomeFolder.mkdir()) {
        System.out.println(
            "TerrainControl: error create biome configs directory, working with defaults");
        return;
      }
    }

    ArrayList<LocalBiome> localBiomes = new ArrayList<LocalBiome>(world.getDefaultBiomes());

    // Add custom biomes to world
    for (String biomeName : this.CustomBiomes) {
      if (checkOnly) localBiomes.add(world.getNullBiome(biomeName));
      else localBiomes.add(world.AddBiome(biomeName, this.CustomBiomeIds.get(biomeName)));
    }

    // Build biome replace matrix
    for (int i = 0; i < this.ReplaceMatrixBiomes.length; i++)
      this.ReplaceMatrixBiomes[i] = (byte) i;

    this.biomeConfigs = new BiomeConfig[world.getMaxBiomesCount()];

    String LoadedBiomeNames = "";

    for (LocalBiome localBiome : localBiomes) {
      BiomeConfig config = new BiomeConfig(BiomeFolder, localBiome, this);
      if (checkOnly) continue;

      if (!config.ReplaceBiomeName.equals("")) {
        this.HaveBiomeReplace = true;
        this.ReplaceMatrixBiomes[config.Biome.getId()] =
            (byte) world.getBiomeIdByName(config.ReplaceBiomeName);
      }

      if (this.NormalBiomes.contains(config.Name)) this.normalBiomesRarity += config.BiomeRarity;
      if (this.IceBiomes.contains(config.Name)) this.iceBiomesRarity += config.BiomeRarity;

      this.biomeConfigs[localBiome.getId()] = config;
      if (!this.BiomeConfigsHaveReplacement)
        this.BiomeConfigsHaveReplacement = config.ReplaceCount > 0;
      if (this.biomes.size() != 0) LoadedBiomeNames += ", ";
      LoadedBiomeNames += localBiome.getName();
      this.biomes.add(config);

      if (this.ModeBiome == BiomeMode.FromImage) {
        if (this.biomeColorMap == null) this.biomeColorMap = new HashMap<Integer, Integer>();

        try {
          int color = Integer.decode(config.BiomeColor);
          if (color <= 0xFFFFFF) this.biomeColorMap.put(color, config.Biome.getId());
        } catch (NumberFormatException ex) {
          System.out.println("TerrainControl: wrong color in " + config.Biome.getName());
        }
      }
    }

    System.out.println("TerrainControl: Loaded biomes - " + LoadedBiomeNames);
  }