73 lines
2.3 KiB
Java
73 lines
2.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.core.particles.SimpleParticleType;
|
|
import net.minecraft.util.RandomSource;
|
|
|
|
public class WakeParticle
|
|
extends SingleQuadParticle {
|
|
private final SpriteSet sprites;
|
|
|
|
private WakeParticle(ClientLevel level, double x, double y, double z, double xa, double ya, double za, SpriteSet sprites) {
|
|
super(level, x, y, z, 0.0, 0.0, 0.0, sprites.first());
|
|
this.sprites = sprites;
|
|
this.xd *= (double)0.3f;
|
|
this.yd = Math.random() * (double)0.2f + (double)0.1f;
|
|
this.zd *= (double)0.3f;
|
|
this.setSize(0.01f, 0.01f);
|
|
this.lifetime = (int)(8.0 / (Math.random() * 0.8 + 0.2));
|
|
this.setSpriteFromAge(sprites);
|
|
this.gravity = 0.0f;
|
|
this.xd = xa;
|
|
this.yd = ya;
|
|
this.zd = za;
|
|
}
|
|
|
|
@Override
|
|
public SingleQuadParticle.Layer getLayer() {
|
|
return SingleQuadParticle.Layer.OPAQUE;
|
|
}
|
|
|
|
@Override
|
|
public void tick() {
|
|
this.xo = this.x;
|
|
this.yo = this.y;
|
|
this.zo = this.z;
|
|
int life = 60 - this.lifetime;
|
|
if (this.lifetime-- <= 0) {
|
|
this.remove();
|
|
return;
|
|
}
|
|
this.yd -= (double)this.gravity;
|
|
this.move(this.xd, this.yd, this.zd);
|
|
this.xd *= (double)0.98f;
|
|
this.yd *= (double)0.98f;
|
|
this.zd *= (double)0.98f;
|
|
float size = (float)life * 0.001f;
|
|
this.setSize(size, size);
|
|
this.setSprite(this.sprites.get(life % 4, 4));
|
|
}
|
|
|
|
public static class Provider
|
|
implements ParticleProvider<SimpleParticleType> {
|
|
private final SpriteSet sprites;
|
|
|
|
public Provider(SpriteSet sprites) {
|
|
this.sprites = sprites;
|
|
}
|
|
|
|
@Override
|
|
public Particle createParticle(SimpleParticleType options, ClientLevel level, double x, double y, double z, double xAux, double yAux, double zAux, RandomSource random) {
|
|
return new WakeParticle(level, x, y, z, xAux, yAux, zAux, this.sprites);
|
|
}
|
|
}
|
|
}
|
|
|