Mutable registry
This commit is contained in:
parent
de7c7e1cdb
commit
b89afced36
4 changed files with 42 additions and 0 deletions
|
@ -51,6 +51,7 @@ public class BiomeDefinition {
|
|||
private float fogDensity = 1F;
|
||||
|
||||
private final Identifier id;
|
||||
private float genChance = 1F;
|
||||
|
||||
private ConfiguredSurfaceBuilder<?> surface;
|
||||
|
||||
|
@ -86,6 +87,11 @@ public class BiomeDefinition {
|
|||
this.particleConfig = config;
|
||||
return this;
|
||||
}
|
||||
|
||||
public BiomeDefinition setGenChance(float genChance) {
|
||||
this.genChance = genChance;
|
||||
return this;
|
||||
}
|
||||
|
||||
public BiomeDefinition addMobSpawn(EntityType<?> type, int weight, int minGroupSize, int maxGroupSize) {
|
||||
Identifier eID = Registry.ENTITY_TYPE.getId(type);
|
||||
|
@ -223,4 +229,8 @@ public class BiomeDefinition {
|
|||
public float getFodDensity() {
|
||||
return fogDensity;
|
||||
}
|
||||
|
||||
public float getGenChance() {
|
||||
return genChance;
|
||||
}
|
||||
}
|
|
@ -21,6 +21,7 @@ public class EndBiome {
|
|||
|
||||
protected EndBiome biomeParent;
|
||||
protected float maxSubBiomeChance = 1;
|
||||
protected final float genChanceUnmutable;
|
||||
protected float genChance = 1;
|
||||
|
||||
private final float fogDensity;
|
||||
|
@ -29,12 +30,14 @@ public class EndBiome {
|
|||
biome = definition.build();
|
||||
mcID = definition.getID();
|
||||
fogDensity = definition.getFodDensity();
|
||||
genChanceUnmutable = definition.getGenChance();
|
||||
}
|
||||
|
||||
public EndBiome(Biome biome) {
|
||||
this.biome = biome;
|
||||
mcID = BuiltinRegistries.BIOME.getId(biome);
|
||||
fogDensity = 1;
|
||||
genChanceUnmutable = 1;
|
||||
}
|
||||
|
||||
public void genSurfColumn(WorldAccess world, BlockPos pos, Random random) {
|
||||
|
@ -106,6 +109,7 @@ public class EndBiome {
|
|||
}
|
||||
|
||||
public float setGenChance(float chance) {
|
||||
genChance = genChanceUnmutable;
|
||||
genChance += chance;
|
||||
return genChance;
|
||||
}
|
||||
|
|
|
@ -10,11 +10,26 @@ import ru.betterend.world.biome.EndBiome;
|
|||
|
||||
public class BiomePicker {
|
||||
private final List<EndBiome> biomes = Lists.newArrayList();
|
||||
private float maxChanceUnmutable = 0;
|
||||
private float maxChance = 0;
|
||||
private int biomeCount = 0;
|
||||
|
||||
public void addBiome(EndBiome biome) {
|
||||
biomes.add(biome);
|
||||
maxChance = biome.setGenChance(maxChance);
|
||||
biomeCount ++;
|
||||
maxChanceUnmutable = maxChance;
|
||||
}
|
||||
|
||||
public void addBiomeMutable(EndBiome biome) {
|
||||
biomes.add(biome);
|
||||
maxChance = biome.setGenChance(maxChance);
|
||||
}
|
||||
|
||||
public void clearMutables() {
|
||||
maxChance = maxChanceUnmutable;
|
||||
for (int i = biomes.size() - 1; i >= biomeCount; i--)
|
||||
biomes.remove(i);
|
||||
}
|
||||
|
||||
public EndBiome getBiome(Random random) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue