PlayerCloudParticle .java

net.minecraft.client.particle.PlayerCloudParticle (class): members: SneezeProvider, getQuadSize, za, sprites, getLayer, Provider, tick. imports: Player.

net.minecraft.client.particleclass115 linesclientextends SingleQuadParticle3.1 KB

API Surface (5)

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

PlayerCloudParticle.java115 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.Mth;
8
import net.minecraft.util.RandomSource;
9
import net.minecraft.world.entity.player.Player;
10
11
@Environment(EnvType.CLIENT)
12
public class PlayerCloudParticle extends SingleQuadParticle {
13
	private final SpriteSet sprites;
14
15
	private PlayerCloudParticle(
16
		final ClientLevel level, final double x, final double y, final double z, final double xa, final double ya, final double za, final SpriteSet sprites
17
	) {
18
		super(level, x, y, z, 0.0, 0.0, 0.0, sprites.first());
19
		this.friction = 0.96F;
20
		this.sprites = sprites;
21
		float scale = 2.5F;
22
		this.xd *= 0.1F;
23
		this.yd *= 0.1F;
24
		this.zd *= 0.1F;
25
		this.xd += xa;
26
		this.yd += ya;
27
		this.zd += za;
28
		float col = 1.0F - this.random.nextFloat() * 0.3F;
29
		this.rCol = col;
30
		this.gCol = col;
31
		this.bCol = col;
32
		this.quadSize *= 1.875F;
33
		int baseLifetime = (int)(8.0 / (this.random.nextFloat() * 0.8 + 0.3));
34
		this.lifetime = (int)Math.max(baseLifetime * 2.5F, 1.0F);
35
		this.hasPhysics = false;
36
		this.setSpriteFromAge(sprites);
37
	}
38
39
	@Override
40
	public SingleQuadParticle.Layer getLayer() {
41
		return SingleQuadParticle.Layer.TRANSLUCENT;
42
	}
43
44
	@Override
45
	public float getQuadSize(final float a) {
46
		return this.quadSize * Mth.clamp((this.age + a) / this.lifetime * 32.0F, 0.0F, 1.0F);
47
	}
48
49
	@Override
50
	public void tick() {
51
		super.tick();
52
		if (!this.removed) {
53
			this.setSpriteFromAge(this.sprites);
54
			Player player = this.level.getNearestPlayer(this.x, this.y, this.z, 2.0, false);
55
			if (player != null) {
56
				double playerY = player.getY();
57
				if (this.y > playerY) {
58
					this.y = this.y + (playerY - this.y) * 0.2;
59
					this.yd = this.yd + (player.getDeltaMovement().y - this.yd) * 0.2;
60
					this.setPos(this.x, this.y, this.z);
61
				}
62
			}
63
		}
64
	}
65
66
	@Environment(EnvType.CLIENT)
67
	public static class Provider implements ParticleProvider<SimpleParticleType> {
68
		private final SpriteSet sprites;
69
70
		public Provider(final SpriteSet sprites) {
71
			this.sprites = sprites;
72
		}
73
74
		public Particle createParticle(
75
			final SimpleParticleType options,
76
			final ClientLevel level,
77
			final double x,
78
			final double y,
79
			final double z,
80
			final double xAux,
81
			final double yAux,
82
			final double zAux,
83
			final RandomSource random
84
		) {
85
			return new PlayerCloudParticle(level, x, y, z, xAux, yAux, zAux, this.sprites);
86
		}
87
	}
88
89
	@Environment(EnvType.CLIENT)
90
	public static class SneezeProvider implements ParticleProvider<SimpleParticleType> {
91
		private final SpriteSet sprites;
92
93
		public SneezeProvider(final SpriteSet sprites) {
94
			this.sprites = sprites;
95
		}
96
97
		public Particle createParticle(
98
			final SimpleParticleType options,
99
			final ClientLevel level,
100
			final double x,
101
			final double y,
102
			final double z,
103
			final double xAux,
104
			final double yAux,
105
			final double zAux,
106
			final RandomSource random
107
		) {
108
			PlayerCloudParticle particle = new PlayerCloudParticle(level, x, y, z, xAux, yAux, zAux, this.sprites);
109
			particle.setColor(0.22F, 1.0F, 0.53F);
110
			particle.setAlpha(0.4F);
111
			return particle;
112
		}
113
	}
114
}
115

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