package dev.crucifixbeta.api.events.impl;

import dev.crucifixbeta.api.events.Event;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.entity.LivingEntity;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.Vec3d;

@Environment(EnvType.CLIENT)
public class FireworkShooterRotationEvent extends Event {
   private static final FireworkShooterRotationEvent instance = new FireworkShooterRotationEvent();
   public LivingEntity shooter;
   public float pitch;
   public float yaw;

   private FireworkShooterRotationEvent() {
   }

   public static FireworkShooterRotationEvent get(LivingEntity shooter, float yaw, float pitch) {
      instance.shooter = shooter;
      instance.yaw = yaw;
      instance.pitch = pitch;
      instance.setCancelled(false);
      return instance;
   }

   public final Vec3d getRotationVector() {
      float var1 = this.pitch * (float) (Math.PI / 180.0);
      float var2 = -this.yaw * (float) (Math.PI / 180.0);
      float var3 = MathHelper.cos(var2);
      float var4 = MathHelper.sin(var2);
      float var5 = MathHelper.cos(var1);
      float var6 = MathHelper.sin(var1);
      return new Vec3d((double)(var4 * var5), (double)(-var6), (double)(var3 * var5));
   }
}
