158 lines
5.7 KiB
Java
158 lines
5.7 KiB
Java
/*
|
|
* Decompiled with CFR 0.152.
|
|
*/
|
|
package net.minecraft.client.particle;
|
|
|
|
import net.minecraft.client.Camera;
|
|
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.state.QuadParticleRenderState;
|
|
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
|
import net.minecraft.core.particles.SimpleParticleType;
|
|
import net.minecraft.util.RandomSource;
|
|
|
|
public class FlyTowardsPositionParticle
|
|
extends SingleQuadParticle {
|
|
private final double xStart;
|
|
private final double yStart;
|
|
private final double zStart;
|
|
private final boolean isGlowing;
|
|
private final Particle.LifetimeAlpha lifetimeAlpha;
|
|
|
|
private FlyTowardsPositionParticle(ClientLevel level, double x, double y, double z, double xd, double yd, double zd, TextureAtlasSprite sprite) {
|
|
this(level, x, y, z, xd, yd, zd, false, Particle.LifetimeAlpha.ALWAYS_OPAQUE, sprite);
|
|
}
|
|
|
|
private FlyTowardsPositionParticle(ClientLevel level, double x, double y, double z, double xd, double yd, double zd, boolean isGlowing, Particle.LifetimeAlpha lifetimeAlpha, TextureAtlasSprite sprite) {
|
|
super(level, x, y, z, sprite);
|
|
this.isGlowing = isGlowing;
|
|
this.lifetimeAlpha = lifetimeAlpha;
|
|
this.setAlpha(lifetimeAlpha.startAlpha());
|
|
this.xd = xd;
|
|
this.yd = yd;
|
|
this.zd = zd;
|
|
this.xStart = x;
|
|
this.yStart = y;
|
|
this.zStart = z;
|
|
this.xo = x + xd;
|
|
this.yo = y + yd;
|
|
this.zo = z + zd;
|
|
this.x = this.xo;
|
|
this.y = this.yo;
|
|
this.z = this.zo;
|
|
this.quadSize = 0.1f * (this.random.nextFloat() * 0.5f + 0.2f);
|
|
float br = this.random.nextFloat() * 0.6f + 0.4f;
|
|
this.rCol = 0.9f * br;
|
|
this.gCol = 0.9f * br;
|
|
this.bCol = br;
|
|
this.hasPhysics = false;
|
|
this.lifetime = (int)(Math.random() * 10.0) + 30;
|
|
}
|
|
|
|
@Override
|
|
public SingleQuadParticle.Layer getLayer() {
|
|
if (this.lifetimeAlpha.isOpaque()) {
|
|
return SingleQuadParticle.Layer.OPAQUE;
|
|
}
|
|
return SingleQuadParticle.Layer.TRANSLUCENT;
|
|
}
|
|
|
|
@Override
|
|
public void move(double xa, double ya, double za) {
|
|
this.setBoundingBox(this.getBoundingBox().move(xa, ya, za));
|
|
this.setLocationFromBoundingbox();
|
|
}
|
|
|
|
@Override
|
|
public int getLightColor(float a) {
|
|
if (this.isGlowing) {
|
|
return 240;
|
|
}
|
|
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() {
|
|
this.xo = this.x;
|
|
this.yo = this.y;
|
|
this.zo = this.z;
|
|
if (this.age++ >= this.lifetime) {
|
|
this.remove();
|
|
return;
|
|
}
|
|
float pos = (float)this.age / (float)this.lifetime;
|
|
pos = 1.0f - pos;
|
|
float pp = 1.0f - pos;
|
|
pp *= pp;
|
|
pp *= pp;
|
|
this.x = this.xStart + this.xd * (double)pos;
|
|
this.y = this.yStart + this.yd * (double)pos - (double)(pp * 1.2f);
|
|
this.z = this.zStart + this.zd * (double)pos;
|
|
}
|
|
|
|
@Override
|
|
public void extract(QuadParticleRenderState particleTypeRenderState, Camera camera, float partialTickTime) {
|
|
this.setAlpha(this.lifetimeAlpha.currentAlphaForAge(this.age, this.lifetime, partialTickTime));
|
|
super.extract(particleTypeRenderState, camera, partialTickTime);
|
|
}
|
|
|
|
public static class VaultConnectionProvider
|
|
implements ParticleProvider<SimpleParticleType> {
|
|
private final SpriteSet sprite;
|
|
|
|
public VaultConnectionProvider(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) {
|
|
FlyTowardsPositionParticle particle = new FlyTowardsPositionParticle(level, x, y, z, xAux, yAux, zAux, true, new Particle.LifetimeAlpha(0.0f, 0.6f, 0.25f, 1.0f), this.sprite.get(random));
|
|
particle.scale(1.5f);
|
|
return particle;
|
|
}
|
|
}
|
|
|
|
public static class NautilusProvider
|
|
implements ParticleProvider<SimpleParticleType> {
|
|
private final SpriteSet sprite;
|
|
|
|
public NautilusProvider(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) {
|
|
FlyTowardsPositionParticle particle = new FlyTowardsPositionParticle(level, x, y, z, xAux, yAux, zAux, this.sprite.get(random));
|
|
return particle;
|
|
}
|
|
}
|
|
|
|
public static class EnchantProvider
|
|
implements ParticleProvider<SimpleParticleType> {
|
|
private final SpriteSet sprite;
|
|
|
|
public EnchantProvider(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) {
|
|
FlyTowardsPositionParticle particle = new FlyTowardsPositionParticle(level, x, y, z, xAux, yAux, zAux, this.sprite.get(random));
|
|
return particle;
|
|
}
|
|
}
|
|
}
|
|
|