Feature/propagate diff and object cleanup (#1190)

* Feature/main/propagate diff annotations (#1187)

* 25% done

* More work

* More work

* 50%

* More work

* 75%

* 100% & cleanup

* Update adapters

* Squish squash, applesauce

commit 275ba9bd84
Author: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Date:   Sat Jul 17 01:10:20 2021 +0200

    Update dependency com.comphenix.protocol:ProtocolLib to v4.7.0 (#1173)

    Co-authored-by: Renovate Bot <bot@renovateapp.com>

commit 9fd8984804
Author: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Date:   Sat Jul 17 01:09:29 2021 +0200

    Update dependency org.checkerframework:checker-qual to v3.16.0 (#1184)

    Co-authored-by: Renovate Bot <bot@renovateapp.com>

commit 861fb45e5c
Author: dordsor21 <dordsor21@gmail.com>
Date:   Fri Jul 16 19:07:02 2021 +0100

    Fix #1075

commit 420c45a29a
Author: dordsor21 <dordsor21@gmail.com>
Date:   Fri Jul 16 18:48:21 2021 +0100

    Entity removal should be on the main thread as we're just passing through rather than doing chunk operations
     - Fixes #1164
     - Not working: butcher/remove history

commit 4d4db7dcd0
Author: SirYwell <hannesgreule@outlook.de>
Date:   Fri Jul 16 17:52:44 2021 +0200

    Make sure leaves category is loaded for heightmaps (fixes #1176)

commit c98f6e4f37
Author: dordsor21 <dordsor21@gmail.com>
Date:   Fri Jul 16 10:44:52 2021 +0100

    Do not allow generation commands to generate outside selection

commit 2485f5eccc
Author: dordsor21 <dordsor21@gmail.com>
Date:   Fri Jul 16 10:43:15 2021 +0100

    EditSession needs to override some Extent methods to ensure block changes are correctly set through the various extents
    Fixes #1152

commit d9418ec8ae
Author: dordsor21 <dordsor21@gmail.com>
Date:   Fri Jul 16 09:52:44 2021 +0100

    Undo part of 41073bb1a0
    Fixes #1178

* Update Upstream

fb1fb84 Fixed typo and grammar

* We don't support custom heights yet

* Casing inconsistency

* Address a few comments

* Address comments

* Don't refactor to AP classpath

* Document annotation style

* Refactoring & shade cleanup

* Address a few comments

* More work

* Resolve comments not being resolved yet

* Feature/main/propagate diff annotations (#1187) (#1194)

* Remove beta package, fix history packages, move classes out of object package

* Resolve comments not being resolved yet

* Remove beta package, fix history packages, move classes out of object package

Co-authored-by: NotMyFault <mc.cache@web.de>

* brushes should be under brush

* More refactoring
 - Filters/processors should be in the same place and are related to extents
 - Transforms are in `extent.transform` in upstream

* Move history classes under history

* Update adapters

Co-authored-by: dordsor21 <dordsor21@gmail.com>
This commit is contained in:
NotMyFault
2021-07-23 17:48:51 +02:00
committed by GitHub
parent ad102ab7a9
commit 50ab8ad5c7
799 changed files with 4916 additions and 10589 deletions

View File

@ -19,6 +19,7 @@
package com.sk89q.worldedit.math;
import com.fastasyncworldedit.core.math.MutableBlockVector2;
import com.sk89q.worldedit.math.transform.AffineTransform;
import java.util.Comparator;
@ -26,7 +27,9 @@ import java.util.Comparator;
/**
* An immutable 2-dimensional vector.
*/
//FAWE start - un-finalize
public class BlockVector2 {
//FAWE end
public static final BlockVector2 ZERO = new BlockVector2(0, 0);
public static final BlockVector2 UNIT_X = new BlockVector2(1, 0);
@ -57,6 +60,7 @@ public class BlockVector2 {
}
public static BlockVector2 at(int x, int z) {
//FAWE start
/* unnecessary
switch (x) {
case 0:
@ -112,6 +116,7 @@ public class BlockVector2 {
public MutableBlockVector2 mutZ(int z) {
return new MutableBlockVector2(x, z);
}
//FAWE end
/**
* Get the X coordinate.
@ -169,6 +174,7 @@ public class BlockVector2 {
return BlockVector2.at(x, z);
}
//FAWE start
public MutableBlockVector2 nextPosition() {
int absX = Math.abs(x);
int absY = Math.abs(z);
@ -197,6 +203,7 @@ public class BlockVector2 {
return setComponents(x + 1, z);
}
}
//FAWE end
/**
* Add another vector to this vector and return the result as a new vector.

View File

@ -19,6 +19,7 @@
package com.sk89q.worldedit.math;
import com.fastasyncworldedit.core.math.MutableBlockVector3;
import com.sk89q.jnbt.CompoundTag;
import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.math.transform.AffineTransform;
@ -52,7 +53,7 @@ public abstract class BlockVector3 {
}
public static BlockVector3 at(int x, int y, int z) {
/* unnecessary
/*FAWE start unnecessary
// switch for efficiency on typical cases
// in MC y is rarely 0/1 on selections
switch (y) {
@ -70,11 +71,13 @@ public abstract class BlockVector3 {
break;
}
*/
//FAWE end
return new BlockVector3Imp(x, y, z);
}
private static final int WORLD_XZ_MINMAX = 30_000_000;
private static final int WORLD_Y_MAX = 4095;
private static final int WORLD_Y_MIN = -2048;
private static final int WORLD_Y_MAX = 2047;
private static boolean isHorizontallyInBounds(int h) {
return -WORLD_XZ_MINMAX <= h && h <= WORLD_XZ_MINMAX;
@ -83,7 +86,7 @@ public abstract class BlockVector3 {
public static boolean isLongPackable(BlockVector3 location) {
return isHorizontallyInBounds(location.getX())
&& isHorizontallyInBounds(location.getZ())
&& 0 <= location.getY() && location.getY() <= WORLD_Y_MAX;
&& WORLD_Y_MIN <= location.getY() && location.getY() <= WORLD_Y_MAX;
}
public static void checkLongPackable(BlockVector3 location) {
@ -117,6 +120,7 @@ public abstract class BlockVector3 {
return YzxOrderComparator.YZX_ORDER;
}
//FAWE start
public MutableBlockVector3 setComponents(double x, double y, double z) {
return new MutableBlockVector3((int) x, (int) y, (int) z);
}
@ -157,22 +161,27 @@ public abstract class BlockVector3 {
public BlockVector3 toImmutable() {
return BlockVector3.at(getX(), getY(), getZ());
}
//FAWE end
/**
* Get the X coordinate.
*
* @return the x coordinate
*/
//FAWE start - Made abstract
public abstract int getX();
//FAWE end
/**
* Get the X coordinate.
*
* @return the x coordinate
*/
//FAWE start - getter
public int getBlockX() {
return getX();
}
//FAWE end
/**
* Set the X coordinate.
@ -180,25 +189,31 @@ public abstract class BlockVector3 {
* @param x the new X
* @return a new vector
*/
//FAWE start - getter
public BlockVector3 withX(int x) {
return BlockVector3.at(x, getY(), getZ());
}
//FAWE end
/**
* Get the Y coordinate.
*
* @return the y coordinate
*/
//FAWE start - Made abstract
public abstract int getY();
//FAWE end
/**
* Get the Y coordinate.
*
* @return the y coordinate
*/
//FAWE start - getter
public int getBlockY() {
return getY();
}
//FAWE end
/**
* Set the Y coordinate.
@ -206,25 +221,31 @@ public abstract class BlockVector3 {
* @param y the new Y
* @return a new vector
*/
//FAWE start - getter
public BlockVector3 withY(int y) {
return BlockVector3.at(getX(), y, getZ());
}
//FAWE end
/**
* Get the Z coordinate.
*
* @return the z coordinate
*/
//FAWE start - Made abstract
public abstract int getZ();
//FAWE end
/**
* Get the Z coordinate.
*
* @return the z coordinate
*/
//FAWE start - getter
public int getBlockZ() {
return getZ();
}
//FAWE end
/**
* Set the Z coordinate.
@ -232,9 +253,11 @@ public abstract class BlockVector3 {
* @param z the new Z
* @return a new vector
*/
//FAWE start - getter
public BlockVector3 withZ(int z) {
return BlockVector3.at(getX(), getY(), z);
}
//FAWE end
/**
* Add another vector to this vector and return the result as a new vector.
@ -242,9 +265,11 @@ public abstract class BlockVector3 {
* @param other the other vector
* @return a new vector
*/
//FAWE start - getter
public BlockVector3 add(BlockVector3 other) {
return add(other.getX(), other.getY(), other.getZ());
}
//FAWE end
/**
* Add another vector to this vector and return the result as a new vector.
@ -254,9 +279,11 @@ public abstract class BlockVector3 {
* @param z the value to add
* @return a new vector
*/
//FAWE start - getter
public BlockVector3 add(int x, int y, int z) {
return BlockVector3.at(this.getX() + x, this.getY() + y, this.getZ() + z);
}
//FAWE end
/**
* Add a list of vectors to this vector and return the
@ -265,6 +292,7 @@ public abstract class BlockVector3 {
* @param others an array of vectors
* @return a new vector
*/
//FAWE start - getter
public BlockVector3 add(BlockVector3... others) {
int newX = getX();
int newY = getY();
@ -278,6 +306,7 @@ public abstract class BlockVector3 {
return BlockVector3.at(newX, newY, newZ);
}
//FAWE end
/**
* Subtract another vector from this vector and return the result
@ -286,9 +315,11 @@ public abstract class BlockVector3 {
* @param other the other vector
* @return a new vector
*/
//FAWE start - getter
public BlockVector3 subtract(BlockVector3 other) {
return subtract(other.getX(), other.getY(), other.getZ());
}
//FAWE end
/**
* Subtract another vector from this vector and return the result
@ -299,9 +330,11 @@ public abstract class BlockVector3 {
* @param z the value to subtract
* @return a new vector
*/
//FAWE start - getter
public BlockVector3 subtract(int x, int y, int z) {
return BlockVector3.at(this.getX() - x, this.getY() - y, this.getZ() - z);
}
//FAWE end
/**
* Subtract a list of vectors from this vector and return the result
@ -310,6 +343,7 @@ public abstract class BlockVector3 {
* @param others an array of vectors
* @return a new vector
*/
//FAWE start - getter
public BlockVector3 subtract(BlockVector3... others) {
int newX = getX();
int newY = getY();
@ -323,6 +357,7 @@ public abstract class BlockVector3 {
return BlockVector3.at(newX, newY, newZ);
}
//FAWE end
/**
* Multiply this vector by another vector on each component.
@ -330,9 +365,11 @@ public abstract class BlockVector3 {
* @param other the other vector
* @return a new vector
*/
//FAWE start - getter
public BlockVector3 multiply(BlockVector3 other) {
return multiply(other.getX(), other.getY(), other.getZ());
}
//FAWE end
/**
* Multiply this vector by another vector on each component.
@ -342,9 +379,11 @@ public abstract class BlockVector3 {
* @param z the value to multiply
* @return a new vector
*/
//FAWE start - getter
public BlockVector3 multiply(int x, int y, int z) {
return BlockVector3.at(this.getX() * x, this.getY() * y, this.getZ() * z);
}
//FAWE end
/**
* Multiply this vector by zero or more vectors on each component.
@ -352,6 +391,7 @@ public abstract class BlockVector3 {
* @param others an array of vectors
* @return a new vector
*/
//FAWE start - getter
public BlockVector3 multiply(BlockVector3... others) {
int newX = getX();
int newY = getY();
@ -365,6 +405,7 @@ public abstract class BlockVector3 {
return BlockVector3.at(newX, newY, newZ);
}
//FAWE end
/**
* Perform scalar multiplication and return a new vector.
@ -382,9 +423,11 @@ public abstract class BlockVector3 {
* @param other the other vector
* @return a new vector
*/
//FAWE start - getter
public BlockVector3 divide(BlockVector3 other) {
return divide(other.getX(), other.getY(), other.getZ());
}
//FAWE end
/**
* Divide this vector by another vector on each component.
@ -394,9 +437,11 @@ public abstract class BlockVector3 {
* @param z the value to divide by
* @return a new vector
*/
//FAWE start - getter
public BlockVector3 divide(int x, int y, int z) {
return BlockVector3.at(this.getX() / x, this.getY() / y, this.getZ() / z);
}
//FAWE end
/**
* Perform scalar division and return a new vector.
@ -416,9 +461,11 @@ public abstract class BlockVector3 {
* @param z the value to shift z by
* @return a new vector
*/
//FAWE start - getter
public BlockVector3 shr(int x, int y, int z) {
return at(this.getX() >> x, this.getY() >> y, this.getZ() >> z);
}
//FAWE end
/**
* Shift all components right by {@code n}.
@ -438,9 +485,11 @@ public abstract class BlockVector3 {
* @param z the value to shift z by
* @return a new vector
*/
//FAWE start - getter
public BlockVector3 shl(int x, int y, int z) {
return at(this.getX() << x, this.getY() << y, this.getZ() << z);
}
//FAWE end
/**
* Shift all components left by {@code n}.
@ -466,9 +515,11 @@ public abstract class BlockVector3 {
*
* @return length, squared
*/
//FAWE start - getter
public int lengthSq() {
return getX() * getX() + getY() * getY() + getZ() * getZ();
}
//FAWE end
/**
* Get the distance between this vector and another vector.
@ -486,12 +537,14 @@ public abstract class BlockVector3 {
* @param other the other vector
* @return distance
*/
//FAWE start - getter
public int distanceSq(BlockVector3 other) {
int dx = other.getX() - getX();
int dy = other.getY() - getY();
int dz = other.getZ() - getZ();
return dx * dx + dy * dy + dz * dz;
}
//FAWE end
/**
* Get the normalized vector, which is the vector divided by its
@ -499,6 +552,7 @@ public abstract class BlockVector3 {
*
* @return a new vector
*/
//FAWE start - getter
public BlockVector3 normalize() {
double len = length();
double x = this.getX() / len;
@ -506,6 +560,7 @@ public abstract class BlockVector3 {
double z = this.getZ() / len;
return BlockVector3.at(x, y, z);
}
//FAWE end
/**
* Gets the dot product of this and another vector.
@ -513,9 +568,11 @@ public abstract class BlockVector3 {
* @param other the other vector
* @return the dot product of this and the other vector
*/
//FAWE start - getter
public double dot(BlockVector3 other) {
return getX() * other.getX() + getY() * other.getY() + getZ() * other.getZ();
}
//FAWE end
/**
* Gets the cross product of this and another vector.
@ -523,6 +580,7 @@ public abstract class BlockVector3 {
* @param other the other vector
* @return the cross product of this and the other vector
*/
//FAWE start - getter
public BlockVector3 cross(BlockVector3 other) {
return new BlockVector3Imp(
getY() * other.getZ() - getZ() * other.getY(),
@ -530,6 +588,7 @@ public abstract class BlockVector3 {
getX() * other.getY() - getY() * other.getX()
);
}
//FAWE end
/**
* Checks to see if a vector is contained with another.
@ -538,10 +597,12 @@ public abstract class BlockVector3 {
* @param max the maximum point (X, Y, and Z are the lowest)
* @return true if the vector is contained
*/
//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();
}
//FAWE end
/**
* Clamp the Y component.
@ -550,6 +611,7 @@ public abstract class BlockVector3 {
* @param max the maximum value
* @return a new vector
*/
//FAWE start - getter
public BlockVector3 clampY(int min, int max) {
checkArgument(min <= max, "minimum cannot be greater than maximum");
if (getY() < min) {
@ -560,6 +622,7 @@ public abstract class BlockVector3 {
}
return this;
}
//FAWE end
/**
* Floors the values of all components.
@ -599,9 +662,11 @@ public abstract class BlockVector3 {
*
* @return a new vector
*/
//FAWE start - getter
public BlockVector3 abs() {
return BlockVector3.at(Math.abs(getX()), Math.abs(getY()), Math.abs(getZ()));
}
//FAWE end
/**
* Perform a 2D transformation on this vector and return a new one.
@ -614,6 +679,7 @@ public abstract class BlockVector3 {
* @return a new vector
* @see AffineTransform another method to transform vectors
*/
//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;
@ -629,6 +695,7 @@ public abstract class BlockVector3 {
z2 + aboutZ + translateZ
);
}
//FAWE end
/**
* Get this vector's pitch as used within the game.
@ -670,6 +737,7 @@ public abstract class BlockVector3 {
* @param v2 the second vector
* @return minimum
*/
//FAWE start - getter
public BlockVector3 getMinimum(BlockVector3 v2) {
return new BlockVector3Imp(
Math.min(getX(), v2.getX()),
@ -677,6 +745,7 @@ public abstract class BlockVector3 {
Math.min(getZ(), v2.getZ())
);
}
//FAWE end
/**
* Gets the maximum components of two vectors.
@ -684,6 +753,7 @@ public abstract class BlockVector3 {
* @param v2 the second vector
* @return maximum
*/
//FAWE start - getter
public BlockVector3 getMaximum(BlockVector3 v2) {
return new BlockVector3Imp(
Math.max(getX(), v2.getX()),
@ -691,7 +761,9 @@ public abstract class BlockVector3 {
Math.max(getZ(), v2.getZ())
);
}
//FAWE end
//FAWE start
/*
Methods for getting/setting blocks
@ -799,5 +871,6 @@ public abstract class BlockVector3 {
public BlockVector3 plus(BlockVector3 other) {
return add(other);
}
//FAWE end
}

View File

@ -1,396 +0,0 @@
package com.sk89q.worldedit.math;
import com.sk89q.jnbt.CompoundTag;
import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockState;
import java.util.Comparator;
public class DelegateBlockVector3 extends BlockVector3 {
private BlockVector3 parent;
public DelegateBlockVector3 init(BlockVector3 parent) {
this.parent = parent;
return this;
}
public static BlockVector3 at(double x, double y, double z) {
return BlockVector3.at(x, y, z);
}
public static BlockVector3 at(int x, int y, int z) {
return BlockVector3.at(x, y, z);
}
public static boolean isLongPackable(BlockVector3 location) {
return BlockVector3.isLongPackable(location);
}
public static void checkLongPackable(BlockVector3 location) {
BlockVector3.checkLongPackable(location);
}
public static BlockVector3 fromLongPackedForm(long packed) {
return BlockVector3.fromLongPackedForm(packed);
}
public static Comparator<BlockVector3> sortByCoordsYzx() {
return BlockVector3.sortByCoordsYzx();
}
@Override
public MutableBlockVector3 setComponents(double x, double y, double z) {
return parent.setComponents(x, y, z);
}
@Override
public MutableBlockVector3 setComponents(int x, int y, int z) {
return parent.setComponents(x, y, z);
}
@Override
public MutableBlockVector3 mutX(double x) {
return parent.mutX(x);
}
@Override
public MutableBlockVector3 mutY(double y) {
return parent.mutY(y);
}
@Override
public MutableBlockVector3 mutZ(double z) {
return parent.mutZ(z);
}
@Override
public MutableBlockVector3 mutX(int x) {
return parent.mutX(x);
}
@Override
public MutableBlockVector3 mutY(int y) {
return parent.mutY(y);
}
@Override
public MutableBlockVector3 mutZ(int z) {
return parent.mutZ(z);
}
@Override
public BlockVector3 toImmutable() {
return parent.toImmutable();
}
@Override
public long toLongPackedForm() {
return parent.toLongPackedForm();
}
@Override
public int getX() {
return parent.getX();
}
@Override
public int getBlockX() {
return parent.getBlockX();
}
@Override
public BlockVector3 withX(int x) {
return parent.withX(x);
}
@Override
public int getY() {
return parent.getY();
}
@Override
public int getBlockY() {
return parent.getBlockY();
}
@Override
public BlockVector3 withY(int y) {
return parent.withY(y);
}
@Override
public int getZ() {
return parent.getZ();
}
@Override
public int getBlockZ() {
return parent.getBlockZ();
}
@Override
public BlockVector3 withZ(int z) {
return parent.withZ(z);
}
@Override
public BlockVector3 add(BlockVector3 other) {
return parent.add(other);
}
@Override
public BlockVector3 add(int x, int y, int z) {
return parent.add(x, y, z);
}
@Override
public BlockVector3 add(BlockVector3... others) {
return parent.add(others);
}
@Override
public BlockVector3 subtract(BlockVector3 other) {
return parent.subtract(other);
}
@Override
public BlockVector3 subtract(int x, int y, int z) {
return parent.subtract(x, y, z);
}
@Override
public BlockVector3 subtract(BlockVector3... others) {
return parent.subtract(others);
}
@Override
public BlockVector3 multiply(BlockVector3 other) {
return parent.multiply(other);
}
@Override
public BlockVector3 multiply(int x, int y, int z) {
return parent.multiply(x, y, z);
}
@Override
public BlockVector3 multiply(BlockVector3... others) {
return parent.multiply(others);
}
@Override
public BlockVector3 multiply(int n) {
return parent.multiply(n);
}
@Override
public BlockVector3 divide(BlockVector3 other) {
return parent.divide(other);
}
@Override
public BlockVector3 divide(int x, int y, int z) {
return parent.divide(x, y, z);
}
@Override
public BlockVector3 divide(int n) {
return parent.divide(n);
}
@Override
public BlockVector3 shr(int x, int y, int z) {
return parent.shr(x, y, z);
}
@Override
public BlockVector3 shr(int n) {
return parent.shr(n);
}
@Override
public BlockVector3 shl(int x, int y, int z) {
return parent.shl(x, y, z);
}
@Override
public BlockVector3 shl(int n) {
return parent.shl(n);
}
@Override
public double length() {
return parent.length();
}
@Override
public int lengthSq() {
return parent.lengthSq();
}
@Override
public double distance(BlockVector3 other) {
return parent.distance(other);
}
@Override
public int distanceSq(BlockVector3 other) {
return parent.distanceSq(other);
}
@Override
public BlockVector3 normalize() {
return parent.normalize();
}
@Override
public double dot(BlockVector3 other) {
return parent.dot(other);
}
@Override
public BlockVector3 cross(BlockVector3 other) {
return parent.cross(other);
}
@Override
public boolean containedWithin(BlockVector3 min, BlockVector3 max) {
return parent.containedWithin(min, max);
}
@Override
public BlockVector3 clampY(int min, int max) {
return parent.clampY(min, max);
}
@Override
public BlockVector3 floor() {
return parent.floor();
}
@Override
public BlockVector3 ceil() {
return parent.ceil();
}
@Override
public BlockVector3 round() {
return parent.round();
}
@Override
public BlockVector3 abs() {
return parent.abs();
}
@Override
public BlockVector3 transform2D(double angle, double aboutX, double aboutZ, double translateX, double translateZ) {
return parent.transform2D(angle, aboutX, aboutZ, translateX, translateZ);
}
@Override
public double toPitch() {
return parent.toPitch();
}
@Override
public double toYaw() {
return parent.toYaw();
}
@Override
public BlockVector3 getMinimum(BlockVector3 v2) {
return parent.getMinimum(v2);
}
@Override
public BlockVector3 getMaximum(BlockVector3 v2) {
return parent.getMaximum(v2);
}
@Override
public boolean setOrdinal(Extent orDefault, int ordinal) {
return parent.setOrdinal(orDefault, ordinal);
}
@Override
public boolean setBlock(Extent orDefault, BlockState state) {
return parent.setBlock(orDefault, state);
}
@Override
public boolean setFullBlock(Extent orDefault, BaseBlock block) {
return parent.setFullBlock(orDefault, block);
}
@Override
public int getOrdinal(Extent orDefault) {
return parent.getOrdinal(orDefault);
}
@Override
public char getOrdinalChar(Extent orDefault) {
return parent.getOrdinalChar(orDefault);
}
@Override
public BlockState getBlock(Extent orDefault) {
return parent.getBlock(orDefault);
}
@Override
public BaseBlock getFullBlock(Extent orDefault) {
return parent.getFullBlock(orDefault);
}
@Override
public CompoundTag getNbtData(Extent orDefault) {
return parent.getNbtData(orDefault);
}
@Override
public BlockState getOrdinalBelow(Extent orDefault) {
return parent.getOrdinalBelow(orDefault);
}
@Override
public BlockState getStateAbove(Extent orDefault) {
return parent.getStateAbove(orDefault);
}
@Override
public BlockState getStateRelativeY(Extent orDefault, int y) {
return parent.getStateRelativeY(orDefault, y);
}
@Override
public BlockVector2 toBlockVector2() {
return parent.toBlockVector2();
}
@Override
public Vector3 toVector3() {
return parent.toVector3();
}
@Override
public boolean equals(Object obj) {
return parent.equals(obj);
}
@Override
public int hashCode() {
return parent.hashCode();
}
@Override
public String toString() {
return parent.toString();
}
@Override
public BlockVector3 plus(BlockVector3 other) {
return parent.plus(other);
}
}

View File

@ -1,48 +0,0 @@
package com.sk89q.worldedit.math;
public class MutableBlockVector2 extends BlockVector2 {
private static ThreadLocal<MutableBlockVector2> MUTABLE_CACHE = ThreadLocal.withInitial(MutableBlockVector2::new);
public static MutableBlockVector2 get(int x, int z) {
return MUTABLE_CACHE.get().setComponents(x, z);
}
public MutableBlockVector2() {
}
public MutableBlockVector2(int x, int z) {
super(x, z);
}
@Override
public MutableBlockVector2 setComponents(int x, int z) {
this.x = x;
this.z = z;
return this;
}
@Override
public MutableBlockVector2 mutX(double x) {
this.x = (int) x;
return this;
}
@Override
public MutableBlockVector2 mutZ(double z) {
this.z = (int) z;
return this;
}
@Override
public MutableBlockVector2 mutX(int x) {
this.x = x;
return this;
}
@Override
public MutableBlockVector2 mutZ(int z) {
this.z = z;
return this;
}
}

View File

@ -1,98 +0,0 @@
package com.sk89q.worldedit.math;
import com.fastasyncworldedit.core.FaweCache;
public class MutableBlockVector3 extends BlockVector3 {
public static MutableBlockVector3 at(double x, double y, double z) {
return at((int) Math.floor(x), (int) Math.floor(y), (int) Math.floor(z));
}
public static MutableBlockVector3 at(int x, int y, int z) {
return new MutableBlockVector3(x, y, z);
}
public static MutableBlockVector3 get(int x, int y, int z) {
return FaweCache.IMP.MUTABLE_BLOCKVECTOR3.get().setComponents(x, y, z);
}
public MutableBlockVector3() {
}
public MutableBlockVector3(BlockVector3 other) {
this(other.getX(), other.getY(), other.getZ());
}
public MutableBlockVector3 setComponents(BlockVector3 other) {
return setComponents(other.getBlockX(), other.getBlockY(), other.getBlockZ());
}
private int x;
private int y;
private int z;
public MutableBlockVector3(int x, int y, int z) {
this.x = x;
this.y = y;
this.z = z;
}
@Override
public MutableBlockVector3 setComponents(int x, int y, int z) {
this.x = x;
this.y = y;
this.z = z;
return this;
}
@Override
public final int getX() {
return x;
}
@Override
public final int getY() {
return y;
}
@Override
public final int getZ() {
return z;
}
@Override
public MutableBlockVector3 mutX(double x) {
this.x = (int) x;
return this;
}
@Override
public MutableBlockVector3 mutY(double y) {
this.y = (int) y;
return this;
}
@Override
public MutableBlockVector3 mutZ(double z) {
this.z = (int) z;
return this;
}
@Override
public final MutableBlockVector3 mutX(int x) {
this.x = x;
return this;
}
@Override
public final MutableBlockVector3 mutY(int y) {
this.y = y;
return this;
}
@Override
public final MutableBlockVector3 mutZ(int z) {
this.z = z;
return this;
}
}

View File

@ -1,111 +0,0 @@
package com.sk89q.worldedit.math;
import com.fastasyncworldedit.core.FaweCache;
public class MutableVector3 extends Vector3 {
private double x;
private double y;
private double z;
public MutableVector3() {
}
public MutableVector3(double x, double y, double z) {
this.x = x;
this.y = y;
this.z = z;
}
public MutableVector3(float x, float y, float z) {
this((double) x, (double) y, (double) z);
}
public MutableVector3(Vector3 other) {
this(other.getX(), other.getY(), other.getZ());
}
public static MutableVector3 get(int x, int y, int z) {
return FaweCache.IMP.MUTABLE_VECTOR3.get().setComponents(x, y, z);
}
public static MutableVector3 get(double x, double y, double z) {
return FaweCache.IMP.MUTABLE_VECTOR3.get().setComponents(x, y, z);
}
@Override
public MutableVector3 setComponents(Vector3 other) {
this.x = other.getX();
this.y = other.getY();
this.z = other.getZ();
return this;
}
@Override
public MutableVector3 setComponents(int x, int y, int z) {
this.x = x;
this.y = y;
this.z = z;
return this;
}
@Override
public MutableVector3 setComponents(double x, double y, double z) {
this.x = x;
this.y = y;
this.z = z;
return this;
}
@Override
public MutableVector3 mutX(int x) {
this.x = x;
return this;
}
@Override
public MutableVector3 mutX(double x) {
this.x = x;
return this;
}
@Override
public MutableVector3 mutY(int y) {
this.y = y;
return this;
}
@Override
public MutableVector3 mutY(double y) {
this.y = y;
return this;
}
@Override
public MutableVector3 mutZ(int z) {
this.z = z;
return this;
}
@Override
public MutableVector3 mutZ(double z) {
this.z = z;
return this;
}
@Override
public double getX() {
return x;
}
@Override
public double getY() {
return y;
}
@Override
public double getZ() {
return z;
}
}

View File

@ -1,24 +0,0 @@
package com.sk89q.worldedit.math;
public class OffsetBlockVector3 extends DelegateBlockVector3 {
private final BlockVector3 offset;
public OffsetBlockVector3(BlockVector3 offset) {
this.offset = offset;
}
@Override
public int getX() {
return super.getX() + offset.getX();
}
@Override
public int getY() {
return super.getY() + offset.getY();
}
@Override
public int getZ() {
return super.getZ() + offset.getZ();
}
}

View File

@ -470,7 +470,9 @@ public final class Vector2 {
@Override
public int hashCode() {
//FAWE start - XOR over x z calc
return (int) x << 16 ^ (int) z;
//FAWE end
}
@Override

View File

@ -19,6 +19,8 @@
package com.sk89q.worldedit.math;
import com.fastasyncworldedit.core.math.MutableVector3;
import com.fastasyncworldedit.core.math.Vector3Impl;
import com.fastasyncworldedit.core.util.MathMan;
import com.google.common.collect.ComparisonChain;
import com.sk89q.worldedit.math.transform.AffineTransform;
@ -39,7 +41,7 @@ public abstract class Vector3 {
public static final Vector3 ONE = Vector3.at(1, 1, 1);
public static Vector3 at(double x, double y, double z) {
/* Unnecessary
/*FAWE start - Unnecessary
// switch for efficiency on typical cases
// in MC y is rarely 0/1 on selections
int yTrunc = (int) y;
@ -57,6 +59,7 @@ public abstract class Vector3 {
default:
break;
}
Fawe end
*/
return new Vector3Impl(x, y, z);
}
@ -83,6 +86,7 @@ public abstract class Vector3 {
return YzxOrderComparator.YZX_ORDER;
}
//FAWE start
/**
* Gets the x coordinate rounded, accounting for negative coordinates
*
@ -145,13 +149,16 @@ public abstract class Vector3 {
public MutableVector3 mutZ(double z) {
return new MutableVector3(getX(), getY(), z);
}
//FAWE end
/**
* Get the X coordinate.
*
* @return the x coordinate
*/
//FAWE start - made abstract
public abstract double getX();
//FAWE end
/**
* Set the X coordinate.
@ -159,16 +166,20 @@ public abstract class Vector3 {
* @param x the new X
* @return a new vector
*/
//FAWE start - getter
public Vector3 withX(double x) {
return Vector3.at(x, getY(), getZ());
}
//FAWE end
/**
* Get the Y coordinate.
*
* @return the y coordinate
*/
//FAWE start - made abstract
public abstract double getY();
//FAWE end
/**
* Set the Y coordinate.
@ -176,16 +187,20 @@ public abstract class Vector3 {
* @param y the new Y
* @return a new vector
*/
//FAWE start - getter
public Vector3 withY(double y) {
return Vector3.at(getX(), y, getZ());
}
//FAWE end
/**
* Get the Z coordinate.
*
* @return the z coordinate
*/
//FAWE start - made abstract
public abstract double getZ();
//FAWE end
/**
* Set the Z coordinate.
@ -193,9 +208,11 @@ public abstract class Vector3 {
* @param z the new Z
* @return a new vector
*/
//FAWE start - getter
public Vector3 withZ(double z) {
return Vector3.at(getX(), getY(), z);
}
//FAWE end
/**
* Add another vector to this vector and return the result as a new vector.
@ -203,9 +220,11 @@ public abstract class Vector3 {
* @param other the other vector
* @return a new vector
*/
//FAWE start - getter
public Vector3 add(Vector3 other) {
return add(other.getX(), other.getY(), other.getZ());
}
//FAWE end
/**
* Add another vector to this vector and return the result as a new vector.
@ -215,9 +234,11 @@ public abstract class Vector3 {
* @param z the value to add
* @return a new vector
*/
//FAWE start - getter
public Vector3 add(double x, double y, double z) {
return Vector3.at(this.getX() + x, this.getY() + y, this.getZ() + z);
}
//FAWE end
/**
* Add a list of vectors to this vector and return the
@ -226,6 +247,7 @@ public abstract class Vector3 {
* @param others an array of vectors
* @return a new vector
*/
//FAWE start - getter
public Vector3 add(Vector3... others) {
double newX = getX();
double newY = getY();
@ -239,6 +261,7 @@ public abstract class Vector3 {
return Vector3.at(newX, newY, newZ);
}
//FAWE end
/**
* Subtract another vector from this vector and return the result
@ -247,9 +270,11 @@ public abstract class Vector3 {
* @param other the other vector
* @return a new vector
*/
//FAWE start - getter
public Vector3 subtract(Vector3 other) {
return subtract(other.getX(), other.getY(), other.getZ());
}
//FAWE end
/**
* Subtract another vector from this vector and return the result
@ -260,9 +285,11 @@ public abstract class Vector3 {
* @param z the value to subtract
* @return a new vector
*/
//FAWE start - getter
public Vector3 subtract(double x, double y, double z) {
return Vector3.at(this.getX() - x, this.getY() - y, this.getZ() - z);
}
//FAWE end
/**
* Subtract a list of vectors from this vector and return the result
@ -271,6 +298,7 @@ public abstract class Vector3 {
* @param others an array of vectors
* @return a new vector
*/
//FAWE start - getter
public Vector3 subtract(Vector3... others) {
double newX = getX();
double newY = getY();
@ -284,6 +312,7 @@ public abstract class Vector3 {
return Vector3.at(newX, newY, newZ);
}
//FAWE end
/**
* Multiply this vector by another vector on each component.
@ -291,9 +320,11 @@ public abstract class Vector3 {
* @param other the other vector
* @return a new vector
*/
//FAWE start - getter
public Vector3 multiply(Vector3 other) {
return multiply(other.getX(), other.getY(), other.getZ());
}
//FAWE end
/**
* Multiply this vector by another vector on each component.
@ -303,9 +334,11 @@ public abstract class Vector3 {
* @param z the value to multiply
* @return a new vector
*/
//FAWE start - getter
public Vector3 multiply(double x, double y, double z) {
return Vector3.at(this.getX() * x, this.getY() * y, this.getZ() * z);
}
//FAWE end
/**
* Multiply this vector by zero or more vectors on each component.
@ -313,6 +346,7 @@ public abstract class Vector3 {
* @param others an array of vectors
* @return a new vector
*/
//FAWE start - getter
public Vector3 multiply(Vector3... others) {
double newX = getX();
double newY = getY();
@ -326,6 +360,7 @@ public abstract class Vector3 {
return Vector3.at(newX, newY, newZ);
}
//FAWE end
/**
* Perform scalar multiplication and return a new vector.
@ -343,9 +378,11 @@ public abstract class Vector3 {
* @param other the other vector
* @return a new vector
*/
//FAWE start - getter
public Vector3 divide(Vector3 other) {
return divide(other.getX(), other.getY(), other.getZ());
}
//FAWE end
/**
* Divide this vector by another vector on each component.
@ -355,9 +392,11 @@ public abstract class Vector3 {
* @param z the value to divide by
* @return a new vector
*/
//FAWE start - getter
public Vector3 divide(double x, double y, double z) {
return Vector3.at(this.getX() / x, this.getY() / y, this.getZ() / z);
}
//FAWE end
/**
* Perform scalar division and return a new vector.
@ -383,9 +422,11 @@ public abstract class Vector3 {
*
* @return length, squared
*/
//FAWE start - getter
public double lengthSq() {
return getX() * getX() + getY() * getY() + getZ() * getZ();
}
//FAWE end
/**
* Get the distance between this vector and another vector.
@ -403,12 +444,14 @@ public abstract class Vector3 {
* @param other the other vector
* @return distance
*/
//FAWE start - getter
public double distanceSq(Vector3 other) {
double dx = other.getX() - getX();
double dy = other.getY() - getY();
double dz = other.getZ() - getZ();
return dx * dx + dy * dy + dz * dz;
}
//FAWE end
/**
* Get the normalized vector, which is the vector divided by its
@ -426,9 +469,11 @@ public abstract class Vector3 {
* @param other the other vector
* @return the dot product of this and the other vector
*/
//FAWE start - getter
public double dot(Vector3 other) {
return getX() * other.getX() + getY() * other.getY() + getZ() * other.getZ();
}
//FAWE end
/**
* Gets the cross product of this and another vector.
@ -436,6 +481,7 @@ public abstract class Vector3 {
* @param other the other vector
* @return the cross product of this and the other vector
*/
//FAWE start - getter
public Vector3 cross(Vector3 other) {
return Vector3.at(
getY() * other.getZ() - getZ() * other.getY(),
@ -443,6 +489,7 @@ public abstract class Vector3 {
getX() * other.getY() - getY() * other.getX()
);
}
//FAWE end
/**
* Checks to see if a vector is contained with another.
@ -451,9 +498,11 @@ public abstract class Vector3 {
* @param max the maximum point (X, Y, and Z are the lowest)
* @return true if the vector is contained
*/
//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();
}
//FAWE end
/**
* Clamp the Y component.
@ -462,6 +511,7 @@ public abstract class Vector3 {
* @param max the maximum value
* @return a new vector
*/
//FAWE start - getter
public Vector3 clampY(int min, int max) {
checkArgument(min <= max, "minimum cannot be greater than maximum");
if (getY() < min) {
@ -472,24 +522,29 @@ public abstract class Vector3 {
}
return this;
}
//FAWE end
/**
* Floors the values of all components.
*
* @return a new vector
*/
//FAWE start - getter
public Vector3 floor() {
return Vector3.at(Math.floor(getX()), Math.floor(getY()), Math.floor(getZ()));
}
//FAWE end
/**
* Rounds all components up.
*
* @return a new vector
*/
//FAWE start - getter
public Vector3 ceil() {
return Vector3.at(Math.ceil(getX()), Math.ceil(getY()), Math.ceil(getZ()));
}
//FAWE end
/**
* Rounds all components to the closest integer.
@ -498,18 +553,22 @@ public abstract class Vector3 {
*
* @return a new vector
*/
//FAWE start - getter
public Vector3 round() {
return Vector3.at(Math.floor(getX() + 0.5), Math.floor(getY() + 0.5), Math.floor(getZ() + 0.5));
}
//FAWE end
/**
* Rounds all components using {@link MathUtils#roundHalfUp(double)}
*
* @return a new vector
*/
//FAWE start - getter
public Vector3 roundHalfUp() {
return Vector3.at(MathUtils.roundHalfUp(getX()), MathUtils.roundHalfUp(getY()), MathUtils.roundHalfUp(getZ()));
}
//FAWE end
/**
* Returns a vector with the absolute values of the components of
@ -517,9 +576,11 @@ public abstract class Vector3 {
*
* @return a new vector
*/
//FAWE start - getter
public Vector3 abs() {
return Vector3.at(Math.abs(getX()), Math.abs(getY()), Math.abs(getZ()));
}
//FAWE end
/**
* Perform a 2D transformation on this vector and return a new one.
@ -532,6 +593,7 @@ public abstract class Vector3 {
* @return a new vector
* @see AffineTransform another method to transform vectors
*/
//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;
@ -547,6 +609,7 @@ public abstract class Vector3 {
z2 + aboutZ + translateZ
);
}
//FAWE end
/**
* Get this vector's pitch as used within the game.
@ -588,6 +651,7 @@ public abstract class Vector3 {
* @param v2 the second vector
* @return minimum
*/
//FAWE start - getter
public Vector3 getMinimum(Vector3 v2) {
return Vector3.at(
Math.min(getX(), v2.getX()),
@ -595,6 +659,7 @@ public abstract class Vector3 {
Math.min(getZ(), v2.getZ())
);
}
//FAWE end
/**
* Gets the maximum components of two vectors.
@ -602,6 +667,7 @@ public abstract class Vector3 {
* @param v2 the second vector
* @return maximum
*/
//FAWE start - getter
public Vector3 getMaximum(Vector3 v2) {
return Vector3.at(
Math.max(getX(), v2.getX()),
@ -609,6 +675,7 @@ public abstract class Vector3 {
Math.max(getZ(), v2.getZ())
);
}
//FAWE end
/**
* Create a new {@code BlockVector} using the given components.
@ -627,18 +694,22 @@ public abstract class Vector3 {
*
* @return a new {@code BlockVector}
*/
//FAWE start - getter
public BlockVector3 toBlockPoint() {
return toBlockPoint(getX(), getY(), getZ());
}
//FAWE end
/**
* Creates a 2D vector by dropping the Y component from this vector.
*
* @return a new {@link Vector2}
*/
//FAWE start - getter
public Vector2 toVector2() {
return Vector2.at(getX(), getZ());
}
//FAWE end
@Override
public boolean equals(Object obj) {
@ -647,9 +718,12 @@ public abstract class Vector3 {
}
Vector3 other = (Vector3) obj;
//FAWE start - getter
return other.getX() == this.getX() && other.getY() == this.getY() && other.getZ() == this.getZ();
//FAWE end
}
//FAWE start
/**
* Tests if vectors are equal, accounting for floating point errors
*
@ -673,17 +747,21 @@ public abstract class Vector3 {
}
return true;
}
//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());
//FAWE end
return "(" + x + ", " + y + ", " + z + ")";
}
@ -691,8 +769,10 @@ public abstract class Vector3 {
* Returns a string representation that is supported by the parser.
* @return string
*/
//FAWE start - getter
public String toParserString() {
return getX() + "," + getY() + "," + getZ();
}
//FAWE end
}

View File

@ -1,32 +0,0 @@
package com.sk89q.worldedit.math;
public class Vector3Impl extends Vector3 {
private final double x;
private final double y;
private final double z;
public Vector3Impl(double x, double y, double z) {
this.x = x;
this.y = y;
this.z = z;
}
public Vector3Impl(Vector3 other) {
this(other.getX(), other.getY(), other.getZ());
}
@Override
public final double getX() {
return x;
}
@Override
public final double getY() {
return y;
}
@Override
public final double getZ() {
return z;
}
}

View File

@ -26,7 +26,7 @@ import com.sk89q.worldedit.math.BlockVector2;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.regions.Regions;
import com.sk89q.worldedit.registry.state.PropertyGroup;
import com.fastasyncworldedit.core.registry.state.PropertyGroup;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockStateHolder;
import com.sk89q.worldedit.world.block.BlockTypes;
@ -43,9 +43,11 @@ import static com.google.common.base.Preconditions.checkNotNull;
*/
public class HeightMap {
//FAWE start
private final boolean layers;
private int[] data;
private boolean[] invalid;
//FAWE end
private final int[] data;
private final int width;
private final int height;
@ -58,6 +60,7 @@ public class HeightMap {
* @param session an edit session
* @param region the region
*/
//FAWE start
public HeightMap(EditSession session, Region region) {
this(session, region, (Mask) null, false);
}
@ -65,6 +68,7 @@ public class HeightMap {
public HeightMap(EditSession session, Region region, @Nullable Mask mask) {
this(session, region, mask, false);
}
//FAWE end
public HeightMap(EditSession session, Region region, @Nullable Mask mask, boolean layers) {
checkNotNull(session);
@ -87,6 +91,7 @@ public class HeightMap {
data = new int[width * height];
invalid = new boolean[data.length];
//FAWE start
if (layers) {
BlockVector3 min = region.getMinimumPoint();
int bx = min.getBlockX();
@ -141,6 +146,7 @@ public class HeightMap {
this.layers = layers;
}
//FAWE end
/**
* Apply the filter 'iterations' amount times.
@ -160,6 +166,7 @@ public class HeightMap {
newData = filter.filter(newData, width, height);
}
//FAWE start - check layers
return layers ? applyLayers(newData) : apply(newData);
}
@ -249,6 +256,7 @@ public class HeightMap {
}
return blocksChanged;
}
//FAWE end
/**
* Apply a raw heightmap to the region.
@ -273,6 +281,7 @@ public class HeightMap {
BlockState tmpBlock = BlockTypes.AIR.getDefaultState();
// Apply heightmap
int index = 0;
//FAWE start
for (int z = 0; z < height; ++z) {
int zr = z + originZ;
for (int x = 0; x < width; ++x, index++) {
@ -326,6 +335,7 @@ public class HeightMap {
}
}
}
//FAWE end
// Drop trees to the floor -- TODO

View File

@ -21,7 +21,7 @@
package com.sk89q.worldedit.math.interpolation;
import com.sk89q.worldedit.math.MutableVector3;
import com.fastasyncworldedit.core.math.MutableVector3;
import com.sk89q.worldedit.math.Vector3;
import java.util.Collections;
@ -161,12 +161,14 @@ public class KochanekBartelsInterpolation implements Interpolation {
final Vector3 c = coeffC[index];
final Vector3 d = coeffD[index];
//FAWE start
double r2 = remainder * remainder;
double r3 = r2 * remainder;
mutable.mutX((a.getX() * r3 + b.getX() * r2 + c.getX() * remainder + d.getX()));
mutable.mutY((a.getY() * r3 + b.getY() * r2 + c.getY() * remainder + d.getY()));
mutable.mutZ((a.getZ() * r3 + b.getZ() * r2 + c.getZ() * remainder + d.getZ()));
return Vector3.at(mutable.getX(), mutable.getY(), mutable.getZ());
//FAWE end
}
@Override

View File

@ -1,23 +0,0 @@
package com.sk89q.worldedit.math.noise;
import com.fastasyncworldedit.core.object.random.SimplexNoise;
import com.sk89q.worldedit.math.Vector2;
import com.sk89q.worldedit.math.Vector3;
public class SimplexNoiseGenerator implements NoiseGenerator {
@Override
public float noise(Vector2 position) {
return convert(SimplexNoise.noise(position.getX(), position.getZ()));
}
@Override
public float noise(Vector3 position) {
return convert(SimplexNoise.noise(position.getX(), position.getY(), position.getZ()));
}
private float convert(double d) {
// we need to go from [-1, 1] to [0, 1] and from double to float
return (float) ((d + 1) * 0.5);
}
}

View File

@ -32,7 +32,9 @@ import java.io.Serializable;
* <a href="http://geom-java.sourceforge.net/index.html">JavaGeom project</a>,
* which is licensed under LGPL v2.1.</p>
*/
//FAWE start - made Serializable
public class AffineTransform implements Transform, Serializable {
//FAWE end
/**
* coefficients for x coordinate.
@ -139,6 +141,7 @@ public class AffineTransform implements Transform, Serializable {
return new double[]{m00, m01, m02, m03, m10, m11, m12, m13, m20, m21, m22, m23};
}
//FAWE start
public boolean isOffAxis() {
double[] c = coefficients();
for (int i = 0; i < c.length; i++) {
@ -150,6 +153,7 @@ public class AffineTransform implements Transform, Serializable {
}
return false;
}
//FAWE end
/**
* Computes the determinant of this transform. Can be zero.
@ -294,6 +298,7 @@ public class AffineTransform implements Transform, Serializable {
return scale(vec.getX(), vec.getY(), vec.getZ());
}
//FAWE start
public boolean isScaled(Vector3 vector) {
boolean flip = vector.getX() != 0 && m00 < 0;
if (vector.getY() != 0 && m11 < 0) {
@ -317,6 +322,7 @@ public class AffineTransform implements Transform, Serializable {
}
return flip;
}
//FAWE end
@Override
public Vector3 apply(Vector3 vector) {
@ -335,9 +341,11 @@ public class AffineTransform implements Transform, Serializable {
@Override
public Transform combine(Transform other) {
//FAWE start - check other identity
if (other instanceof Identity || other.isIdentity()) {
return this;
} else if (other instanceof AffineTransform) {
//FAWE end
return concatenate((AffineTransform) other);
} else {
return new CombinedTransform(this, other);

View File

@ -1,36 +0,0 @@
package com.sk89q.worldedit.math.transform;
import com.sk89q.worldedit.math.Vector3;
public class RoundedTransform implements Transform {
private final Transform transform;
public RoundedTransform(Transform transform) {
this.transform = transform;
}
@Override
public boolean isIdentity() {
return transform.isIdentity();
}
@Override
public Vector3 apply(Vector3 input) {
Vector3 val = transform.apply(input);
return val.round();
}
@Override
public RoundedTransform inverse() {
return new RoundedTransform(transform.inverse());
}
@Override
public RoundedTransform combine(Transform other) {
return new RoundedTransform(transform.combine(other));
}
public Transform getTransform() {
return transform;
}
}