EntityBoundSoundInstance .java

net.minecraft.client.resources.sounds.EntityBoundSoundInstance (class, 40 lines): members: canPlaySound, entity, tick. imports: SoundSource.

net.minecraft.client.resources.soundsclass40 linesclientextends AbstractTickableSoundInstance1.1 KB

API Surface (2)

boolean canPlaySound()
void tick()

Fields & Constants (1)

entity

Code Graph: Dependencies (5)

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

Full Source

EntityBoundSoundInstance.java40 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.client.resources.sounds;
2
3
import net.fabricmc.api.EnvType;
4
import net.fabricmc.api.Environment;
5
import net.minecraft.sounds.SoundEvent;
6
import net.minecraft.sounds.SoundSource;
7
import net.minecraft.util.RandomSource;
8
import net.minecraft.world.entity.Entity;
9
10
@Environment(EnvType.CLIENT)
11
public class EntityBoundSoundInstance extends AbstractTickableSoundInstance {
12
	private final Entity entity;
13
14
	public EntityBoundSoundInstance(final SoundEvent event, final SoundSource source, final float volume, final float pitch, final Entity entity, final long seed) {
15
		super(event, source, RandomSource.create(seed));
16
		this.volume = volume;
17
		this.pitch = pitch;
18
		this.entity = entity;
19
		this.x = (float)this.entity.getX();
20
		this.y = (float)this.entity.getY();
21
		this.z = (float)this.entity.getZ();
22
	}
23
24
	@Override
25
	public boolean canPlaySound() {
26
		return !this.entity.isSilent();
27
	}
28
29
	@Override
30
	public void tick() {
31
		if (this.entity.isRemoved()) {
32
			this.stop();
33
		} else {
34
			this.x = (float)this.entity.getX();
35
			this.y = (float)this.entity.getY();
36
			this.z = (float)this.entity.getZ();
37
		}
38
	}
39
}
40

Decompiled Minecraft 26.3 source of EntityBoundSoundInstance (net/minecraft/client/resources/sounds/EntityBoundSoundInstance.java) with Mojang official mappings, stored verbatim on the site.