GuardianAttackSoundInstance .java

net.minecraft.client.resources.sounds.GuardianAttackSoundInstance (class): members: VOLUME_SCALE, PITCH_SCALE, guardian, VOLUME_MIN, PITCH_MIN, tick.

net.minecraft.client.resources.soundsclass44 linesclientextends AbstractTickableSoundInstance1.3 KB

API Surface (2)

boolean canPlaySound()
void tick()

Fields & Constants (5)

VOLUME_MIN
VOLUME_SCALE
PITCH_MIN
PITCH_SCALE
guardian

Code Graph: Dependencies (5)

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

Full Source

GuardianAttackSoundInstance.java44 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.SoundEvents;
6
import net.minecraft.sounds.SoundSource;
7
import net.minecraft.world.entity.monster.Guardian;
8
9
@Environment(EnvType.CLIENT)
10
public class GuardianAttackSoundInstance extends AbstractTickableSoundInstance {
11
	private static final float VOLUME_MIN = 0.0F;
12
	private static final float VOLUME_SCALE = 1.0F;
13
	private static final float PITCH_MIN = 0.7F;
14
	private static final float PITCH_SCALE = 0.5F;
15
	private final Guardian guardian;
16
17
	public GuardianAttackSoundInstance(final Guardian guardian) {
18
		super(SoundEvents.GUARDIAN_ATTACK, SoundSource.HOSTILE, SoundInstance.createUnseededRandom());
19
		this.guardian = guardian;
20
		this.attenuation = SoundInstance.Attenuation.NONE;
21
		this.looping = true;
22
		this.delay = 0;
23
	}
24
25
	@Override
26
	public boolean canPlaySound() {
27
		return !this.guardian.isSilent();
28
	}
29
30
	@Override
31
	public void tick() {
32
		if (!this.guardian.isRemoved() && this.guardian.getTarget() == null) {
33
			this.x = (float)this.guardian.getX();
34
			this.y = (float)this.guardian.getY();
35
			this.z = (float)this.guardian.getZ();
36
			float scale = this.guardian.getAttackAnimationScale(0.0F);
37
			this.volume = 0.0F + 1.0F * scale * scale;
38
			this.pitch = 0.7F + 0.5F * scale;
39
		} else {
40
			this.stop();
41
		}
42
	}
43
}
44

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