67 lines
2.1 KiB
Java
67 lines
2.1 KiB
Java
|
|
package hal.studios.hpm.client.particle;
|
|
|
|
import net.minecraftforge.api.distmarker.OnlyIn;
|
|
import net.minecraftforge.api.distmarker.Dist;
|
|
|
|
import net.minecraft.core.particles.SimpleParticleType;
|
|
import net.minecraft.client.particle.TextureSheetParticle;
|
|
import net.minecraft.client.particle.SpriteSet;
|
|
import net.minecraft.client.particle.ParticleRenderType;
|
|
import net.minecraft.client.particle.ParticleProvider;
|
|
import net.minecraft.client.particle.Particle;
|
|
import net.minecraft.client.multiplayer.ClientLevel;
|
|
|
|
@OnlyIn(Dist.CLIENT)
|
|
public class PlankSplinterParticle extends TextureSheetParticle {
|
|
public static PlankSplinterParticleProvider provider(SpriteSet spriteSet) {
|
|
return new PlankSplinterParticleProvider(spriteSet);
|
|
}
|
|
|
|
public static class PlankSplinterParticleProvider implements ParticleProvider<SimpleParticleType> {
|
|
private final SpriteSet spriteSet;
|
|
|
|
public PlankSplinterParticleProvider(SpriteSet spriteSet) {
|
|
this.spriteSet = spriteSet;
|
|
}
|
|
|
|
public Particle createParticle(SimpleParticleType typeIn, ClientLevel worldIn, double x, double y, double z, double xSpeed, double ySpeed, double zSpeed) {
|
|
return new PlankSplinterParticle(worldIn, x, y, z, xSpeed, ySpeed, zSpeed, this.spriteSet);
|
|
}
|
|
}
|
|
|
|
private final SpriteSet spriteSet;
|
|
|
|
private float angularVelocity;
|
|
private float angularAcceleration;
|
|
|
|
protected PlankSplinterParticle(ClientLevel world, double x, double y, double z, double vx, double vy, double vz, SpriteSet spriteSet) {
|
|
super(world, x, y, z);
|
|
this.spriteSet = spriteSet;
|
|
this.setSize(0.4f, 0.4f);
|
|
this.quadSize *= 1.2f;
|
|
this.lifetime = (int) Math.max(1, 46 + (this.random.nextInt(24) - 12));
|
|
this.gravity = 1f;
|
|
this.hasPhysics = true;
|
|
this.xd = vx * 0.3;
|
|
this.yd = vy * 0.3;
|
|
this.zd = vz * 0.3;
|
|
this.angularVelocity = 0.4f;
|
|
this.angularAcceleration = 0.01f;
|
|
this.pickSprite(spriteSet);
|
|
}
|
|
|
|
@Override
|
|
public ParticleRenderType getRenderType() {
|
|
return ParticleRenderType.PARTICLE_SHEET_OPAQUE;
|
|
}
|
|
|
|
@Override
|
|
public void tick() {
|
|
super.tick();
|
|
this.oRoll = this.roll;
|
|
this.roll += this.angularVelocity;
|
|
this.angularVelocity += this.angularAcceleration;
|
|
}
|
|
}
|