From 465c7ab72b5366d17810cecdd944c3a23a8c5235 Mon Sep 17 00:00:00 2001 From: Matthew Czyr Date: Tue, 7 May 2024 19:41:16 -0400 Subject: [PATCH] Hide biomes with the c:hidden_from_locator_selection tag (#177) --- .../naturescompass/util/BiomeUtils.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/chaosthedude/naturescompass/util/BiomeUtils.java b/src/main/java/com/chaosthedude/naturescompass/util/BiomeUtils.java index 5986e59..a3cb21f 100644 --- a/src/main/java/com/chaosthedude/naturescompass/util/BiomeUtils.java +++ b/src/main/java/com/chaosthedude/naturescompass/util/BiomeUtils.java @@ -55,7 +55,7 @@ public static List getAllowedBiomeKeys(Level level) { Biome biome = entry.getValue(); if (biome != null) { Optional 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()); } } @@ -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 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 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 = "^";