WaterDropParticle .java

net.minecraft.client.particle.WaterDropParticle (class): members: getLayer, Provider, tick. imports: TextureAtlasSprite, SimpleParticleType, Axis.

net.minecraft.client.particleclass85 linesclientextends SingleQuadParticle2.3 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)

Full Source

WaterDropParticle.java85 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.Direction.Axis;
9
import net.minecraft.core.particles.SimpleParticleType;
10
import net.minecraft.util.RandomSource;
11
12
@Environment(EnvType.CLIENT)
13
public class WaterDropParticle extends SingleQuadParticle {
14
	protected WaterDropParticle(final ClientLevel level, final double x, final double y, final double z, final TextureAtlasSprite sprite) {
15
		super(level, x, y, z, 0.0, 0.0, 0.0, sprite);
16
		this.xd *= 0.3F;
17
		this.yd = this.random.nextFloat() * 0.2F + 0.1F;
18
		this.zd *= 0.3F;
19
		this.setSize(0.01F, 0.01F);
20
		this.gravity = 0.06F;
21
		this.lifetime = (int)(8.0 / (this.random.nextFloat() * 0.8 + 0.2));
22
	}
23
24
	@Override
25
	public SingleQuadParticle.Layer getLayer() {
26
		return SingleQuadParticle.Layer.OPAQUE;
27
	}
28
29
	@Override
30
	public void tick() {
31
		this.xo = this.x;
32
		this.yo = this.y;
33
		this.zo = this.z;
34
		if (this.lifetime-- <= 0) {
35
			this.remove();
36
		} else {
37
			this.yd = this.yd - this.gravity;
38
			this.move(this.xd, this.yd, this.zd);
39
			this.xd *= 0.98F;
40
			this.yd *= 0.98F;
41
			this.zd *= 0.98F;
42
			if (this.onGround) {
43
				if (this.random.nextFloat() < 0.5F) {
44
					this.remove();
45
				}
46
47
				this.xd *= 0.7F;
48
				this.zd *= 0.7F;
49
			}
50
51
			BlockPos pos = BlockPos.containing(this.x, this.y, this.z);
52
			double offset = Math.max(
53
				this.level.getBlockState(pos).getCollisionShape(this.level, pos).max(Axis.Y, this.x - pos.getX(), this.z - pos.getZ()),
54
				this.level.getFluidState(pos).getHeight(this.level, pos)
55
			);
56
			if (offset > 0.0 && this.y < pos.getY() + offset) {
57
				this.remove();
58
			}
59
		}
60
	}
61
62
	@Environment(EnvType.CLIENT)
63
	public static class Provider implements ParticleProvider<SimpleParticleType> {
64
		private final SpriteSet sprite;
65
66
		public Provider(final SpriteSet sprite) {
67
			this.sprite = sprite;
68
		}
69
70
		public Particle createParticle(
71
			final SimpleParticleType options,
72
			final ClientLevel level,
73
			final double x,
74
			final double y,
75
			final double z,
76
			final double xAux,
77
			final double yAux,
78
			final double zAux,
79
			final RandomSource random
80
		) {
81
			return new WaterDropParticle(level, x, y, z, this.sprite.get(random));
82
		}
83
	}
84
}
85

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