Implemented tick 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.core.BlockPos;
|
||||||
import net.minecraft.util.Mth;
|
import net.minecraft.util.Mth;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
@ -45,4 +46,17 @@ public class FireflyParticle extends TextureSheetParticle {
|
|||||||
private float getLifetimeProgress(float age) {
|
private float getLifetimeProgress(float age) {
|
||||||
return Mth.clamp(age / this.lifetime, 0.0F, 1.0F);
|
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());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user