Preserve original biome order

Evaluate biomes in the order they are listed, as some mods contain biomes which overlap (e.g. Frost and Alpine in Ethereal), and if there more than one biome is tied for closest matching, then Minetest uses the first in the list.
master
Treer 2018-04-22 18:22:29 +10:00
parent 0cd857a894
commit c9cd285d20
2 changed files with 3 additions and 19 deletions

View File

@ -159,13 +159,9 @@ public class MinetestBiomeProfileImpl implements BiomeProfile {
return output + "\r\n] }\r\n";
}
/**
* This method uses the sorted color map, so the serialization will have a
* reproducible order.
*/
private String serializeColorMap() {
String output = "";
for (MinetestBiome biome : getSortedBiomeEntries()) {
for (MinetestBiome biome : biomeList) {
output += String.format(" { \"name\": \"%s\", \"color\": %s, \"y_min\": %d, \"y_max\": %d, \"heat_point\": %.2f, \"humidity_point\": %.2f },\r\n",
biome.getName(),
biome.getDefaultColor().createBiomeColorJson().toString(),
@ -175,19 +171,6 @@ public class MinetestBiomeProfileImpl implements BiomeProfile {
return output.substring(0, output.length() - 3);
}
private List<MinetestBiome> getSortedBiomeEntries() {
Comparator<MinetestBiome> SortByName = new Comparator<MinetestBiome>() {
@Override
public int compare(MinetestBiome a, MinetestBiome b) {
return a.getName().compareTo(b.getName());
}
};
List<MinetestBiome> result = new ArrayList<>(biomeList);
Collections.sort(result, SortByName);
return result;
}
private boolean writeToFile(File file, String output) {
try (BufferedWriter writer = new BufferedWriter(new FileWriter(file))) {
writer.write(output);

View File

@ -94,7 +94,8 @@ public abstract class MinetestBiomeDataOracle implements IBiomeDataOracle, Biome
float dist_min = Float.MAX_VALUE;
float dist_min_blend = Float.MAX_VALUE;
for (short i = (short)(biomes.length - 1); i >= 0; i--) {
short biomesArrayLength = (short)biomes.length;
for (short i = 0; i < biomesArrayLength; i++) {
MinetestBiome b = biomes[i];
if (y > b.y_max + b.vertical_blend || y < b.y_min)
continue;