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

104 lines
3.5 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.Mth;
import net.minecraft.util.RandomSource;
public class CritParticle
extends SingleQuadParticle {
private CritParticle(ClientLevel level, double x, double y, double z, double xa, double ya, double za, TextureAtlasSprite sprite) {
super(level, x, y, z, 0.0, 0.0, 0.0, sprite);
float col;
this.friction = 0.7f;
this.gravity = 0.5f;
this.xd *= (double)0.1f;
this.yd *= (double)0.1f;
this.zd *= (double)0.1f;
this.xd += xa * 0.4;
this.yd += ya * 0.4;
this.zd += za * 0.4;
this.rCol = col = (float)(Math.random() * (double)0.3f + (double)0.6f);
this.gCol = col;
this.bCol = col;
this.quadSize *= 0.75f;
this.lifetime = Math.max((int)(6.0 / (Math.random() * 0.8 + 0.6)), 1);
this.hasPhysics = false;
this.tick();
}
@Override
public float getQuadSize(float a) {
return this.quadSize * Mth.clamp(((float)this.age + a) / (float)this.lifetime * 32.0f, 0.0f, 1.0f);
}
@Override
public void tick() {
super.tick();
this.gCol *= 0.96f;
this.bCol *= 0.9f;
}
@Override
public SingleQuadParticle.Layer getLayer() {
return SingleQuadParticle.Layer.OPAQUE;
}
public static class DamageIndicatorProvider
implements ParticleProvider<SimpleParticleType> {
private final SpriteSet sprite;
public DamageIndicatorProvider(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) {
CritParticle particle = new CritParticle(level, x, y, z, xAux, yAux + 1.0, zAux, this.sprite.get(random));
particle.setLifetime(20);
return particle;
}
}
public static class MagicProvider
implements ParticleProvider<SimpleParticleType> {
private final SpriteSet sprite;
public MagicProvider(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) {
CritParticle particle = new CritParticle(level, x, y, z, xAux, yAux, zAux, this.sprite.get(random));
particle.rCol *= 0.3f;
particle.gCol *= 0.8f;
return particle;
}
}
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) {
CritParticle particle = new CritParticle(level, x, y, z, xAux, yAux, zAux, this.sprite.get(random));
return particle;
}
}
}