[Fix] Edge Biomes are never selected when only a single biome is available
This commit is contained in:
parent
90d0c191f5
commit
e411dc10d9
1 changed files with 29 additions and 6 deletions
|
@ -59,13 +59,25 @@ public class BiomePicker {
|
||||||
|
|
||||||
public void rebuild() {
|
public void rebuild() {
|
||||||
WeightedList<ActualBiome> list = new WeightedList<>();
|
WeightedList<ActualBiome> list = new WeightedList<>();
|
||||||
if (biomes.isEmpty()) {
|
|
||||||
|
biomes.forEach(biome -> {
|
||||||
|
if (biome.isValid)
|
||||||
|
list.add(biome, biome.bclBiome.getGenChance());
|
||||||
|
});
|
||||||
|
//only a single biome, we need to add the edges as well
|
||||||
|
if (list.size() == 1) {
|
||||||
|
ActualBiome biome = list.get(0);
|
||||||
|
|
||||||
|
if (biome.getEdge() != null) {
|
||||||
|
float defaultBiomeSize = 128;
|
||||||
|
float edgeSize = (biome.bclBiome.getEdgeSize() * list.getWeight(0)) / defaultBiomeSize;
|
||||||
|
list.add(biome.getEdge(), edgeSize);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//no Biome, make sure we add at least one, otherwise bad things will happen
|
||||||
|
if (list.isEmpty()) {
|
||||||
list.add(create(BiomeAPI.EMPTY_BIOME), 1);
|
list.add(create(BiomeAPI.EMPTY_BIOME), 1);
|
||||||
} else {
|
|
||||||
biomes.forEach(biome -> {
|
|
||||||
if (biome.isValid)
|
|
||||||
list.add(biome, biome.bclBiome.getGenChance());
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -131,5 +143,16 @@ public class BiomePicker {
|
||||||
public boolean isSame(ActualBiome e) {
|
public boolean isSame(ActualBiome e) {
|
||||||
return bclBiome.isSame(e.bclBiome);
|
return bclBiome.isSame(e.bclBiome);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "ActualBiome{" +
|
||||||
|
"key=" + key.location() +
|
||||||
|
", subbiomes=" + subbiomes.size() +
|
||||||
|
", edge=" + (edge != null ? edge.key.location() : "null") +
|
||||||
|
", parent=" + (parent != null ? parent.key.location() : "null") +
|
||||||
|
", isValid=" + isValid +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue