CowSoundVariant .java

net.minecraft.world.entity.animal.cow.CowSoundVariant (record, 31 lines): members: ambientSound, hurtSound, deathSound, stepSound, NETWORK_CODEC, codec.

net.minecraft.world.entity.animal.cowrecord31 linescommon1.5 KB

API Surface (1)

record CowSoundVariant(Holder<SoundEvent> ambientSound, Holder<SoundEvent> hurtSound, Holder<SoundEvent> deathSound, Holder<SoundEvent> stepSound)

Fields & Constants (4)

DIRECT_CODEC
NETWORK_CODEC
CODEC
STREAM_CODEC

String literals (4)

"ambient_sound"
"hurt_sound"
"death_sound"
"step_sound"

Code Graph: Dependencies (7)

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

Full Source

CowSoundVariant.java31 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.world.entity.animal.cow;
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 CowSoundVariant(Holder<SoundEvent> ambientSound, Holder<SoundEvent> hurtSound, Holder<SoundEvent> deathSound, Holder<SoundEvent> stepSound) {
14
	public static final Codec<CowSoundVariant> DIRECT_CODEC = codec();
15
	public static final Codec<CowSoundVariant> NETWORK_CODEC = codec();
16
	public static final Codec<Holder<CowSoundVariant>> CODEC = RegistryCodecs.holder(Registries.COW_SOUND_VARIANT);
17
	public static final StreamCodec<RegistryFriendlyByteBuf, Holder<CowSoundVariant>> STREAM_CODEC = ByteBufCodecs.holderRegistry(Registries.COW_SOUND_VARIANT);
18
19
	private static Codec<CowSoundVariant> codec() {
20
		return RecordCodecBuilder.create(
21
			i -> i.group(
22
					SoundEvent.CODEC.fieldOf("ambient_sound").forGetter(CowSoundVariant::ambientSound),
23
					SoundEvent.CODEC.fieldOf("hurt_sound").forGetter(CowSoundVariant::hurtSound),
24
					SoundEvent.CODEC.fieldOf("death_sound").forGetter(CowSoundVariant::deathSound),
25
					SoundEvent.CODEC.fieldOf("step_sound").forGetter(CowSoundVariant::stepSound)
26
				)
27
				.apply(i, CowSoundVariant::new)
28
		);
29
	}
30
}
31

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