BubbleColumnAmbientSoundHandler .java

net.minecraft.client.resources.sounds.BubbleColumnAmbientSoundHandler (class): members: wasInBubbleColumn, firstTick, player, tick. imports: LocalPlayer.

net.minecraft.client.resources.soundsclass47 linesclient1.5 KB

Implements

API Surface (1)

void tick()

Fields & Constants (3)

player
wasInBubbleColumn
firstTick

Code Graph: Dependencies (7)

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

Full Source

BubbleColumnAmbientSoundHandler.java47 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.player.LocalPlayer;
6
import net.minecraft.sounds.SoundEvents;
7
import net.minecraft.world.level.Level;
8
import net.minecraft.world.level.block.Blocks;
9
import net.minecraft.world.level.block.BubbleColumnBlock;
10
import net.minecraft.world.level.block.state.BlockState;
11
12
@Environment(EnvType.CLIENT)
13
public class BubbleColumnAmbientSoundHandler implements AmbientSoundHandler {
14
	private final LocalPlayer player;
15
	private boolean wasInBubbleColumn;
16
	private boolean firstTick = true;
17
18
	public BubbleColumnAmbientSoundHandler(final LocalPlayer player) {
19
		this.player = player;
20
	}
21
22
	@Override
23
	public void tick() {
24
		Level level = this.player.level();
25
		BlockState state = level.getBlockStatesIfLoaded(this.player.getBoundingBox().inflate(0.0, -0.4F, 0.0).deflate(1.0E-6))
26
			.filter(s -> s.is(Blocks.BUBBLE_COLUMN))
27
			.findFirst()
28
			.orElse(null);
29
		if (state != null) {
30
			if (!this.wasInBubbleColumn && !this.firstTick && state.is(Blocks.BUBBLE_COLUMN) && !this.player.isSpectator()) {
31
				boolean dragDown = state.getValue(BubbleColumnBlock.DRAG_DOWN);
32
				if (dragDown) {
33
					this.player.playSound(SoundEvents.BUBBLE_COLUMN_WHIRLPOOL_INSIDE, 1.0F, 1.0F);
34
				} else {
35
					this.player.playSound(SoundEvents.BUBBLE_COLUMN_UPWARDS_INSIDE, 1.0F, 1.0F);
36
				}
37
			}
38
39
			this.wasInBubbleColumn = true;
40
		} else {
41
			this.wasInBubbleColumn = false;
42
		}
43
44
		this.firstTick = false;
45
	}
46
}
47

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