PigSoundVariant .java

net.minecraft.world.entity.animal.pig.PigSoundVariant (record, 44 lines): members: adultSounds, babySounds, PigSoundSet, stepSound, NETWORK_CODEC, codec.

net.minecraft.world.entity.animal.pigrecord44 linescommon2.1 KB

API Surface (2)

record PigSoundVariant(PigSoundVariant.PigSoundSet adultSounds, PigSoundVariant.PigSoundSet babySounds)
record PigSoundSet(Holder<SoundEvent> ambientSound, Holder<SoundEvent> hurtSound, Holder<SoundEvent> deathSound, Holder<SoundEvent> stepSound, Holder<SoundEvent> eatSound)

Fields & Constants (5)

DIRECT_CODEC
NETWORK_CODEC
CODEC
STREAM_CODEC
stepSound

String literals (7)

"adult_sounds"
"baby_sounds"
"ambient_sound"
"hurt_sound"
"death_sound"
"step_sound"
"eat_sound"

Code Graph: Dependencies (7)

Edges (calls / imports / inherits / references) resolved by graphify from the AST. Every chip opens the class source.

Full Source

PigSoundVariant.java44 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.world.entity.animal.pig;
2
3
import com.mojang.serialization.Codec;
4
import com.mojang.serialization.codecs.RecordCodecBuilder;
5
import net.minecraft.core.Holder;
6
import net.minecraft.core.registries.Registries;
7
import net.minecraft.core.registries.codec.RegistryCodecs;
8
import net.minecraft.network.RegistryFriendlyByteBuf;
9
import net.minecraft.network.codec.ByteBufCodecs;
10
import net.minecraft.network.codec.StreamCodec;
11
import net.minecraft.sounds.SoundEvent;
12
13
public record PigSoundVariant(PigSoundVariant.PigSoundSet adultSounds, PigSoundVariant.PigSoundSet babySounds) {
14
	public static final Codec<PigSoundVariant> DIRECT_CODEC = codec();
15
	public static final Codec<PigSoundVariant> NETWORK_CODEC = codec();
16
	public static final Codec<Holder<PigSoundVariant>> CODEC = RegistryCodecs.holder(Registries.PIG_SOUND_VARIANT);
17
	public static final StreamCodec<RegistryFriendlyByteBuf, Holder<PigSoundVariant>> STREAM_CODEC = ByteBufCodecs.holderRegistry(Registries.PIG_SOUND_VARIANT);
18
19
	private static Codec<PigSoundVariant> codec() {
20
		return RecordCodecBuilder.create(
21
			i -> i.group(
22
					PigSoundVariant.PigSoundSet.CODEC.fieldOf("adult_sounds").forGetter(PigSoundVariant::adultSounds),
23
					PigSoundVariant.PigSoundSet.CODEC.fieldOf("baby_sounds").forGetter(PigSoundVariant::babySounds)
24
				)
25
				.apply(i, PigSoundVariant::new)
26
		);
27
	}
28
29
	public record PigSoundSet(
30
		Holder<SoundEvent> ambientSound, Holder<SoundEvent> hurtSound, Holder<SoundEvent> deathSound, Holder<SoundEvent> stepSound, Holder<SoundEvent> eatSound
31
	) {
32
		public static final Codec<PigSoundVariant.PigSoundSet> CODEC = RecordCodecBuilder.create(
33
			i -> i.group(
34
					SoundEvent.CODEC.fieldOf("ambient_sound").forGetter(PigSoundVariant.PigSoundSet::ambientSound),
35
					SoundEvent.CODEC.fieldOf("hurt_sound").forGetter(PigSoundVariant.PigSoundSet::hurtSound),
36
					SoundEvent.CODEC.fieldOf("death_sound").forGetter(PigSoundVariant.PigSoundSet::deathSound),
37
					SoundEvent.CODEC.fieldOf("step_sound").forGetter(PigSoundVariant.PigSoundSet::stepSound),
38
					SoundEvent.CODEC.fieldOf("eat_sound").forGetter(PigSoundVariant.PigSoundSet::eatSound)
39
				)
40
				.apply(i, PigSoundVariant.PigSoundSet::new)
41
		);
42
	}
43
}
44

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