Implemented particle light color method.
This commit is contained in:
@ -3,6 +3,7 @@ package dev.micle.firefly_bush_backport.particle;
|
|||||||
import net.minecraft.client.multiplayer.ClientLevel;
|
import net.minecraft.client.multiplayer.ClientLevel;
|
||||||
import net.minecraft.client.particle.ParticleRenderType;
|
import net.minecraft.client.particle.ParticleRenderType;
|
||||||
import net.minecraft.client.particle.TextureSheetParticle;
|
import net.minecraft.client.particle.TextureSheetParticle;
|
||||||
|
import net.minecraft.util.Mth;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public class FireflyParticle extends TextureSheetParticle {
|
public class FireflyParticle extends TextureSheetParticle {
|
||||||
@ -27,4 +28,21 @@ public class FireflyParticle extends TextureSheetParticle {
|
|||||||
public @NotNull ParticleRenderType getRenderType() {
|
public @NotNull ParticleRenderType getRenderType() {
|
||||||
return ParticleRenderType.PARTICLE_SHEET_TRANSLUCENT;
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user