Mirror von
https://github.com/IntellectualSites/FastAsyncWorldEdit.git
synchronisiert 2024-11-03 01:50:07 +01:00
Change Vector hash codes (#456)
And add additional unit vectors where needed.
Dieser Commit ist enthalten in:
Ursprung
35bb4deee9
Commit
4de5487c51
@ -1182,7 +1182,7 @@ public class EditSession implements Extent, AutoCloseable {
|
||||
checkNotNull(pattern);
|
||||
|
||||
BlockReplace replace = new BlockReplace(this, pattern);
|
||||
RegionOffset offset = new RegionOffset(BlockVector3.at(0, 1, 0), replace);
|
||||
RegionOffset offset = new RegionOffset(BlockVector3.UNIT_Y, replace);
|
||||
GroundFunction ground = new GroundFunction(new ExistingBlockMask(this), offset);
|
||||
LayerVisitor visitor = new LayerVisitor(asFlatRegion(region), minimumBlockY(region), maximumBlockY(region), ground);
|
||||
Operations.completeLegacy(visitor);
|
||||
|
@ -568,15 +568,15 @@ public class SelectionCommands {
|
||||
int change = args.getInteger(0);
|
||||
|
||||
if (!args.hasFlag('h')) {
|
||||
changes.add((BlockVector3.at(0, 1, 0)).multiply(change));
|
||||
changes.add((BlockVector3.at(0, -1, 0)).multiply(change));
|
||||
changes.add((BlockVector3.UNIT_Y).multiply(change));
|
||||
changes.add((BlockVector3.UNIT_MINUS_Y).multiply(change));
|
||||
}
|
||||
|
||||
if (!args.hasFlag('v')) {
|
||||
changes.add((BlockVector3.at(1, 0, 0)).multiply(change));
|
||||
changes.add((BlockVector3.at(-1, 0, 0)).multiply(change));
|
||||
changes.add((BlockVector3.at(0, 0, 1)).multiply(change));
|
||||
changes.add((BlockVector3.at(0, 0, -1)).multiply(change));
|
||||
changes.add((BlockVector3.UNIT_X).multiply(change));
|
||||
changes.add((BlockVector3.UNIT_MINUS_X).multiply(change));
|
||||
changes.add((BlockVector3.UNIT_Z).multiply(change));
|
||||
changes.add((BlockVector3.UNIT_MINUS_Z).multiply(change));
|
||||
}
|
||||
|
||||
return changes.toArray(new BlockVector3[0]);
|
||||
|
@ -26,6 +26,7 @@ import com.sk89q.worldedit.function.RegionFunction;
|
||||
import com.sk89q.worldedit.function.operation.Operation;
|
||||
import com.sk89q.worldedit.function.operation.RunContext;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.util.Direction;
|
||||
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.ArrayList;
|
||||
@ -85,22 +86,22 @@ public abstract class BreadthFirstSearch implements Operation {
|
||||
* Add the directions along the axes as directions to visit.
|
||||
*/
|
||||
protected void addAxes() {
|
||||
directions.add(BlockVector3.at(0, -1, 0));
|
||||
directions.add(BlockVector3.at(0, 1, 0));
|
||||
directions.add(BlockVector3.at(-1, 0, 0));
|
||||
directions.add(BlockVector3.at(1, 0, 0));
|
||||
directions.add(BlockVector3.at(0, 0, -1));
|
||||
directions.add(BlockVector3.at(0, 0, 1));
|
||||
directions.add(BlockVector3.UNIT_MINUS_Y);
|
||||
directions.add(BlockVector3.UNIT_Y);
|
||||
directions.add(BlockVector3.UNIT_MINUS_X);
|
||||
directions.add(BlockVector3.UNIT_X);
|
||||
directions.add(BlockVector3.UNIT_MINUS_Z);
|
||||
directions.add(BlockVector3.UNIT_Z);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the diagonal directions as directions to visit.
|
||||
*/
|
||||
protected void addDiagonal() {
|
||||
directions.add(BlockVector3.at(1, 0, 1));
|
||||
directions.add(BlockVector3.at(-1, 0, -1));
|
||||
directions.add(BlockVector3.at(1, 0, -1));
|
||||
directions.add(BlockVector3.at(-1, 0, 1));
|
||||
directions.add(Direction.NORTHEAST.toBlockVector());
|
||||
directions.add(Direction.SOUTHEAST.toBlockVector());
|
||||
directions.add(Direction.SOUTHWEST.toBlockVector());
|
||||
directions.add(Direction.NORTHWEST.toBlockVector());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -53,11 +53,11 @@ public class DownwardVisitor extends RecursiveVisitor {
|
||||
|
||||
Collection<BlockVector3> directions = getDirections();
|
||||
directions.clear();
|
||||
directions.add(BlockVector3.at(1, 0, 0));
|
||||
directions.add(BlockVector3.at(-1, 0, 0));
|
||||
directions.add(BlockVector3.at(0, 0, 1));
|
||||
directions.add(BlockVector3.at(0, 0, -1));
|
||||
directions.add(BlockVector3.at(0, -1, 0));
|
||||
directions.add(BlockVector3.UNIT_X);
|
||||
directions.add(BlockVector3.UNIT_MINUS_X);
|
||||
directions.add(BlockVector3.UNIT_Z);
|
||||
directions.add(BlockVector3.UNIT_MINUS_Z);
|
||||
directions.add(BlockVector3.UNIT_MINUS_Y);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -40,11 +40,11 @@ public class NonRisingVisitor extends RecursiveVisitor {
|
||||
super(mask, function);
|
||||
Collection<BlockVector3> directions = getDirections();
|
||||
directions.clear();
|
||||
directions.add(BlockVector3.at(1, 0, 0));
|
||||
directions.add(BlockVector3.at(-1, 0, 0));
|
||||
directions.add(BlockVector3.at(0, 0, 1));
|
||||
directions.add(BlockVector3.at(0, 0, -1));
|
||||
directions.add(BlockVector3.at(0, -1, 0));
|
||||
directions.add(BlockVector3.UNIT_X);
|
||||
directions.add(BlockVector3.UNIT_MINUS_X);
|
||||
directions.add(BlockVector3.UNIT_Z);
|
||||
directions.add(BlockVector3.UNIT_MINUS_Z);
|
||||
directions.add(BlockVector3.UNIT_MINUS_Y);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -525,10 +525,7 @@ public final class BlockVector2 {
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int hash = 17;
|
||||
hash = 31 * hash + Integer.hashCode(x);
|
||||
hash = 31 * hash + Integer.hashCode(z);
|
||||
return hash;
|
||||
return (x << 16) ^ z;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -35,6 +35,9 @@ public final class BlockVector3 {
|
||||
public static final BlockVector3 UNIT_X = new BlockVector3(1, 0, 0);
|
||||
public static final BlockVector3 UNIT_Y = new BlockVector3(0, 1, 0);
|
||||
public static final BlockVector3 UNIT_Z = new BlockVector3(0, 0, 1);
|
||||
public static final BlockVector3 UNIT_MINUS_X = new BlockVector3(-1, 0, 0);
|
||||
public static final BlockVector3 UNIT_MINUS_Y = new BlockVector3(0, -1, 0);
|
||||
public static final BlockVector3 UNIT_MINUS_Z = new BlockVector3(0, 0, -1);
|
||||
public static final BlockVector3 ONE = new BlockVector3(1, 1, 1);
|
||||
|
||||
public static BlockVector3 at(double x, double y, double z) {
|
||||
@ -609,11 +612,7 @@ public final class BlockVector3 {
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int hash = 17;
|
||||
hash = 31 * hash + Integer.hashCode(x);
|
||||
hash = 31 * hash + Integer.hashCode(y);
|
||||
hash = 31 * hash + Integer.hashCode(z);
|
||||
return hash;
|
||||
return (x ^ (z << 12)) ^ (y << 24);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -38,7 +38,7 @@ public class Node {
|
||||
private double continuity;
|
||||
|
||||
public Node() {
|
||||
this(Vector3.at(0, 0, 0));
|
||||
this(Vector3.ZERO);
|
||||
}
|
||||
|
||||
public Node(Node other) {
|
||||
|
@ -58,8 +58,10 @@ public enum Direction {
|
||||
|
||||
private final Vector3 direction;
|
||||
private final int flags;
|
||||
private final BlockVector3 blockPoint;
|
||||
|
||||
Direction(Vector3 vector, int flags) {
|
||||
this.blockPoint = vector.toBlockPoint();
|
||||
this.direction = vector.normalize();
|
||||
this.flags = flags;
|
||||
}
|
||||
@ -121,7 +123,7 @@ public enum Direction {
|
||||
* @return the vector
|
||||
*/
|
||||
public BlockVector3 toBlockVector() {
|
||||
return direction.toBlockPoint();
|
||||
return blockPoint;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren