2025-11-24 22:52:51 +03:00

108 lines
3.3 KiB
Java

/*
* Decompiled with CFR 0.152.
*/
package net.minecraft.client.particle;
import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.client.particle.Particle;
import net.minecraft.client.particle.ParticleProvider;
import net.minecraft.client.particle.SingleQuadParticle;
import net.minecraft.client.particle.SpriteSet;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.core.particles.SimpleParticleType;
import net.minecraft.util.RandomSource;
public class PortalParticle
extends SingleQuadParticle {
private final double xStart;
private final double yStart;
private final double zStart;
protected PortalParticle(ClientLevel level, double x, double y, double z, double xd, double yd, double zd, TextureAtlasSprite sprite) {
super(level, x, y, z, sprite);
this.xd = xd;
this.yd = yd;
this.zd = zd;
this.x = x;
this.y = y;
this.z = z;
this.xStart = this.x;
this.yStart = this.y;
this.zStart = this.z;
this.quadSize = 0.1f * (this.random.nextFloat() * 0.2f + 0.5f);
float br = this.random.nextFloat() * 0.6f + 0.4f;
this.rCol = br * 0.9f;
this.gCol = br * 0.3f;
this.bCol = br;
this.lifetime = (int)(Math.random() * 10.0) + 40;
}
@Override
public SingleQuadParticle.Layer getLayer() {
return SingleQuadParticle.Layer.OPAQUE;
}
@Override
public void move(double xa, double ya, double za) {
this.setBoundingBox(this.getBoundingBox().move(xa, ya, za));
this.setLocationFromBoundingbox();
}
@Override
public float getQuadSize(float a) {
float s = ((float)this.age + a) / (float)this.lifetime;
s = 1.0f - s;
s *= s;
s = 1.0f - s;
return this.quadSize * s;
}
@Override
public int getLightColor(float a) {
int br = super.getLightColor(a);
float pos = (float)this.age / (float)this.lifetime;
pos *= pos;
pos *= pos;
int br1 = br & 0xFF;
int br2 = br >> 16 & 0xFF;
if ((br2 += (int)(pos * 15.0f * 16.0f)) > 240) {
br2 = 240;
}
return br1 | br2 << 16;
}
@Override
public void tick() {
float pos;
this.xo = this.x;
this.yo = this.y;
this.zo = this.z;
if (this.age++ >= this.lifetime) {
this.remove();
return;
}
float a = pos = (float)this.age / (float)this.lifetime;
pos = -pos + pos * pos * 2.0f;
pos = 1.0f - pos;
this.x = this.xStart + this.xd * (double)pos;
this.y = this.yStart + this.yd * (double)pos + (double)(1.0f - a);
this.z = this.zStart + this.zd * (double)pos;
}
public static class Provider
implements ParticleProvider<SimpleParticleType> {
private final SpriteSet sprite;
public Provider(SpriteSet sprite) {
this.sprite = sprite;
}
@Override
public Particle createParticle(SimpleParticleType options, ClientLevel level, double x, double y, double z, double xAux, double yAux, double zAux, RandomSource random) {
PortalParticle particle = new PortalParticle(level, x, y, z, xAux, yAux, zAux, this.sprite.get(random));
return particle;
}
}
}