mirror of
https://github.com/KAMKEEL/CustomNPC-Plus-API.git
synced 2026-11-14 04:59:48 +00:00
130 lines
3.1 KiB
Java
130 lines
3.1 KiB
Java
package net.minecraft.util;
|
|
|
|
import com.google.common.base.Objects;
|
|
|
|
/**
|
|
* This code is owned by Minecraft
|
|
*/
|
|
|
|
public class Vec3i implements Comparable<Vec3i> {
|
|
/**
|
|
* X coordinate
|
|
*/
|
|
private final int x;
|
|
/**
|
|
* Y coordinate
|
|
*/
|
|
private final int y;
|
|
/**
|
|
* Z coordinate
|
|
*/
|
|
private final int z;
|
|
|
|
/**
|
|
* Double X coordinate
|
|
*/
|
|
private final double xd;
|
|
/**
|
|
* Double Y coordinate
|
|
*/
|
|
private final double yd;
|
|
/**
|
|
* Double Z coordinate
|
|
*/
|
|
private final double zd;
|
|
|
|
public Vec3i(int xIn, int yIn, int zIn) {
|
|
this((double) xIn, (double) yIn, (double) zIn);
|
|
}
|
|
|
|
public Vec3i(double xIn, double yIn, double zIn) {
|
|
this.x = MathHelper.floor_double(xIn);
|
|
this.y = MathHelper.floor_double(yIn);
|
|
this.z = MathHelper.floor_double(zIn);
|
|
this.xd = xIn;
|
|
this.yd = yIn;
|
|
this.zd = zIn;
|
|
}
|
|
|
|
public boolean equals(Object p_equals_1_) {
|
|
if (this == p_equals_1_) {
|
|
return true;
|
|
} else if (!(p_equals_1_ instanceof Vec3i)) {
|
|
return false;
|
|
} else {
|
|
Vec3i vec3I = (Vec3i) p_equals_1_;
|
|
return this.getX() != vec3I.getX() ? false : (this.getY() != vec3I.getY() ? false : this.getZ() == vec3I.getZ());
|
|
}
|
|
}
|
|
|
|
public int hashCode() {
|
|
return (this.getY() + this.getZ() * 31) * 31 + this.getX();
|
|
}
|
|
|
|
public int compareTo(Vec3i p_compareTo_1_) {
|
|
return this.getY() == p_compareTo_1_.getY() ? (this.getZ() == p_compareTo_1_.getZ() ? this.getX() - p_compareTo_1_.getX() : this.getZ() - p_compareTo_1_.getZ()) : this.getY() - p_compareTo_1_.getY();
|
|
}
|
|
|
|
/**
|
|
* Get the X coordinate
|
|
* @return the X component
|
|
*/
|
|
public int getX() {
|
|
return this.x;
|
|
}
|
|
|
|
/**
|
|
* Get the Y coordinate
|
|
* @return the Y component
|
|
*/
|
|
public int getY() {
|
|
return this.y;
|
|
}
|
|
|
|
/**
|
|
* Get the Z coordinate
|
|
* @return the Z component
|
|
*/
|
|
public int getZ() {
|
|
return this.z;
|
|
}
|
|
|
|
|
|
/**
|
|
* Get the X coordinate as a double
|
|
* @return the X component as a double
|
|
*/
|
|
public double getXD() {
|
|
return this.xd;
|
|
}
|
|
|
|
/**
|
|
* Get the Y coordinate as a double
|
|
* @return the Y component as a double
|
|
*/
|
|
public double getYD() {
|
|
return this.yd;
|
|
}
|
|
|
|
/**
|
|
* Get the Z coordinate as a double
|
|
* @return the Z component as a double
|
|
*/
|
|
public double getZD() {
|
|
return this.zd;
|
|
}
|
|
|
|
/**
|
|
* Calculate the cross product of this and the given Vector
|
|
* @param vec the other vector
|
|
* @return the cross product of this vector and the given vector
|
|
*/
|
|
public Vec3i crossProduct(Vec3i vec) {
|
|
return new Vec3i(this.getYD() * vec.getZD() - this.getZD() * vec.getYD(), this.getZD() * vec.getXD() - this.getXD() * vec.getZD(), this.getXD() * vec.getYD() - this.getYD() * vec.getXD());
|
|
}
|
|
|
|
public String toString() {
|
|
return Objects.toStringHelper(this).add("x", this.getX()).add("y", this.getY()).add("z", this.getZ()).toString();
|
|
}
|
|
}
|