ReversePortalParticle .java

net.minecraft.client.particle.ReversePortalParticle (class, 64 lines): members: ReversePortalProvider, zd, getQuadSize, tick. imports: TextureAtlasSprite.

net.minecraft.client.particleclass64 linesclientextends PortalParticle1.8 KB

API Surface (3)

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)

Fields & Constants (1)

zd

Full Source

ReversePortalParticle.java64 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.RandomSource;
9
10
@Environment(EnvType.CLIENT)
11
public class ReversePortalParticle extends PortalParticle {
12
	private ReversePortalParticle(
13
		final ClientLevel level, final double x, final double y, final double z, final double xd, final double yd, final double zd, final TextureAtlasSprite sprite
14
	) {
15
		super(level, x, y, z, xd, yd, zd, sprite);
16
		this.quadSize *= 1.5F;
17
		this.lifetime = (int)(this.random.nextFloat() * 2.0F) + 60;
18
	}
19
20
	@Override
21
	public float getQuadSize(final float a) {
22
		float s = 1.0F - (this.age + a) / (this.lifetime * 1.5F);
23
		return this.quadSize * s;
24
	}
25
26
	@Override
27
	public void tick() {
28
		this.xo = this.x;
29
		this.yo = this.y;
30
		this.zo = this.z;
31
		if (this.age++ >= this.lifetime) {
32
			this.remove();
33
		} else {
34
			float speedMultiplier = (float)this.age / this.lifetime;
35
			this.x = this.x + this.xd * speedMultiplier;
36
			this.y = this.y + this.yd * speedMultiplier;
37
			this.z = this.z + this.zd * speedMultiplier;
38
		}
39
	}
40
41
	@Environment(EnvType.CLIENT)
42
	public static class ReversePortalProvider implements ParticleProvider<SimpleParticleType> {
43
		private final SpriteSet sprite;
44
45
		public ReversePortalProvider(final SpriteSet sprite) {
46
			this.sprite = sprite;
47
		}
48
49
		public Particle createParticle(
50
			final SimpleParticleType options,
51
			final ClientLevel level,
52
			final double x,
53
			final double y,
54
			final double z,
55
			final double xAux,
56
			final double yAux,
57
			final double zAux,
58
			final RandomSource random
59
		) {
60
			return new ReversePortalParticle(level, x, y, z, xAux, yAux, zAux, this.sprite.get(random));
61
		}
62
	}
63
}
64

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