WaterCurrentDownParticle .java

net.minecraft.client.particle.WaterCurrentDownParticle (class, 79 lines): members: angle, getLayer, Provider, tick. imports: TextureAtlasSprite, FluidTags.

net.minecraft.client.particleclass79 linesclientextends SingleQuadParticle2.2 KB

API Surface (3)

SingleQuadParticle.Layer getLayer()
void tick()
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)

angle

Full Source

WaterCurrentDownParticle.java79 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.Mth;
11
import net.minecraft.util.RandomSource;
12
13
@Environment(EnvType.CLIENT)
14
public class WaterCurrentDownParticle extends SingleQuadParticle {
15
	private float angle;
16
17
	private WaterCurrentDownParticle(final ClientLevel level, final double x, final double y, final double z, final TextureAtlasSprite sprite) {
18
		super(level, x, y, z, sprite);
19
		this.lifetime = (int)(this.random.nextFloat() * 60.0F) + 30;
20
		this.hasPhysics = false;
21
		this.xd = 0.0;
22
		this.yd = -0.05;
23
		this.zd = 0.0;
24
		this.setSize(0.02F, 0.02F);
25
		this.quadSize = this.quadSize * (this.random.nextFloat() * 0.6F + 0.2F);
26
		this.gravity = 0.002F;
27
	}
28
29
	@Override
30
	public SingleQuadParticle.Layer getLayer() {
31
		return SingleQuadParticle.Layer.OPAQUE;
32
	}
33
34
	@Override
35
	public void tick() {
36
		this.xo = this.x;
37
		this.yo = this.y;
38
		this.zo = this.z;
39
		if (this.age++ >= this.lifetime) {
40
			this.remove();
41
		} else {
42
			float radius = 0.6F;
43
			this.xd = this.xd + 0.6F * Mth.cos(this.angle);
44
			this.zd = this.zd + 0.6F * Mth.sin(this.angle);
45
			this.xd *= 0.07;
46
			this.zd *= 0.07;
47
			this.move(this.xd, this.yd, this.zd);
48
			if (!this.level.getFluidState(BlockPos.containing(this.x, this.y, this.z)).is(FluidTags.WATER) || this.onGround) {
49
				this.remove();
50
			}
51
52
			this.angle += 0.08F;
53
		}
54
	}
55
56
	@Environment(EnvType.CLIENT)
57
	public static class Provider implements ParticleProvider<SimpleParticleType> {
58
		private final SpriteSet sprite;
59
60
		public Provider(final SpriteSet sprite) {
61
			this.sprite = sprite;
62
		}
63
64
		public Particle createParticle(
65
			final SimpleParticleType options,
66
			final ClientLevel level,
67
			final double x,
68
			final double y,
69
			final double z,
70
			final double xAux,
71
			final double yAux,
72
			final double zAux,
73
			final RandomSource random
74
		) {
75
			return new WaterCurrentDownParticle(level, x, y, z, this.sprite.get(random));
76
		}
77
	}
78
}
79

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