47 lines
2.5 KiB
Java
47 lines
2.5 KiB
Java
/*
|
|
* Decompiled with CFR 0.152.
|
|
*/
|
|
package net.minecraft.world.entity.animal;
|
|
|
|
import net.minecraft.core.HolderSet;
|
|
import net.minecraft.core.registries.Registries;
|
|
import net.minecraft.data.worldgen.BootstrapContext;
|
|
import net.minecraft.resources.Identifier;
|
|
import net.minecraft.resources.ResourceKey;
|
|
import net.minecraft.tags.BiomeTags;
|
|
import net.minecraft.tags.TagKey;
|
|
import net.minecraft.world.entity.animal.CowVariant;
|
|
import net.minecraft.world.entity.animal.TemperatureVariants;
|
|
import net.minecraft.world.entity.variant.BiomeCheck;
|
|
import net.minecraft.world.entity.variant.ModelAndTexture;
|
|
import net.minecraft.world.entity.variant.SpawnPrioritySelectors;
|
|
import net.minecraft.world.level.biome.Biome;
|
|
|
|
public class CowVariants {
|
|
public static final ResourceKey<CowVariant> TEMPERATE = CowVariants.createKey(TemperatureVariants.TEMPERATE);
|
|
public static final ResourceKey<CowVariant> WARM = CowVariants.createKey(TemperatureVariants.WARM);
|
|
public static final ResourceKey<CowVariant> COLD = CowVariants.createKey(TemperatureVariants.COLD);
|
|
public static final ResourceKey<CowVariant> DEFAULT = TEMPERATE;
|
|
|
|
private static ResourceKey<CowVariant> createKey(Identifier id) {
|
|
return ResourceKey.create(Registries.COW_VARIANT, id);
|
|
}
|
|
|
|
public static void bootstrap(BootstrapContext<CowVariant> context) {
|
|
CowVariants.register(context, TEMPERATE, CowVariant.ModelType.NORMAL, "temperate_cow", SpawnPrioritySelectors.fallback(0));
|
|
CowVariants.register(context, WARM, CowVariant.ModelType.WARM, "warm_cow", BiomeTags.SPAWNS_WARM_VARIANT_FARM_ANIMALS);
|
|
CowVariants.register(context, COLD, CowVariant.ModelType.COLD, "cold_cow", BiomeTags.SPAWNS_COLD_VARIANT_FARM_ANIMALS);
|
|
}
|
|
|
|
private static void register(BootstrapContext<CowVariant> context, ResourceKey<CowVariant> name, CowVariant.ModelType modelType, String textureName, TagKey<Biome> spawnBiome) {
|
|
HolderSet.Named<Biome> biomes = context.lookup(Registries.BIOME).getOrThrow(spawnBiome);
|
|
CowVariants.register(context, name, modelType, textureName, SpawnPrioritySelectors.single(new BiomeCheck(biomes), 1));
|
|
}
|
|
|
|
private static void register(BootstrapContext<CowVariant> context, ResourceKey<CowVariant> name, CowVariant.ModelType modelType, String textureName, SpawnPrioritySelectors selectors) {
|
|
Identifier textureId = Identifier.withDefaultNamespace("entity/cow/" + textureName);
|
|
context.register(name, new CowVariant(new ModelAndTexture<CowVariant.ModelType>(modelType, textureId), selectors));
|
|
}
|
|
}
|
|
|