Biome config
This commit is contained in:
parent
69d11c0e5a
commit
a2dec40b0a
6 changed files with 44 additions and 7 deletions
|
@ -7,6 +7,8 @@ import com.google.gson.JsonObject;
|
|||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.level.biome.Biome;
|
||||
import net.minecraft.world.level.biome.Biomes;
|
||||
import ru.bclib.config.Configs;
|
||||
import ru.bclib.util.JsonFactory;
|
||||
import ru.bclib.util.StructureHelper;
|
||||
import ru.bclib.util.WeightedList;
|
||||
|
@ -38,6 +40,7 @@ public class BCLBiome {
|
|||
private Biome actualBiome;
|
||||
|
||||
public BCLBiome(BCLBiomeDef definition) {
|
||||
definition.loadConfigValues(Configs.BIOMES_CONFIG);
|
||||
this.mcID = definition.getID();
|
||||
this.readStructureList();
|
||||
if (structuresFeature != null) {
|
||||
|
@ -53,8 +56,15 @@ public class BCLBiome {
|
|||
public BCLBiome(ResourceLocation id, Biome biome, float fogDensity, float genChance) {
|
||||
this.mcID = id;
|
||||
this.biome = biome;
|
||||
this.genChance = genChance;
|
||||
this.fogDensity = fogDensity;
|
||||
if (id.equals(Biomes.THE_VOID.location())) {
|
||||
this.genChance = fogDensity;
|
||||
this.fogDensity = genChance;
|
||||
}
|
||||
else {
|
||||
String biomePath = id.getNamespace() + "." + id.getPath();
|
||||
this.genChance = Configs.BIOMES_CONFIG.getFloat(biomePath, "generation_chance", genChance);
|
||||
this.fogDensity = Configs.BIOMES_CONFIG.getFloat(biomePath, "fog_density", fogDensity);
|
||||
}
|
||||
this.readStructureList();
|
||||
this.customData = Maps.newHashMap();
|
||||
subbiomes.add(this, 1);
|
||||
|
|
|
@ -32,6 +32,7 @@ import net.minecraft.world.level.levelgen.surfacebuilders.ConfiguredSurfaceBuild
|
|||
import net.minecraft.world.level.levelgen.surfacebuilders.SurfaceBuilder;
|
||||
import net.minecraft.world.level.levelgen.surfacebuilders.SurfaceBuilderBaseConfiguration;
|
||||
import ru.bclib.config.IdConfig;
|
||||
import ru.bclib.config.PathConfig;
|
||||
import ru.bclib.util.ColorUtil;
|
||||
import ru.bclib.world.features.BCLFeature;
|
||||
import ru.bclib.world.structures.BCLStructureFeature;
|
||||
|
@ -113,7 +114,6 @@ public class BCLBiomeDef {
|
|||
|
||||
/**
|
||||
* Used to load biome settings from config.
|
||||
*
|
||||
* @param config - {@link IdConfig}.
|
||||
* @return this {@link BCLBiomeDef}.
|
||||
*/
|
||||
|
@ -124,9 +124,21 @@ public class BCLBiomeDef {
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to load biome settings from config.
|
||||
* @param config - {@link PathConfig}.
|
||||
* @return this {@link BCLBiomeDef}.
|
||||
*/
|
||||
public BCLBiomeDef loadConfigValues(PathConfig config) {
|
||||
String biomePath = id.getNamespace() + "." + id.getPath();
|
||||
this.fogDensity = config.getFloat(biomePath, "fog_density", this.fogDensity);
|
||||
this.genChance = config.getFloat(biomePath, "generation_chance", this.genChance);
|
||||
this.edgeSize = config.getInt(biomePath, "edge_size", this.edgeSize);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set category of the biome.
|
||||
*
|
||||
* @param category - {@link BiomeCategory}.
|
||||
* @return this {@link BCLBiomeDef}.
|
||||
*/
|
||||
|
|
|
@ -14,6 +14,7 @@ import net.minecraft.world.level.levelgen.WorldgenRandom;
|
|||
import net.minecraft.world.level.levelgen.synth.SimplexNoise;
|
||||
import ru.bclib.BCLib;
|
||||
import ru.bclib.api.BiomeAPI;
|
||||
import ru.bclib.config.Configs;
|
||||
import ru.bclib.noise.OpenSimplexNoise;
|
||||
import ru.bclib.world.biomes.BCLBiome;
|
||||
|
||||
|
@ -62,6 +63,8 @@ public class BCLibEndBiomeSource extends BiomeSource {
|
|||
}
|
||||
});
|
||||
|
||||
Configs.BIOMES_CONFIG.saveChanges();
|
||||
|
||||
BiomeAPI.END_LAND_BIOME_PICKER.getBiomes().forEach(biome -> biome.updateActualBiomes(biomeRegistry));
|
||||
BiomeAPI.END_VOID_BIOME_PICKER.getBiomes().forEach(biome -> biome.updateActualBiomes(biomeRegistry));
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@ import net.minecraft.world.level.biome.Biome.BiomeCategory;
|
|||
import net.minecraft.world.level.biome.BiomeSource;
|
||||
import ru.bclib.BCLib;
|
||||
import ru.bclib.api.BiomeAPI;
|
||||
import ru.bclib.config.Configs;
|
||||
import ru.bclib.world.biomes.BCLBiome;
|
||||
|
||||
import java.util.LinkedList;
|
||||
|
@ -52,6 +53,7 @@ public class BCLibNetherBiomeSource extends BiomeSource {
|
|||
}
|
||||
});
|
||||
|
||||
Configs.BIOMES_CONFIG.saveChanges();
|
||||
BiomeAPI.NETHER_BIOME_PICKER.getBiomes().forEach(biome -> biome.updateActualBiomes(biomeRegistry));
|
||||
BiomeAPI.NETHER_BIOME_PICKER.rebuild();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue