package net.minecraft.core;

import com.google.common.base.MoreObjects;
import net.minecraft.util.Mth;
import javax.annotation.concurrent.Immutable;

@Immutable
public class Vec3i implements Comparable<Vec3i> {
    public static final Vec3i ZERO;
    @Deprecated
    private final int x;
    @Deprecated
    private final int y;
    @Deprecated
    private final int z;
    
    public Vec3i(final int integer1, final int integer2, final int integer3) {
        this.x = integer1;
        this.y = integer2;
        this.z = integer3;
    }
    
    public Vec3i(final double double1, final double double2, final double double3) {
        this(Mth.floor(double1), Mth.floor(double2), Mth.floor(double3));
    }
    
    @Override
    public boolean equals(final Object object) {
        if (this == object) {
            return true;
        }
        if (!(object instanceof Vec3i)) {
            return false;
        }
        final Vec3i gg3 = (Vec3i)object;
        return this.getX() == gg3.getX() && this.getY() == gg3.getY() && this.getZ() == gg3.getZ();
    }
    
    @Override
    public int hashCode() {
        return (this.getY() + this.getZ() * 31) * 31 + this.getX();
    }
    
    @Override
    public int compareTo(final Vec3i gg) {
        if (this.getY() != gg.getY()) {
            return this.getY() - gg.getY();
        }
        if (this.getZ() == gg.getZ()) {
            return this.getX() - gg.getX();
        }
        return this.getZ() - gg.getZ();
    }
    
    public int getX() {
        return this.x;
    }
    
    public int getY() {
        return this.y;
    }
    
    public int getZ() {
        return this.z;
    }
    
    public Vec3i below() {
        return this.below(1);
    }
    
    public Vec3i below(final int integer) {
        return this.relative(Direction.DOWN, integer);
    }
    
    public Vec3i relative(final Direction fp, final int integer) {
        if (integer == 0) {
            return this;
        }
        return new Vec3i(this.getX() + fp.getStepX() * integer, this.getY() + fp.getStepY() * integer, this.getZ() + fp.getStepZ() * integer);
    }
    
    public Vec3i cross(final Vec3i gg) {
        return new Vec3i(this.getY() * gg.getZ() - this.getZ() * gg.getY(), this.getZ() * gg.getX() - this.getX() * gg.getZ(), this.getX() * gg.getY() - this.getY() * gg.getX());
    }
    
    public boolean closerThan(final Vec3i gg, final double double2) {
        return this.distSqr(gg.getX(), gg.getY(), gg.getZ(), false) < double2 * double2;
    }
    
    public boolean closerThan(final Position fz, final double double2) {
        return this.distSqr(fz.x(), fz.y(), fz.z(), true) < double2 * double2;
    }
    
    public double distSqr(final Vec3i gg) {
        return this.distSqr(gg.getX(), gg.getY(), gg.getZ(), true);
    }
    
    public double distSqr(final Position fz, final boolean boolean2) {
        return this.distSqr(fz.x(), fz.y(), fz.z(), boolean2);
    }
    
    public double distSqr(final double double1, final double double2, final double double3, final boolean boolean4) {
        final double double4 = boolean4 ? 0.5 : 0.0;
        final double double5 = this.getX() + double4 - double1;
        final double double6 = this.getY() + double4 - double2;
        final double double7 = this.getZ() + double4 - double3;
        return double5 * double5 + double6 * double6 + double7 * double7;
    }
    
    public int distManhattan(final Vec3i gg) {
        final float float3 = (float)Math.abs(gg.getX() - this.getX());
        final float float4 = (float)Math.abs(gg.getY() - this.getY());
        final float float5 = (float)Math.abs(gg.getZ() - this.getZ());
        return (int)(float3 + float4 + float5);
    }
    
    @Override
    public String toString() {
        return MoreObjects.toStringHelper(this).add("x", this.getX()).add("y", this.getY()).add("z", this.getZ()).toString();
    }
    
    public String toShortString() {
        return "" + this.getX() + ", " + this.getY() + ", " + this.getZ();
    }
    
    static {
        ZERO = new Vec3i(0, 0, 0);
    }
}
