Private
Public Access
1
0

Implemented tick method.

This commit is contained in:
2025-06-05 23:55:27 +01:00
parent 8b4dd563de
commit 136b6ea144

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.core.BlockPos;
import net.minecraft.util.Mth;
import org.jetbrains.annotations.NotNull;
@ -45,4 +46,17 @@ public class FireflyParticle extends TextureSheetParticle {
private float getLifetimeProgress(float age) {
return Mth.clamp(age / this.lifetime, 0.0F, 1.0F);
}
@Override
public void tick() {
super.tick();
if (!this.level.getBlockState(BlockPos.containing(this.x, this.y, this.z)).isAir()) {
this.remove();
} else {
this.setAlpha(getFadeAmount(this.getLifetimeProgress(this.age), PARTICLE_FADE_IN_ALPHA_TIME, PARTICLE_FADE_OUT_ALPHA_TIME));
if (Math.random() > 0.95 || this.age == 1) {
this.setParticleSpeed(-0.05F + 0.1F * Math.random(), -0.05F + 0.1F * Math.random(), -0.05F + 0.1F * Math.random());
}
}
}
}