Restore explosion particle modes
All checks were successful
Build / build (push) Successful in 12m38s

This commit is contained in:
MrSphay
2026-05-09 12:14:16 +02:00
parent 1859e69b01
commit 1ce8376c1b
8 changed files with 296 additions and 14 deletions

View File

@@ -7,11 +7,30 @@ import net.minecraft.client.particle.ParticleProvider;
import net.minecraft.client.particle.ParticleRenderType;
import net.minecraft.client.particle.SpriteSet;
import net.minecraft.client.particle.TextureSheetParticle;
import net.minecraft.util.Mth;
public class SmokeParticle extends TextureSheetParticle {
private final SpriteSet sprites;
private final float startSize;
private final float startAlpha;
protected SmokeParticle(ClientLevel level, double x, double y, double z, double xSpeed, double ySpeed, double zSpeed, SmokeParticleOptions options, SpriteSet sprites) {
super(level, x, y, z, xSpeed, ySpeed, zSpeed);
this.lifetime = 1;
this.sprites = sprites;
this.lifetime = Math.max(6, options.getLifetime());
this.startSize = options.getScale() * (options.isHeavy() ? 1.45f : 1.0f);
this.startAlpha = options.getAlpha();
this.quadSize = this.startSize;
this.rCol = options.getRed();
this.gCol = options.getGreen();
this.bCol = options.getBlue();
this.alpha = this.startAlpha;
this.friction = options.isHeavy() ? 0.94f : 0.9f;
this.gravity = options.isHeavy() ? -0.004f : -0.012f;
this.hasPhysics = false;
this.xd = xSpeed + options.getWindSpeed() * 0.02;
this.yd = ySpeed + 0.008 + options.getHeightPercent() * 0.01;
this.zd = zSpeed;
this.pickSprite(sprites);
}
@@ -24,6 +43,18 @@ public class SmokeParticle extends TextureSheetParticle {
return false;
}
@Override
public void tick() {
super.tick();
if (this.age >= this.lifetime) {
return;
}
float progress = this.age / (float)this.lifetime;
this.setSpriteFromAge(this.sprites);
this.quadSize = this.startSize * (1.0f + progress * 1.6f);
this.alpha = this.startAlpha * Mth.clamp(1.0f - progress, 0.0f, 1.0f);
}
public static class Provider implements ParticleProvider<SmokeParticleOptions> {
private final SpriteSet sprites;