[Change] Change handling of End Biomes once more. (EndSource will consider Barrens and MainIsland biomes as well now)

This commit is contained in:
Frank 2022-07-02 14:33:52 +02:00
parent e411dc10d9
commit e35fe997c1
15 changed files with 714 additions and 334 deletions

View file

@ -0,0 +1,101 @@
package org.betterx.bclib.config;
import org.betterx.bclib.BCLib;
import org.betterx.bclib.api.v2.levelgen.biomes.BiomeAPI;
import java.util.*;
public class BiomesConfig extends PathConfig {
private Map<BiomeAPI.BiomeType, List<String>> BIOME_INCLUDE_LIST = null;
private Map<BiomeAPI.BiomeType, List<String>> BIOME_EXCLUDE_LIST = null;
public static final BiomeAPI.BiomeType[] endTypes = {
BiomeAPI.BiomeType.END_LAND,
BiomeAPI.BiomeType.END_VOID,
BiomeAPI.BiomeType.END_CENTER,
BiomeAPI.BiomeType.END_BARRENS
};
public static final BiomeAPI.BiomeType[] netherTypes = {
BiomeAPI.BiomeType.NETHER
};
private static final BiomeAPI.BiomeType[] includeTypes = all();
private static final BiomeAPI.BiomeType[] excludeTypes = {BiomeAPI.BiomeType.NETHER, BiomeAPI.BiomeType.END};
public BiomesConfig() {
super(BCLib.MOD_ID, "biomes", false);
for (var type : includeTypes) {
keeper.registerEntry(
new ConfigKey(type.getName(), "force_include"),
new ConfigKeeper.StringArrayEntry(Collections.EMPTY_LIST)
);
}
for (var type : excludeTypes) {
keeper.registerEntry(
new ConfigKey(type.getName(), "force_exclude"),
new ConfigKeeper.StringArrayEntry(Collections.EMPTY_LIST)
);
}
}
private static BiomeAPI.BiomeType[] all() {
BiomeAPI.BiomeType[] res = new BiomeAPI.BiomeType[endTypes.length + netherTypes.length];
System.arraycopy(netherTypes, 0, res, 0, netherTypes.length);
System.arraycopy(endTypes, 0, res, netherTypes.length, endTypes.length);
return res;
}
private List<String> getBiomeIncludeList(BiomeAPI.BiomeType type) {
var entry = getEntry(
"force_include",
type.getName(),
ConfigKeeper.StringArrayEntry.class
);
if (entry == null)
return List.of();
return entry.getValue();
}
private List<String> getBiomeExcludeList(BiomeAPI.BiomeType type) {
var entry = getEntry(
"force_exclude",
type.getName(),
ConfigKeeper.StringArrayEntry.class
);
if (entry == null)
return List.of();
return entry.getValue();
}
public List<String> getIncludeMatching(BiomeAPI.BiomeType type) {
return getBiomeIncludeMap().entrySet()
.stream()
.filter(e -> e.getKey().is(type))
.map(e -> e.getValue())
.flatMap(Collection::stream)
.toList();
}
public Map<BiomeAPI.BiomeType, List<String>> getBiomeIncludeMap() {
if (BIOME_INCLUDE_LIST == null) {
BIOME_INCLUDE_LIST = new HashMap<>();
for (BiomeAPI.BiomeType type : includeTypes) {
BIOME_INCLUDE_LIST.put(type, getBiomeIncludeList(type));
}
}
return BIOME_INCLUDE_LIST;
}
public Map<BiomeAPI.BiomeType, List<String>> getBiomeExcludeMap() {
if (BIOME_EXCLUDE_LIST == null) {
BIOME_EXCLUDE_LIST = new HashMap<>();
for (BiomeAPI.BiomeType type : excludeTypes) {
BIOME_EXCLUDE_LIST.put(type, getBiomeExcludeList(type));
}
}
return BIOME_EXCLUDE_LIST;
}
}

View file

@ -18,7 +18,7 @@ public class Configs {
public static final MainConfig MAIN_CONFIG = new MainConfig();
public static final PathConfig RECIPE_CONFIG = new PathConfig(BCLib.MOD_ID, "recipes");
public static final PathConfig BIOMES_CONFIG = new PathConfig(BCLib.MOD_ID, "biomes", false);
public static final BiomesConfig BIOMES_CONFIG = new BiomesConfig();
public static final String MAIN_PATCH_CATEGORY = "patches";
@ -29,6 +29,7 @@ public class Configs {
BIOMES_CONFIG.saveChanges();
}
static {
BIOMES_CONFIG.keeper.registerEntry(
new ConfigKey("end_land_biomes", "force_include"),