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

84 lines
3.1 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 CampfireSmokeParticle
extends SingleQuadParticle {
private CampfireSmokeParticle(ClientLevel level, double x, double y, double z, double xa, double ya, double za, boolean isSignalFire, TextureAtlasSprite sprite) {
super(level, x, y, z, sprite);
this.scale(3.0f);
this.setSize(0.25f, 0.25f);
this.lifetime = isSignalFire ? this.random.nextInt(50) + 280 : this.random.nextInt(50) + 80;
this.gravity = 3.0E-6f;
this.xd = xa;
this.yd = ya + (double)(this.random.nextFloat() / 500.0f);
this.zd = za;
}
@Override
public void tick() {
this.xo = this.x;
this.yo = this.y;
this.zo = this.z;
if (this.age++ >= this.lifetime || this.alpha <= 0.0f) {
this.remove();
return;
}
this.xd += (double)(this.random.nextFloat() / 5000.0f * (float)(this.random.nextBoolean() ? 1 : -1));
this.zd += (double)(this.random.nextFloat() / 5000.0f * (float)(this.random.nextBoolean() ? 1 : -1));
this.yd -= (double)this.gravity;
this.move(this.xd, this.yd, this.zd);
if (this.age >= this.lifetime - 60 && this.alpha > 0.01f) {
this.alpha -= 0.015f;
}
}
@Override
public SingleQuadParticle.Layer getLayer() {
return SingleQuadParticle.Layer.TRANSLUCENT;
}
public static class SignalProvider
implements ParticleProvider<SimpleParticleType> {
private final SpriteSet sprites;
public SignalProvider(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) {
CampfireSmokeParticle particle = new CampfireSmokeParticle(level, x, y, z, xAux, yAux, zAux, true, this.sprites.get(random));
particle.setAlpha(0.95f);
return particle;
}
}
public static class CosyProvider
implements ParticleProvider<SimpleParticleType> {
private final SpriteSet sprites;
public CosyProvider(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) {
CampfireSmokeParticle particle = new CampfireSmokeParticle(level, x, y, z, xAux, yAux, zAux, false, this.sprites.get(random));
particle.setAlpha(0.9f);
return particle;
}
}
}