示例#1
0
  private static void createBiomes() throws InstantiationException, IllegalAccessException {
    for (final VanillaBiome biome : VanillaBiome.values()) {
      final BiomeGenBase biomeGen = biome.toBiomeGen();
      if (!biome.enableGeneration) {
        Extrabiomes.proxy.removeBiome(biomeGen);
        ExtrabiomesLog.info("Vanilla biome %s disabled.", biome.toString());
      }

      VillageSpawnHelper.setVillageSpawn(biomeGen, biome.enableVillages);
      ExtrabiomesLog.info(
          "Village spawning %s for vanilla biome %s.",
          biome.enableVillages ? "enabled" : "disabled", biome.toString());
    }
  }
  private static void enableVillageSpawnBiomeChanges() {
    if (!villageSpawnBiomeChangesEnabled) {
      final List<BiomeGenBase> villageSpawnBiomes = new ArrayList();
      villageSpawnBiomes.addAll(MapGenVillage.villageSpawnBiomes);

      // get MapGenVillageSpawnBiomes.villageSpawnBiomes field
      Field field = MapGenVillage.class.getDeclaredFields()[0];
      field.setAccessible(true);

      // Make the field non final and set it
      try {
        Field modifiersField = Field.class.getDeclaredField("modifiers");
        modifiersField.setAccessible(true);
        modifiersField.setInt(field, field.getModifiers() & ~Modifier.FINAL);

        field.set(null, villageSpawnBiomes);
      } catch (Exception e) {
        ExtrabiomesLog.info("Could not access village spawn biomes.");
      } finally {
        villageSpawnBiomeChangesEnabled = true;
      }
    }
  }