Skip to content

Commit

Permalink
Hide biomes with the c:hidden_from_locator_selection tag (#177)
Browse files Browse the repository at this point in the history
  • Loading branch information
MattCzyr committed May 7, 2024
1 parent 8ef02ad commit 465c7ab
Showing 1 changed file with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public static List<ResourceLocation> getAllowedBiomeKeys(Level level) {
Biome biome = entry.getValue();
if (biome != null) {
Optional<ResourceLocation> optionalBiomeKey = getKeyForBiome(level, biome);
if (biome != null && optionalBiomeKey.isPresent() && !biomeKeyIsBlacklisted(level, optionalBiomeKey.get())) {
if (biome != null && optionalBiomeKey.isPresent() && !biomeKeyIsBlacklisted(level, optionalBiomeKey.get()) && !biomeKeyIsHidden(level, optionalBiomeKey.get())) {
biomeKeys.add(optionalBiomeKey.get());
}
}
Expand Down Expand Up @@ -233,6 +233,18 @@ public static boolean biomeKeyIsBlacklisted(Level level, ResourceLocation biomeK
}
return false;
}

public static boolean biomeKeyIsHidden(Level level, ResourceLocation biomeKey) {
if (getBiomeRegistry(level).isPresent() && getBiomeForKey(level, biomeKey).isPresent()) {
final Registry<Biome> biomeRegistry = getBiomeRegistry(level).get();
final Biome biome = getBiomeForKey(level, biomeKey).get();
if (biomeRegistry.getResourceKey(biome).isPresent() && biomeRegistry.getHolder(biomeRegistry.getResourceKey(biome).get()).isPresent()) {
final Holder<Biome> biomeHolder = biomeRegistry.getHolder(biomeRegistry.getResourceKey(biome).get()).get();
return biomeHolder.tags().anyMatch(tag -> tag.location().getPath().equals("c:hidden_from_locator_selection"));
}
}
return false;
}

private static String convertToRegex(String glob) {
String regex = "^";
Expand Down

0 comments on commit 465c7ab

Please sign in to comment.