DirectionalSoundInstance .java

net.minecraft.client.resources.sounds.DirectionalSoundInstance (class): members: xAngle, yAngle, camera, tick. imports: Camera, SoundSource, SoundEvent.

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

API Surface (1)

void tick()

Fields & Constants (3)

camera
xAngle
yAngle

Code Graph: Dependencies (6)

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

Full Source

DirectionalSoundInstance.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.client.Camera;
6
import net.minecraft.sounds.SoundEvent;
7
import net.minecraft.sounds.SoundSource;
8
import net.minecraft.util.RandomSource;
9
import net.minecraft.world.phys.Vec3;
10
11
@Environment(EnvType.CLIENT)
12
public class DirectionalSoundInstance extends AbstractTickableSoundInstance {
13
	private final Camera camera;
14
	private final float xAngle;
15
	private final float yAngle;
16
17
	public DirectionalSoundInstance(
18
		final SoundEvent event, final SoundSource source, final RandomSource random, final Camera camera, final float xAngle, final float yAngle
19
	) {
20
		super(event, source, random);
21
		this.camera = camera;
22
		this.xAngle = xAngle;
23
		this.yAngle = yAngle;
24
		this.setPosition();
25
	}
26
27
	private void setPosition() {
28
		Vec3 direction = Vec3.directionFromRotation(this.xAngle, this.yAngle).scale(10.0);
29
		this.x = this.camera.position().x + direction.x;
30
		this.y = this.camera.position().y + direction.y;
31
		this.z = this.camera.position().z + direction.z;
32
		this.attenuation = SoundInstance.Attenuation.NONE;
33
	}
34
35
	@Override
36
	public void tick() {
37
		this.setPosition();
38
	}
39
}
40

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