minecraft-src/net/minecraft/world/entity/animal/frog/FrogVariants.java
2025-09-18 12:27:44 +00:00

39 lines
1.9 KiB
Java

package net.minecraft.world.entity.animal.frog;
import net.minecraft.core.ClientAsset;
import net.minecraft.core.HolderSet;
import net.minecraft.core.registries.Registries;
import net.minecraft.data.worldgen.BootstrapContext;
import net.minecraft.resources.ResourceKey;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.tags.BiomeTags;
import net.minecraft.tags.TagKey;
import net.minecraft.world.entity.animal.TemperatureVariants;
import net.minecraft.world.entity.variant.BiomeCheck;
import net.minecraft.world.entity.variant.SpawnPrioritySelectors;
import net.minecraft.world.level.biome.Biome;
public interface FrogVariants {
ResourceKey<FrogVariant> TEMPERATE = createKey(TemperatureVariants.TEMPERATE);
ResourceKey<FrogVariant> WARM = createKey(TemperatureVariants.WARM);
ResourceKey<FrogVariant> COLD = createKey(TemperatureVariants.COLD);
private static ResourceKey<FrogVariant> createKey(ResourceLocation name) {
return ResourceKey.create(Registries.FROG_VARIANT, name);
}
static void bootstrap(BootstrapContext<FrogVariant> context) {
register(context, TEMPERATE, "entity/frog/temperate_frog", SpawnPrioritySelectors.fallback(0));
register(context, WARM, "entity/frog/warm_frog", BiomeTags.SPAWNS_WARM_VARIANT_FROGS);
register(context, COLD, "entity/frog/cold_frog", BiomeTags.SPAWNS_COLD_VARIANT_FROGS);
}
private static void register(BootstrapContext<FrogVariant> context, ResourceKey<FrogVariant> key, String name, TagKey<Biome> biome) {
HolderSet<Biome> holderSet = context.lookup(Registries.BIOME).getOrThrow(biome);
register(context, key, name, SpawnPrioritySelectors.single(new BiomeCheck(holderSet), 1));
}
private static void register(BootstrapContext<FrogVariant> context, ResourceKey<FrogVariant> key, String name, SpawnPrioritySelectors spawnConditions) {
context.register(key, new FrogVariant(new ClientAsset(ResourceLocation.withDefaultNamespace(name)), spawnConditions));
}
}