diff --git a/fabric-biome-api-v1/src/main/java/net/fabricmc/fabric/api/biome/v1/TheEndBiomes.java b/fabric-biome-api-v1/src/main/java/net/fabricmc/fabric/api/biome/v1/TheEndBiomes.java index 7070a582ab..6eee5cbc9f 100644 --- a/fabric-biome-api-v1/src/main/java/net/fabricmc/fabric/api/biome/v1/TheEndBiomes.java +++ b/fabric-biome-api-v1/src/main/java/net/fabricmc/fabric/api/biome/v1/TheEndBiomes.java @@ -103,4 +103,49 @@ public static void addMidlandsBiome(RegistryKey highlands, RegistryKey highlands, RegistryKey barrens, double weight) { TheEndBiomeData.addEndBarrensReplacement(highlands, barrens, weight); } + + /** + * Returns true if the given biome was added as a main end Biome in the end, considering the Vanilla end biomes, + * and any biomes added to the End by mods. + * @param biome The biome to search for + */ + public static boolean isMainIslandBiome(RegistryKey biome) { + return TheEndBiomeData.ADDED_BIOMES.get(biome) == BiomeKeys.THE_END; + } + + /** + * Returns true if the given biome was added as a small end islands Biome in the end, considering the Vanilla end biomes, + * and any biomes added to the End by mods. + * @param biome The biome to search for + */ + public static boolean isSmallIslandsBiome(RegistryKey biome) { + return TheEndBiomeData.ADDED_BIOMES.get(biome) == BiomeKeys.SMALL_END_ISLANDS; + } + + /** + * Returns true if the given biome was added as a Highland Biome in the end, considering the Vanilla end biomes, + * and any biomes added to the End by mods. + * @param biome The biome to search for + */ + public static boolean isHighlandsBiome(RegistryKey biome) { + return TheEndBiomeData.ADDED_BIOMES.get(biome) == BiomeKeys.END_HIGHLANDS; + } + + /** + * Returns true if the given biome was added as midland biome in the end, considering the Vanilla end biomes, + * and any biomes added to the End as midland biome by mods. + * @param biome The biome to search for + */ + public static boolean isMidlandsBiome(RegistryKey biome) { + return TheEndBiomeData.ADDED_BIOMES.get(biome) == BiomeKeys.END_MIDLANDS; + } + + /** + * Returns true if the given biome was added as barrens biome in the end, considering the Vanilla end biomes, + * and any biomes added to the End as barrens biome by mods. + * @param biome The biome to search for + */ + public static boolean isBarrensBiome(RegistryKey biome) { + return TheEndBiomeData.ADDED_BIOMES.get(biome) == BiomeKeys.END_BARRENS; + } } diff --git a/fabric-biome-api-v1/src/main/java/net/fabricmc/fabric/impl/biome/TheEndBiomeData.java b/fabric-biome-api-v1/src/main/java/net/fabricmc/fabric/impl/biome/TheEndBiomeData.java index 04ad88aaa5..f17cd2d501 100644 --- a/fabric-biome-api-v1/src/main/java/net/fabricmc/fabric/impl/biome/TheEndBiomeData.java +++ b/fabric-biome-api-v1/src/main/java/net/fabricmc/fabric/impl/biome/TheEndBiomeData.java @@ -16,7 +16,7 @@ package net.fabricmc.fabric.impl.biome; -import java.util.HashSet; +import java.util.HashMap; import java.util.IdentityHashMap; import java.util.Map; import java.util.Set; @@ -26,9 +26,9 @@ import javax.annotation.Nullable; import com.google.common.base.Preconditions; -import org.jetbrains.annotations.ApiStatus; import it.unimi.dsi.fastutil.Hash; import it.unimi.dsi.fastutil.objects.Object2ObjectOpenCustomHashMap; +import org.jetbrains.annotations.ApiStatus; import net.minecraft.util.math.noise.PerlinNoiseSampler; import net.minecraft.util.registry.Registry; @@ -44,7 +44,7 @@ */ @ApiStatus.Internal public final class TheEndBiomeData { - public static final Set> ADDED_BIOMES = new HashSet<>(); + public static final Map, RegistryKey> ADDED_BIOMES = new HashMap<>(); private static final Map, WeightedPicker>> END_BIOMES_MAP = new IdentityHashMap<>(); private static final Map, WeightedPicker>> END_MIDLANDS_MAP = new IdentityHashMap<>(); private static final Map, WeightedPicker>> END_BARRENS_MAP = new IdentityHashMap<>(); @@ -71,7 +71,7 @@ public static void addEndBiomeReplacement(RegistryKey replaced, RegistryK Preconditions.checkNotNull(variant, "variant entry is null"); Preconditions.checkArgument(weight > 0.0, "Weight is less than or equal to 0.0 (got %s)", weight); END_BIOMES_MAP.computeIfAbsent(replaced, key -> new WeightedPicker<>()).add(variant, weight); - ADDED_BIOMES.add(variant); + ADDED_BIOMES.put(variant, replaced); } public static void addEndMidlandsReplacement(RegistryKey highlands, RegistryKey midlands, double weight) { @@ -79,7 +79,7 @@ public static void addEndMidlandsReplacement(RegistryKey highlands, Regis Preconditions.checkNotNull(midlands, "midlands entry is null"); Preconditions.checkArgument(weight > 0.0, "Weight is less than or equal to 0.0 (got %s)", weight); END_MIDLANDS_MAP.computeIfAbsent(highlands, key -> new WeightedPicker<>()).add(midlands, weight); - ADDED_BIOMES.add(midlands); + ADDED_BIOMES.put(midlands, BiomeKeys.END_MIDLANDS); } public static void addEndBarrensReplacement(RegistryKey highlands, RegistryKey barrens, double weight) { @@ -87,7 +87,7 @@ public static void addEndBarrensReplacement(RegistryKey highlands, Regist Preconditions.checkNotNull(barrens, "midlands entry is null"); Preconditions.checkArgument(weight > 0.0, "Weight is less than or equal to 0.0 (got %s)", weight); END_BARRENS_MAP.computeIfAbsent(highlands, key -> new WeightedPicker<>()).add(barrens, weight); - ADDED_BIOMES.add(barrens); + ADDED_BIOMES.put(barrens, BiomeKeys.END_BARRENS); } public static Overrides createOverrides(Registry biomeRegistry) { @@ -114,7 +114,7 @@ public static class Overrides { private final Map samplers = new WeakHashMap<>(); public Overrides(Registry biomeRegistry) { - this.customBiomes = ADDED_BIOMES.stream().map(biomeRegistry::entryOf).collect(Collectors.toSet()); + this.customBiomes = ADDED_BIOMES.keySet().stream().map(biomeRegistry::entryOf).collect(Collectors.toSet()); this.endMidlands = biomeRegistry.entryOf(BiomeKeys.END_MIDLANDS); this.endBarrens = biomeRegistry.entryOf(BiomeKeys.END_BARRENS);