change package names

This commit is contained in:
Sen 2025-05-07 18:19:24 +02:00
parent 3e70accb76
commit d08d0e11fc
1246 changed files with 9285 additions and 9272 deletions

View file

@ -0,0 +1,111 @@
package common.clipboard;
public class BlockTransform {
private double m00, m01, m02, m03;
private double m10, m11, m12, m13;
private double m20, m21, m22, m23;
public BlockTransform() {
m00 = m11 = m22 = 1;
m01 = m02 = m03 = 0;
m10 = m12 = m13 = 0;
m20 = m21 = m23 = 0;
}
private BlockTransform(double xx, double yx, double zx, double tx,
double xy, double yy, double zy, double ty, double xz, double yz,
double zz, double tz) {
m00 = xx;
m01 = yx;
m02 = zx;
m03 = tx;
m10 = xy;
m11 = yy;
m12 = zy;
m13 = ty;
m20 = xz;
m21 = yz;
m22 = zz;
m23 = tz;
}
private BlockTransform concatenate(BlockTransform that) {
double n00 = m00 * that.m00 + m01 * that.m10 + m02 * that.m20;
double n01 = m00 * that.m01 + m01 * that.m11 + m02 * that.m21;
double n02 = m00 * that.m02 + m01 * that.m12 + m02 * that.m22;
double n03 = m00 * that.m03 + m01 * that.m13 + m02 * that.m23 + m03;
double n10 = m10 * that.m00 + m11 * that.m10 + m12 * that.m20;
double n11 = m10 * that.m01 + m11 * that.m11 + m12 * that.m21;
double n12 = m10 * that.m02 + m11 * that.m12 + m12 * that.m22;
double n13 = m10 * that.m03 + m11 * that.m13 + m12 * that.m23 + m13;
double n20 = m20 * that.m00 + m21 * that.m10 + m22 * that.m20;
double n21 = m20 * that.m01 + m21 * that.m11 + m22 * that.m21;
double n22 = m20 * that.m02 + m21 * that.m12 + m22 * that.m22;
double n23 = m20 * that.m03 + m21 * that.m13 + m22 * that.m23 + m23;
return new BlockTransform(
n00, n01, n02, n03,
n10, n11, n12, n13,
n20, n21, n22, n23);
}
public BlockTransform rotateY(int theta) {
double cot = dCos(theta);
double sit = dSin(theta);
return concatenate(
new BlockTransform(
cot, 0, sit, 0,
0, 1, 0, 0,
-sit, 0, cot, 0));
}
public BlockTransform scale(Vector vec) {
return concatenate(new BlockTransform(vec.getX(), 0, 0, 0, 0, vec.getY(), 0, 0, 0, 0, vec.getZ(), 0));
}
public Vector apply(Vector vector) {
return new Vector(
vector.getX() * m00 + vector.getY() * m01 + vector.getZ() * m02 + m03,
vector.getX() * m10 + vector.getY() * m11 + vector.getZ() * m12 + m13,
vector.getX() * m20 + vector.getY() * m21 + vector.getZ() * m22 + m23);
}
private static double dSin(int degrees) {
if (degrees % 90 == 0) {
degrees %= 360;
if (degrees < 0) {
degrees += 360;
}
switch (degrees) {
case 0:
return 0.0;
case 90:
return 1.0;
case 180:
return 0.0;
case 270:
return -1.0;
}
}
return Math.cos(Math.toRadians(degrees));
}
private static double dCos(int degrees) {
if (degrees % 90 == 0) {
degrees %= 360;
if (degrees < 0) {
degrees += 360;
}
switch (degrees) {
case 0:
return 1.0;
case 90:
return 0.0;
case 180:
return -1.0;
case 270:
return 0.0;
}
}
return Math.cos(Math.toRadians(degrees));
}
}

View file

@ -0,0 +1,33 @@
package common.clipboard;
import common.nbt.NBTTagCompound;
import common.tileentity.TileEntity;
import common.world.State;
public class ClipboardBlock {
private State state;
private NBTTagCompound nbt;
public ClipboardBlock(State state) {
this.state = state;
}
public ClipboardBlock(State data, TileEntity tile) {
this(data);
NBTTagCompound tag = new NBTTagCompound();
tile.writeToNBT(tag);
this.nbt = tag;
}
public State getState() {
return this.state;
}
public void setState(State state) {
this.state = state;
}
public NBTTagCompound getNbtData() {
return this.nbt;
}
}

View file

@ -0,0 +1,166 @@
package common.clipboard;
import java.util.Deque;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import common.block.Block;
import common.block.BlockDoor;
import common.block.BlockRailBase;
import common.block.ITileEntityProvider;
import common.collect.Lists;
import common.init.Blocks;
import common.init.ReorderRegistry;
import common.inventory.IInventory;
import common.tileentity.TileEntity;
import common.world.BlockPos;
import common.world.Vec3i;
import common.world.WorldServer;
public class ClipboardPlacer {
private static class BlockEntry {
private final BlockPos pos;
private final ClipboardBlock block;
private BlockEntry(BlockPos pos, ClipboardBlock block) {
this.pos = pos;
this.block = block;
}
}
private final WorldServer world;
private final List<BlockEntry> stage1 = Lists.newArrayList();
private final List<BlockEntry> stage2 = Lists.newArrayList();
private final List<BlockEntry> stage3 = Lists.newArrayList();
public ClipboardPlacer(WorldServer world) {
this.world = world;
}
public void setBlock(BlockPos location, ClipboardBlock block) {
if(location.getY() < 0 || location.getY() > 511)
return;
Block type = block.getState().getBlock();
if (ReorderRegistry.shouldPlaceLast(type)) {
// Place torches, etc. last
this.stage2.add(new BlockEntry(location, block));
} else if (ReorderRegistry.shouldPlaceFinal(type)) {
// Place signs, reed, etc even later
this.stage3.add(new BlockEntry(location, block));
} else if (ReorderRegistry.shouldPlaceLast(this.world.getState(location).getBlock())) {
// Destroy torches, etc. first
this.setBlockQuirk(location, new ClipboardBlock(Blocks.air.getState()));
this.setBlockQuirk(location, block);
} else {
this.stage1.add(new BlockEntry(location, block));
}
}
private boolean setBlockQuirk(BlockPos location, ClipboardBlock block) {
Block existing = this.world.getState(location).getBlock();
if (existing instanceof ITileEntityProvider) {
TileEntity tile = this.world.getTileEntity(location);
if ((tile instanceof IInventory)) {
IInventory inv = (IInventory) tile;
int size = inv.getSizeInventory();
for (int i = 0; i < size; i++) {
inv.setInventorySlotContents(i, null);
}
}
}
else if (existing == Blocks.ice) {
this.world.setBlock(location, new ClipboardBlock(Blocks.air.getState())); // Ice turns until water so this has to be done first
}
return this.world.setBlock(location, block);
}
public void commit() {
// Iterator<Entry<BlockEntry>> iterator = Iterators.concat(this.stage1.iterator(), this.stage2.iterator());
// while (iterator.hasNext()) {
// Map.Entry<BlockPos, EditBlock> entry = iterator.next();
//
// }
for(BlockEntry entry : this.stage1) {
this.setBlockQuirk(entry.pos, entry.block);
}
this.stage1.clear();
for(BlockEntry entry : this.stage2) {
this.setBlockQuirk(entry.pos, entry.block);
}
this.stage2.clear();
final Set<BlockPos> blocks = new HashSet<BlockPos>();
final Map<BlockPos, ClipboardBlock> blockTypes = new HashMap<BlockPos, ClipboardBlock>();
for(BlockEntry entry : this.stage3) {
// final BlockPos pt = entry.getKey();
blocks.add(entry.pos);
blockTypes.put(entry.pos, entry.block);
}
this.stage3.clear();
while (!blocks.isEmpty()) {
BlockPos current = blocks.iterator().next();
if (!blocks.contains(current)) {
continue;
}
final Deque<BlockPos> walked = new LinkedList<BlockPos>();
while (true) {
walked.addFirst(current);
assert (blockTypes.containsKey(current));
final ClipboardBlock baseBlock = blockTypes.get(current);
final Block type = baseBlock.getState().getBlock();
if(type instanceof BlockDoor) {
if (baseBlock.getState().getValue(BlockDoor.HALF) == BlockDoor.EnumDoorHalf.LOWER) {
// Deal with lower door halves being attached to the floor AND the upper half
BlockPos upperBlock = current.add(0, 1, 0);
if (blocks.contains(upperBlock) && !walked.contains(upperBlock)) {
walked.addFirst(upperBlock);
}
}
}
else if(type instanceof BlockRailBase) {
// Here, rails are hardcoded to be attached to the block below them.
// They're also attached to the block they're ascending towards via BlockType.getAttachment.
BlockPos lowerBlock = current.add(0, -1, 0);
if (blocks.contains(lowerBlock) && !walked.contains(lowerBlock)) {
walked.addFirst(lowerBlock);
}
break;
}
final Vec3i attachment = ReorderRegistry.getAttachment(baseBlock.getState());
if (attachment == null) {
// Block is not attached to anything => we can place it
break;
}
current = current.add(attachment);
if (!blocks.contains(current)) {
// We ran outside the remaining set => assume we can place blocks on this
break;
}
if (walked.contains(current)) {
// Cycle detected => This will most likely go wrong, but there's nothing we can do about it.
break;
}
}
for(BlockPos pt : walked) {
this.setBlockQuirk(pt, blockTypes.get(pt));
blocks.remove(pt);
}
}
}
}

View file

@ -0,0 +1,43 @@
package common.clipboard;
import java.util.function.Predicate;
public class Rotation {
private final RotationValue[] values;
private final boolean[] dirFlags = new boolean[16];
public Rotation(RotationValue[] values, Predicate<Integer> predicate) {
this.values = values;
for(int z = 0; z < 16; z++) {
if(predicate != null && !predicate.test(z)) {
this.dirFlags[z] = false;
continue;
}
boolean flag = false;
for(RotationValue value : values) {
if(value.getDirection() != null) {
flag = true;
break;
}
}
this.dirFlags[z] = flag;
}
}
public RotationValue[] getValues() {
return this.values;
}
public RotationValue getValue(int meta) {
for (RotationValue value : this.values) {
if (value.isSet(meta)) {
return value;
}
}
return null;
}
public boolean hasDirection(int meta) {
return this.dirFlags[meta & 15];
}
}

View file

@ -0,0 +1,25 @@
package common.clipboard;
public class RotationValue {
public final byte mask;
public final byte data;
public final Vector direction;
public RotationValue(byte mask, byte data, Vector direction) {
this.mask = mask;
this.data = data;
this.direction = direction;
}
public boolean isSet(int meta) {
return (meta & mask) == data;
}
public int set(int meta) {
return ((meta & ~mask) | data);
}
public Vector getDirection() {
return direction;
}
}

View file

@ -0,0 +1,802 @@
package common.clipboard;
public class Vector implements Comparable<Vector> {
public static final Vector ZERO = new Vector(0, 0, 0);
protected final double x, y, z;
public Vector(double x, double y, double z) {
this.x = x;
this.y = y;
this.z = z;
}
// /**
// * Construct an instance.
// *
// * @param x the X coordinate
// * @param y the Y coordinate
// * @param z the Z coordinate
// */
// public Vector(int x, int y, int z) {
// this.x = (double) x;
// this.y = (double) y;
// this.z = (double) z;
// }
// /**
// * Construct an instance.
// *
// * @param x the X coordinate
// * @param y the Y coordinate
// * @param z the Z coordinate
// */
// public Vector(float x, float y, float z) {
// this.x = (double) x;
// this.y = (double) y;
// this.z = (double) z;
// }
// /**
// * Copy another vector.
// *
// * @param other another vector to make a copy of
// */
// public Vector(Vector other) {
// this.x = other.x;
// this.y = other.y;
// this.z = other.z;
// }
/**
* Construct a new instance with X, Y, and Z coordinates set to 0.
*
* <p>One can also refer to a static {@link #ZERO}.</p>
*/
public Vector() {
this.x = 0;
this.y = 0;
this.z = 0;
}
/**
* Get the X coordinate.
*
* @return the x coordinate
*/
public double getX() {
return x;
}
/**
* Get the X coordinate rounded.
*
* @return the x coordinate
*/
public int getBlockX() {
return (int) Math.round(x);
}
// /**
// * Set the X coordinate.
// *
// * @param x the new X
// * @return a new vector
// */
// public Vector setX(double x) {
// return new Vector(x, y, z);
// }
// /**
// * Set the X coordinate.
// *
// * @param x the X coordinate
// * @return new vector
// */
// public Vector setX(int x) {
// return new Vector(x, y, z);
// }
/**
* Get the Y coordinate.
*
* @return the y coordinate
*/
public double getY() {
return y;
}
/**
* Get the Y coordinate rounded.
*
* @return the y coordinate
*/
public int getBlockY() {
return (int) Math.round(y);
}
// /**
// * Set the Y coordinate.
// *
// * @param y the new Y
// * @return a new vector
// */
// public Vector setY(double y) {
// return new Vector(x, y, z);
// }
// /**
// * Set the Y coordinate.
// *
// * @param y the new Y
// * @return a new vector
// */
// public Vector setY(int y) {
// return new Vector(x, y, z);
// }
/**
* Get the Z coordinate.
*
* @return the z coordinate
*/
public double getZ() {
return z;
}
/**
* Get the Z coordinate rounded.
*
* @return the z coordinate
*/
public int getBlockZ() {
return (int) Math.round(z);
}
// /**
// * Set the Z coordinate.
// *
// * @param z the new Z
// * @return a new vector
// */
// public Vector setZ(double z) {
// return new Vector(x, y, z);
// }
// /**
// * Set the Z coordinate.
// *
// * @param z the new Z
// * @return a new vector
// */
// public Vector setZ(int z) {
// return new Vector(x, y, z);
// }
// /**
// * Add another vector to this vector and return the result as a new vector.
// *
// * @param other the other vector
// * @return a new vector
// */
// public Vector add(Vector other) {
// return new Vector(x + other.x, y + other.y, z + other.z);
// }
// /**
// * Add another vector to this vector and return the result as a new vector.
// *
// * @param x the value to add
// * @param y the value to add
// * @param z the value to add
// * @return a new vector
// */
// public Vector add(double x, double y, double z) {
// return new Vector(this.x + x, this.y + y, this.z + z);
// }
// /**
// * Add another vector to this vector and return the result as a new vector.
// *
// * @param x the value to add
// * @param y the value to add
// * @param z the value to add
// * @return a new vector
// */
// public Vector add(int x, int y, int z) {
// return new Vector(this.x + x, this.y + y, this.z + z);
// }
// /**
// * Add a list of vectors to this vector and return the
// * result as a new vector.
// *
// * @param others an array of vectors
// * @return a new vector
// */
// public Vector add(Vector... others) {
// double newX = x, newY = y, newZ = z;
//
// for (Vector other : others) {
// newX += other.x;
// newY += other.y;
// newZ += other.z;
// }
//
// return new Vector(newX, newY, newZ);
// }
/**
* Subtract another vector from this vector and return the result
* as a new vector.
*
* @param other the other vector
* @return a new vector
*/
public Vector subtract(Vector other) {
return new Vector(x - other.x, y - other.y, z - other.z);
}
// /**
// * Subtract another vector from this vector and return the result
// * as a new vector.
// *
// * @param x the value to subtract
// * @param y the value to subtract
// * @param z the value to subtract
// * @return a new vector
// */
// public Vector subtract(double x, double y, double z) {
// return new Vector(this.x - x, this.y - y, this.z - z);
// }
// /**
// * Subtract another vector from this vector and return the result
// * as a new vector.
// *
// * @param x the value to subtract
// * @param y the value to subtract
// * @param z the value to subtract
// * @return a new vector
// */
// public Vector subtract(int x, int y, int z) {
// return new Vector(this.x - x, this.y - y, this.z - z);
// }
//
// /**
// * Subtract a list of vectors from this vector and return the result
// * as a new vector.
// *
// * @param others an array of vectors
// * @return a new vector
// */
// public Vector subtract(Vector... others) {
// double newX = x, newY = y, newZ = z;
//
// for (Vector other : others) {
// newX -= other.x;
// newY -= other.y;
// newZ -= other.z;
// }
//
// return new Vector(newX, newY, newZ);
// }
// /**
// * Multiply this vector by another vector on each component.
// *
// * @param other the other vector
// * @return a new vector
// */
// public Vector multiply(Vector other) {
// return new Vector(x * other.x, y * other.y, z * other.z);
// }
// /**
// * Multiply this vector by another vector on each component.
// *
// * @param x the value to multiply
// * @param y the value to multiply
// * @param z the value to multiply
// * @return a new vector
// */
// public Vector multiply(double x, double y, double z) {
// return new Vector(this.x * x, this.y * y, this.z * z);
// }
//
// /**
// * Multiply this vector by another vector on each component.
// *
// * @param x the value to multiply
// * @param y the value to multiply
// * @param z the value to multiply
// * @return a new vector
// */
// public Vector multiply(int x, int y, int z) {
// return new Vector(this.x * x, this.y * y, this.z * z);
// }
//
// /**
// * Multiply this vector by zero or more vectors on each component.
// *
// * @param others an array of vectors
// * @return a new vector
// */
// public Vector multiply(Vector... others) {
// double newX = x, newY = y, newZ = z;
//
// for (Vector other : others) {
// newX *= other.x;
// newY *= other.y;
// newZ *= other.z;
// }
//
// return new Vector(newX, newY, newZ);
// }
// /**
// * Perform scalar multiplication and return a new vector.
// *
// * @param n the value to multiply
// * @return a new vector
// */
// public Vector multiply(double n) {
// return new Vector(this.x * n, this.y * n, this.z * n);
// }
// /**
// * Perform scalar multiplication and return a new vector.
// *
// * @param n the value to multiply
// * @return a new vector
// */
// public Vector multiply(float n) {
// return new Vector(this.x * n, this.y * n, this.z * n);
// }
// /**
// * Perform scalar multiplication and return a new vector.
// *
// * @param n the value to multiply
// * @return a new vector
// */
// public Vector multiply(int n) {
// return new Vector(this.x * n, this.y * n, this.z * n);
// }
//
// /**
// * Divide this vector by another vector on each component.
// *
// * @param other the other vector
// * @return a new vector
// */
// public Vector divide(Vector other) {
// return new Vector(x / other.x, y / other.y, z / other.z);
// }
// /**
// * Divide this vector by another vector on each component.
// *
// * @param x the value to divide by
// * @param y the value to divide by
// * @param z the value to divide by
// * @return a new vector
// */
// public Vector divide(double x, double y, double z) {
// return new Vector(this.x / x, this.y / y, this.z / z);
// }
//
// /**
// * Divide this vector by another vector on each component.
// *
// * @param x the value to divide by
// * @param y the value to divide by
// * @param z the value to divide by
// * @return a new vector
// */
// public Vector divide(int x, int y, int z) {
// return new Vector(this.x / x, this.y / y, this.z / z);
// }
// /**
// * Perform scalar division and return a new vector.
// *
// * @param n the value to divide by
// * @return a new vector
// */
// public Vector divide(int n) {
// return new Vector(x / n, y / n, z / n);
// }
/**
* Perform scalar division and return a new vector.
*
* @param n the value to divide by
* @return a new vector
*/
public Vector divide(double n) {
return new Vector(x / n, y / n, z / n);
}
// /**
// * Perform scalar division and return a new vector.
// *
// * @param n the value to divide by
// * @return a new vector
// */
// public Vector divide(float n) {
// return new Vector(x / n, y / n, z / n);
// }
/**
* Get the length of the vector.
*
* @return length
*/
public double length() {
return Math.sqrt(x * x + y * y + z * z);
}
// /**
// * Get the length, squared, of the vector.
// *
// * @return length, squared
// */
// public double lengthSq() {
// return x * x + y * y + z * z;
// }
// /**
// * Get the distance between this vector and another vector.
// *
// * @param other the other vector
// * @return distance
// */
// public double distance(Vector other) {
// return Math.sqrt(Math.pow(other.x - x, 2) +
// Math.pow(other.y - y, 2) +
// Math.pow(other.z - z, 2));
// }
// /**
// * Get the distance between this vector and another vector, squared.
// *
// * @param other the other vector
// * @return distance
// */
// public double distanceSq(Vector other) {
// return Math.pow(other.x - x, 2) +
// Math.pow(other.y - y, 2) +
// Math.pow(other.z - z, 2);
// }
/**
* Get the normalized vector, which is the vector divided by its
* length, as a new vector.
*
* @return a new vector
*/
public Vector normalize() {
return divide(length());
}
/**
* Gets the dot product of this and another vector.
*
* @param other the other vector
* @return the dot product of this and the other vector
*/
public double dot(Vector other) {
return x * other.x + y * other.y + z * other.z;
}
// /**
// * Gets the cross product of this and another vector.
// *
// * @param other the other vector
// * @return the cross product of this and the other vector
// */
// public Vector cross(Vector other) {
// return new Vector(
// y * other.z - z * other.y,
// z * other.x - x * other.z,
// x * other.y - y * other.x
// );
// }
//
// /**
// * Checks to see if a vector is contained with another.
// *
// * @param min the minimum point (X, Y, and Z are the lowest)
// * @param max the maximum point (X, Y, and Z are the lowest)
// * @return true if the vector is contained
// */
// public boolean containedWithin(Vector min, Vector max) {
// return x >= min.x && x <= max.x && y >= min.y && y <= max.y && z >= min.z && z <= max.z;
// }
//
// /**
// * Checks to see if a vector is contained with another, comparing
// * using discrete comparisons, inclusively.
// *
// * @param min the minimum point (X, Y, and Z are the lowest)
// * @param max the maximum point (X, Y, and Z are the lowest)
// * @return true if the vector is contained
// */
// public boolean containedWithinBlock(Vector min, Vector max) {
// return getBlockX() >= min.getBlockX() && getBlockX() <= max.getBlockX()
// && getBlockY() >= min.getBlockY() && getBlockY() <= max.getBlockY()
// && getBlockZ() >= min.getBlockZ() && getBlockZ() <= max.getBlockZ();
// }
/**
* Clamp the Y component.
*
* @param min the minimum value
* @param max the maximum value
* @return a new vector
*/
public Vector clampY(int min, int max) {
return new Vector(x, Math.max(min, Math.min(max, y)), z);
}
// /**
// * Floors the values of all components.
// *
// * @return a new vector
// */
// public Vector floor() {
// return new Vector(Math.floor(x), Math.floor(y), Math.floor(z));
// }
//
// /**
// * Rounds all components up.
// *
// * @return a new vector
// */
// public Vector ceil() {
// return new Vector(Math.ceil(x), Math.ceil(y), Math.ceil(z));
// }
//
// /**
// * Rounds all components to the closest integer.
// *
// * <p>Components &lt; 0.5 are rounded down, otherwise up.</p>
// *
// * @return a new vector
// */
// public Vector round() {
// return new Vector(Math.floor(x + 0.5), Math.floor(y + 0.5), Math.floor(z + 0.5));
// }
// /**
// * Returns a vector with the absolute values of the components of
// * this vector.
// *
// * @return a new vector
// */
// public Vector positive() {
// return new Vector(Math.abs(x), Math.abs(y), Math.abs(z));
// }
// /**
// * Perform a 2D transformation on this vector and return a new one.
// *
// * @param angle in degrees
// * @param aboutX about which x coordinate to rotate
// * @param aboutZ about which z coordinate to rotate
// * @param translateX what to add after rotation
// * @param translateZ what to add after rotation
// * @return a new vector
// * @see AffineTransform another method to transform vectors
// */
// public Vector transform2D(double angle, double aboutX, double aboutZ, double translateX, double translateZ) {
// angle = Math.toRadians(angle);
// double x = this.x - aboutX;
// double z = this.z - aboutZ;
// double x2 = x * Math.cos(angle) - z * Math.sin(angle);
// double z2 = x * Math.sin(angle) + z * Math.cos(angle);
//
// return new Vector(
// x2 + aboutX + translateX,
// y,
// z2 + aboutZ + translateZ
// );
// }
//
// /**
// * Returns whether this vector is collinear with another vector.
// *
// * @param other the other vector
// * @return true if collinear
// */
// public boolean isCollinearWith(Vector other) {
// if (x == 0 && y == 0 && z == 0) {
// // this is a zero vector
// return true;
// }
//
// final double otherX = other.x;
// final double otherY = other.y;
// final double otherZ = other.z;
//
// if (otherX == 0 && otherY == 0 && otherZ == 0) {
// // other is a zero vector
// return true;
// }
//
// if ((x == 0) != (otherX == 0)) return false;
// if ((y == 0) != (otherY == 0)) return false;
// if ((z == 0) != (otherZ == 0)) return false;
//
// final double quotientX = otherX / x;
// if (!Double.isNaN(quotientX)) {
// return other.equals(multiply(quotientX));
// }
//
// final double quotientY = otherY / y;
// if (!Double.isNaN(quotientY)) {
// return other.equals(multiply(quotientY));
// }
//
// final double quotientZ = otherZ / z;
// if (!Double.isNaN(quotientZ)) {
// return other.equals(multiply(quotientZ));
// }
//
// throw new RuntimeException("This should not happen");
// }
// /**
// * Get this vector's pitch as used within the game.
// *
// * @return pitch in radians
// */
// public float toPitch() {
// double x = getX();
// double z = getZ();
//
// if (x == 0 && z == 0) {
// return getY() > 0 ? -90 : 90;
// } else {
// double x2 = x * x;
// double z2 = z * z;
// double xz = Math.sqrt(x2 + z2);
// return (float) Math.toDegrees(Math.atan(-getY() / xz));
// }
// }
// /**
// * Get this vector's yaw as used within the game.
// *
// * @return yaw in radians
// */
// public float toYaw() {
// double x = getX();
// double z = getZ();
//
// double t = Math.atan2(-x, z);
// double _2pi = 2 * Math.PI;
//
// return (float) Math.toDegrees(((t + _2pi) % _2pi));
// }
// /**
// * Create a new {@code BlockVector} using the given components.
// *
// * @param x the X coordinate
// * @param y the Y coordinate
// * @param z the Z coordinate
// * @return a new {@code BlockVector}
// */
// public static BlockVector toBlockPoint(double x, double y, double z) {
// return new BlockVector(
// Math.floor(x),
// Math.floor(y),
// Math.floor(z)
// );
// }
// /**
// * Create a new {@code BlockVector} from this vector.
// *
// * @return a new {@code BlockVector}
// */
// public BlockVector toBlockVector() {
// return new BlockVector(this);
// }
// /**
// * Creates a 2D vector by dropping the Y component from this vector.
// *
// * @return a new {@code Vector2D}
// */
// public Vector2D toVector2D() {
// return new Vector2D(x, z);
// }
@Override
public boolean equals(Object obj) {
if (!(obj instanceof Vector)) {
return false;
}
Vector other = (Vector) obj;
return other.x == this.x && other.y == this.y && other.z == this.z;
}
@Override
public int compareTo(Vector other) {
if (other == null) {
throw new IllegalArgumentException("null not supported");
}
if (y != other.y) return Double.compare(y, other.y);
if (z != other.z) return Double.compare(z, other.z);
if (x != other.x) return Double.compare(x, other.x);
return 0;
}
@Override
public int hashCode() {
int hash = 7;
hash = 79 * hash + (int) (Double.doubleToLongBits(this.x) ^ (Double.doubleToLongBits(this.x) >>> 32));
hash = 79 * hash + (int) (Double.doubleToLongBits(this.y) ^ (Double.doubleToLongBits(this.y) >>> 32));
hash = 79 * hash + (int) (Double.doubleToLongBits(this.z) ^ (Double.doubleToLongBits(this.z) >>> 32));
return hash;
}
@Override
public String toString() {
return x + ", " + y + ", " + z;
}
// /**
// * Gets the minimum components of two vectors.
// *
// * @param v1 the first vector
// * @param v2 the second vector
// * @return minimum
// */
// public static Vector getMinimum(Vector v1, Vector v2) {
// return new Vector(
// Math.min(v1.x, v2.x),
// Math.min(v1.y, v2.y),
// Math.min(v1.z, v2.z)
// );
// }
//
// /**
// * Gets the maximum components of two vectors.
// *
// * @param v1 the first vector
// * @param v2 the second vector
// * @return maximum
// */
// public static Vector getMaximum(Vector v1, Vector v2) {
// return new Vector(
// Math.max(v1.x, v2.x),
// Math.max(v1.y, v2.y),
// Math.max(v1.z, v2.z)
// );
// }
// /**
// * Gets the midpoint of two vectors.
// *
// * @param v1 the first vector
// * @param v2 the second vector
// * @return maximum
// */
// public static Vector getMidpoint(Vector v1, Vector v2) {
// return new Vector(
// (v1.x + v2.x) / 2,
// (v1.y + v2.y) / 2,
// (v1.z + v2.z) / 2
// );
// }
// public BlockPos toBlockPos() {
// return new BlockPos(x, y, z);
// }
}