package com.leisuretimedock.blasttravelreborn.client.particle;

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;
@OnlyIn(Dist.CLIENT)
public class CannonBlastParticle extends RisingParticle {
	private final SpriteSet sprites;

	public CannonBlastParticle(ClientLevel world, double x, double y, double z, double vx, double vy, double vz, SpriteSet sprites) {
		super(world, x, y, z, vx, vy, vz);
		this.sprites = sprites;
		this.age = world.random.nextInt(2);
		this.lifetime = 16;
		this.friction = 0.76f;
		this.scale(1.5f + world.random.nextFloat() * 0.2f);
		this.setSpriteFromAge(sprites);
	}

	@Override
	public void tick() {
		super.tick();
		this.setSpriteFromAge(this.sprites);
	}

	@Override
	public @NotNull ParticleRenderType getRenderType() {
		return ParticleRenderType.PARTICLE_SHEET_OPAQUE;
	}

	public static class Provider implements ParticleProvider<SimpleParticleType> {
		private final SpriteSet sprites;

		public Provider(SpriteSet sprites) {
			this.sprites = sprites;
		}

		public Particle createParticle(@NotNull SimpleParticleType type, @NotNull ClientLevel world, double x, double y, double z, double vx, double vy, double vz) {
			return new CannonBlastParticle(world, x, y, z, vx, vy, vz, this.sprites);
		}
	}
}
