BubbleParticle .java

net.minecraft.client.particle.BubbleParticle (class): members: za, getLayer, Provider, tick. imports: TextureAtlasSprite, SimpleParticleType, FluidTags.

net.minecraft.client.particleclass73 linesclientextends SingleQuadParticle2.1 KB

API Surface (3)

void tick()
SingleQuadParticle.Layer getLayer()
Particle createParticle(final SimpleParticleType options, final ClientLevel level, final double x, final double y, final double z, final double xAux, final double yAux, final double zAux, final RandomSource random)

Fields & Constants (1)

za

Full Source

BubbleParticle.java73 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.client.particle;
2
3
import net.fabricmc.api.EnvType;
4
import net.fabricmc.api.Environment;
5
import net.minecraft.client.multiplayer.ClientLevel;
6
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
7
import net.minecraft.core.BlockPos;
8
import net.minecraft.core.particles.SimpleParticleType;
9
import net.minecraft.tags.FluidTags;
10
import net.minecraft.util.RandomSource;
11
12
@Environment(EnvType.CLIENT)
13
public class BubbleParticle extends SingleQuadParticle {
14
	private BubbleParticle(
15
		final ClientLevel level, final double x, final double y, final double z, final double xa, final double ya, final double za, final TextureAtlasSprite sprite
16
	) {
17
		super(level, x, y, z, sprite);
18
		this.setSize(0.02F, 0.02F);
19
		this.quadSize = this.quadSize * (this.random.nextFloat() * 0.6F + 0.2F);
20
		this.xd = xa * 0.2F + (this.random.nextFloat() * 2.0F - 1.0F) * 0.02F;
21
		this.yd = ya * 0.2F + (this.random.nextFloat() * 2.0F - 1.0F) * 0.02F;
22
		this.zd = za * 0.2F + (this.random.nextFloat() * 2.0F - 1.0F) * 0.02F;
23
		this.lifetime = (int)(8.0 / (this.random.nextFloat() * 0.8 + 0.2));
24
	}
25
26
	@Override
27
	public void tick() {
28
		this.xo = this.x;
29
		this.yo = this.y;
30
		this.zo = this.z;
31
		if (this.lifetime-- <= 0) {
32
			this.remove();
33
		} else {
34
			this.yd += 0.002;
35
			this.move(this.xd, this.yd, this.zd);
36
			this.xd *= 0.85F;
37
			this.yd *= 0.85F;
38
			this.zd *= 0.85F;
39
			if (!this.level.getFluidState(BlockPos.containing(this.x, this.y, this.z)).is(FluidTags.WATER)) {
40
				this.remove();
41
			}
42
		}
43
	}
44
45
	@Override
46
	public SingleQuadParticle.Layer getLayer() {
47
		return SingleQuadParticle.Layer.OPAQUE;
48
	}
49
50
	@Environment(EnvType.CLIENT)
51
	public static class Provider implements ParticleProvider<SimpleParticleType> {
52
		private final SpriteSet sprite;
53
54
		public Provider(final SpriteSet sprite) {
55
			this.sprite = sprite;
56
		}
57
58
		public Particle createParticle(
59
			final SimpleParticleType options,
60
			final ClientLevel level,
61
			final double x,
62
			final double y,
63
			final double z,
64
			final double xAux,
65
			final double yAux,
66
			final double zAux,
67
			final RandomSource random
68
		) {
69
			return new BubbleParticle(level, x, y, z, xAux, yAux, zAux, this.sprite.get(random));
70
		}
71
	}
72
}
73

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