package dev.crucifixbeta.api.utils.path;

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

@Environment(EnvType.CLIENT)
public record Vec3(double x, double y, double z) {
   public Vec3 addVector(double x, double y, double z) {
      return new Vec3(this.x + x, this.y + y, this.z + z);
   }

   public Vec3 floor() {
      return new Vec3(Math.floor(this.x), Math.floor(this.y), Math.floor(this.z));
   }

   public double squareDistanceTo(Vec3 v) {
      return Math.pow(v.x - this.x, 2.0) + Math.pow(v.y - this.y, 2.0) + Math.pow(v.z - this.z, 2.0);
   }

   public Vec3 add(Vec3 v) {
      return this.addVector(v.x(), v.y(), v.z());
   }

   public Vec3d mc() {
      return new Vec3d(this.x, this.y, this.z);
   }

   @Override
   public String toString() {
      return "[" + this.x + ";" + this.y + ";" + this.z + "]";
   }

   @Override
   public boolean equals(Object obj) {
      if (!(obj instanceof Vec3 var2)) {
         return false;
      } else {
         double var5;
         try {
            var5 = var2.x();
         } catch (Throwable var12) {
            throw new MatchException(var12.toString(), var12);
         }

         double var8 = var2.y();
         double var10 = var2.z();
         if (this.x != var5) {
            return false;
         } else {
            return this.y != var8 ? false : this.z == var10;
         }
      }
   }
}
