63 lines
1.9 KiB
Java
63 lines
1.9 KiB
Java
package com.jenny.enhancedexplosives.particles.arrow;
|
|
|
|
import net.minecraft.client.multiplayer.ClientLevel;
|
|
import net.minecraft.client.particle.*;
|
|
import net.minecraft.core.particles.SimpleParticleType;
|
|
import net.minecraftforge.api.distmarker.Dist;
|
|
import net.minecraftforge.api.distmarker.OnlyIn;
|
|
import org.jetbrains.annotations.NotNull;
|
|
|
|
public class ArrowParticle extends TextureSheetParticle {
|
|
private final float quadSizeStart;
|
|
|
|
protected ArrowParticle(ClientLevel level, double xCoord, double yCoord, double zCoord,
|
|
SpriteSet spriteSet, double xd, double yd, double zd) {
|
|
super(level, xCoord, yCoord, zCoord, xd, yd, zd);
|
|
|
|
this.friction = 0.8F;
|
|
this.xd = xd;
|
|
this.yd = yd;
|
|
this.zd = zd;
|
|
this.quadSize *= 0.85F;
|
|
this.quadSizeStart = this.quadSize;
|
|
this.lifetime = 20;
|
|
this.setSpriteFromAge(spriteSet);
|
|
|
|
this.rCol = 1f;
|
|
this.gCol = 1f;
|
|
this.bCol = 1f;
|
|
}
|
|
|
|
@Override
|
|
public void tick() {
|
|
super.tick();
|
|
fadeOut();
|
|
}
|
|
|
|
private void fadeOut() {
|
|
this.alpha = (-(1/(float)lifetime) * age + 1);
|
|
this.quadSize = this.quadSizeStart * ((float) age / lifetime);
|
|
}
|
|
|
|
@Override
|
|
@NotNull
|
|
public ParticleRenderType getRenderType() {
|
|
return ParticleRenderType.PARTICLE_SHEET_TRANSLUCENT;
|
|
}
|
|
|
|
@OnlyIn(Dist.CLIENT)
|
|
public static class Provider implements ParticleProvider<SimpleParticleType> {
|
|
private final SpriteSet sprites;
|
|
|
|
public Provider(SpriteSet spriteSet) {
|
|
this.sprites = spriteSet;
|
|
}
|
|
|
|
public Particle createParticle(@NotNull SimpleParticleType particleType, @NotNull ClientLevel level,
|
|
double x, double y, double z,
|
|
double dx, double dy, double dz) {
|
|
return new ArrowParticle(level, x, y, z, this.sprites, dx, dy, dz);
|
|
}
|
|
}
|
|
}
|