SimpleAnimatedParticle .java

net.minecraft.client.particle.SimpleAnimatedParticle (class): members: setFadeColor, hasFade, fadeB, fadeG, fadeR, setColor, getLightCoords, sprites, tick.

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

API Surface (5)

void setColor(final int rgb)
void setFadeColor(final int rgb)
SingleQuadParticle.Layer getLayer()
void tick()
int getLightCoords(final float a)

Fields & Constants (5)

sprites
fadeR
fadeG
fadeB
hasFade

Code Graph: Dependencies (3)

Edges (calls / imports / inherits / references) resolved by graphify from the AST. Every chip opens the class source.

Full Source

SimpleAnimatedParticle.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
7
@Environment(EnvType.CLIENT)
8
public abstract class SimpleAnimatedParticle extends SingleQuadParticle {
9
	protected final SpriteSet sprites;
10
	private float fadeR;
11
	private float fadeG;
12
	private float fadeB;
13
	private boolean hasFade;
14
15
	protected SimpleAnimatedParticle(final ClientLevel level, final double x, final double y, final double z, final SpriteSet sprites, final float gravity) {
16
		super(level, x, y, z, sprites.first());
17
		this.friction = 0.91F;
18
		this.gravity = gravity;
19
		this.sprites = sprites;
20
	}
21
22
	public void setColor(final int rgb) {
23
		float r = ((rgb & 0xFF0000) >> 16) / 255.0F;
24
		float g = ((rgb & 0xFF00) >> 8) / 255.0F;
25
		float b = ((rgb & 0xFF) >> 0) / 255.0F;
26
		float scale = 1.0F;
27
		this.setColor(r * 1.0F, g * 1.0F, b * 1.0F);
28
	}
29
30
	public void setFadeColor(final int rgb) {
31
		this.fadeR = ((rgb & 0xFF0000) >> 16) / 255.0F;
32
		this.fadeG = ((rgb & 0xFF00) >> 8) / 255.0F;
33
		this.fadeB = ((rgb & 0xFF) >> 0) / 255.0F;
34
		this.hasFade = true;
35
	}
36
37
	@Override
38
	public SingleQuadParticle.Layer getLayer() {
39
		return SingleQuadParticle.Layer.TRANSLUCENT;
40
	}
41
42
	@Override
43
	public void tick() {
44
		super.tick();
45
		this.setSpriteFromAge(this.sprites);
46
		if (this.age > this.lifetime / 2) {
47
			this.setAlpha(1.0F - ((float)this.age - this.lifetime / 2) / this.lifetime);
48
			if (this.hasFade) {
49
				this.rCol = this.rCol + (this.fadeR - this.rCol) * 0.2F;
50
				this.gCol = this.gCol + (this.fadeG - this.gCol) * 0.2F;
51
				this.bCol = this.bCol + (this.fadeB - this.bCol) * 0.2F;
52
			}
53
		}
54
	}
55
56
	@Override
57
	public int getLightCoords(final float a) {
58
		return 15728880;
59
	}
60
}
61

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