Private
Public Access
1
0

Implemented particle light color method.

This commit is contained in:
2025-06-05 23:50:39 +01:00
parent 818e2e7a7d
commit ffb52b2d8b

View File

@ -3,6 +3,7 @@ package dev.micle.firefly_bush_backport.particle;
import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.client.particle.ParticleRenderType;
import net.minecraft.client.particle.TextureSheetParticle;
import net.minecraft.util.Mth;
import org.jetbrains.annotations.NotNull;
public class FireflyParticle extends TextureSheetParticle {
@ -27,4 +28,21 @@ public class FireflyParticle extends TextureSheetParticle {
public @NotNull ParticleRenderType getRenderType() {
return ParticleRenderType.PARTICLE_SHEET_TRANSLUCENT;
}
@Override
public int getLightColor(float partialTick) {
return (int) (255.0F * getFadeAmount(this.getLifetimeProgress(this.age + partialTick), PARTICLE_FADE_IN_LIGHT_TIME, PARTICLE_FADE_OUT_LIGHT_TIME));
}
private static float getFadeAmount(float lifetimeProgress, float fadeIn, float fadeOut) {
if (lifetimeProgress >= 1.0F - fadeIn) {
return (1.0F - lifetimeProgress) / fadeIn;
} else {
return lifetimeProgress <= fadeOut ? lifetimeProgress / fadeOut : 1.0F;
}
}
private float getLifetimeProgress(float age) {
return Mth.clamp(age / this.lifetime, 0.0F, 1.0F);
}
}