GeyserPlumeParticle .java

net.minecraft.client.particle.GeyserPlumeParticle (class, 113 lines): members: REMAINING_FRAMES_AFTER_REACHING_MAX_HEIGHT, INITIAL_PROPULSION_FACTOR, done.

net.minecraft.client.particleclass113 linesclientextends SingleQuadParticle3.9 KB

API Surface (2)

void tick()
SingleQuadParticle.Layer getLayer()

Fields & Constants (27)

NO_FRICTION
MAX_FRICTION
INITIAL_PROPULSION_FACTOR
GRAVITY_EXPONENT
GRADUAL_GRAVITY_FACTOR
INITIAL_SPRAY_SPREAD
LINEAR_SPRAY_SPREAD
REMAINING_FRAMES_AFTER_REACHING_MAX_HEIGHT
MIN_SCALE_FACTOR
MAX_SCALE_FACTOR
sprites
startY
maxY
initialPropulsion
horizontalSprayX
horizontalSprayZ
minSize
maxSize
done
level
x
y
z
xa
ya
za
options

Full Source

GeyserPlumeParticle.java113 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.GeyserParticleOptions;
7
import net.minecraft.util.RandomSource;
8
import org.jspecify.annotations.Nullable;
9
10
@Environment(EnvType.CLIENT)
11
public class GeyserPlumeParticle extends SingleQuadParticle {
12
	private static final float NO_FRICTION = 1.0F;
13
	private static final float MAX_FRICTION = 0.0F;
14
	private static final float INITIAL_PROPULSION_FACTOR = 1.45F;
15
	private static final float GRAVITY_EXPONENT = 3.0F;
16
	private static final float GRADUAL_GRAVITY_FACTOR = 0.12F;
17
	private static final float INITIAL_SPRAY_SPREAD = 0.2F;
18
	private static final float LINEAR_SPRAY_SPREAD = 0.2F;
19
	private static final int REMAINING_FRAMES_AFTER_REACHING_MAX_HEIGHT = 5;
20
	private static final float MIN_SCALE_FACTOR = 2.0F;
21
	private static final float MAX_SCALE_FACTOR = 3.0F;
22
	private final SpriteSet sprites;
23
	private final double startY;
24
	private final double maxY;
25
	private final float initialPropulsion;
26
	private final float horizontalSprayX;
27
	private final float horizontalSprayZ;
28
	private final float minSize;
29
	private final float maxSize;
30
	private boolean done;
31
32
	private GeyserPlumeParticle(
33
		final ClientLevel level,
34
		final double x,
35
		final double y,
36
		final double z,
37
		final double xa,
38
		final double ya,
39
		final double za,
40
		final GeyserParticleOptions options,
41
		final SpriteSet sprites
42
	) {
43
		super(level, x, y, z, xa, ya, za, sprites.first());
44
		int plumeHeight = 5 * Math.max(1, options.waterBlocks());
45
		this.hasPhysics = true;
46
		this.speedUpWhenYMotionIsBlocked = true;
47
		this.lifetime = plumeHeight * 5;
48
		this.yd = 0.0;
49
		this.startY = y;
50
		this.maxY = this.startY + plumeHeight - 1.0;
51
		this.horizontalSprayX = (level.getRandom().nextFloat() - 0.5F) * 0.2F;
52
		this.horizontalSprayZ = (level.getRandom().nextFloat() - 0.5F) * 0.2F;
53
		this.friction = 1.0F;
54
		this.initialPropulsion = (options.waterBlocks() == 1 ? 1.5F : 1.0F) * plumeHeight * 1.45F;
55
		this.gravity = -this.initialPropulsion;
56
		float initiallyRandomizedSize = this.quadSize * 0.75F;
57
		this.minSize = initiallyRandomizedSize * (2.0F + plumeHeight / 8.0F);
58
		this.maxSize = initiallyRandomizedSize * (3.0F + plumeHeight / 8.0F);
59
		this.quadSize = this.minSize;
60
		this.sprites = sprites;
61
		this.setSpriteFromAge(sprites);
62
	}
63
64
	@Override
65
	public void tick() {
66
		super.tick();
67
		if (!this.done && (this.yd < 0.0 || this.y > this.maxY || this.y == this.yo)) {
68
			this.lifetime = Math.min(this.lifetime, this.age + 5);
69
			this.friction = 0.0F;
70
			this.done = true;
71
		}
72
73
		double yProgressLinear = Math.clamp((this.y - this.startY) / (this.maxY - this.startY), 0.0, 1.0);
74
		double yProgressExponential = Math.pow(yProgressLinear, 3.0);
75
		this.gravity = this.initialPropulsion * (float)yProgressExponential * 0.12F;
76
		this.xd = yProgressLinear * this.horizontalSprayX;
77
		this.zd = yProgressLinear * this.horizontalSprayZ;
78
		this.setSpriteFromAge(this.sprites);
79
		this.quadSize = this.minSize + (float)(yProgressLinear * (this.maxSize - this.minSize));
80
	}
81
82
	@Override
83
	protected SingleQuadParticle.Layer getLayer() {
84
		return SingleQuadParticle.Layer.OPAQUE;
85
	}
86
87
	@Environment(EnvType.CLIENT)
88
	public static class Provider implements ParticleProvider<GeyserParticleOptions> {
89
		private final SpriteSet sprites;
90
91
		public Provider(final SpriteSet sprites) {
92
			this.sprites = sprites;
93
		}
94
95
		public @Nullable Particle createParticle(
96
			final GeyserParticleOptions options,
97
			final ClientLevel level,
98
			final double x,
99
			final double y,
100
			final double z,
101
			final double xAux,
102
			final double yAux,
103
			final double zAux,
104
			final RandomSource random
105
		) {
106
			double randomX = x + (random.nextFloat() - 0.5F) * 0.2F;
107
			double randomY = y + random.nextFloat();
108
			double randomZ = z + (random.nextFloat() - 0.5F) * 0.2F;
109
			return new GeyserPlumeParticle(level, randomX, randomY, randomZ, xAux, yAux, zAux, options, this.sprites);
110
		}
111
	}
112
}
113

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