TrackingEmitter .java

net.minecraft.client.particle.TrackingEmitter (class): members: lifeTime, particleType, life, entity, tick. imports: ParticleOptions, ClientLevel, Entity.

net.minecraft.client.particleclass53 linesclientextends NoRenderParticle1.8 KB

API Surface (1)

void tick()

Fields & Constants (4)

entity
life
lifeTime
particleType

Code Graph: Dependencies (6)

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

Full Source

TrackingEmitter.java53 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.ParticleOptions;
7
import net.minecraft.world.entity.Entity;
8
import net.minecraft.world.phys.Vec3;
9
10
@Environment(EnvType.CLIENT)
11
public class TrackingEmitter extends NoRenderParticle {
12
	private final Entity entity;
13
	private int life;
14
	private final int lifeTime;
15
	private final ParticleOptions particleType;
16
17
	public TrackingEmitter(final ClientLevel level, final Entity entity, final ParticleOptions particleType) {
18
		this(level, entity, particleType, 3);
19
	}
20
21
	public TrackingEmitter(final ClientLevel level, final Entity entity, final ParticleOptions particleType, final int lifeTime) {
22
		this(level, entity, particleType, lifeTime, entity.getDeltaMovement());
23
	}
24
25
	private TrackingEmitter(final ClientLevel level, final Entity entity, final ParticleOptions particleType, final int lifeTime, final Vec3 movement) {
26
		super(level, entity.getX(), entity.getY(0.5), entity.getZ(), movement.x, movement.y, movement.z);
27
		this.entity = entity;
28
		this.lifeTime = lifeTime;
29
		this.particleType = particleType;
30
		this.tick();
31
	}
32
33
	@Override
34
	public void tick() {
35
		for (int i = 0; i < 16; i++) {
36
			double xa = this.random.nextFloat() * 2.0F - 1.0F;
37
			double ya = this.random.nextFloat() * 2.0F - 1.0F;
38
			double za = this.random.nextFloat() * 2.0F - 1.0F;
39
			if (!(xa * xa + ya * ya + za * za > 1.0)) {
40
				double x = this.entity.getX(xa / 4.0);
41
				double y = this.entity.getY(0.5 + ya / 4.0);
42
				double z = this.entity.getZ(za / 4.0);
43
				this.level.addParticle(this.particleType, x, y, z, xa, ya + 0.2, za);
44
			}
45
		}
46
47
		this.life++;
48
		if (this.life >= this.lifeTime) {
49
			this.remove();
50
		}
51
	}
52
}
53

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