mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-12-22 17:27:38 +00:00
Fix compatibility with WorldGuard (#2743)
* Make the Vector classes into Records (#2477) * Make the Vector classes into Records * Drop custom equals and hashCode methods in Vector/BlockVector classes (cherry picked from commit 0df2b6af4c1ce18b77eedd5c62eeb45011512103) Signed-off-by: Pierre Maurice Schwang <mail@pschwang.eu> * chore: cleanup cherry-pick issues, migrate to new methods * chore: add since attributes to deprecated tags, use MathMan instead of Math std lib for rounding ints * chore: mark custom hashCode + equals implementations diffing from upstream --------- Co-authored-by: Maddy Miller <mnmiller1@me.com>
This commit is contained in:
parent
f9c523c173
commit
c77d34156b
@ -12,6 +12,6 @@ repositories {
|
||||
|
||||
dependencies {
|
||||
// url=https://repo.papermc.io/service/rest/repository/browse/maven-public/io/papermc/paper/dev-bundle/1.20.6-R0.1-SNAPSHOT/
|
||||
the<PaperweightUserDependenciesExtension>().paperDevBundle("1.20.6-R0.1-20240520.005421-60")
|
||||
the<PaperweightUserDependenciesExtension>().paperDevBundle("1.20.6-R0.1-20240523.202134-70")
|
||||
compileOnly(libs.paperlib)
|
||||
}
|
||||
|
@ -31,18 +31,18 @@ public abstract class AbstractFilterBlock extends FilterBlock {
|
||||
public abstract Extent getExtent();
|
||||
|
||||
@Override
|
||||
public int getX() {
|
||||
return getPosition().getX();
|
||||
public int x() {
|
||||
return getPosition().x();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getY() {
|
||||
return getPosition().getY();
|
||||
public int y() {
|
||||
return getPosition().y();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getZ() {
|
||||
return getPosition().getZ();
|
||||
public int z() {
|
||||
return getPosition().z();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -72,12 +72,12 @@ public abstract class AbstractFilterBlock extends FilterBlock {
|
||||
|
||||
@Override
|
||||
public BlockVector3 getMinimumPoint() {
|
||||
return at(getX(), getY(), getZ());
|
||||
return at(x(), y(), z());
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockVector3 getMaximumPoint() {
|
||||
return at(getX(), getY(), getZ());
|
||||
return at(x(), y(), z());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -88,7 +88,7 @@ public abstract class AbstractFilterBlock extends FilterBlock {
|
||||
@Override
|
||||
public <T extends BlockStateHolder<T>> boolean setBlock(int x, int y, int z, T block)
|
||||
throws WorldEditException {
|
||||
if (x == this.getX() && y == this.getY() && z == this.getZ()) {
|
||||
if (x == this.x() && y == this.y() && z == this.z()) {
|
||||
setFullBlock(block.toBaseBlock());
|
||||
return true;
|
||||
}
|
||||
@ -97,7 +97,7 @@ public abstract class AbstractFilterBlock extends FilterBlock {
|
||||
|
||||
@Override
|
||||
public boolean setBiome(int x, int y, int z, BiomeType biome) {
|
||||
if (x == this.getX() && y == this.getY() && z == this.getZ()) {
|
||||
if (x == this.x() && y == this.y() && z == this.z()) {
|
||||
setBiome(biome);
|
||||
return true;
|
||||
}
|
||||
|
@ -80,17 +80,17 @@ public class ArrayFilterBlock extends AbstractExtentFilterBlock {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getX() {
|
||||
public int x() {
|
||||
return x;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getY() {
|
||||
public int y() {
|
||||
return (heights[index] & 0xFF) + yOffset;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getZ() {
|
||||
public int z() {
|
||||
return z;
|
||||
}
|
||||
|
||||
@ -112,12 +112,12 @@ public class ArrayFilterBlock extends AbstractExtentFilterBlock {
|
||||
|
||||
@Override
|
||||
public void setBiome(final BiomeType biome) {
|
||||
getExtent().setBiome(getX(), getY(), getZ(), biome);
|
||||
getExtent().setBiome(x(), y(), z(), biome);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BiomeType getBiome() {
|
||||
return getExtent().getBiomeType(getX(), getY(), getZ());
|
||||
return getExtent().getBiomeType(x(), y(), z());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -190,17 +190,17 @@ public class CharFilterBlock extends ChunkFilterBlock {
|
||||
}
|
||||
|
||||
@Override
|
||||
public final int getX() {
|
||||
public final int x() {
|
||||
return xx + x;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final int getY() {
|
||||
public final int y() {
|
||||
return yy + y;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final int getZ() {
|
||||
public final int z() {
|
||||
return zz + z;
|
||||
}
|
||||
|
||||
@ -304,7 +304,7 @@ public class CharFilterBlock extends ChunkFilterBlock {
|
||||
if (z > 0) {
|
||||
return states[getArr[index - 16]];
|
||||
}
|
||||
return getExtent().getBlock(getX(), getY(), getZ() - 1);
|
||||
return getExtent().getBlock(x(), y(), z() - 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -312,7 +312,7 @@ public class CharFilterBlock extends ChunkFilterBlock {
|
||||
if (x < 15) {
|
||||
return states[getArr[index + 1]];
|
||||
}
|
||||
return getExtent().getBlock(getX() + 1, getY(), getZ());
|
||||
return getExtent().getBlock(x() + 1, y(), z());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -320,7 +320,7 @@ public class CharFilterBlock extends ChunkFilterBlock {
|
||||
if (z < 15) {
|
||||
return states[getArr[index + 16]];
|
||||
}
|
||||
return getExtent().getBlock(getX(), getY(), getZ() + 1);
|
||||
return getExtent().getBlock(x(), y(), z() + 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -328,7 +328,7 @@ public class CharFilterBlock extends ChunkFilterBlock {
|
||||
if (x > 0) {
|
||||
return states[getArr[index - 1]];
|
||||
}
|
||||
return getExtent().getBlock(getX() - 1, getY(), getZ());
|
||||
return getExtent().getBlock(x() - 1, y(), z());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -401,7 +401,7 @@ public class CharFilterBlock extends ChunkFilterBlock {
|
||||
|
||||
@Override
|
||||
public boolean setBiome(BlockVector3 position, BiomeType biome) {
|
||||
return setBiome(position.getX(), position.getY(), position.getBlockZ(), biome);
|
||||
return setBiome(position.x(), position.y(), position.z(), biome);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -73,60 +73,60 @@ public abstract class FilterBlock extends BlockVector3 implements Extent, TileEn
|
||||
}
|
||||
|
||||
public BlockState getBlockBelow() {
|
||||
return getBlock(getX(), getY() - 1, getZ());
|
||||
return getBlock(x(), y() - 1, z());
|
||||
}
|
||||
|
||||
public BlockState getBlockAbove() {
|
||||
return getBlock(getX(), getY() + 1, getZ());
|
||||
return getBlock(x(), y() + 1, z());
|
||||
}
|
||||
|
||||
public BlockState getBlockNorth() {
|
||||
return getBlock(getX(), getY(), getZ() - 1);
|
||||
return getBlock(x(), y(), z() - 1);
|
||||
}
|
||||
|
||||
public BlockState getBlockEast() {
|
||||
return getBlock(getX() + 1, getY(), getZ());
|
||||
return getBlock(x() + 1, y(), z());
|
||||
}
|
||||
|
||||
public BlockState getBlockSouth() {
|
||||
return getBlock(getX(), getY(), getZ() + 1);
|
||||
return getBlock(x(), y(), z() + 1);
|
||||
}
|
||||
|
||||
public BlockState getBlockWest() {
|
||||
return getBlock(getX() - 1, getY(), getZ());
|
||||
return getBlock(x() - 1, y(), z());
|
||||
}
|
||||
|
||||
public BlockState getBlockRelativeY(int y) {
|
||||
return getBlock(getX(), getY() + y, getZ());
|
||||
return getBlock(x(), y() + y, z());
|
||||
}
|
||||
|
||||
@Override
|
||||
public abstract int getX();
|
||||
public abstract int x();
|
||||
|
||||
@Override
|
||||
public abstract int getY();
|
||||
public abstract int y();
|
||||
|
||||
@Override
|
||||
public abstract int getZ();
|
||||
public abstract int z();
|
||||
|
||||
public int getLocalX() {
|
||||
return getX() & 15;
|
||||
return x() & 15;
|
||||
}
|
||||
|
||||
public int getLocalY() {
|
||||
return getY() & 15;
|
||||
return y() & 15;
|
||||
}
|
||||
|
||||
public int getLocalZ() {
|
||||
return getZ() & 15;
|
||||
return z() & 15;
|
||||
}
|
||||
|
||||
public int getChunkX() {
|
||||
return getX() >> 4;
|
||||
return x() >> 4;
|
||||
}
|
||||
|
||||
public int getChunkZ() {
|
||||
return getZ() >> 4;
|
||||
return z() >> 4;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -204,7 +204,7 @@ public abstract class FilterBlock extends BlockVector3 implements Extent, TileEn
|
||||
|
||||
@Override
|
||||
public boolean setBiome(BlockVector3 position, BiomeType biome) {
|
||||
return setBiome(position.getX(), position.getY(), position.getZ(), biome);
|
||||
return setBiome(position.x(), position.y(), position.z(), biome);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -17,17 +17,17 @@ public class SingleFilterBlock extends AbstractSingleFilterBlock {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getX() {
|
||||
public int x() {
|
||||
return x;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getY() {
|
||||
public int y() {
|
||||
return y;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getZ() {
|
||||
public int z() {
|
||||
return z;
|
||||
}
|
||||
|
||||
|
@ -95,13 +95,8 @@ public class DelegateBlockVector3 extends BlockVector3 {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getX() {
|
||||
return parent.getX();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBlockX() {
|
||||
return parent.getBlockX();
|
||||
public int x() {
|
||||
return parent.x();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -110,13 +105,8 @@ public class DelegateBlockVector3 extends BlockVector3 {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getY() {
|
||||
return parent.getY();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBlockY() {
|
||||
return parent.getBlockY();
|
||||
public int y() {
|
||||
return parent.y();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -125,13 +115,8 @@ public class DelegateBlockVector3 extends BlockVector3 {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getZ() {
|
||||
return parent.getZ();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBlockZ() {
|
||||
return parent.getBlockZ();
|
||||
public int z() {
|
||||
return parent.z();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -21,11 +21,11 @@ public class MutableBlockVector3 extends BlockVector3 {
|
||||
}
|
||||
|
||||
public MutableBlockVector3(BlockVector3 other) {
|
||||
this(other.getX(), other.getY(), other.getZ());
|
||||
this(other.x(), other.y(), other.z());
|
||||
}
|
||||
|
||||
public MutableBlockVector3 setComponents(BlockVector3 other) {
|
||||
return setComponents(other.getBlockX(), other.getBlockY(), other.getBlockZ());
|
||||
return setComponents(other.x(), other.y(), other.z());
|
||||
}
|
||||
|
||||
private int x;
|
||||
@ -47,33 +47,33 @@ public class MutableBlockVector3 extends BlockVector3 {
|
||||
}
|
||||
|
||||
@Override
|
||||
public final int getX() {
|
||||
public final int x() {
|
||||
return x;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final int getY() {
|
||||
public final int y() {
|
||||
return y;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final int getZ() {
|
||||
public final int z() {
|
||||
return z;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockVector3 getMinimum(BlockVector3 v2) {
|
||||
this.x = Math.min(v2.getX(), x);
|
||||
this.y = Math.min(v2.getY(), y);
|
||||
this.z = Math.min(v2.getZ(), z);
|
||||
this.x = Math.min(v2.x(), x);
|
||||
this.y = Math.min(v2.y(), y);
|
||||
this.z = Math.min(v2.z(), z);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockVector3 getMaximum(BlockVector3 v2) {
|
||||
this.x = Math.max(v2.getX(), x);
|
||||
this.y = Math.max(v2.getY(), y);
|
||||
this.z = Math.max(v2.getZ(), z);
|
||||
this.x = Math.max(v2.x(), x);
|
||||
this.y = Math.max(v2.y(), y);
|
||||
this.z = Math.max(v2.z(), z);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -23,7 +23,7 @@ public class MutableVector3 extends Vector3 {
|
||||
}
|
||||
|
||||
public MutableVector3(Vector3 other) {
|
||||
this(other.getX(), other.getY(), other.getZ());
|
||||
this(other.x(), other.y(), other.z());
|
||||
}
|
||||
|
||||
public static MutableVector3 get(int x, int y, int z) {
|
||||
@ -36,9 +36,9 @@ public class MutableVector3 extends Vector3 {
|
||||
|
||||
@Override
|
||||
public MutableVector3 setComponents(Vector3 other) {
|
||||
this.x = other.getX();
|
||||
this.y = other.getY();
|
||||
this.z = other.getZ();
|
||||
this.x = other.x();
|
||||
this.y = other.y();
|
||||
this.z = other.z();
|
||||
return this;
|
||||
}
|
||||
|
||||
@ -95,17 +95,17 @@ public class MutableVector3 extends Vector3 {
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getX() {
|
||||
public double x() {
|
||||
return x;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getY() {
|
||||
public double y() {
|
||||
return y;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getZ() {
|
||||
public double z() {
|
||||
return z;
|
||||
}
|
||||
|
||||
|
@ -11,18 +11,18 @@ public class OffsetBlockVector3 extends DelegateBlockVector3 {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getX() {
|
||||
return super.getX() + offset.getX();
|
||||
public int x() {
|
||||
return super.x() + offset.x();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getY() {
|
||||
return super.getY() + offset.getY();
|
||||
public int y() {
|
||||
return super.y() + offset.y();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getZ() {
|
||||
return super.getZ() + offset.getZ();
|
||||
public int z() {
|
||||
return super.z() + offset.z();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -15,21 +15,21 @@ public class Vector3Impl extends Vector3 {
|
||||
}
|
||||
|
||||
public Vector3Impl(Vector3 other) {
|
||||
this(other.getX(), other.getY(), other.getZ());
|
||||
this(other.x(), other.y(), other.z());
|
||||
}
|
||||
|
||||
@Override
|
||||
public final double getX() {
|
||||
public final double x() {
|
||||
return x;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final double getY() {
|
||||
public final double y() {
|
||||
return y;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final double getZ() {
|
||||
public final double z() {
|
||||
return z;
|
||||
}
|
||||
|
||||
|
@ -27,7 +27,7 @@ import java.util.Comparator;
|
||||
/**
|
||||
* An immutable 2-dimensional vector.
|
||||
*/
|
||||
//FAWE start - un-finalize
|
||||
//FAWE start - not a record
|
||||
public class BlockVector2 {
|
||||
//FAWE end
|
||||
|
||||
@ -122,7 +122,19 @@ public class BlockVector2 {
|
||||
* Get the X coordinate.
|
||||
*
|
||||
* @return the x coordinate
|
||||
* @since TODO
|
||||
*/
|
||||
public int x() {
|
||||
return x;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the X coordinate.
|
||||
*
|
||||
* @return the x coordinate
|
||||
* @deprecated use {@link #x()} instead
|
||||
*/
|
||||
@Deprecated(forRemoval = true, since = "TODO")
|
||||
public int getX() {
|
||||
return x;
|
||||
}
|
||||
@ -131,7 +143,9 @@ public class BlockVector2 {
|
||||
* Get the X coordinate.
|
||||
*
|
||||
* @return the x coordinate
|
||||
* @deprecated use {@link #x()} instead
|
||||
*/
|
||||
@Deprecated(forRemoval = true, since = "TODO")
|
||||
public int getBlockX() {
|
||||
return x;
|
||||
}
|
||||
@ -150,7 +164,19 @@ public class BlockVector2 {
|
||||
* Get the Z coordinate.
|
||||
*
|
||||
* @return the z coordinate
|
||||
* @since TODO
|
||||
*/
|
||||
public int z() {
|
||||
return z;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Z coordinate.
|
||||
*
|
||||
* @return the z coordinate
|
||||
* @deprecated use {@link #z()} instead
|
||||
*/
|
||||
@Deprecated(forRemoval = true, since = "TODO")
|
||||
public int getZ() {
|
||||
return z;
|
||||
}
|
||||
@ -159,7 +185,9 @@ public class BlockVector2 {
|
||||
* Get the Z coordinate.
|
||||
*
|
||||
* @return the z coordinate
|
||||
* @deprecated use {@link #z()} instead
|
||||
*/
|
||||
@Deprecated(forRemoval = true, since = "TODO")
|
||||
public int getBlockZ() {
|
||||
return z;
|
||||
}
|
||||
@ -598,13 +626,13 @@ public class BlockVector2 {
|
||||
return BlockVector3.at(x, y, z);
|
||||
}
|
||||
|
||||
//FAWE start - not a record, need own implementations
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (!(obj instanceof BlockVector2)) {
|
||||
if (!(obj instanceof BlockVector2 other)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
BlockVector2 other = (BlockVector2) obj;
|
||||
return other.x == this.x && other.z == this.z;
|
||||
|
||||
}
|
||||
@ -613,6 +641,7 @@ public class BlockVector2 {
|
||||
public int hashCode() {
|
||||
return (x << 16) ^ z;
|
||||
}
|
||||
//FAWE end
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
|
@ -38,7 +38,9 @@ import static com.sk89q.worldedit.math.BitMath.unpackZ;
|
||||
/**
|
||||
* An immutable 3-dimensional vector.
|
||||
*/
|
||||
//FAWE start - not a record
|
||||
public abstract class BlockVector3 {
|
||||
//FAWE end
|
||||
|
||||
public static final BlockVector3 ZERO = BlockVector3.at(0, 0, 0);
|
||||
public static final BlockVector3 UNIT_X = BlockVector3.at(1, 0, 0);
|
||||
@ -85,9 +87,9 @@ public abstract class BlockVector3 {
|
||||
}
|
||||
|
||||
public static boolean isLongPackable(BlockVector3 location) {
|
||||
return isHorizontallyInBounds(location.getX())
|
||||
&& isHorizontallyInBounds(location.getZ())
|
||||
&& WORLD_Y_MIN <= location.getY() && location.getY() <= WORLD_Y_MAX;
|
||||
return isHorizontallyInBounds(location.x())
|
||||
&& isHorizontallyInBounds(location.z())
|
||||
&& WORLD_Y_MIN <= location.y() && location.y() <= WORLD_Y_MAX;
|
||||
}
|
||||
|
||||
public static void checkLongPackable(BlockVector3 location) {
|
||||
@ -107,9 +109,9 @@ public abstract class BlockVector3 {
|
||||
private static final class YzxOrderComparator {
|
||||
|
||||
private static final Comparator<BlockVector3> YZX_ORDER =
|
||||
Comparator.comparingInt(BlockVector3::getY)
|
||||
.thenComparingInt(BlockVector3::getZ)
|
||||
.thenComparingInt(BlockVector3::getX);
|
||||
Comparator.comparingInt(BlockVector3::y)
|
||||
.thenComparingInt(BlockVector3::z)
|
||||
.thenComparingInt(BlockVector3::x);
|
||||
|
||||
}
|
||||
|
||||
@ -135,57 +137,69 @@ public abstract class BlockVector3 {
|
||||
|
||||
public long toLongPackedForm() {
|
||||
checkLongPackable(this);
|
||||
return (getX() & BITS_26) | ((getZ() & BITS_26) << 26) | (((getY() & BITS_12) << (26 + 26)));
|
||||
return (x() & BITS_26) | ((z() & BITS_26) << 26) | (((y() & BITS_12) << (26 + 26)));
|
||||
}
|
||||
|
||||
public MutableBlockVector3 mutX(double x) {
|
||||
return new MutableBlockVector3((int) x, getY(), getZ());
|
||||
return new MutableBlockVector3((int) x, y(), z());
|
||||
}
|
||||
|
||||
public MutableBlockVector3 mutY(double y) {
|
||||
return new MutableBlockVector3(getX(), (int) y, getZ());
|
||||
return new MutableBlockVector3(x(), (int) y, z());
|
||||
}
|
||||
|
||||
public MutableBlockVector3 mutZ(double z) {
|
||||
return new MutableBlockVector3(getX(), getY(), (int) z);
|
||||
return new MutableBlockVector3(x(), y(), (int) z);
|
||||
}
|
||||
|
||||
public MutableBlockVector3 mutX(int x) {
|
||||
return new MutableBlockVector3(x, getY(), getZ());
|
||||
return new MutableBlockVector3(x, y(), z());
|
||||
}
|
||||
|
||||
public MutableBlockVector3 mutY(int y) {
|
||||
return new MutableBlockVector3(getX(), y, getZ());
|
||||
return new MutableBlockVector3(x(), y, z());
|
||||
}
|
||||
|
||||
public MutableBlockVector3 mutZ(int z) {
|
||||
return new MutableBlockVector3(getX(), getY(), z);
|
||||
return new MutableBlockVector3(x(), y(), z);
|
||||
}
|
||||
|
||||
public BlockVector3 toImmutable() {
|
||||
return BlockVector3.at(getX(), getY(), getZ());
|
||||
return BlockVector3.at(x(), y(), z());
|
||||
}
|
||||
//FAWE end
|
||||
|
||||
//FAWE start - make record getters to abstract methods
|
||||
/**
|
||||
* Get the X coordinate.
|
||||
*
|
||||
* @return the x coordinate
|
||||
* @since TODO
|
||||
*/
|
||||
//FAWE start - Made abstract
|
||||
public abstract int getX();
|
||||
public abstract int x();
|
||||
//FAWE end
|
||||
|
||||
/**
|
||||
* Get the X coordinate.
|
||||
*
|
||||
* @return the x coordinate
|
||||
* @deprecated use {@link #x()} instead
|
||||
*/
|
||||
//FAWE start - getter
|
||||
@Deprecated(forRemoval = true, since = "TODO")
|
||||
public int getX() {
|
||||
return this.x(); //FAWE - access abstract getter instead of local field
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the X coordinate.
|
||||
*
|
||||
* @return the x coordinate
|
||||
* @deprecated use {@link #x()} instead
|
||||
*/
|
||||
@Deprecated(forRemoval = true, since = "TODO")
|
||||
public int getBlockX() {
|
||||
return getX();
|
||||
return this.x(); //FAWE - access abstract getter instead of local field
|
||||
}
|
||||
//FAWE end
|
||||
|
||||
/**
|
||||
* Set the X coordinate.
|
||||
@ -195,29 +209,42 @@ public abstract class BlockVector3 {
|
||||
*/
|
||||
//FAWE start - getter
|
||||
public BlockVector3 withX(int x) {
|
||||
return BlockVector3.at(x, getY(), getZ());
|
||||
return BlockVector3.at(x, y(), z());
|
||||
}
|
||||
//FAWE end
|
||||
|
||||
|
||||
//FAWE start - make record getters to abstract methods
|
||||
/**
|
||||
* Get the Y coordinate.
|
||||
*
|
||||
* @return the y coordinate
|
||||
* @since TODO
|
||||
*/
|
||||
//FAWE start - Made abstract
|
||||
public abstract int getY();
|
||||
public abstract int y();
|
||||
//FAWE end
|
||||
|
||||
/**
|
||||
* Get the Y coordinate.
|
||||
*
|
||||
* @return the y coordinate
|
||||
* @deprecated use {@link #y()} instead
|
||||
*/
|
||||
//FAWE start - getter
|
||||
@Deprecated(forRemoval = true, since = "TODO")
|
||||
public int getY() {
|
||||
return this.y(); //FAWE - access abstract getter instead of local field
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Y coordinate.
|
||||
*
|
||||
* @return the y coordinate
|
||||
* @deprecated use {@link #y()} instead
|
||||
*/
|
||||
@Deprecated(forRemoval = true, since = "TODO")
|
||||
public int getBlockY() {
|
||||
return getY();
|
||||
return this.y(); //FAWE - access abstract getter instead of local field
|
||||
}
|
||||
//FAWE end
|
||||
|
||||
/**
|
||||
* Set the Y coordinate.
|
||||
@ -231,25 +258,37 @@ public abstract class BlockVector3 {
|
||||
}
|
||||
//FAWE end
|
||||
|
||||
//FAWE start - make record getters to abstract methods
|
||||
/**
|
||||
* Get the Z coordinate.
|
||||
*
|
||||
* @return the z coordinate
|
||||
* @return the Z coordinate
|
||||
* @since TODO
|
||||
*/
|
||||
//FAWE start - Made abstract
|
||||
public abstract int getZ();
|
||||
public abstract int z();
|
||||
//FAWE end
|
||||
|
||||
/**
|
||||
* Get the Z coordinate.
|
||||
*
|
||||
* @return the z coordinate
|
||||
* @deprecated use {@link #z()} instead
|
||||
*/
|
||||
//FAWE start - getter
|
||||
public int getBlockZ() {
|
||||
return getZ();
|
||||
@Deprecated(forRemoval = true, since = "TODO")
|
||||
public int getZ() {
|
||||
return this.z(); //FAWE - access abstract getter instead of local field
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Z coordinate.
|
||||
*
|
||||
* @return the z coordinate
|
||||
* @deprecated use {@link #z()} instead
|
||||
*/
|
||||
@Deprecated(forRemoval = true, since = "TODO")
|
||||
public int getBlockZ() {
|
||||
return this.z(); //FAWE - access abstract getter instead of local field
|
||||
}
|
||||
//FAWE end
|
||||
|
||||
/**
|
||||
* Set the Z coordinate.
|
||||
@ -259,7 +298,7 @@ public abstract class BlockVector3 {
|
||||
*/
|
||||
//FAWE start - getter
|
||||
public BlockVector3 withZ(int z) {
|
||||
return BlockVector3.at(getX(), getY(), z);
|
||||
return BlockVector3.at(x(), y(), z);
|
||||
}
|
||||
//FAWE end
|
||||
|
||||
@ -271,7 +310,7 @@ public abstract class BlockVector3 {
|
||||
*/
|
||||
//FAWE start - getter
|
||||
public BlockVector3 add(BlockVector3 other) {
|
||||
return add(other.getX(), other.getY(), other.getZ());
|
||||
return add(other.x(), other.y(), other.z());
|
||||
}
|
||||
//FAWE end
|
||||
|
||||
@ -285,7 +324,7 @@ public abstract class BlockVector3 {
|
||||
*/
|
||||
//FAWE start - getter
|
||||
public BlockVector3 add(int x, int y, int z) {
|
||||
return BlockVector3.at(this.getX() + x, this.getY() + y, this.getZ() + z);
|
||||
return BlockVector3.at(this.x() + x, this.y() + y, this.z() + z);
|
||||
}
|
||||
//FAWE end
|
||||
|
||||
@ -298,14 +337,14 @@ public abstract class BlockVector3 {
|
||||
*/
|
||||
//FAWE start - getter
|
||||
public BlockVector3 add(BlockVector3... others) {
|
||||
int newX = getX();
|
||||
int newY = getY();
|
||||
int newZ = getZ();
|
||||
int newX = x();
|
||||
int newY = y();
|
||||
int newZ = z();
|
||||
|
||||
for (BlockVector3 other : others) {
|
||||
newX += other.getX();
|
||||
newY += other.getY();
|
||||
newZ += other.getZ();
|
||||
newX += other.x();
|
||||
newY += other.y();
|
||||
newZ += other.z();
|
||||
}
|
||||
|
||||
return BlockVector3.at(newX, newY, newZ);
|
||||
@ -321,7 +360,7 @@ public abstract class BlockVector3 {
|
||||
*/
|
||||
//FAWE start - getter
|
||||
public BlockVector3 subtract(BlockVector3 other) {
|
||||
return subtract(other.getX(), other.getY(), other.getZ());
|
||||
return subtract(other.x(), other.y(), other.z());
|
||||
}
|
||||
//FAWE end
|
||||
|
||||
@ -336,7 +375,7 @@ public abstract class BlockVector3 {
|
||||
*/
|
||||
//FAWE start - getter
|
||||
public BlockVector3 subtract(int x, int y, int z) {
|
||||
return BlockVector3.at(this.getX() - x, this.getY() - y, this.getZ() - z);
|
||||
return BlockVector3.at(this.x() - x, this.y() - y, this.z() - z);
|
||||
}
|
||||
//FAWE end
|
||||
|
||||
@ -349,14 +388,14 @@ public abstract class BlockVector3 {
|
||||
*/
|
||||
//FAWE start - getter
|
||||
public BlockVector3 subtract(BlockVector3... others) {
|
||||
int newX = getX();
|
||||
int newY = getY();
|
||||
int newZ = getZ();
|
||||
int newX = x();
|
||||
int newY = y();
|
||||
int newZ = z();
|
||||
|
||||
for (BlockVector3 other : others) {
|
||||
newX -= other.getX();
|
||||
newY -= other.getY();
|
||||
newZ -= other.getZ();
|
||||
newX -= other.x();
|
||||
newY -= other.y();
|
||||
newZ -= other.z();
|
||||
}
|
||||
|
||||
return BlockVector3.at(newX, newY, newZ);
|
||||
@ -371,7 +410,7 @@ public abstract class BlockVector3 {
|
||||
*/
|
||||
//FAWE start - getter
|
||||
public BlockVector3 multiply(BlockVector3 other) {
|
||||
return multiply(other.getX(), other.getY(), other.getZ());
|
||||
return multiply(other.x(), other.y(), other.z());
|
||||
}
|
||||
//FAWE end
|
||||
|
||||
@ -385,7 +424,7 @@ public abstract class BlockVector3 {
|
||||
*/
|
||||
//FAWE start - getter
|
||||
public BlockVector3 multiply(int x, int y, int z) {
|
||||
return BlockVector3.at(this.getX() * x, this.getY() * y, this.getZ() * z);
|
||||
return BlockVector3.at(this.x() * x, this.y() * y, this.z() * z);
|
||||
}
|
||||
//FAWE end
|
||||
|
||||
@ -397,14 +436,14 @@ public abstract class BlockVector3 {
|
||||
*/
|
||||
//FAWE start - getter
|
||||
public BlockVector3 multiply(BlockVector3... others) {
|
||||
int newX = getX();
|
||||
int newY = getY();
|
||||
int newZ = getZ();
|
||||
int newX = x();
|
||||
int newY = y();
|
||||
int newZ = z();
|
||||
|
||||
for (BlockVector3 other : others) {
|
||||
newX *= other.getX();
|
||||
newY *= other.getY();
|
||||
newZ *= other.getZ();
|
||||
newX *= other.x();
|
||||
newY *= other.y();
|
||||
newZ *= other.z();
|
||||
}
|
||||
|
||||
return BlockVector3.at(newX, newY, newZ);
|
||||
@ -429,7 +468,7 @@ public abstract class BlockVector3 {
|
||||
*/
|
||||
//FAWE start - getter
|
||||
public BlockVector3 divide(BlockVector3 other) {
|
||||
return divide(other.getX(), other.getY(), other.getZ());
|
||||
return divide(other.x(), other.y(), other.z());
|
||||
}
|
||||
//FAWE end
|
||||
|
||||
@ -443,7 +482,7 @@ public abstract class BlockVector3 {
|
||||
*/
|
||||
//FAWE start - getter
|
||||
public BlockVector3 divide(int x, int y, int z) {
|
||||
return BlockVector3.at(this.getX() / x, this.getY() / y, this.getZ() / z);
|
||||
return BlockVector3.at(this.x() / x, this.y() / y, this.z() / z);
|
||||
}
|
||||
//FAWE end
|
||||
|
||||
@ -467,7 +506,7 @@ public abstract class BlockVector3 {
|
||||
*/
|
||||
//FAWE start - getter
|
||||
public BlockVector3 shr(int x, int y, int z) {
|
||||
return at(this.getX() >> x, this.getY() >> y, this.getZ() >> z);
|
||||
return at(this.x() >> x, this.y() >> y, this.z() >> z);
|
||||
}
|
||||
//FAWE end
|
||||
|
||||
@ -491,7 +530,7 @@ public abstract class BlockVector3 {
|
||||
*/
|
||||
//FAWE start - getter
|
||||
public BlockVector3 shl(int x, int y, int z) {
|
||||
return at(this.getX() << x, this.getY() << y, this.getZ() << z);
|
||||
return at(this.x() << x, this.y() << y, this.z() << z);
|
||||
}
|
||||
//FAWE end
|
||||
|
||||
@ -521,7 +560,7 @@ public abstract class BlockVector3 {
|
||||
*/
|
||||
//FAWE start - getter
|
||||
public int lengthSq() {
|
||||
return getX() * getX() + getY() * getY() + getZ() * getZ();
|
||||
return x() * x() + y() * y() + z() * z();
|
||||
}
|
||||
//FAWE end
|
||||
|
||||
@ -543,9 +582,9 @@ public abstract class BlockVector3 {
|
||||
*/
|
||||
//FAWE start - getter
|
||||
public int distanceSq(BlockVector3 other) {
|
||||
int dx = other.getX() - getX();
|
||||
int dy = other.getY() - getY();
|
||||
int dz = other.getZ() - getZ();
|
||||
int dx = other.x() - x();
|
||||
int dy = other.y() - y();
|
||||
int dz = other.z() - z();
|
||||
return dx * dx + dy * dy + dz * dz;
|
||||
}
|
||||
//FAWE end
|
||||
@ -559,9 +598,9 @@ public abstract class BlockVector3 {
|
||||
//FAWE start - getter
|
||||
public BlockVector3 normalize() {
|
||||
double len = length();
|
||||
double x = this.getX() / len;
|
||||
double y = this.getY() / len;
|
||||
double z = this.getZ() / len;
|
||||
double x = this.x() / len;
|
||||
double y = this.y() / len;
|
||||
double z = this.z() / len;
|
||||
return BlockVector3.at(x, y, z);
|
||||
}
|
||||
//FAWE end
|
||||
@ -574,7 +613,7 @@ public abstract class BlockVector3 {
|
||||
*/
|
||||
//FAWE start - getter
|
||||
public double dot(BlockVector3 other) {
|
||||
return getX() * other.getX() + getY() * other.getY() + getZ() * other.getZ();
|
||||
return x() * other.x() + y() * other.y() + z() * other.z();
|
||||
}
|
||||
//FAWE end
|
||||
|
||||
@ -587,9 +626,9 @@ public abstract class BlockVector3 {
|
||||
//FAWE start - getter
|
||||
public BlockVector3 cross(BlockVector3 other) {
|
||||
return new BlockVector3Imp(
|
||||
getY() * other.getZ() - getZ() * other.getY(),
|
||||
getZ() * other.getX() - getX() * other.getZ(),
|
||||
getX() * other.getY() - getY() * other.getX()
|
||||
y() * other.z() - z() * other.y(),
|
||||
z() * other.x() - x() * other.z(),
|
||||
x() * other.y() - y() * other.x()
|
||||
);
|
||||
}
|
||||
//FAWE end
|
||||
@ -603,8 +642,7 @@ public abstract class BlockVector3 {
|
||||
*/
|
||||
//FAWE start - getter
|
||||
public boolean containedWithin(BlockVector3 min, BlockVector3 max) {
|
||||
return getX() >= min.getX() && getX() <= max.getX() && getY() >= min.getY() && getY() <= max
|
||||
.getY() && getZ() >= min.getZ() && getZ() <= max.getZ();
|
||||
return x() >= min.x() && x() <= max.x() && y() >= min.y() && y() <= max.y() && z() >= min.z() && z() <= max.z();
|
||||
}
|
||||
//FAWE end
|
||||
|
||||
@ -618,11 +656,11 @@ public abstract class BlockVector3 {
|
||||
//FAWE start - getter
|
||||
public BlockVector3 clampY(int min, int max) {
|
||||
checkArgument(min <= max, "minimum cannot be greater than maximum");
|
||||
if (getY() < min) {
|
||||
return BlockVector3.at(getX(), min, getZ());
|
||||
if (y() < min) {
|
||||
return BlockVector3.at(x(), min, z());
|
||||
}
|
||||
if (getY() > max) {
|
||||
return BlockVector3.at(getX(), max, getZ());
|
||||
if (y() > max) {
|
||||
return BlockVector3.at(x(), max, z());
|
||||
}
|
||||
return this;
|
||||
}
|
||||
@ -668,7 +706,7 @@ public abstract class BlockVector3 {
|
||||
*/
|
||||
//FAWE start - getter
|
||||
public BlockVector3 abs() {
|
||||
return BlockVector3.at(Math.abs(getX()), Math.abs(getY()), Math.abs(getZ()));
|
||||
return BlockVector3.at(Math.abs(x()), Math.abs(y()), Math.abs(z()));
|
||||
}
|
||||
//FAWE end
|
||||
|
||||
@ -686,8 +724,8 @@ public abstract class BlockVector3 {
|
||||
//FAWE start - getter
|
||||
public BlockVector3 transform2D(double angle, double aboutX, double aboutZ, double translateX, double translateZ) {
|
||||
angle = Math.toRadians(angle);
|
||||
double x = this.getX() - aboutX;
|
||||
double z = this.getZ() - aboutZ;
|
||||
double x = this.x() - aboutX;
|
||||
double z = this.z() - aboutZ;
|
||||
double cos = Math.cos(angle);
|
||||
double sin = Math.sin(angle);
|
||||
double x2 = x * cos - z * sin;
|
||||
@ -695,7 +733,7 @@ public abstract class BlockVector3 {
|
||||
|
||||
return BlockVector3.at(
|
||||
x2 + aboutX + translateX,
|
||||
getY(),
|
||||
y(),
|
||||
z2 + aboutZ + translateZ
|
||||
);
|
||||
}
|
||||
@ -707,16 +745,16 @@ public abstract class BlockVector3 {
|
||||
* @return pitch in radians
|
||||
*/
|
||||
public double toPitch() {
|
||||
double x = getX();
|
||||
double z = getZ();
|
||||
double x = x();
|
||||
double z = z();
|
||||
|
||||
if (x == 0 && z == 0) {
|
||||
return getY() > 0 ? -90 : 90;
|
||||
return y() > 0 ? -90 : 90;
|
||||
} else {
|
||||
double x2 = x * x;
|
||||
double z2 = z * z;
|
||||
double xz = Math.sqrt(x2 + z2);
|
||||
return Math.toDegrees(Math.atan(-getY() / xz));
|
||||
return Math.toDegrees(Math.atan(-y() / xz));
|
||||
}
|
||||
}
|
||||
|
||||
@ -726,8 +764,8 @@ public abstract class BlockVector3 {
|
||||
* @return yaw in radians
|
||||
*/
|
||||
public double toYaw() {
|
||||
double x = getX();
|
||||
double z = getZ();
|
||||
double x = x();
|
||||
double z = z();
|
||||
|
||||
double t = Math.atan2(-x, z);
|
||||
double tau = 2 * Math.PI;
|
||||
@ -744,9 +782,9 @@ public abstract class BlockVector3 {
|
||||
//FAWE start - getter
|
||||
public BlockVector3 getMinimum(BlockVector3 v2) {
|
||||
return new BlockVector3Imp(
|
||||
Math.min(getX(), v2.getX()),
|
||||
Math.min(getY(), v2.getY()),
|
||||
Math.min(getZ(), v2.getZ())
|
||||
Math.min(x(), v2.x()),
|
||||
Math.min(y(), v2.y()),
|
||||
Math.min(z(), v2.z())
|
||||
);
|
||||
}
|
||||
//FAWE end
|
||||
@ -760,9 +798,9 @@ public abstract class BlockVector3 {
|
||||
//FAWE start - getter
|
||||
public BlockVector3 getMaximum(BlockVector3 v2) {
|
||||
return new BlockVector3Imp(
|
||||
Math.max(getX(), v2.getX()),
|
||||
Math.max(getY(), v2.getY()),
|
||||
Math.max(getZ(), v2.getZ())
|
||||
Math.max(x(), v2.x()),
|
||||
Math.max(y(), v2.y()),
|
||||
Math.max(z(), v2.z())
|
||||
);
|
||||
}
|
||||
//FAWE end
|
||||
@ -815,19 +853,19 @@ public abstract class BlockVector3 {
|
||||
}
|
||||
|
||||
public CompoundTag getNbtData(Extent orDefault) {
|
||||
return orDefault.getFullBlock(getX(), getY(), getZ()).getNbtData();
|
||||
return orDefault.getFullBlock(x(), y(), z()).getNbtData();
|
||||
}
|
||||
|
||||
public BlockState getOrdinalBelow(Extent orDefault) {
|
||||
return orDefault.getBlock(getX(), getY() - 1, getZ());
|
||||
return orDefault.getBlock(x(), y() - 1, z());
|
||||
}
|
||||
|
||||
public BlockState getStateAbove(Extent orDefault) {
|
||||
return orDefault.getBlock(getX(), getY() + 1, getZ());
|
||||
return orDefault.getBlock(x(), y() + 1, z());
|
||||
}
|
||||
|
||||
public BlockState getStateRelativeY(Extent orDefault, final int y) {
|
||||
return orDefault.getBlock(getX(), getY() + y, getZ());
|
||||
return orDefault.getBlock(x(), y() + y, z());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -836,21 +874,21 @@ public abstract class BlockVector3 {
|
||||
* @return a new {@link BlockVector2}
|
||||
*/
|
||||
public BlockVector2 toBlockVector2() {
|
||||
return BlockVector2.at(getX(), getZ());
|
||||
return BlockVector2.at(x(), z());
|
||||
}
|
||||
|
||||
public Vector3 toVector3() {
|
||||
return Vector3.at(getX(), getY(), getZ());
|
||||
return Vector3.at(x(), y(), z());
|
||||
}
|
||||
|
||||
//FAWE start - not a record, need own implementations
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (!(obj instanceof BlockVector3)) {
|
||||
if (!(obj instanceof final BlockVector3 other)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
BlockVector3 other = (BlockVector3) obj;
|
||||
return other.getX() == this.getX() && other.getY() == this.getY() && other.getZ() == this.getZ();
|
||||
return other.x() == this.x() && other.y() == this.y() && other.z() == this.z();
|
||||
}
|
||||
|
||||
public final boolean equals(BlockVector3 other) {
|
||||
@ -858,17 +896,18 @@ public abstract class BlockVector3 {
|
||||
return false;
|
||||
}
|
||||
|
||||
return other.getX() == this.getX() && other.getY() == this.getY() && other.getZ() == this.getZ();
|
||||
return other.x() == this.x() && other.y() == this.y() && other.z() == this.z();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return (getX() ^ (getZ() << 12)) ^ (getY() << 24);
|
||||
return (x() ^ (z() << 12)) ^ (y() << 24);
|
||||
}
|
||||
//FAWE end
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "(" + getX() + ", " + getY() + ", " + getZ() + ")";
|
||||
return "(" + x() + ", " + y() + ", " + z() + ")";
|
||||
}
|
||||
|
||||
/**
|
||||
@ -877,7 +916,7 @@ public abstract class BlockVector3 {
|
||||
* @return string
|
||||
*/
|
||||
public String toParserString() {
|
||||
return getX() + "," + getY() + "," + getZ();
|
||||
return x() + "," + y() + "," + z();
|
||||
}
|
||||
|
||||
//Used by VS fork
|
||||
|
@ -56,33 +56,33 @@ public final class BlockVector3Imp extends BlockVector3 {
|
||||
}
|
||||
|
||||
@Override
|
||||
public final int getX() {
|
||||
public int x() {
|
||||
return x;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final int getY() {
|
||||
public int y() {
|
||||
return y;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final int getZ() {
|
||||
public int z() {
|
||||
return z;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return (getX() ^ (getZ() << 12)) ^ (getY() << 24);
|
||||
return (x() ^ (z() << 12)) ^ (y() << 24);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final BlockVector3 toImmutable() {
|
||||
public BlockVector3 toImmutable() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "(" + getX() + ", " + getY() + ", " + getZ() + ")";
|
||||
return "(" + x() + ", " + y() + ", " + z() + ")";
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -19,12 +19,13 @@
|
||||
|
||||
package com.sk89q.worldedit.math;
|
||||
|
||||
import com.fastasyncworldedit.core.util.MathMan;
|
||||
import com.sk89q.worldedit.math.transform.AffineTransform;
|
||||
|
||||
/**
|
||||
* An immutable 2-dimensional vector.
|
||||
*/
|
||||
public final class Vector2 {
|
||||
public record Vector2(double x, double z) {
|
||||
|
||||
public static final Vector2 ZERO = new Vector2(0, 0);
|
||||
public static final Vector2 UNIT_X = new Vector2(1, 0);
|
||||
@ -50,29 +51,27 @@ public final class Vector2 {
|
||||
return new Vector2(x, z);
|
||||
}
|
||||
|
||||
private final double x;
|
||||
private final double z;
|
||||
|
||||
/**
|
||||
* Construct an instance.
|
||||
*
|
||||
* @param x the X coordinate
|
||||
* @param z the Z coordinate
|
||||
*/
|
||||
private Vector2(double x, double z) {
|
||||
this.x = x;
|
||||
this.z = z;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the X coordinate.
|
||||
*
|
||||
* @return the x coordinate
|
||||
* @deprecated use {@link #x()} instead
|
||||
*/
|
||||
@Deprecated(forRemoval = true, since = "TODO")
|
||||
public double getX() {
|
||||
return x;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the X coordinate, aligned to the block grid.
|
||||
*
|
||||
* @return the block-aligned x coordinate
|
||||
* @since TODO
|
||||
*/
|
||||
public int blockX() {
|
||||
return MathMan.roundInt(x);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the X coordinate.
|
||||
*
|
||||
@ -83,11 +82,23 @@ public final class Vector2 {
|
||||
return Vector2.at(x, z);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Z coordinate, aligned to the block grid.
|
||||
*
|
||||
* @return the block-aligned z coordinate
|
||||
* @since TODO
|
||||
*/
|
||||
public int blockZ() {
|
||||
return MathMan.roundInt(z);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Z coordinate.
|
||||
*
|
||||
* @return the z coordinate
|
||||
* @deprecated use {@link #z()} instead
|
||||
*/
|
||||
@Deprecated(forRemoval = true, since = "TODO")
|
||||
public double getZ() {
|
||||
return z;
|
||||
}
|
||||
@ -458,24 +469,6 @@ public final class Vector2 {
|
||||
return Vector3.at(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (!(obj instanceof Vector2)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Vector2 other = (Vector2) obj;
|
||||
return other.x == this.x && other.z == this.z;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
//FAWE start - XOR over x z calc
|
||||
return (int) x << 16 ^ (int) z;
|
||||
//FAWE end
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "(" + x + ", " + z + ")";
|
||||
|
@ -32,7 +32,9 @@ import static com.google.common.base.Preconditions.checkArgument;
|
||||
/**
|
||||
* An immutable 3-dimensional vector.
|
||||
*/
|
||||
//FAWE start - not a record, make abstract
|
||||
public abstract class Vector3 {
|
||||
//FAWE end
|
||||
|
||||
public static final Vector3 ZERO = Vector3.at(0, 0, 0);
|
||||
public static final Vector3 UNIT_X = Vector3.at(1, 0, 0);
|
||||
@ -69,9 +71,9 @@ public abstract class Vector3 {
|
||||
|
||||
private static final Comparator<Vector3> YZX_ORDER = (a, b) -> {
|
||||
return ComparisonChain.start()
|
||||
.compare(a.getY(), b.getY())
|
||||
.compare(a.getZ(), b.getZ())
|
||||
.compare(a.getX(), b.getX())
|
||||
.compare(a.y(), b.y())
|
||||
.compare(a.z(), b.z())
|
||||
.compare(a.x(), b.x())
|
||||
.result();
|
||||
};
|
||||
|
||||
@ -96,7 +98,7 @@ public abstract class Vector3 {
|
||||
* @return the x coordinate
|
||||
*/
|
||||
public int getBlockX() {
|
||||
return MathMan.roundInt(getX());
|
||||
return MathMan.roundInt(x());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -105,7 +107,7 @@ public abstract class Vector3 {
|
||||
* @return the y coordinate
|
||||
*/
|
||||
public int getBlockY() {
|
||||
return MathMan.roundInt(getY());
|
||||
return MathMan.roundInt(y());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -114,7 +116,7 @@ public abstract class Vector3 {
|
||||
* @return the z coordinate
|
||||
*/
|
||||
public int getBlockZ() {
|
||||
return MathMan.roundInt(getZ());
|
||||
return MathMan.roundInt(z());
|
||||
}
|
||||
|
||||
public MutableVector3 setComponents(Vector3 other) {
|
||||
@ -130,27 +132,27 @@ public abstract class Vector3 {
|
||||
}
|
||||
|
||||
public MutableVector3 mutX(int x) {
|
||||
return new MutableVector3(x, getY(), getZ());
|
||||
return new MutableVector3(x, y(), z());
|
||||
}
|
||||
|
||||
public MutableVector3 mutX(double x) {
|
||||
return new MutableVector3(x, getY(), getZ());
|
||||
return new MutableVector3(x, y(), z());
|
||||
}
|
||||
|
||||
public MutableVector3 mutY(int y) {
|
||||
return new MutableVector3(getX(), y, getZ());
|
||||
return new MutableVector3(x(), y, z());
|
||||
}
|
||||
|
||||
public MutableVector3 mutY(double y) {
|
||||
return new MutableVector3(getX(), y, getZ());
|
||||
return new MutableVector3(x(), y, z());
|
||||
}
|
||||
|
||||
public MutableVector3 mutZ(int z) {
|
||||
return new MutableVector3(getX(), getY(), z);
|
||||
return new MutableVector3(x(), y(), z);
|
||||
}
|
||||
|
||||
public MutableVector3 mutZ(double z) {
|
||||
return new MutableVector3(getX(), getY(), z);
|
||||
return new MutableVector3(x(), y(), z);
|
||||
}
|
||||
//FAWE end
|
||||
|
||||
@ -158,10 +160,29 @@ public abstract class Vector3 {
|
||||
* Get the X coordinate.
|
||||
*
|
||||
* @return the x coordinate
|
||||
* @since TODO
|
||||
*/
|
||||
//FAWE start - made abstract
|
||||
public abstract double getX();
|
||||
//FAWE end
|
||||
public abstract double x();
|
||||
|
||||
/**
|
||||
* Get the X coordinate, aligned to the block grid.
|
||||
*
|
||||
* @return the block-aligned x coordinate
|
||||
*/
|
||||
public int blockX() {
|
||||
return MathMan.roundInt(this.x());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the X coordinate.
|
||||
*
|
||||
* @return the x coordinate
|
||||
* @deprecated use {@link #x()} instead
|
||||
*/
|
||||
@Deprecated(forRemoval = true, since = "TODO")
|
||||
public double getX() {
|
||||
return this.x();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the X coordinate.
|
||||
@ -171,18 +192,38 @@ public abstract class Vector3 {
|
||||
*/
|
||||
//FAWE start - getter
|
||||
public Vector3 withX(double x) {
|
||||
return Vector3.at(x, getY(), getZ());
|
||||
return Vector3.at(x, y(), z());
|
||||
}
|
||||
//FAWE end
|
||||
|
||||
|
||||
/**
|
||||
* Get the Y coordinate.
|
||||
*
|
||||
* @return the y coordinate
|
||||
* @since TODO
|
||||
*/
|
||||
//FAWE start - made abstract
|
||||
public abstract double getY();
|
||||
//FAWE end
|
||||
public abstract double y();
|
||||
|
||||
/**
|
||||
* Get the Y coordinate, aligned to the block grid.
|
||||
*
|
||||
* @return the block-aligned y coordinate
|
||||
*/
|
||||
public int blockY() {
|
||||
return MathMan.roundInt(this.y());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Y coordinate.
|
||||
*
|
||||
* @return the y coordinate
|
||||
* @deprecated use {@link #y()} instead
|
||||
*/
|
||||
@Deprecated(forRemoval = true, since = "TODO")
|
||||
public double getY() {
|
||||
return this.y();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the Y coordinate.
|
||||
@ -192,7 +233,7 @@ public abstract class Vector3 {
|
||||
*/
|
||||
//FAWE start - getter
|
||||
public Vector3 withY(double y) {
|
||||
return Vector3.at(getX(), y, getZ());
|
||||
return Vector3.at(x(), y, z());
|
||||
}
|
||||
//FAWE end
|
||||
|
||||
@ -200,10 +241,29 @@ public abstract class Vector3 {
|
||||
* Get the Z coordinate.
|
||||
*
|
||||
* @return the z coordinate
|
||||
* @since TODO
|
||||
*/
|
||||
//FAWE start - made abstract
|
||||
public abstract double getZ();
|
||||
//FAWE end
|
||||
public abstract double z();
|
||||
|
||||
/**
|
||||
* Get the Z coordinate, aligned to the block grid.
|
||||
*
|
||||
* @return the block-aligned z coordinate
|
||||
*/
|
||||
public int blockZ() {
|
||||
return MathMan.roundInt(this.z());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Z coordinate.
|
||||
*
|
||||
* @return the z coordinate
|
||||
* @deprecated use {@link #z()} instead
|
||||
*/
|
||||
@Deprecated(forRemoval = true, since = "TODO")
|
||||
public double getZ() {
|
||||
return this.z();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the Z coordinate.
|
||||
@ -213,7 +273,7 @@ public abstract class Vector3 {
|
||||
*/
|
||||
//FAWE start - getter
|
||||
public Vector3 withZ(double z) {
|
||||
return Vector3.at(getX(), getY(), z);
|
||||
return Vector3.at(x(), y(), z);
|
||||
}
|
||||
//FAWE end
|
||||
|
||||
@ -225,7 +285,7 @@ public abstract class Vector3 {
|
||||
*/
|
||||
//FAWE start - getter
|
||||
public Vector3 add(Vector3 other) {
|
||||
return add(other.getX(), other.getY(), other.getZ());
|
||||
return add(other.x(), other.y(), other.z());
|
||||
}
|
||||
//FAWE end
|
||||
|
||||
@ -239,7 +299,7 @@ public abstract class Vector3 {
|
||||
*/
|
||||
//FAWE start - getter
|
||||
public Vector3 add(double x, double y, double z) {
|
||||
return Vector3.at(this.getX() + x, this.getY() + y, this.getZ() + z);
|
||||
return Vector3.at(this.x() + x, this.y() + y, this.z() + z);
|
||||
}
|
||||
//FAWE end
|
||||
|
||||
@ -252,14 +312,14 @@ public abstract class Vector3 {
|
||||
*/
|
||||
//FAWE start - getter
|
||||
public Vector3 add(Vector3... others) {
|
||||
double newX = getX();
|
||||
double newY = getY();
|
||||
double newZ = getZ();
|
||||
double newX = x();
|
||||
double newY = y();
|
||||
double newZ = z();
|
||||
|
||||
for (Vector3 other : others) {
|
||||
newX += other.getX();
|
||||
newY += other.getY();
|
||||
newZ += other.getZ();
|
||||
newX += other.x();
|
||||
newY += other.y();
|
||||
newZ += other.z();
|
||||
}
|
||||
|
||||
return Vector3.at(newX, newY, newZ);
|
||||
@ -275,7 +335,7 @@ public abstract class Vector3 {
|
||||
*/
|
||||
//FAWE start - getter
|
||||
public Vector3 subtract(Vector3 other) {
|
||||
return subtract(other.getX(), other.getY(), other.getZ());
|
||||
return subtract(other.x(), other.y(), other.z());
|
||||
}
|
||||
//FAWE end
|
||||
|
||||
@ -290,7 +350,7 @@ public abstract class Vector3 {
|
||||
*/
|
||||
//FAWE start - getter
|
||||
public Vector3 subtract(double x, double y, double z) {
|
||||
return Vector3.at(this.getX() - x, this.getY() - y, this.getZ() - z);
|
||||
return Vector3.at(this.x() - x, this.y() - y, this.z() - z);
|
||||
}
|
||||
//FAWE end
|
||||
|
||||
@ -303,14 +363,14 @@ public abstract class Vector3 {
|
||||
*/
|
||||
//FAWE start - getter
|
||||
public Vector3 subtract(Vector3... others) {
|
||||
double newX = getX();
|
||||
double newY = getY();
|
||||
double newZ = getZ();
|
||||
double newX = x();
|
||||
double newY = y();
|
||||
double newZ = z();
|
||||
|
||||
for (Vector3 other : others) {
|
||||
newX -= other.getX();
|
||||
newY -= other.getY();
|
||||
newZ -= other.getZ();
|
||||
newX -= other.x();
|
||||
newY -= other.y();
|
||||
newZ -= other.z();
|
||||
}
|
||||
|
||||
return Vector3.at(newX, newY, newZ);
|
||||
@ -325,7 +385,7 @@ public abstract class Vector3 {
|
||||
*/
|
||||
//FAWE start - getter
|
||||
public Vector3 multiply(Vector3 other) {
|
||||
return multiply(other.getX(), other.getY(), other.getZ());
|
||||
return multiply(other.x(), other.y(), other.z());
|
||||
}
|
||||
//FAWE end
|
||||
|
||||
@ -339,7 +399,7 @@ public abstract class Vector3 {
|
||||
*/
|
||||
//FAWE start - getter
|
||||
public Vector3 multiply(double x, double y, double z) {
|
||||
return Vector3.at(this.getX() * x, this.getY() * y, this.getZ() * z);
|
||||
return Vector3.at(this.x() * x, this.y() * y, this.z() * z);
|
||||
}
|
||||
//FAWE end
|
||||
|
||||
@ -351,14 +411,14 @@ public abstract class Vector3 {
|
||||
*/
|
||||
//FAWE start - getter
|
||||
public Vector3 multiply(Vector3... others) {
|
||||
double newX = getX();
|
||||
double newY = getY();
|
||||
double newZ = getZ();
|
||||
double newX = x();
|
||||
double newY = y();
|
||||
double newZ = z();
|
||||
|
||||
for (Vector3 other : others) {
|
||||
newX *= other.getX();
|
||||
newY *= other.getY();
|
||||
newZ *= other.getZ();
|
||||
newX *= other.x();
|
||||
newY *= other.y();
|
||||
newZ *= other.z();
|
||||
}
|
||||
|
||||
return Vector3.at(newX, newY, newZ);
|
||||
@ -383,7 +443,7 @@ public abstract class Vector3 {
|
||||
*/
|
||||
//FAWE start - getter
|
||||
public Vector3 divide(Vector3 other) {
|
||||
return divide(other.getX(), other.getY(), other.getZ());
|
||||
return divide(other.x(), other.y(), other.z());
|
||||
}
|
||||
//FAWE end
|
||||
|
||||
@ -397,7 +457,7 @@ public abstract class Vector3 {
|
||||
*/
|
||||
//FAWE start - getter
|
||||
public Vector3 divide(double x, double y, double z) {
|
||||
return Vector3.at(this.getX() / x, this.getY() / y, this.getZ() / z);
|
||||
return Vector3.at(this.x() / x, this.y() / y, this.z() / z);
|
||||
}
|
||||
//FAWE end
|
||||
|
||||
@ -427,7 +487,7 @@ public abstract class Vector3 {
|
||||
*/
|
||||
//FAWE start - getter
|
||||
public double lengthSq() {
|
||||
return getX() * getX() + getY() * getY() + getZ() * getZ();
|
||||
return x() * x() + y() * y() + z() * z();
|
||||
}
|
||||
//FAWE end
|
||||
|
||||
@ -449,9 +509,9 @@ public abstract class Vector3 {
|
||||
*/
|
||||
//FAWE start - getter
|
||||
public double distanceSq(Vector3 other) {
|
||||
double dx = other.getX() - getX();
|
||||
double dy = other.getY() - getY();
|
||||
double dz = other.getZ() - getZ();
|
||||
double dx = other.x() - x();
|
||||
double dy = other.y() - y();
|
||||
double dz = other.z() - z();
|
||||
return dx * dx + dy * dy + dz * dz;
|
||||
}
|
||||
//FAWE end
|
||||
@ -474,7 +534,7 @@ public abstract class Vector3 {
|
||||
*/
|
||||
//FAWE start - getter
|
||||
public double dot(Vector3 other) {
|
||||
return getX() * other.getX() + getY() * other.getY() + getZ() * other.getZ();
|
||||
return x() * other.x() + y() * other.y() + z() * other.z();
|
||||
}
|
||||
//FAWE end
|
||||
|
||||
@ -487,9 +547,9 @@ public abstract class Vector3 {
|
||||
//FAWE start - getter
|
||||
public Vector3 cross(Vector3 other) {
|
||||
return Vector3.at(
|
||||
getY() * other.getZ() - getZ() * other.getY(),
|
||||
getZ() * other.getX() - getX() * other.getZ(),
|
||||
getX() * other.getY() - getY() * other.getX()
|
||||
y() * other.z() - z() * other.y(),
|
||||
z() * other.x() - x() * other.z(),
|
||||
x() * other.y() - y() * other.x()
|
||||
);
|
||||
}
|
||||
//FAWE end
|
||||
@ -503,8 +563,7 @@ public abstract class Vector3 {
|
||||
*/
|
||||
//FAWE start - getter
|
||||
public boolean containedWithin(Vector3 min, Vector3 max) {
|
||||
return getX() >= min.getX() && getX() <= max.getX() && getY() >= min.getY() && getY() <= max.getY() && getZ() >= min.getZ() && getZ() <= max
|
||||
.getZ();
|
||||
return x() >= min.x() && x() <= max.x() && y() >= min.y() && y() <= max.y() && z() >= min.z() && z() <= max.z();
|
||||
}
|
||||
//FAWE end
|
||||
|
||||
@ -518,11 +577,11 @@ public abstract class Vector3 {
|
||||
//FAWE start - getter
|
||||
public Vector3 clampY(int min, int max) {
|
||||
checkArgument(min <= max, "minimum cannot be greater than maximum");
|
||||
if (getY() < min) {
|
||||
return Vector3.at(getX(), min, getZ());
|
||||
if (y() < min) {
|
||||
return Vector3.at(x(), min, z());
|
||||
}
|
||||
if (getY() > max) {
|
||||
return Vector3.at(getX(), max, getZ());
|
||||
if (y() > max) {
|
||||
return Vector3.at(x(), max, z());
|
||||
}
|
||||
return this;
|
||||
}
|
||||
@ -535,7 +594,7 @@ public abstract class Vector3 {
|
||||
*/
|
||||
//FAWE start - getter
|
||||
public Vector3 floor() {
|
||||
return Vector3.at(Math.floor(getX()), Math.floor(getY()), Math.floor(getZ()));
|
||||
return Vector3.at(Math.floor(x()), Math.floor(y()), Math.floor(z()));
|
||||
}
|
||||
//FAWE end
|
||||
|
||||
@ -546,7 +605,7 @@ public abstract class Vector3 {
|
||||
*/
|
||||
//FAWE start - getter
|
||||
public Vector3 ceil() {
|
||||
return Vector3.at(Math.ceil(getX()), Math.ceil(getY()), Math.ceil(getZ()));
|
||||
return Vector3.at(Math.ceil(x()), Math.ceil(y()), Math.ceil(z()));
|
||||
}
|
||||
//FAWE end
|
||||
|
||||
@ -559,7 +618,7 @@ public abstract class Vector3 {
|
||||
*/
|
||||
//FAWE start - getter
|
||||
public Vector3 round() {
|
||||
return Vector3.at(Math.floor(getX() + 0.5), Math.floor(getY() + 0.5), Math.floor(getZ() + 0.5));
|
||||
return Vector3.at(Math.floor(x() + 0.5), Math.floor(y() + 0.5), Math.floor(z() + 0.5));
|
||||
}
|
||||
//FAWE end
|
||||
|
||||
@ -570,7 +629,7 @@ public abstract class Vector3 {
|
||||
*/
|
||||
//FAWE start - getter
|
||||
public Vector3 roundHalfUp() {
|
||||
return Vector3.at(MathUtils.roundHalfUp(getX()), MathUtils.roundHalfUp(getY()), MathUtils.roundHalfUp(getZ()));
|
||||
return Vector3.at(MathUtils.roundHalfUp(x()), MathUtils.roundHalfUp(y()), MathUtils.roundHalfUp(z()));
|
||||
}
|
||||
//FAWE end
|
||||
|
||||
@ -582,7 +641,7 @@ public abstract class Vector3 {
|
||||
*/
|
||||
//FAWE start - getter
|
||||
public Vector3 abs() {
|
||||
return Vector3.at(Math.abs(getX()), Math.abs(getY()), Math.abs(getZ()));
|
||||
return Vector3.at(Math.abs(x()), Math.abs(y()), Math.abs(z()));
|
||||
}
|
||||
//FAWE end
|
||||
|
||||
@ -600,8 +659,8 @@ public abstract class Vector3 {
|
||||
//FAWE start - getter
|
||||
public Vector3 transform2D(double angle, double aboutX, double aboutZ, double translateX, double translateZ) {
|
||||
angle = Math.toRadians(angle);
|
||||
double x = this.getX() - aboutX;
|
||||
double z = this.getZ() - aboutZ;
|
||||
double x = this.x() - aboutX;
|
||||
double z = this.z() - aboutZ;
|
||||
double cos = Math.cos(angle);
|
||||
double sin = Math.sin(angle);
|
||||
double x2 = x * cos - z * sin;
|
||||
@ -609,7 +668,7 @@ public abstract class Vector3 {
|
||||
|
||||
return Vector3.at(
|
||||
x2 + aboutX + translateX,
|
||||
getY(),
|
||||
y(),
|
||||
z2 + aboutZ + translateZ
|
||||
);
|
||||
}
|
||||
@ -621,16 +680,16 @@ public abstract class Vector3 {
|
||||
* @return pitch in radians
|
||||
*/
|
||||
public double toPitch() {
|
||||
double x = getX();
|
||||
double z = getZ();
|
||||
double x = x();
|
||||
double z = z();
|
||||
|
||||
if (x == 0 && z == 0) {
|
||||
return getY() > 0 ? -90 : 90;
|
||||
return y() > 0 ? -90 : 90;
|
||||
} else {
|
||||
double x2 = x * x;
|
||||
double z2 = z * z;
|
||||
double xz = Math.sqrt(x2 + z2);
|
||||
return Math.toDegrees(Math.atan(-getY() / xz));
|
||||
return Math.toDegrees(Math.atan(-y() / xz));
|
||||
}
|
||||
}
|
||||
|
||||
@ -640,8 +699,8 @@ public abstract class Vector3 {
|
||||
* @return yaw in radians
|
||||
*/
|
||||
public double toYaw() {
|
||||
double x = getX();
|
||||
double z = getZ();
|
||||
double x = x();
|
||||
double z = z();
|
||||
|
||||
double t = Math.atan2(-x, z);
|
||||
double tau = 2 * Math.PI;
|
||||
@ -658,9 +717,9 @@ public abstract class Vector3 {
|
||||
//FAWE start - getter
|
||||
public Vector3 getMinimum(Vector3 v2) {
|
||||
return Vector3.at(
|
||||
Math.min(getX(), v2.getX()),
|
||||
Math.min(getY(), v2.getY()),
|
||||
Math.min(getZ(), v2.getZ())
|
||||
Math.min(x(), v2.x()),
|
||||
Math.min(y(), v2.y()),
|
||||
Math.min(z(), v2.z())
|
||||
);
|
||||
}
|
||||
//FAWE end
|
||||
@ -674,9 +733,9 @@ public abstract class Vector3 {
|
||||
//FAWE start - getter
|
||||
public Vector3 getMaximum(Vector3 v2) {
|
||||
return Vector3.at(
|
||||
Math.max(getX(), v2.getX()),
|
||||
Math.max(getY(), v2.getY()),
|
||||
Math.max(getZ(), v2.getZ())
|
||||
Math.max(x(), v2.x()),
|
||||
Math.max(y(), v2.y()),
|
||||
Math.max(z(), v2.z())
|
||||
);
|
||||
}
|
||||
//FAWE end
|
||||
@ -700,7 +759,7 @@ public abstract class Vector3 {
|
||||
*/
|
||||
//FAWE start - getter
|
||||
public BlockVector3 toBlockPoint() {
|
||||
return toBlockPoint(getX(), getY(), getZ());
|
||||
return toBlockPoint(x(), y(), z());
|
||||
}
|
||||
//FAWE end
|
||||
|
||||
@ -711,24 +770,20 @@ public abstract class Vector3 {
|
||||
*/
|
||||
//FAWE start - getter
|
||||
public Vector2 toVector2() {
|
||||
return Vector2.at(getX(), getZ());
|
||||
return Vector2.at(x(), z());
|
||||
}
|
||||
//FAWE end
|
||||
|
||||
//FAWE start - not a record, need own implementations
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (!(obj instanceof Vector3)) {
|
||||
if (!(obj instanceof final Vector3 other)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Vector3 other = (Vector3) obj;
|
||||
//FAWE start - getter
|
||||
return other.getX() == this.getX() && other.getY() == this.getY() && other.getZ() == this.getZ();
|
||||
//FAWE end
|
||||
return other.x() == this.x() && other.y() == this.y() && other.z() == this.z();
|
||||
}
|
||||
|
||||
//FAWE start
|
||||
|
||||
/**
|
||||
* Tests if vectors are equal, accounting for floating point errors
|
||||
*
|
||||
@ -741,28 +796,27 @@ public abstract class Vector3 {
|
||||
}
|
||||
|
||||
// Minecraft deals in whole blocks, thus any difference smaller than this is unnecessary
|
||||
if (Math.abs(getX() - other.getX()) > 0.000001d) {
|
||||
if (Math.abs(x() - other.x()) > 0.000001d) {
|
||||
return false;
|
||||
}
|
||||
if (Math.abs(getY() - other.getY()) > 0.000001d) {
|
||||
if (Math.abs(y() - other.y()) > 0.000001d) {
|
||||
return false;
|
||||
}
|
||||
return !(Math.abs(getZ() - other.getZ()) > 0.000001d);
|
||||
return !(Math.abs(z() - other.z()) > 0.000001d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return (int) x() ^ (int) z() << 12 ^ (int) y() << 24;
|
||||
}
|
||||
//FAWE end
|
||||
|
||||
@Override
|
||||
//FAWE start - XOR over get calculating all values independently
|
||||
public int hashCode() {
|
||||
return (int) getX() ^ (int) getZ() << 12 ^ (int) getY() << 24;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
//FAWE start - getter & ternary
|
||||
String x = (getX() == getBlockX() ? "" + getBlockX() : "" + getX());
|
||||
String y = (getY() == getBlockY() ? "" + getBlockY() : "" + getY());
|
||||
String z = (getZ() == getBlockZ() ? "" + getBlockZ() : "" + getZ());
|
||||
String x = (x() == blockX() ? "" + blockX() : "" + x());
|
||||
String y = (y() == blockY() ? "" + blockY() : "" + y());
|
||||
String z = (z() == blockZ() ? "" + blockZ() : "" + z());
|
||||
//FAWE end
|
||||
return "(" + x + ", " + y + ", " + z + ")";
|
||||
}
|
||||
@ -774,7 +828,7 @@ public abstract class Vector3 {
|
||||
*/
|
||||
//FAWE start - getter
|
||||
public String toParserString() {
|
||||
return getX() + "," + getY() + "," + getZ();
|
||||
return x() + "," + y() + "," + z();
|
||||
}
|
||||
//FAWE end
|
||||
|
||||
|
@ -302,11 +302,11 @@ public class Location extends Vector3Impl {
|
||||
@Override
|
||||
public Location clampY(int min, int max) {
|
||||
checkArgument(min <= max, "minimum cannot be greater than maximum");
|
||||
if (getY() < min) {
|
||||
return new Location(extent, getX(), min, getZ());
|
||||
if (y() < min) {
|
||||
return new Location(extent, x(), min, z());
|
||||
}
|
||||
if (getY() > max) {
|
||||
return new Location(extent, getX(), max, getZ());
|
||||
if (y() > max) {
|
||||
return new Location(extent, x(), max, z());
|
||||
}
|
||||
return this;
|
||||
|
||||
@ -331,13 +331,13 @@ public class Location extends Vector3Impl {
|
||||
return false;
|
||||
}
|
||||
//FAWE start
|
||||
if (this.getX() != location.getX()) {
|
||||
if (this.x() != location.x()) {
|
||||
return false;
|
||||
}
|
||||
if (this.getZ() != location.getZ()) {
|
||||
if (this.z() != location.z()) {
|
||||
return false;
|
||||
}
|
||||
if (this.getY() != location.getY()) {
|
||||
if (this.y() != location.y()) {
|
||||
return false;
|
||||
}
|
||||
return extent.equals(location.extent);
|
||||
|
Loading…
Reference in New Issue
Block a user