WakeParticle .java

net.minecraft.client.particle.WakeParticle (class): members: za, sprites, getLayer, Provider, tick. imports: SimpleParticleType, ClientLevel, RandomSource.

net.minecraft.client.particleclass78 linesclientextends SingleQuadParticle2.0 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 (2)

sprites
za

Full Source

WakeParticle.java78 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.core.particles.SimpleParticleType;
7
import net.minecraft.util.RandomSource;
8
9
@Environment(EnvType.CLIENT)
10
public class WakeParticle extends SingleQuadParticle {
11
	private final SpriteSet sprites;
12
13
	private WakeParticle(
14
		final ClientLevel level, final double x, final double y, final double z, final double xa, final double ya, final double za, final SpriteSet sprites
15
	) {
16
		super(level, x, y, z, 0.0, 0.0, 0.0, sprites.first());
17
		this.sprites = sprites;
18
		this.xd *= 0.3F;
19
		this.yd = this.random.nextFloat() * 0.2F + 0.1F;
20
		this.zd *= 0.3F;
21
		this.setSize(0.01F, 0.01F);
22
		this.lifetime = (int)(8.0 / (this.random.nextFloat() * 0.8 + 0.2));
23
		this.setSpriteFromAge(sprites);
24
		this.gravity = 0.0F;
25
		this.xd = xa;
26
		this.yd = ya;
27
		this.zd = za;
28
	}
29
30
	@Override
31
	public SingleQuadParticle.Layer getLayer() {
32
		return SingleQuadParticle.Layer.OPAQUE;
33
	}
34
35
	@Override
36
	public void tick() {
37
		this.xo = this.x;
38
		this.yo = this.y;
39
		this.zo = this.z;
40
		int life = 60 - this.lifetime;
41
		if (this.lifetime-- <= 0) {
42
			this.remove();
43
		} else {
44
			this.yd = this.yd - this.gravity;
45
			this.move(this.xd, this.yd, this.zd);
46
			this.xd *= 0.98F;
47
			this.yd *= 0.98F;
48
			this.zd *= 0.98F;
49
			float size = life * 0.001F;
50
			this.setSize(size, size);
51
			this.setSprite(this.sprites.get(life % 4, 4));
52
		}
53
	}
54
55
	@Environment(EnvType.CLIENT)
56
	public static class Provider implements ParticleProvider<SimpleParticleType> {
57
		private final SpriteSet sprites;
58
59
		public Provider(final SpriteSet sprites) {
60
			this.sprites = sprites;
61
		}
62
63
		public Particle createParticle(
64
			final SimpleParticleType options,
65
			final ClientLevel level,
66
			final double x,
67
			final double y,
68
			final double z,
69
			final double xAux,
70
			final double yAux,
71
			final double zAux,
72
			final RandomSource random
73
		) {
74
			return new WakeParticle(level, x, y, z, xAux, yAux, zAux, this.sprites);
75
		}
76
	}
77
}
78

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