SnowflakeParticle .java

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

net.minecraft.client.particleclass67 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

SnowflakeParticle.java67 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 SnowflakeParticle extends SingleQuadParticle {
11
	private final SpriteSet sprites;
12
13
	protected SnowflakeParticle(
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, sprites.first());
17
		this.gravity = 0.225F;
18
		this.friction = 1.0F;
19
		this.sprites = sprites;
20
		this.xd = xa + (this.random.nextFloat() * 2.0F - 1.0F) * 0.05F;
21
		this.yd = ya + (this.random.nextFloat() * 2.0F - 1.0F) * 0.05F;
22
		this.zd = za + (this.random.nextFloat() * 2.0F - 1.0F) * 0.05F;
23
		this.quadSize = 0.1F * (this.random.nextFloat() * this.random.nextFloat() * 1.0F + 1.0F);
24
		this.lifetime = (int)(16.0 / (this.random.nextFloat() * 0.8 + 0.2)) + 2;
25
		this.setSpriteFromAge(sprites);
26
	}
27
28
	@Override
29
	public SingleQuadParticle.Layer getLayer() {
30
		return SingleQuadParticle.Layer.OPAQUE;
31
	}
32
33
	@Override
34
	public void tick() {
35
		super.tick();
36
		this.setSpriteFromAge(this.sprites);
37
		this.xd *= 0.95F;
38
		this.yd *= 0.9F;
39
		this.zd *= 0.95F;
40
	}
41
42
	@Environment(EnvType.CLIENT)
43
	public static class Provider implements ParticleProvider<SimpleParticleType> {
44
		private final SpriteSet sprites;
45
46
		public Provider(final SpriteSet sprites) {
47
			this.sprites = sprites;
48
		}
49
50
		public Particle createParticle(
51
			final SimpleParticleType options,
52
			final ClientLevel level,
53
			final double x,
54
			final double y,
55
			final double z,
56
			final double xAux,
57
			final double yAux,
58
			final double zAux,
59
			final RandomSource random
60
		) {
61
			SnowflakeParticle snowflakeParticle = new SnowflakeParticle(level, x, y, z, xAux, yAux, zAux, this.sprites);
62
			snowflakeParticle.setColor(0.923F, 0.964F, 0.999F);
63
			return snowflakeParticle;
64
		}
65
	}
66
}
67

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