Skip to content

Commit

Permalink
- fix handling of biome ids like "DarkForest"
Browse files Browse the repository at this point in the history
- slightly rewrite parseOptiFineConfig to only disable ctmEnabled
  • Loading branch information
Fourmisain committed Dec 12, 2023
1 parent 99e981f commit 39e81ec
Showing 1 changed file with 27 additions and 8 deletions.
35 changes: 27 additions & 8 deletions src/main/java/randommcsomethin/fallingleaves/util/CTM.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,11 @@ public static void parseOptiFineConfig() {
if (option.length != 2)
return;

if (option[0].equalsIgnoreCase("ofConnectedTextures")) {
// 1 = fast, 2 = fancy, 3 = off
ctmEnabled = !option[1].equals("3");

if (ctmEnabled)
LOGGER.info("OptiFine Connected Textures are enabled.");
// 1 = fast, 2 = fancy, 3 = off
if (option[0].equalsIgnoreCase("ofConnectedTextures") && option[1].equals("3")) {
ctmEnabled = false;
} else {
LOGGER.info("OptiFine Connected Textures are enabled.");
}
});
} catch (IOException e) {
Expand Down Expand Up @@ -133,8 +132,28 @@ public static void readBiomeTextures(ResourceManager resManager) {
private static List<Identifier> parseBiome(String biomes) {
List<Identifier> biomeList = new ArrayList<>();

for (String biome : biomes.split(" "))
biomeList.add(new Identifier(biome.toLowerCase(Locale.ROOT)));
for (String biome : biomes.split(" ")) {
if (biome.isEmpty()) continue;

// convert e.g. DarkForest -> dark_forest
StringBuilder biomeId = new StringBuilder();
for (int i = 0; i < biome.length(); i++) {
char c = biome.charAt(i);

if (Character.isUpperCase(c)) {
if (i > 0) biomeId.append('_');
c = Character.toLowerCase(c);
}

biomeId.append(c);
}

try {
biomeList.add(new Identifier(biomeId.toString()));
} catch (Exception e) {
LOGGER.error("couldn't parse biome \"{}\"", biome);
}
}

return biomeList;
}
Expand Down

0 comments on commit 39e81ec

Please sign in to comment.