mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-07-10 04:38:35 +00:00
Major command changes that don't work yet.
This commit is contained in:
@ -19,7 +19,6 @@
|
||||
|
||||
package com.sk89q.worldedit.math;
|
||||
|
||||
import com.google.common.collect.ComparisonChain;
|
||||
import com.sk89q.worldedit.math.transform.AffineTransform;
|
||||
|
||||
import java.util.Comparator;
|
||||
@ -28,7 +27,7 @@ import java.util.Comparator;
|
||||
* An immutable 2-dimensional vector.
|
||||
*/
|
||||
public class BlockVector2 {
|
||||
|
||||
|
||||
public static final BlockVector2 ZERO = new BlockVector2(0, 0);
|
||||
public static final BlockVector2 UNIT_X = new BlockVector2(1, 0);
|
||||
public static final BlockVector2 UNIT_Z = new BlockVector2(0, 1);
|
||||
@ -48,18 +47,26 @@ public class BlockVector2 {
|
||||
* cdef
|
||||
* </pre>
|
||||
*/
|
||||
public static final Comparator<BlockVector2> COMPARING_GRID_ARRANGEMENT = (a, b) -> {
|
||||
return ComparisonChain.start()
|
||||
.compare(a.getBlockZ(), b.getBlockZ())
|
||||
.compare(a.getBlockX(), b.getBlockX())
|
||||
.result();
|
||||
};
|
||||
public static final Comparator<BlockVector2> COMPARING_GRID_ARRANGEMENT =
|
||||
Comparator.comparingInt(BlockVector2::getZ).thenComparingInt(BlockVector2::getX);
|
||||
|
||||
public static BlockVector2 at(double x, double z) {
|
||||
return at((int) Math.floor(x), (int) Math.floor(z));
|
||||
}
|
||||
|
||||
public static BlockVector2 at(int x, int z) {
|
||||
switch (x) {
|
||||
case 0:
|
||||
if (z == 0) {
|
||||
return ZERO;
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
if (z == 1) {
|
||||
return ONE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
return new BlockVector2(x, z);
|
||||
}
|
||||
|
||||
@ -342,6 +349,27 @@ public class BlockVector2 {
|
||||
return divide(n, n);
|
||||
}
|
||||
|
||||
/**
|
||||
* Shift all components right.
|
||||
*
|
||||
* @param x the value to shift x by
|
||||
* @param z the value to shift z by
|
||||
* @return a new vector
|
||||
*/
|
||||
public BlockVector2 shr(int x, int z) {
|
||||
return at(this.x >> x, this.z >> z);
|
||||
}
|
||||
|
||||
/**
|
||||
* Shift all components right by {@code n}.
|
||||
*
|
||||
* @param n the value to shift by
|
||||
* @return a new vector
|
||||
*/
|
||||
public BlockVector2 shr(int n) {
|
||||
return shr(n, n);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the length of the vector.
|
||||
*
|
||||
@ -571,5 +599,4 @@ public class BlockVector2 {
|
||||
public String toString() {
|
||||
return "(" + x + ", " + z + ")";
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -21,7 +21,6 @@ package com.sk89q.worldedit.math;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
|
||||
import com.google.common.collect.ComparisonChain;
|
||||
import com.sk89q.worldedit.math.transform.AffineTransform;
|
||||
|
||||
import java.util.Comparator;
|
||||
@ -45,19 +44,29 @@ public class BlockVector3 {
|
||||
}
|
||||
|
||||
public static BlockVector3 at(int x, int y, int z) {
|
||||
// switch for efficiency on typical cases
|
||||
// in MC y is rarely 0/1 on selections
|
||||
switch (y) {
|
||||
case 0:
|
||||
if (x == 0 && z == 0) {
|
||||
return ZERO;
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
if (x == 1 && z == 1) {
|
||||
return ONE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
return new BlockVector3(x, y, z);
|
||||
}
|
||||
|
||||
// thread-safe initialization idiom
|
||||
private static final class YzxOrderComparator {
|
||||
private static final Comparator<BlockVector3> YZX_ORDER = (a, b) -> {
|
||||
//noinspection SuspiciousNameCombination
|
||||
return ComparisonChain.start()
|
||||
.compare(a.y, b.y)
|
||||
.compare(a.z, b.z)
|
||||
.compare(a.x, b.x)
|
||||
.result();
|
||||
};
|
||||
private static final Comparator<BlockVector3> YZX_ORDER =
|
||||
Comparator.comparingInt(BlockVector3::getY)
|
||||
.thenComparingInt(BlockVector3::getZ)
|
||||
.thenComparingInt(BlockVector3::getX);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -369,6 +378,50 @@ public class BlockVector3 {
|
||||
return divide(n, n, n);
|
||||
}
|
||||
|
||||
/**
|
||||
* Shift all components right.
|
||||
*
|
||||
* @param x the value to shift x by
|
||||
* @param y the value to shift y by
|
||||
* @param z the value to shift z by
|
||||
* @return a new vector
|
||||
*/
|
||||
public BlockVector3 shr(int x, int y, int z) {
|
||||
return at(this.x >> x, this.y >> y, this.z >> z);
|
||||
}
|
||||
|
||||
/**
|
||||
* Shift all components right by {@code n}.
|
||||
*
|
||||
* @param n the value to shift by
|
||||
* @return a new vector
|
||||
*/
|
||||
public BlockVector3 shr(int n) {
|
||||
return shr(n, n, n);
|
||||
}
|
||||
|
||||
/**
|
||||
* Shift all components left.
|
||||
*
|
||||
* @param x the value to shift x by
|
||||
* @param y the value to shift y by
|
||||
* @param z the value to shift z by
|
||||
* @return a new vector
|
||||
*/
|
||||
public BlockVector3 shl(int x, int y, int z) {
|
||||
return at(this.x << x, this.y << y, this.z << z);
|
||||
}
|
||||
|
||||
/**
|
||||
* Shift all components left by {@code n}.
|
||||
*
|
||||
* @param n the value to shift by
|
||||
* @return a new vector
|
||||
*/
|
||||
public BlockVector3 shl(int n) {
|
||||
return shl(n, n, n);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the length of the vector.
|
||||
*
|
||||
|
@ -63,14 +63,14 @@ public final class MathUtils {
|
||||
dInt += 360;
|
||||
}
|
||||
switch (dInt) {
|
||||
case 0:
|
||||
return 1.0;
|
||||
case 90:
|
||||
return 0.0;
|
||||
case 180:
|
||||
return -1.0;
|
||||
case 270:
|
||||
return 0.0;
|
||||
case 0:
|
||||
return 1.0;
|
||||
case 90:
|
||||
return 0.0;
|
||||
case 180:
|
||||
return -1.0;
|
||||
case 270:
|
||||
return 0.0;
|
||||
}
|
||||
}
|
||||
return Math.cos(Math.toRadians(degrees));
|
||||
@ -92,14 +92,14 @@ public final class MathUtils {
|
||||
dInt += 360;
|
||||
}
|
||||
switch (dInt) {
|
||||
case 0:
|
||||
return 0.0;
|
||||
case 90:
|
||||
return 1.0;
|
||||
case 180:
|
||||
return 0.0;
|
||||
case 270:
|
||||
return -1.0;
|
||||
case 0:
|
||||
return 0.0;
|
||||
case 90:
|
||||
return 1.0;
|
||||
case 180:
|
||||
return 0.0;
|
||||
case 270:
|
||||
return -1.0;
|
||||
}
|
||||
}
|
||||
return Math.sin(Math.toRadians(degrees));
|
||||
|
@ -2,7 +2,7 @@ package com.sk89q.worldedit.math;
|
||||
|
||||
public class MutableBlockVector2 extends BlockVector2 {
|
||||
|
||||
private static ThreadLocal<MutableBlockVector2> MUTABLE_CACHE = ThreadLocal.withInitial(() -> new MutableBlockVector2());
|
||||
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);
|
||||
|
@ -1,9 +1,9 @@
|
||||
package com.sk89q.worldedit.math;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class MutableVector2 extends Vector2 {
|
||||
public MutableVector2() {}
|
||||
|
||||
public MutableVector2() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct an instance.
|
||||
@ -47,21 +47,25 @@ public class MutableVector2 extends Vector2 {
|
||||
this.z = z;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MutableVector2 mutX(int x) {
|
||||
this.x = x;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MutableVector2 mutZ(int z) {
|
||||
this.z = z;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MutableVector2 mutX(double x) {
|
||||
this.x = x;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MutableVector2 mutZ(double z) {
|
||||
this.z = z;
|
||||
|
@ -2,7 +2,8 @@ package com.sk89q.worldedit.math;
|
||||
|
||||
public class MutableVector3 extends Vector3 {
|
||||
|
||||
public MutableVector3() {}
|
||||
public MutableVector3() {
|
||||
}
|
||||
|
||||
public MutableVector3(double x, double y, double z) {
|
||||
super(x, y, z);
|
||||
@ -45,11 +46,13 @@ public class MutableVector3 extends Vector3 {
|
||||
this.x = x;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MutableVector3 mutZ(int z) {
|
||||
this.z = z;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MutableVector3 mutX(double x) {
|
||||
this.x = x;
|
||||
|
@ -33,6 +33,19 @@ public class Vector2 {
|
||||
public static final Vector2 ONE = new Vector2(1, 1);
|
||||
|
||||
public static Vector2 at(double x, double z) {
|
||||
int xTrunc = (int) x;
|
||||
switch (xTrunc) {
|
||||
case 0:
|
||||
if (x == 0 && z == 0) {
|
||||
return ZERO;
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
if (x == 1 && z == 1) {
|
||||
return ONE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
return new Vector2(x, z);
|
||||
}
|
||||
|
||||
@ -445,7 +458,7 @@ public class Vector2 {
|
||||
Math.max(z, v2.z)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
public static BlockVector2 toBlockPoint(double x, double z) {
|
||||
return BlockVector2.at(x, z);
|
||||
}
|
||||
@ -491,7 +504,7 @@ public class Vector2 {
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return (((int) x) << 16) ^ ((int) z);
|
||||
return ((int) x << 16) ^ ((int) z);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -499,4 +512,4 @@ public class Vector2 {
|
||||
return "(" + x + ", " + z + ")";
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -25,7 +25,6 @@ import com.boydti.fawe.util.MathMan;
|
||||
import com.google.common.collect.ComparisonChain;
|
||||
import com.sk89q.worldedit.math.transform.AffineTransform;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Comparator;
|
||||
|
||||
/**
|
||||
@ -40,6 +39,21 @@ public class Vector3 {
|
||||
public static final Vector3 ONE = new Vector3(1, 1, 1);
|
||||
|
||||
public static Vector3 at(double x, double y, double z) {
|
||||
// switch for efficiency on typical cases
|
||||
// in MC y is rarely 0/1 on selections
|
||||
int yTrunc = (int) y;
|
||||
switch (yTrunc) {
|
||||
case 0:
|
||||
if (x == 0 && y == 0 && z == 0) {
|
||||
return ZERO;
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
if (x == 1 && y == 1 && z == 1) {
|
||||
return ONE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
return new Vector3(x, y, z);
|
||||
}
|
||||
|
||||
@ -56,7 +70,7 @@ public class Vector3 {
|
||||
|
||||
/**
|
||||
* Returns a comparator that sorts vectors first by Y, then Z, then X.
|
||||
*
|
||||
*
|
||||
* <p>
|
||||
* Useful for sorting by chunk block storage order.
|
||||
*/
|
||||
@ -632,14 +646,14 @@ public class Vector3 {
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return (((int) x) ^ (((int) z) << 12)) ^ (((int) y) << 24);
|
||||
return (int) x ^ (int) z << 12 ^ (int) y << 24;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
String x = (getX() == getBlockX() ? "" + getBlockX() : "" + getX());
|
||||
String y = (getY() == getBlockY() ? "" + getBlockY() : "" + getY());
|
||||
String z = (getZ() == getBlockZ() ? "" + getBlockZ() : "" + getZ());
|
||||
String x = "" + getX();
|
||||
String y = "" + getY();
|
||||
String z = "" + getZ();
|
||||
return "(" + x + ", " + y + ", " + z + ")";
|
||||
}
|
||||
|
||||
|
@ -22,6 +22,7 @@ package com.sk89q.worldedit.math.convolution;
|
||||
import com.boydti.fawe.object.visitor.Fast2DIterator;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.MaxChangedBlocksException;
|
||||
import com.sk89q.worldedit.function.mask.Mask;
|
||||
@ -252,12 +253,12 @@ public class HeightMap {
|
||||
* @return number of blocks affected
|
||||
* @throws MaxChangedBlocksException
|
||||
*/
|
||||
|
||||
public int apply(int[] data) throws MaxChangedBlocksException {
|
||||
checkNotNull(data);
|
||||
|
||||
BlockVector3 minY = region.getMinimumPoint();
|
||||
int originX = minY.getBlockX();
|
||||
int originY = minY.getBlockY();
|
||||
int originZ = minY.getBlockZ();
|
||||
|
||||
int maxY = region.getMaximumPoint().getBlockY();
|
||||
|
Reference in New Issue
Block a user