WolfSoundVariants .java

net.minecraft.world.entity.animal.wolf.WolfSoundVariants (class): members: GRUMPY, PUGLIN, CUTE, SAD, ANGRY, BIG, pickRandomSoundVariant, SoundSet, key.

net.minecraft.world.entity.animal.wolfclass71 linescommon3.0 KB

API Surface (4)

void bootstrap(final BootstrapContext<WolfSoundVariant> context)
Holder<WolfSoundVariant> pickRandomSoundVariant(final RegistryAccess registryAccess, final RandomSource random)
String getIdentifier()
String getSoundEventIdentifier()

Fields & Constants (8)

CLASSIC
PUGLIN
SAD
ANGRY
GRUMPY
BIG
CUTE
key

String literals (12)

"classic"
"wolf"
"puglin"
"wolf_puglin"
"wolf_sad"
"angry"
"wolf_angry"
"grumpy"
"wolf_grumpy"
"wolf_big"
"cute"
"wolf_cute"

Full Source

WolfSoundVariants.java71 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.world.entity.animal.wolf;
2
3
import net.minecraft.core.Holder;
4
import net.minecraft.core.RegistryAccess;
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.sounds.SoundEvents;
10
import net.minecraft.util.RandomSource;
11
12
public class WolfSoundVariants {
13
	public static final ResourceKey<WolfSoundVariant> CLASSIC = createKey(WolfSoundVariants.SoundSet.CLASSIC);
14
	public static final ResourceKey<WolfSoundVariant> PUGLIN = createKey(WolfSoundVariants.SoundSet.PUGLIN);
15
	public static final ResourceKey<WolfSoundVariant> SAD = createKey(WolfSoundVariants.SoundSet.SAD);
16
	public static final ResourceKey<WolfSoundVariant> ANGRY = createKey(WolfSoundVariants.SoundSet.ANGRY);
17
	public static final ResourceKey<WolfSoundVariant> GRUMPY = createKey(WolfSoundVariants.SoundSet.GRUMPY);
18
	public static final ResourceKey<WolfSoundVariant> BIG = createKey(WolfSoundVariants.SoundSet.BIG);
19
	public static final ResourceKey<WolfSoundVariant> CUTE = createKey(WolfSoundVariants.SoundSet.CUTE);
20
21
	private static ResourceKey<WolfSoundVariant> createKey(final WolfSoundVariants.SoundSet wolfSoundVariant) {
22
		return ResourceKey.create(Registries.WOLF_SOUND_VARIANT, Identifier.withDefaultNamespace(wolfSoundVariant.getIdentifier()));
23
	}
24
25
	public static void bootstrap(final BootstrapContext<WolfSoundVariant> context) {
26
		register(context, CLASSIC, WolfSoundVariants.SoundSet.CLASSIC);
27
		register(context, PUGLIN, WolfSoundVariants.SoundSet.PUGLIN);
28
		register(context, SAD, WolfSoundVariants.SoundSet.SAD);
29
		register(context, ANGRY, WolfSoundVariants.SoundSet.ANGRY);
30
		register(context, GRUMPY, WolfSoundVariants.SoundSet.GRUMPY);
31
		register(context, BIG, WolfSoundVariants.SoundSet.BIG);
32
		register(context, CUTE, WolfSoundVariants.SoundSet.CUTE);
33
	}
34
35
	private static void register(
36
		final BootstrapContext<WolfSoundVariant> context, final ResourceKey<WolfSoundVariant> key, final WolfSoundVariants.SoundSet wolfSoundVariant
37
	) {
38
		context.register(key, SoundEvents.WOLF_SOUNDS.get(wolfSoundVariant));
39
	}
40
41
	public static Holder<WolfSoundVariant> pickRandomSoundVariant(final RegistryAccess registryAccess, final RandomSource random) {
42
		return registryAccess.lookupOrThrow(Registries.WOLF_SOUND_VARIANT).getRandom(random).orElseThrow();
43
	}
44
45
	public enum SoundSet {
46
		CLASSIC("classic", "wolf"),
47
		PUGLIN("puglin", "wolf_puglin"),
48
		SAD("sad", "wolf_sad"),
49
		ANGRY("angry", "wolf_angry"),
50
		GRUMPY("grumpy", "wolf_grumpy"),
51
		BIG("big", "wolf_big"),
52
		CUTE("cute", "wolf_cute");
53
54
		private final String identifier;
55
		private final String soundEventIdentifier;
56
57
		SoundSet(final String identifier, final String soundEventIdentifier) {
58
			this.identifier = identifier;
59
			this.soundEventIdentifier = soundEventIdentifier;
60
		}
61
62
		public String getIdentifier() {
63
			return this.identifier;
64
		}
65
66
		public String getSoundEventIdentifier() {
67
			return this.soundEventIdentifier;
68
		}
69
	}
70
}
71

Decompiled Minecraft 26.3 source of WolfSoundVariants (net/minecraft/world/entity/animal/wolf/WolfSoundVariants.java) with Mojang official mappings, stored verbatim on the site.