NoteParticle .java

net.minecraft.client.particle.NoteParticle (class): members: getQuadSize, getLayer, Provider. imports: TextureAtlasSprite, SimpleParticleType, ClientLevel.

net.minecraft.client.particleclass61 linesclientextends SingleQuadParticle1.9 KB

API Surface (3)

SingleQuadParticle.Layer getLayer()
float getQuadSize(final float a)
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

NoteParticle.java61 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.particles.SimpleParticleType;
8
import net.minecraft.util.Mth;
9
import net.minecraft.util.RandomSource;
10
11
@Environment(EnvType.CLIENT)
12
public class NoteParticle extends SingleQuadParticle {
13
	private NoteParticle(final ClientLevel level, final double x, final double y, final double z, final double color, final TextureAtlasSprite sprite) {
14
		super(level, x, y, z, 0.0, 0.0, 0.0, sprite);
15
		this.friction = 0.66F;
16
		this.speedUpWhenYMotionIsBlocked = true;
17
		this.xd *= 0.01F;
18
		this.yd *= 0.01F;
19
		this.zd *= 0.01F;
20
		this.yd += 0.2;
21
		this.rCol = Math.max(0.0F, Mth.sin(((float)color + 0.0F) * (float) (Math.PI * 2)) * 0.65F + 0.35F);
22
		this.gCol = Math.max(0.0F, Mth.sin(((float)color + 0.33333334F) * (float) (Math.PI * 2)) * 0.65F + 0.35F);
23
		this.bCol = Math.max(0.0F, Mth.sin(((float)color + 0.6666667F) * (float) (Math.PI * 2)) * 0.65F + 0.35F);
24
		this.quadSize *= 1.5F;
25
		this.lifetime = 6;
26
	}
27
28
	@Override
29
	public SingleQuadParticle.Layer getLayer() {
30
		return SingleQuadParticle.Layer.OPAQUE;
31
	}
32
33
	@Override
34
	public float getQuadSize(final float a) {
35
		return this.quadSize * Mth.clamp((this.age + a) / this.lifetime * 32.0F, 0.0F, 1.0F);
36
	}
37
38
	@Environment(EnvType.CLIENT)
39
	public static class Provider implements ParticleProvider<SimpleParticleType> {
40
		private final SpriteSet sprite;
41
42
		public Provider(final SpriteSet sprite) {
43
			this.sprite = sprite;
44
		}
45
46
		public Particle createParticle(
47
			final SimpleParticleType options,
48
			final ClientLevel level,
49
			final double x,
50
			final double y,
51
			final double z,
52
			final double xAux,
53
			final double yAux,
54
			final double zAux,
55
			final RandomSource random
56
		) {
57
			return new NoteParticle(level, x, y, z, xAux, this.sprite.get(random));
58
		}
59
	}
60
}
61

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