Island biomes can now be disabled
This commit is contained in:
parent
8ef12c9856
commit
b591814b1f
3 changed files with 59 additions and 47 deletions
|
@ -10,6 +10,7 @@ package biomesoplenty.common.biome;
|
||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
import com.google.gson.annotations.SerializedName;
|
import com.google.gson.annotations.SerializedName;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
import java.util.TreeMap;
|
import java.util.TreeMap;
|
||||||
|
|
||||||
public class BiomeConfigData
|
public class BiomeConfigData
|
||||||
|
@ -20,8 +21,8 @@ public class BiomeConfigData
|
||||||
@SerializedName("sub_biome_weights")
|
@SerializedName("sub_biome_weights")
|
||||||
public TreeMap<String, SubBiomeEntry> subBiomeEntries = Maps.newTreeMap();
|
public TreeMap<String, SubBiomeEntry> subBiomeEntries = Maps.newTreeMap();
|
||||||
|
|
||||||
//@SerializedName("island_biome_weights")
|
@SerializedName("island_biome_toggles")
|
||||||
//public Map<String, IslandBiomeEntry> islandBiomeEntries = Maps.newHashMap();
|
public Map<String, ToggleableBiomeEntry> islandBiomeEntries = Maps.newHashMap();
|
||||||
|
|
||||||
@SerializedName("vanilla_biome_weights")
|
@SerializedName("vanilla_biome_weights")
|
||||||
public TreeMap<String, WeightedBiomeEntry> vanillaBiomeEntries = Maps.newTreeMap();
|
public TreeMap<String, WeightedBiomeEntry> vanillaBiomeEntries = Maps.newTreeMap();
|
||||||
|
@ -36,6 +37,16 @@ public class BiomeConfigData
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static class ToggleableBiomeEntry
|
||||||
|
{
|
||||||
|
public boolean enabled;
|
||||||
|
|
||||||
|
public ToggleableBiomeEntry(boolean enabled)
|
||||||
|
{
|
||||||
|
this.enabled = enabled;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static class SubBiomeEntry
|
public static class SubBiomeEntry
|
||||||
{
|
{
|
||||||
public int weight;
|
public int weight;
|
||||||
|
|
|
@ -33,7 +33,7 @@ import java.util.function.Consumer;
|
||||||
|
|
||||||
public class BiomeRegistry
|
public class BiomeRegistry
|
||||||
{
|
{
|
||||||
private static final String CONFIG_FILE_NAME = "biome_weights.json";
|
private static final String CONFIG_FILE_NAME = "biomes.json";
|
||||||
|
|
||||||
private static Map<RegistrationType, List<DeferredRegistration>> deferrances = Maps.newHashMap();
|
private static Map<RegistrationType, List<DeferredRegistration>> deferrances = Maps.newHashMap();
|
||||||
|
|
||||||
|
@ -161,49 +161,50 @@ public class BiomeRegistry
|
||||||
public static void configureIslandBiomes()
|
public static void configureIslandBiomes()
|
||||||
{
|
{
|
||||||
// Island biomes are currently not configurable due to them being registered multiple times for different climates
|
// Island biomes are currently not configurable due to them being registered multiple times for different climates
|
||||||
// List<DeferredRegistration> islandBiomeReistrations = deferrances.get(RegistrationType.ISLAND_BIOME);
|
List<DeferredRegistration> islandBiomeReistrations = deferrances.get(RegistrationType.ISLAND_BIOME);
|
||||||
// Map<String, BiomeConfigData.IslandBiomeEntry> defaultIslandBiomeEntries = Maps.newTreeMap();
|
Map<String, BiomeConfigData.ToggleableBiomeEntry> defaultBiomeEntries = Maps.newTreeMap();
|
||||||
// Map<String, IslandBiomeRegistrationData> regDataMap = Maps.newHashMap();
|
|
||||||
//
|
for (DeferredRegistration<SingleClimateRegistrationData> registration : islandBiomeReistrations)
|
||||||
// for (DeferredRegistration<IslandBiomeRegistrationData> registration : islandBiomeReistrations)
|
{
|
||||||
// {
|
SingleClimateRegistrationData regData = registration.regData;
|
||||||
// IslandBiomeRegistrationData regData = registration.regData;
|
String biomeName = regData.getBiome().delegate.name().toString();
|
||||||
// String biomeName = registration.regData.getBiome().delegate.name().toString();
|
defaultBiomeEntries.put(biomeName, new BiomeConfigData.ToggleableBiomeEntry(true));
|
||||||
// defaultIslandBiomeEntries.put(biomeName, new BiomeConfigData.IslandBiomeEntry(regData.getWeight()));
|
}
|
||||||
// regDataMap.put(biomeName, registration.regData);
|
|
||||||
// }
|
BiomeConfigData defaultConfigData = new BiomeConfigData();
|
||||||
//
|
defaultConfigData.islandBiomeEntries = defaultBiomeEntries;
|
||||||
// BiomeConfigData defaultConfigData = new BiomeConfigData();
|
BiomeConfigData configData = getConfigData(defaultConfigData);
|
||||||
// defaultConfigData.islandBiomeEntries = defaultIslandBiomeEntries;
|
|
||||||
// BiomeConfigData configData = getConfigData(defaultConfigData);
|
Map<String, BiomeConfigData.ToggleableBiomeEntry> revisedBiomeEntries = Maps.newHashMap(defaultBiomeEntries);
|
||||||
//
|
|
||||||
// Map<String, BiomeConfigData.IslandBiomeEntry> revisedIslandBiomeEntries = Maps.newHashMap(defaultIslandBiomeEntries);
|
// Merge the config file with the default values
|
||||||
//
|
for (Map.Entry<String, BiomeConfigData.ToggleableBiomeEntry> biomeEntry : configData.islandBiomeEntries.entrySet())
|
||||||
// // Merge the config file with the default values
|
{
|
||||||
// for (Map.Entry<String, BiomeConfigData.IslandBiomeEntry> biomeEntry : configData.islandBiomeEntries.entrySet())
|
if (revisedBiomeEntries.containsKey(biomeEntry.getKey()))
|
||||||
// {
|
{
|
||||||
// if (revisedIslandBiomeEntries.containsKey(biomeEntry.getKey()))
|
revisedBiomeEntries.put(biomeEntry.getKey(), biomeEntry.getValue());
|
||||||
// {
|
}
|
||||||
// revisedIslandBiomeEntries.put(biomeEntry.getKey(), biomeEntry.getValue());
|
}
|
||||||
// }
|
|
||||||
// }
|
// Write back to the config file
|
||||||
//
|
configData.islandBiomeEntries = revisedBiomeEntries;
|
||||||
// // Write back to the config file
|
JsonUtil.writeFile(getConfigFile(), configData);
|
||||||
// configData.islandBiomeEntries = revisedIslandBiomeEntries;
|
|
||||||
// JsonUtil.writeFile(getConfigFile(), configData);
|
for (DeferredRegistration<SingleClimateRegistrationData> registration : islandBiomeReistrations)
|
||||||
//
|
{
|
||||||
// for (Map.Entry<String, BiomeConfigData.IslandBiomeEntry> biomeEntry : configData.islandBiomeEntries.entrySet())
|
SingleClimateRegistrationData regData = registration.regData;
|
||||||
// {
|
String biomeName = regData.getBiome().delegate.name().toString();
|
||||||
// String name = biomeEntry.getKey();
|
|
||||||
// BiomeConfigData.IslandBiomeEntry islandBiomeEntry = biomeEntry.getValue();
|
if (revisedBiomeEntries.containsKey(biomeName))
|
||||||
//
|
{
|
||||||
// // Replace the default values for this biome with those from the config file
|
BiomeConfigData.ToggleableBiomeEntry entry = revisedBiomeEntries.get(biomeName);
|
||||||
// if (regDataMap.containsKey(name))
|
|
||||||
// {
|
if (!entry.enabled)
|
||||||
// IslandBiomeRegistrationData registrationData = regDataMap.get(name);
|
{
|
||||||
// registrationData.setWeight(islandBiomeEntry.weight);
|
registration.regData.setWeight(0);
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void configureVanillaBiomes()
|
public static void configureVanillaBiomes()
|
||||||
|
|
|
@ -154,7 +154,7 @@ public class ModBiomes
|
||||||
registerIslandBiome(tropics, BOPClimates.TROPICAL, 50);
|
registerIslandBiome(tropics, BOPClimates.TROPICAL, 50);
|
||||||
registerIslandBiome(tropics, BOPClimates.HOT_DESERT, 50);
|
registerIslandBiome(tropics, BOPClimates.HOT_DESERT, 50);
|
||||||
|
|
||||||
//BiomeRegistry.configureIslandBiomes();
|
BiomeRegistry.configureIslandBiomes();
|
||||||
BiomeRegistry.finalizeRegistrations(BiomeRegistry.RegistrationType.ISLAND_BIOME);
|
BiomeRegistry.finalizeRegistrations(BiomeRegistry.RegistrationType.ISLAND_BIOME);
|
||||||
|
|
||||||
// Set up vanilla biomes
|
// Set up vanilla biomes
|
||||||
|
|
Loading…
Reference in a new issue