| 1 | package net.minecraft.world.entity.animal.wolf;
|
| 2 |
|
| 3 | import net.minecraft.core.ClientAsset;
|
| 4 | import net.minecraft.core.HolderSet;
|
| 5 | import net.minecraft.core.registries.Registries;
|
| 6 | import net.minecraft.data.worldgen.BootstrapContext;
|
| 7 | import net.minecraft.resources.Identifier;
|
| 8 | import net.minecraft.resources.ResourceKey;
|
| 9 | import net.minecraft.tags.BiomeTags;
|
| 10 | import net.minecraft.tags.TagKey;
|
| 11 | import net.minecraft.world.entity.variant.BiomeCheck;
|
| 12 | import net.minecraft.world.entity.variant.SpawnPrioritySelectors;
|
| 13 | import net.minecraft.world.level.biome.Biome;
|
| 14 | import net.minecraft.world.level.biome.Biomes;
|
| 15 |
|
| 16 | public class WolfVariants {
|
| 17 | public static final ResourceKey<WolfVariant> PALE = createKey("pale");
|
| 18 | public static final ResourceKey<WolfVariant> SPOTTED = createKey("spotted");
|
| 19 | public static final ResourceKey<WolfVariant> SNOWY = createKey("snowy");
|
| 20 | public static final ResourceKey<WolfVariant> BLACK = createKey("black");
|
| 21 | public static final ResourceKey<WolfVariant> ASHEN = createKey("ashen");
|
| 22 | public static final ResourceKey<WolfVariant> RUSTY = createKey("rusty");
|
| 23 | public static final ResourceKey<WolfVariant> WOODS = createKey("woods");
|
| 24 | public static final ResourceKey<WolfVariant> CHESTNUT = createKey("chestnut");
|
| 25 | public static final ResourceKey<WolfVariant> STRIPED = createKey("striped");
|
| 26 | public static final ResourceKey<WolfVariant> DEFAULT = PALE;
|
| 27 |
|
| 28 | private static ResourceKey<WolfVariant> createKey(final String name) {
|
| 29 | return ResourceKey.create(Registries.WOLF_VARIANT, Identifier.withDefaultNamespace(name));
|
| 30 | }
|
| 31 |
|
| 32 | private static void register(
|
| 33 | final BootstrapContext<WolfVariant> context, final ResourceKey<WolfVariant> name, final String fileName, final ResourceKey<Biome> spawnBiome
|
| 34 | ) {
|
| 35 | register(context, name, fileName, highPrioBiome(HolderSet.direct(context.lookup(Registries.BIOME).getOrThrow(spawnBiome))));
|
| 36 | }
|
| 37 |
|
| 38 | private static void register(
|
| 39 | final BootstrapContext<WolfVariant> context, final ResourceKey<WolfVariant> name, final String fileName, final TagKey<Biome> spawnBiome
|
| 40 | ) {
|
| 41 | register(context, name, fileName, highPrioBiome(context.lookup(Registries.BIOME).getOrThrow(spawnBiome)));
|
| 42 | }
|
| 43 |
|
| 44 | private static SpawnPrioritySelectors highPrioBiome(final HolderSet<Biome> biomes) {
|
| 45 | return SpawnPrioritySelectors.single(new BiomeCheck(biomes), 1);
|
| 46 | }
|
| 47 |
|
| 48 | private static void register(
|
| 49 | final BootstrapContext<WolfVariant> context, final ResourceKey<WolfVariant> name, final String fileName, final SpawnPrioritySelectors selectors
|
| 50 | ) {
|
| 51 | Identifier wildTexture = Identifier.withDefaultNamespace("entity/wolf/" + fileName);
|
| 52 | Identifier tameTexture = Identifier.withDefaultNamespace("entity/wolf/" + fileName + "_tame");
|
| 53 | Identifier angryTexture = Identifier.withDefaultNamespace("entity/wolf/" + fileName + "_angry");
|
| 54 | Identifier babyTexture = Identifier.withDefaultNamespace("entity/wolf/" + fileName + "_baby");
|
| 55 | Identifier tameBabyTexture = Identifier.withDefaultNamespace("entity/wolf/" + fileName + "_tame_baby");
|
| 56 | Identifier angryBabyTexture = Identifier.withDefaultNamespace("entity/wolf/" + fileName + "_angry_baby");
|
| 57 | context.register(
|
| 58 | name,
|
| 59 | new WolfVariant(
|
| 60 | new WolfVariant.AssetInfo(
|
| 61 | new ClientAsset.ResourceTexture(wildTexture), new ClientAsset.ResourceTexture(tameTexture), new ClientAsset.ResourceTexture(angryTexture)
|
| 62 | ),
|
| 63 | new WolfVariant.AssetInfo(
|
| 64 | new ClientAsset.ResourceTexture(babyTexture), new ClientAsset.ResourceTexture(tameBabyTexture), new ClientAsset.ResourceTexture(angryBabyTexture)
|
| 65 | ),
|
| 66 | selectors
|
| 67 | )
|
| 68 | );
|
| 69 | }
|
| 70 |
|
| 71 | public static void bootstrap(final BootstrapContext<WolfVariant> context) {
|
| 72 | register(context, PALE, "wolf", SpawnPrioritySelectors.fallback(0));
|
| 73 | register(context, SPOTTED, "wolf_spotted", BiomeTags.IS_SAVANNA);
|
| 74 | register(context, SNOWY, "wolf_snowy", Biomes.GROVE);
|
| 75 | register(context, BLACK, "wolf_black", Biomes.OLD_GROWTH_PINE_TAIGA);
|
| 76 | register(context, ASHEN, "wolf_ashen", Biomes.SNOWY_TAIGA);
|
| 77 | register(context, RUSTY, "wolf_rusty", BiomeTags.IS_JUNGLE);
|
| 78 | register(context, WOODS, "wolf_woods", Biomes.FOREST);
|
| 79 | register(context, CHESTNUT, "wolf_chestnut", Biomes.OLD_GROWTH_SPRUCE_TAIGA);
|
| 80 | register(context, STRIPED, "wolf_striped", BiomeTags.IS_BADLANDS);
|
| 81 | }
|
| 82 | }
|
| 83 |
|