package dev.crucifixbeta.api.utils.combat.crystal;

import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d;

@Environment(EnvType.CLIENT)
public final class AsyncCrystalData {
   private final AsyncCrystalData.Type type;
   private final BlockPos placePos;
   private final int crystalId;
   private final Vec3d crystalVec;
   private final int targetId;
   private final float targetDamage;
   private final float selfDamage;

   private AsyncCrystalData(AsyncCrystalData.Type type, BlockPos placePos, int crystalId, Vec3d crystalVec, int targetId, float targetDamage, float selfDamage) {
      this.type = type;
      this.placePos = placePos;
      this.crystalId = crystalId;
      this.crystalVec = crystalVec;
      this.targetId = targetId;
      this.targetDamage = targetDamage;
      this.selfDamage = selfDamage;
   }

   public static AsyncCrystalData place(BlockPos pos, Vec3d crystalVec, int targetId, float targetDamage, float selfDamage) {
      return new AsyncCrystalData(AsyncCrystalData.Type.Place, pos, -1, crystalVec, targetId, targetDamage, selfDamage);
   }

   public static AsyncCrystalData breakCrystal(CrystalEntitySnapshot crystal, int targetId, float targetDamage, float selfDamage) {
      return new AsyncCrystalData(AsyncCrystalData.Type.Break, null, crystal.id(), crystal.pos(), targetId, targetDamage, selfDamage);
   }

   public AsyncCrystalData.Type type() {
      return this.type;
   }

   public BlockPos placePos() {
      return this.placePos;
   }

   public int crystalId() {
      return this.crystalId;
   }

   public Vec3d crystalVec() {
      return this.crystalVec;
   }

   public int targetId() {
      return this.targetId;
   }

   public float targetDamage() {
      return this.targetDamage;
   }

   public float selfDamage() {
      return this.selfDamage;
   }

   @Environment(EnvType.CLIENT)
   public static enum Type {
      Place,
      Break;

}
}
