Minor Refactor
This commit is contained in:
parent
d738e8ae75
commit
61cf9711a6
4 changed files with 42 additions and 28 deletions
|
@ -378,4 +378,14 @@ public class BCLBiome {
|
||||||
public Map<Decoration, List<Supplier<PlacedFeature>>> getFeatures(){
|
public Map<Decoration, List<Supplier<PlacedFeature>>> getFeatures(){
|
||||||
return features;
|
return features;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the group used in the config Files for this biome
|
||||||
|
*
|
||||||
|
* Example: {@code Configs.BIOMES_CONFIG.getFloat(configGroup(), "generation_chance", 1.0);}
|
||||||
|
* @return The group name
|
||||||
|
*/
|
||||||
|
public String configGroup() {
|
||||||
|
return biomeID.getNamespace() + "." + biomeID.getPath();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,8 @@ import net.minecraft.core.Registry;
|
||||||
import net.minecraft.world.level.biome.Biome;
|
import net.minecraft.world.level.biome.Biome;
|
||||||
import net.minecraft.world.level.biome.BiomeSource;
|
import net.minecraft.world.level.biome.BiomeSource;
|
||||||
import ru.bclib.api.biomes.BiomeAPI;
|
import ru.bclib.api.biomes.BiomeAPI;
|
||||||
|
import ru.bclib.config.Configs;
|
||||||
|
import ru.bclib.world.biomes.BCLBiome;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -24,4 +26,28 @@ public abstract class BCLBiomeSource extends BiomeSource {
|
||||||
|
|
||||||
BiomeAPI.initRegistry(biomeRegistry);
|
BiomeAPI.initRegistry(biomeRegistry);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set Biome configuartion from Config
|
||||||
|
* @param bclBiome The biome you want to configure
|
||||||
|
* @return The input biome
|
||||||
|
*/
|
||||||
|
public static BCLBiome setupFromConfig(BCLBiome bclBiome) {
|
||||||
|
String group = bclBiome.configGroup();
|
||||||
|
float chance = Configs.BIOMES_CONFIG.getFloat(group, "generation_chance", bclBiome.getGenChance());
|
||||||
|
float fog = Configs.BIOMES_CONFIG.getFloat(group, "fog_density", bclBiome.getFogDensity());
|
||||||
|
bclBiome.setGenChance(chance)
|
||||||
|
.setFogDensity(fog);
|
||||||
|
|
||||||
|
if (bclBiome.getEdge()!=null){
|
||||||
|
int edgeSize = Configs.BIOMES_CONFIG.getInt(group, "edge_size", bclBiome.getEdgeSize());
|
||||||
|
bclBiome.setEdgeSize(edgeSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
Configs.BIOMES_CONFIG.saveChanges();
|
||||||
|
|
||||||
|
return bclBiome;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,9 +58,8 @@ public class BCLibEndBiomeSource extends BCLBiomeSource {
|
||||||
String group = key.getNamespace() + "." + key.getPath();
|
String group = key.getNamespace() + "." + key.getPath();
|
||||||
|
|
||||||
if (!BiomeAPI.hasBiome(key)) {
|
if (!BiomeAPI.hasBiome(key)) {
|
||||||
float chance = Configs.BIOMES_CONFIG.getFloat(group, "generation_chance", 1.0F);
|
BCLBiome bclBiome = setupFromConfig(new BCLBiome(key, biome));
|
||||||
float fog = Configs.BIOMES_CONFIG.getFloat(group, "fog_density", 1.0F);
|
|
||||||
BCLBiome bclBiome = new BCLBiome(key, biome).setGenChance(chance).setFogDensity(fog);
|
|
||||||
if (includeVoid.contains(key.toString())) {
|
if (includeVoid.contains(key.toString())) {
|
||||||
BiomeAPI.END_VOID_BIOME_PICKER.addBiomeMutable(bclBiome);
|
BiomeAPI.END_VOID_BIOME_PICKER.addBiomeMutable(bclBiome);
|
||||||
}
|
}
|
||||||
|
@ -71,14 +70,7 @@ public class BCLibEndBiomeSource extends BCLBiomeSource {
|
||||||
else {
|
else {
|
||||||
BCLBiome bclBiome = BiomeAPI.getBiome(key);
|
BCLBiome bclBiome = BiomeAPI.getBiome(key);
|
||||||
if (bclBiome != BiomeAPI.EMPTY_BIOME) {
|
if (bclBiome != BiomeAPI.EMPTY_BIOME) {
|
||||||
float chance = Configs.BIOMES_CONFIG.getFloat(group, "generation_chance", bclBiome.getGenChance());
|
setupFromConfig(bclBiome);
|
||||||
float fog = Configs.BIOMES_CONFIG.getFloat(group, "fog_density", bclBiome.getFogDensity());
|
|
||||||
bclBiome.setGenChance(chance).setFogDensity(fog);
|
|
||||||
if (bclBiome.getEdgeSize()!=0){
|
|
||||||
int edgeSize = Configs.BIOMES_CONFIG.getInt(group, "edge_size", bclBiome.getEdgeSize());
|
|
||||||
bclBiome.setEdgeSize(edgeSize);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if (bclBiome.getParentBiome() == null) {
|
if (bclBiome.getParentBiome() == null) {
|
||||||
if (!BiomeAPI.END_LAND_BIOME_PICKER.containsImmutable(key) && !BiomeAPI.END_VOID_BIOME_PICKER.containsImmutable(key)) {
|
if (!BiomeAPI.END_LAND_BIOME_PICKER.containsImmutable(key) && !BiomeAPI.END_VOID_BIOME_PICKER.containsImmutable(key)) {
|
||||||
|
@ -94,8 +86,6 @@ public class BCLibEndBiomeSource extends BCLBiomeSource {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Configs.BIOMES_CONFIG.saveChanges();
|
|
||||||
|
|
||||||
BiomeAPI.END_LAND_BIOME_PICKER.getBiomes().forEach(biome -> biome.updateActualBiomes(biomeRegistry));
|
BiomeAPI.END_LAND_BIOME_PICKER.getBiomes().forEach(biome -> biome.updateActualBiomes(biomeRegistry));
|
||||||
BiomeAPI.END_VOID_BIOME_PICKER.getBiomes().forEach(biome -> biome.updateActualBiomes(biomeRegistry));
|
BiomeAPI.END_VOID_BIOME_PICKER.getBiomes().forEach(biome -> biome.updateActualBiomes(biomeRegistry));
|
||||||
|
|
||||||
|
|
|
@ -58,30 +58,19 @@ public class BCLibNetherBiomeSource extends BCLBiomeSource {
|
||||||
public BCLibNetherBiomeSource(Registry<Biome> biomeRegistry, long seed) {
|
public BCLibNetherBiomeSource(Registry<Biome> biomeRegistry, long seed) {
|
||||||
super(biomeRegistry, seed, getBiomes(biomeRegistry));
|
super(biomeRegistry, seed, getBiomes(biomeRegistry));
|
||||||
|
|
||||||
|
|
||||||
BiomeAPI.NETHER_BIOME_PICKER.clearMutables();
|
BiomeAPI.NETHER_BIOME_PICKER.clearMutables();
|
||||||
|
|
||||||
this.possibleBiomes().forEach(biome -> {
|
this.possibleBiomes().forEach(biome -> {
|
||||||
ResourceLocation key = biomeRegistry.getKey(biome);
|
ResourceLocation key = biomeRegistry.getKey(biome);
|
||||||
String group = key.getNamespace() + "." + key.getPath();
|
|
||||||
if (!BiomeAPI.hasBiome(key)) {
|
if (!BiomeAPI.hasBiome(key)) {
|
||||||
float chance = Configs.BIOMES_CONFIG.getFloat(group, "generation_chance", 1.0F);
|
BCLBiome bclBiome = setupFromConfig(new BCLBiome(key, biome));
|
||||||
float fog = Configs.BIOMES_CONFIG.getFloat(group, "fog_density", 1.0F);
|
|
||||||
BCLBiome bclBiome = new BCLBiome(key, biome).setGenChance(chance).setFogDensity(fog);
|
|
||||||
BiomeAPI.NETHER_BIOME_PICKER.addBiomeMutable(bclBiome);
|
BiomeAPI.NETHER_BIOME_PICKER.addBiomeMutable(bclBiome);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
BCLBiome bclBiome = BiomeAPI.getBiome(key);
|
BCLBiome bclBiome = BiomeAPI.getBiome(key);
|
||||||
if (bclBiome != BiomeAPI.EMPTY_BIOME) {
|
if (bclBiome != BiomeAPI.EMPTY_BIOME) {
|
||||||
float chance = Configs.BIOMES_CONFIG.getFloat(group, "generation_chance", bclBiome.getGenChance());
|
setupFromConfig(bclBiome);
|
||||||
float fog = Configs.BIOMES_CONFIG.getFloat(group, "fog_density", bclBiome.getFogDensity());
|
|
||||||
bclBiome.setGenChance(chance)
|
|
||||||
.setFogDensity(fog);
|
|
||||||
|
|
||||||
if (bclBiome.getEdgeSize()!=0){
|
|
||||||
int edgeSize = Configs.BIOMES_CONFIG.getInt(group, "edge_size", bclBiome.getEdgeSize());
|
|
||||||
bclBiome.setEdgeSize(edgeSize);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (bclBiome.getParentBiome() == null) {
|
if (bclBiome.getParentBiome() == null) {
|
||||||
if (!BiomeAPI.NETHER_BIOME_PICKER.containsImmutable(key)) {
|
if (!BiomeAPI.NETHER_BIOME_PICKER.containsImmutable(key)) {
|
||||||
|
@ -92,7 +81,6 @@ public class BCLibNetherBiomeSource extends BCLBiomeSource {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Configs.BIOMES_CONFIG.saveChanges();
|
|
||||||
BiomeAPI.NETHER_BIOME_PICKER.getBiomes().forEach(biome -> biome.updateActualBiomes(biomeRegistry));
|
BiomeAPI.NETHER_BIOME_PICKER.getBiomes().forEach(biome -> biome.updateActualBiomes(biomeRegistry));
|
||||||
BiomeAPI.NETHER_BIOME_PICKER.rebuild();
|
BiomeAPI.NETHER_BIOME_PICKER.rebuild();
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue