mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-07-13 14:48:34 +00:00
Refactor vector system to be cleaner
- Move Vector, etc. into `.math` package - Drop many methods that will be auto-promoted anyways, eg. with `divide(int)` and `divide(double)` the first is now gone. - Take Block vectors into their own class hierarchy - Make it clear throughout the API what takes blockvectors - many more improvements
This commit is contained in:
@ -21,8 +21,8 @@ package com.sk89q.worldedit.function;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
@ -81,7 +81,7 @@ public class CombinedRegionFunction implements RegionFunction {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Vector position) throws WorldEditException {
|
||||
public boolean apply(BlockVector3 position) throws WorldEditException {
|
||||
boolean ret = false;
|
||||
for (RegionFunction function : functions) {
|
||||
if (function.apply(position)) {
|
||||
|
@ -19,8 +19,8 @@
|
||||
|
||||
package com.sk89q.worldedit.function;
|
||||
|
||||
import com.sk89q.worldedit.Vector2D;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.regions.FlatRegion;
|
||||
|
||||
/**
|
||||
@ -36,6 +36,6 @@ public interface FlatRegionFunction {
|
||||
* @return true if something was changed
|
||||
* @throws WorldEditException thrown on an error
|
||||
*/
|
||||
boolean apply(Vector2D position) throws WorldEditException;
|
||||
boolean apply(BlockVector2 position) throws WorldEditException;
|
||||
|
||||
}
|
||||
|
@ -21,12 +21,12 @@ package com.sk89q.worldedit.function;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.sk89q.worldedit.Vector2D;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.function.mask.Mask2D;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
|
||||
/**
|
||||
* Passes calls to {@link #apply(com.sk89q.worldedit.Vector2D)} to the
|
||||
* Passes calls to {@link #apply(BlockVector2)} to the
|
||||
* delegate {@link com.sk89q.worldedit.function.FlatRegionFunction} if they
|
||||
* match the given mask.
|
||||
*/
|
||||
@ -50,7 +50,7 @@ public class FlatRegionMaskingFilter implements FlatRegionFunction {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Vector2D position) throws WorldEditException {
|
||||
public boolean apply(BlockVector2 position) throws WorldEditException {
|
||||
return mask.test(position) && function.apply(position);
|
||||
}
|
||||
|
||||
|
@ -21,9 +21,9 @@ package com.sk89q.worldedit.function;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.function.mask.Mask;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
|
||||
/**
|
||||
* Applies a {@link RegionFunction} to the first ground block.
|
||||
@ -76,12 +76,12 @@ public class GroundFunction implements LayerFunction {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isGround(Vector position) {
|
||||
public boolean isGround(BlockVector3 position) {
|
||||
return mask.test(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Vector position, int depth) throws WorldEditException {
|
||||
public boolean apply(BlockVector3 position, int depth) throws WorldEditException {
|
||||
if (depth == 0) {
|
||||
if (function.apply(position)) {
|
||||
affected++;
|
||||
|
@ -19,9 +19,9 @@
|
||||
|
||||
package com.sk89q.worldedit.function;
|
||||
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.function.visitor.LayerVisitor;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
|
||||
/**
|
||||
* A function that takes a position and a depth.
|
||||
@ -35,7 +35,7 @@ public interface LayerFunction {
|
||||
* @param position return whether the given block is the ground
|
||||
* @return true if the search should stop
|
||||
*/
|
||||
boolean isGround(Vector position);
|
||||
boolean isGround(BlockVector3 position);
|
||||
|
||||
/**
|
||||
* Apply the function to the given position.
|
||||
@ -48,5 +48,5 @@ public interface LayerFunction {
|
||||
* @return true whether this method should be called for further layers
|
||||
* @throws WorldEditException thrown on an error
|
||||
*/
|
||||
boolean apply(Vector position, int depth) throws WorldEditException;
|
||||
boolean apply(BlockVector3 position, int depth) throws WorldEditException;
|
||||
}
|
||||
|
@ -19,8 +19,8 @@
|
||||
|
||||
package com.sk89q.worldedit.function;
|
||||
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
|
||||
/**
|
||||
* Performs a function on points in a region.
|
||||
@ -34,6 +34,6 @@ public interface RegionFunction {
|
||||
* @return true if something was changed
|
||||
* @throws WorldEditException thrown on an error
|
||||
*/
|
||||
boolean apply(Vector position) throws WorldEditException;
|
||||
boolean apply(BlockVector3 position) throws WorldEditException;
|
||||
|
||||
}
|
||||
|
@ -21,12 +21,12 @@ package com.sk89q.worldedit.function;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.function.mask.Mask;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
|
||||
/**
|
||||
* Passes calls to {@link #apply(com.sk89q.worldedit.Vector)} to the
|
||||
* Passes calls to {@link #apply(BlockVector3)} to the
|
||||
* delegate {@link com.sk89q.worldedit.function.RegionFunction} if they
|
||||
* match the given mask.
|
||||
*/
|
||||
@ -49,7 +49,7 @@ public class RegionMaskingFilter implements RegionFunction {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Vector position) throws WorldEditException {
|
||||
public boolean apply(BlockVector3 position) throws WorldEditException {
|
||||
return mask.test(position) && function.apply(position);
|
||||
}
|
||||
|
||||
|
@ -21,10 +21,10 @@ package com.sk89q.worldedit.function.biome;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.sk89q.worldedit.Vector2D;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.function.FlatRegionFunction;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.world.biome.BaseBiome;
|
||||
|
||||
/**
|
||||
@ -49,7 +49,7 @@ public class BiomeReplace implements FlatRegionFunction {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Vector2D position) throws WorldEditException {
|
||||
public boolean apply(BlockVector2 position) throws WorldEditException {
|
||||
return extent.setBiome(position, biome);
|
||||
}
|
||||
|
||||
|
@ -19,10 +19,10 @@
|
||||
|
||||
package com.sk89q.worldedit.function.block;
|
||||
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.function.RegionFunction;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.util.Countable;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
@ -47,7 +47,7 @@ public class BlockDistributionCounter implements RegionFunction {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Vector position) throws WorldEditException {
|
||||
public boolean apply(BlockVector3 position) throws WorldEditException {
|
||||
BlockStateHolder blk = extent.getBlock(position);
|
||||
if (fuzzy) {
|
||||
blk = ((BlockState) blk).toFuzzy();
|
||||
|
@ -21,11 +21,11 @@ package com.sk89q.worldedit.function.block;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.function.RegionFunction;
|
||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
|
||||
/**
|
||||
* Replaces blocks with a given pattern.
|
||||
@ -49,7 +49,7 @@ public class BlockReplace implements RegionFunction {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Vector position) throws WorldEditException {
|
||||
public boolean apply(BlockVector3 position) throws WorldEditException {
|
||||
return extent.setBlock(position, pattern.apply(position));
|
||||
}
|
||||
|
||||
|
@ -19,17 +19,18 @@
|
||||
|
||||
package com.sk89q.worldedit.function.block;
|
||||
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.function.RegionFunction;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
|
||||
/**
|
||||
* Keeps a count of the number of times that {@link #apply(Vector)} is called.
|
||||
* Keeps a count of the number of times that {@link #apply(BlockVector3)} is
|
||||
* called.
|
||||
*/
|
||||
public class Counter implements RegionFunction {
|
||||
public class Counter implements RegionFunction {
|
||||
|
||||
private int count;
|
||||
|
||||
|
||||
/**
|
||||
* Returns the number of blocks that have been counted.
|
||||
*
|
||||
@ -40,7 +41,7 @@ import com.sk89q.worldedit.function.RegionFunction;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Vector position) throws WorldEditException {
|
||||
public boolean apply(BlockVector3 position) throws WorldEditException {
|
||||
count++;
|
||||
return false;
|
||||
}
|
||||
|
@ -23,15 +23,16 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.sk89q.jnbt.CompoundTag;
|
||||
import com.sk89q.jnbt.CompoundTagBuilder;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.function.RegionFunction;
|
||||
import com.sk89q.worldedit.internal.helper.MCDirections;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.math.Vector3;
|
||||
import com.sk89q.worldedit.math.transform.Transform;
|
||||
import com.sk89q.worldedit.util.Direction;
|
||||
import com.sk89q.worldedit.util.Direction.Flag;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
|
||||
/**
|
||||
* Copies blocks from one extent to another.
|
||||
@ -40,8 +41,8 @@ public class ExtentBlockCopy implements RegionFunction {
|
||||
|
||||
private final Extent source;
|
||||
private final Extent destination;
|
||||
private final Vector from;
|
||||
private final Vector to;
|
||||
private final BlockVector3 from;
|
||||
private final BlockVector3 to;
|
||||
private final Transform transform;
|
||||
|
||||
/**
|
||||
@ -53,7 +54,7 @@ public class ExtentBlockCopy implements RegionFunction {
|
||||
* @param to the destination offset
|
||||
* @param transform a transform to apply to positions (after source offset, before destination offset)
|
||||
*/
|
||||
public ExtentBlockCopy(Extent source, Vector from, Extent destination, Vector to, Transform transform) {
|
||||
public ExtentBlockCopy(Extent source, BlockVector3 from, Extent destination, BlockVector3 to, Transform transform) {
|
||||
checkNotNull(source);
|
||||
checkNotNull(from);
|
||||
checkNotNull(destination);
|
||||
@ -67,10 +68,10 @@ public class ExtentBlockCopy implements RegionFunction {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Vector position) throws WorldEditException {
|
||||
public boolean apply(BlockVector3 position) throws WorldEditException {
|
||||
BaseBlock block = source.getFullBlock(position);
|
||||
Vector orig = position.subtract(from);
|
||||
Vector transformed = transform.apply(orig);
|
||||
BlockVector3 orig = position.subtract(from);
|
||||
BlockVector3 transformed = transform.apply(orig.toVector3()).toBlockPoint();
|
||||
|
||||
// Apply transformations to NBT data if necessary
|
||||
block = transformNbtData(block);
|
||||
@ -96,7 +97,7 @@ public class ExtentBlockCopy implements RegionFunction {
|
||||
Direction direction = MCDirections.fromRotation(rot);
|
||||
|
||||
if (direction != null) {
|
||||
Vector vector = transform.apply(direction.toVector()).subtract(transform.apply(Vector.ZERO)).normalize();
|
||||
Vector3 vector = transform.apply(direction.toVector()).subtract(transform.apply(Vector3.ZERO)).normalize();
|
||||
Direction newDirection = Direction.findClosest(vector, Flag.CARDINAL | Flag.ORDINAL | Flag.SECONDARY_ORDINAL);
|
||||
|
||||
if (newDirection != null) {
|
||||
|
@ -22,11 +22,11 @@ package com.sk89q.worldedit.function.block;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.function.LayerFunction;
|
||||
import com.sk89q.worldedit.function.mask.BlockTypeMask;
|
||||
import com.sk89q.worldedit.function.mask.Mask;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
|
||||
/**
|
||||
@ -61,12 +61,12 @@ public class Naturalizer implements LayerFunction {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isGround(Vector position) {
|
||||
public boolean isGround(BlockVector3 position) {
|
||||
return mask.test(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Vector position, int depth) throws WorldEditException {
|
||||
public boolean apply(BlockVector3 position, int depth) throws WorldEditException {
|
||||
if (mask.test(position)) {
|
||||
affected++;
|
||||
switch (depth) {
|
||||
|
@ -23,13 +23,14 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.sk89q.jnbt.CompoundTag;
|
||||
import com.sk89q.jnbt.CompoundTagBuilder;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.entity.BaseEntity;
|
||||
import com.sk89q.worldedit.entity.Entity;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.function.EntityFunction;
|
||||
import com.sk89q.worldedit.internal.helper.MCDirections;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.math.Vector3;
|
||||
import com.sk89q.worldedit.math.transform.Transform;
|
||||
import com.sk89q.worldedit.util.Direction;
|
||||
import com.sk89q.worldedit.util.Direction.Flag;
|
||||
@ -42,8 +43,8 @@ import com.sk89q.worldedit.util.Location;
|
||||
public class ExtentEntityCopy implements EntityFunction {
|
||||
|
||||
private final Extent destination;
|
||||
private final Vector from;
|
||||
private final Vector to;
|
||||
private final Vector3 from;
|
||||
private final Vector3 to;
|
||||
private final Transform transform;
|
||||
private boolean removing;
|
||||
|
||||
@ -55,7 +56,7 @@ public class ExtentEntityCopy implements EntityFunction {
|
||||
* @param to the destination position
|
||||
* @param transform the transformation to apply to both position and orientation
|
||||
*/
|
||||
public ExtentEntityCopy(Vector from, Extent destination, Vector to, Transform transform) {
|
||||
public ExtentEntityCopy(Vector3 from, Extent destination, Vector3 to, Transform transform) {
|
||||
checkNotNull(from);
|
||||
checkNotNull(destination);
|
||||
checkNotNull(to);
|
||||
@ -91,13 +92,13 @@ public class ExtentEntityCopy implements EntityFunction {
|
||||
Location newLocation;
|
||||
Location location = entity.getLocation();
|
||||
|
||||
Vector pivot = from.round().add(0.5, 0.5, 0.5);
|
||||
Vector newPosition = transform.apply(location.toVector().subtract(pivot));
|
||||
Vector newDirection;
|
||||
Vector3 pivot = from.round().add(0.5, 0.5, 0.5);
|
||||
Vector3 newPosition = transform.apply(location.toVector().subtract(pivot));
|
||||
Vector3 newDirection;
|
||||
|
||||
newDirection = transform.isIdentity() ?
|
||||
entity.getLocation().getDirection()
|
||||
: transform.apply(location.getDirection()).subtract(transform.apply(Vector.ZERO)).normalize();
|
||||
: transform.apply(location.getDirection()).subtract(transform.apply(Vector3.ZERO)).normalize();
|
||||
newLocation = new Location(destination, newPosition.add(to.round().add(0.5, 0.5, 0.5)), newDirection);
|
||||
|
||||
// Some entities store their position data in NBT
|
||||
@ -134,8 +135,8 @@ public class ExtentEntityCopy implements EntityFunction {
|
||||
boolean hasFacing = tag.containsKey("Facing");
|
||||
|
||||
if (hasTilePosition) {
|
||||
Vector tilePosition = new Vector(tag.asInt("TileX"), tag.asInt("TileY"), tag.asInt("TileZ"));
|
||||
Vector newTilePosition = transform.apply(tilePosition.subtract(from)).add(to);
|
||||
Vector3 tilePosition = new Vector3(tag.asInt("TileX"), tag.asInt("TileY"), tag.asInt("TileZ"));
|
||||
BlockVector3 newTilePosition = transform.apply(tilePosition.subtract(from)).add(to).toBlockPoint();
|
||||
|
||||
CompoundTagBuilder builder = tag.createBuilder()
|
||||
.putInt("TileX", newTilePosition.getBlockX())
|
||||
@ -155,7 +156,7 @@ public class ExtentEntityCopy implements EntityFunction {
|
||||
Direction direction = MCDirections.fromHanging(d);
|
||||
|
||||
if (direction != null) {
|
||||
Vector vector = transform.apply(direction.toVector()).subtract(transform.apply(Vector.ZERO)).normalize();
|
||||
Vector3 vector = transform.apply(direction.toVector()).subtract(transform.apply(Vector3.ZERO)).normalize();
|
||||
Direction newDirection = Direction.findClosest(vector, Flag.CARDINAL);
|
||||
|
||||
if (newDirection != null) {
|
||||
|
@ -23,7 +23,6 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static com.sk89q.worldedit.util.GuavaUtil.firstNonNull;
|
||||
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.extent.NullExtent;
|
||||
@ -32,6 +31,7 @@ import com.sk89q.worldedit.function.EditContext;
|
||||
import com.sk89q.worldedit.function.operation.Operation;
|
||||
import com.sk89q.worldedit.function.operation.RunContext;
|
||||
import com.sk89q.worldedit.internal.expression.ExpressionException;
|
||||
import com.sk89q.worldedit.math.Vector3;
|
||||
import com.sk89q.worldedit.regions.NullRegion;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
|
||||
@ -43,7 +43,7 @@ public class Deform implements Contextual<Operation> {
|
||||
private Region region;
|
||||
private String expression;
|
||||
private Mode mode = Mode.UNIT_CUBE;
|
||||
private Vector offset = new Vector();
|
||||
private Vector3 offset = Vector3.ZERO;
|
||||
|
||||
public Deform(String expression) {
|
||||
this(new NullExtent(), new NullRegion(), expression);
|
||||
@ -104,11 +104,11 @@ public class Deform implements Contextual<Operation> {
|
||||
this.mode = mode;
|
||||
}
|
||||
|
||||
public Vector getOffset() {
|
||||
public Vector3 getOffset() {
|
||||
return offset;
|
||||
}
|
||||
|
||||
public void setOffset(Vector offset) {
|
||||
public void setOffset(Vector3 offset) {
|
||||
checkNotNull(offset, "offset");
|
||||
this.offset = offset;
|
||||
}
|
||||
@ -120,31 +120,31 @@ public class Deform implements Contextual<Operation> {
|
||||
|
||||
@Override
|
||||
public Operation createFromContext(final EditContext context) {
|
||||
final Vector zero;
|
||||
Vector unit;
|
||||
final Vector3 zero;
|
||||
Vector3 unit;
|
||||
|
||||
Region region = firstNonNull(context.getRegion(), this.region);
|
||||
|
||||
switch (mode) {
|
||||
case UNIT_CUBE:
|
||||
final Vector min = region.getMinimumPoint();
|
||||
final Vector max = region.getMaximumPoint();
|
||||
final Vector3 min = region.getMinimumPoint().toVector3();
|
||||
final Vector3 max = region.getMaximumPoint().toVector3();
|
||||
|
||||
zero = max.add(min).multiply(0.5);
|
||||
unit = max.subtract(zero);
|
||||
|
||||
if (unit.getX() == 0) unit = unit.setX(1.0);
|
||||
if (unit.getY() == 0) unit = unit.setY(1.0);
|
||||
if (unit.getZ() == 0) unit = unit.setZ(1.0);
|
||||
if (unit.getX() == 0) unit = unit.withX(1.0);
|
||||
if (unit.getY() == 0) unit = unit.withY(1.0);
|
||||
if (unit.getZ() == 0) unit = unit.withZ(1.0);
|
||||
break;
|
||||
case RAW_COORD:
|
||||
zero = Vector.ZERO;
|
||||
unit = Vector.ONE;
|
||||
zero = Vector3.ZERO;
|
||||
unit = Vector3.ONE;
|
||||
break;
|
||||
case OFFSET:
|
||||
default:
|
||||
zero = offset;
|
||||
unit = Vector.ONE;
|
||||
unit = Vector3.ONE;
|
||||
}
|
||||
|
||||
return new DeformOperation(context.getDestination(), region, zero, unit, expression);
|
||||
@ -153,11 +153,11 @@ public class Deform implements Contextual<Operation> {
|
||||
private static final class DeformOperation implements Operation {
|
||||
private final Extent destination;
|
||||
private final Region region;
|
||||
private final Vector zero;
|
||||
private final Vector unit;
|
||||
private final Vector3 zero;
|
||||
private final Vector3 unit;
|
||||
private final String expression;
|
||||
|
||||
private DeformOperation(Extent destination, Region region, Vector zero, Vector unit, String expression) {
|
||||
private DeformOperation(Extent destination, Region region, Vector3 zero, Vector3 unit, String expression) {
|
||||
this.destination = destination;
|
||||
this.region = region;
|
||||
this.zero = zero;
|
||||
|
@ -20,12 +20,12 @@
|
||||
package com.sk89q.worldedit.function.generator;
|
||||
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.function.RegionFunction;
|
||||
import com.sk89q.worldedit.function.pattern.BlockPattern;
|
||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
import com.sk89q.worldedit.function.pattern.RandomPattern;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
|
||||
@ -103,7 +103,7 @@ public class FloraGenerator implements RegionFunction {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Vector position) throws WorldEditException {
|
||||
public boolean apply(BlockVector3 position) throws WorldEditException {
|
||||
BlockStateHolder block = editSession.getBlock(position);
|
||||
|
||||
if (block.getBlockType() == BlockTypes.GRASS_BLOCK) {
|
||||
|
@ -20,9 +20,9 @@
|
||||
package com.sk89q.worldedit.function.generator;
|
||||
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.function.RegionFunction;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.util.TreeGenerator;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.world.block.BlockType;
|
||||
@ -49,7 +49,7 @@ public class ForestGenerator implements RegionFunction {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Vector position) throws WorldEditException {
|
||||
public boolean apply(BlockVector3 position) throws WorldEditException {
|
||||
BlockStateHolder block = editSession.getBlock(position);
|
||||
BlockType t = block.getBlockType();
|
||||
|
||||
|
@ -21,11 +21,11 @@ package com.sk89q.worldedit.function.generator;
|
||||
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.MaxChangedBlocksException;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.function.RegionFunction;
|
||||
import com.sk89q.worldedit.function.pattern.BlockPattern;
|
||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
@ -84,12 +84,12 @@ public class GardenPatchGenerator implements RegionFunction {
|
||||
* @param basePos the base position
|
||||
* @param pos the vine position
|
||||
*/
|
||||
private void placeVine(Vector basePos, Vector pos) throws MaxChangedBlocksException {
|
||||
private void placeVine(BlockVector3 basePos, BlockVector3 pos) throws MaxChangedBlocksException {
|
||||
if (pos.distance(basePos) > 4) return;
|
||||
if (!editSession.getBlock(pos).getBlockType().getMaterial().isAir()) return;
|
||||
|
||||
for (int i = -1; i > -3; --i) {
|
||||
Vector testPos = pos.add(0, i, 0);
|
||||
BlockVector3 testPos = pos.add(0, i, 0);
|
||||
if (editSession.getBlock(testPos).getBlockType().getMaterial().isAir()) {
|
||||
pos = testPos;
|
||||
} else {
|
||||
@ -102,7 +102,7 @@ public class GardenPatchGenerator implements RegionFunction {
|
||||
|
||||
int t = random.nextInt(4);
|
||||
int h = random.nextInt(3) - 1;
|
||||
Vector p;
|
||||
BlockVector3 p;
|
||||
|
||||
BlockState log = BlockTypes.OAK_LOG.getDefaultState();
|
||||
|
||||
@ -158,7 +158,7 @@ public class GardenPatchGenerator implements RegionFunction {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Vector position) throws WorldEditException {
|
||||
public boolean apply(BlockVector3 position) throws WorldEditException {
|
||||
if (!editSession.getBlock(position).getBlockType().getMaterial().isAir()) {
|
||||
position = position.add(0, 1, 0);
|
||||
}
|
||||
@ -198,7 +198,7 @@ public class GardenPatchGenerator implements RegionFunction {
|
||||
* @return if block was changed
|
||||
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
||||
*/
|
||||
private static boolean setBlockIfAir(EditSession session, Vector position, BlockStateHolder block) throws MaxChangedBlocksException {
|
||||
private static boolean setBlockIfAir(EditSession session, BlockVector3 position, BlockStateHolder block) throws MaxChangedBlocksException {
|
||||
return session.getBlock(position).getBlockType().getMaterial().isAir() && session.setBlock(position, block);
|
||||
}
|
||||
|
||||
|
@ -21,8 +21,8 @@ package com.sk89q.worldedit.function.mask;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.sk89q.worldedit.Vector2D;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.world.biome.BaseBiome;
|
||||
|
||||
import java.util.Arrays;
|
||||
@ -90,7 +90,7 @@ public class BiomeMask2D extends AbstractMask2D {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean test(Vector2D vector) {
|
||||
public boolean test(BlockVector2 vector) {
|
||||
BaseBiome biome = extent.getBiome(vector);
|
||||
return biomes.contains(biome);
|
||||
}
|
||||
|
@ -21,8 +21,8 @@ package com.sk89q.worldedit.function.mask;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.world.block.BlockCategory;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
@ -41,7 +41,7 @@ public class BlockCategoryMask extends AbstractExtentMask {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean test(Vector vector) {
|
||||
public boolean test(BlockVector3 vector) {
|
||||
return category.contains(getExtent().getBlock(vector));
|
||||
}
|
||||
|
||||
|
@ -21,8 +21,8 @@ package com.sk89q.worldedit.function.mask;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
|
||||
import java.util.Arrays;
|
||||
@ -94,7 +94,7 @@ public class BlockMask extends AbstractExtentMask {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean test(Vector vector) {
|
||||
public boolean test(BlockVector3 vector) {
|
||||
BlockStateHolder block = getExtent().getBlock(vector);
|
||||
for (BlockStateHolder testBlock : blocks) {
|
||||
if (testBlock.equalsFuzzy(block)) {
|
||||
|
@ -21,8 +21,8 @@ package com.sk89q.worldedit.function.mask;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.world.block.BlockType;
|
||||
|
||||
import java.util.Arrays;
|
||||
@ -94,7 +94,7 @@ public class BlockTypeMask extends AbstractExtentMask {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean test(Vector vector) {
|
||||
public boolean test(BlockVector3 vector) {
|
||||
return blocks.contains(getExtent().getBlock(vector).getBlockType());
|
||||
}
|
||||
|
||||
|
@ -21,7 +21,7 @@ package com.sk89q.worldedit.function.mask;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
@ -47,7 +47,7 @@ public class BoundedHeightMask extends AbstractMask {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean test(Vector vector) {
|
||||
public boolean test(BlockVector3 vector) {
|
||||
return vector.getY() >= minY && vector.getY() <= maxY;
|
||||
}
|
||||
|
||||
|
@ -19,8 +19,8 @@
|
||||
|
||||
package com.sk89q.worldedit.function.mask;
|
||||
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
@ -40,7 +40,7 @@ public class ExistingBlockMask extends AbstractExtentMask {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean test(Vector vector) {
|
||||
public boolean test(BlockVector3 vector) {
|
||||
return !getExtent().getBlock(vector).getBlockType().getMaterial().isAir();
|
||||
}
|
||||
|
||||
|
@ -21,10 +21,10 @@ package com.sk89q.worldedit.function.mask;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.internal.expression.Expression;
|
||||
import com.sk89q.worldedit.internal.expression.ExpressionException;
|
||||
import com.sk89q.worldedit.internal.expression.runtime.EvaluationException;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.regions.shape.WorldEditExpressionEnvironment;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
@ -61,10 +61,10 @@ public class ExpressionMask extends AbstractMask {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean test(Vector vector) {
|
||||
public boolean test(BlockVector3 vector) {
|
||||
try {
|
||||
if (expression.getEnvironment() instanceof WorldEditExpressionEnvironment) {
|
||||
((WorldEditExpressionEnvironment) expression.getEnvironment()).setCurrentBlock(vector);
|
||||
((WorldEditExpressionEnvironment) expression.getEnvironment()).setCurrentBlock(vector.toVector3());
|
||||
}
|
||||
return expression.evaluate(vector.getX(), vector.getY(), vector.getZ()) > 0;
|
||||
} catch (EvaluationException e) {
|
||||
|
@ -21,10 +21,10 @@ package com.sk89q.worldedit.function.mask;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.sk89q.worldedit.Vector2D;
|
||||
import com.sk89q.worldedit.internal.expression.Expression;
|
||||
import com.sk89q.worldedit.internal.expression.ExpressionException;
|
||||
import com.sk89q.worldedit.internal.expression.runtime.EvaluationException;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
|
||||
public class ExpressionMask2D extends AbstractMask2D {
|
||||
|
||||
@ -52,7 +52,7 @@ public class ExpressionMask2D extends AbstractMask2D {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean test(Vector2D vector) {
|
||||
public boolean test(BlockVector2 vector) {
|
||||
try {
|
||||
return expression.evaluate(vector.getX(), 0, vector.getZ()) > 0;
|
||||
} catch (EvaluationException e) {
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
package com.sk89q.worldedit.function.mask;
|
||||
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
@ -34,7 +34,7 @@ public interface Mask {
|
||||
* @param vector the vector to test
|
||||
* @return true if the criteria is met
|
||||
*/
|
||||
boolean test(Vector vector);
|
||||
boolean test(BlockVector3 vector);
|
||||
|
||||
/**
|
||||
* Get the 2D version of this mask if one exists.
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
package com.sk89q.worldedit.function.mask;
|
||||
|
||||
import com.sk89q.worldedit.Vector2D;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
|
||||
/**
|
||||
* Tests whether a given vector meets a criteria.
|
||||
@ -32,6 +32,6 @@ public interface Mask2D {
|
||||
* @param vector the vector to test
|
||||
* @return true if the criteria is met
|
||||
*/
|
||||
boolean test(Vector2D vector);
|
||||
boolean test(BlockVector2 vector);
|
||||
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ package com.sk89q.worldedit.function.mask;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
@ -89,7 +89,7 @@ public class MaskIntersection extends AbstractMask {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean test(Vector vector) {
|
||||
public boolean test(BlockVector3 vector) {
|
||||
if (masks.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ package com.sk89q.worldedit.function.mask;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.sk89q.worldedit.Vector2D;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
@ -83,7 +83,7 @@ public class MaskIntersection2D implements Mask2D {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean test(Vector2D vector) {
|
||||
public boolean test(BlockVector2 vector) {
|
||||
if (masks.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
package com.sk89q.worldedit.function.mask;
|
||||
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
@ -53,7 +53,7 @@ public class MaskUnion extends MaskIntersection {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean test(Vector vector) {
|
||||
public boolean test(BlockVector3 vector) {
|
||||
Collection<Mask> masks = getMasks();
|
||||
|
||||
for (Mask mask : masks) {
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
package com.sk89q.worldedit.function.mask;
|
||||
|
||||
import com.sk89q.worldedit.Vector2D;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
@ -47,7 +47,7 @@ public class MaskUnion2D extends MaskIntersection2D {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean test(Vector2D vector) {
|
||||
public boolean test(BlockVector2 vector) {
|
||||
Collection<Mask2D> masks = getMasks();
|
||||
|
||||
for (Mask2D mask : masks) {
|
||||
|
@ -21,8 +21,8 @@ package com.sk89q.worldedit.function.mask;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.Vector2D;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
@ -71,7 +71,7 @@ public final class Masks {
|
||||
checkNotNull(mask);
|
||||
return new AbstractMask() {
|
||||
@Override
|
||||
public boolean test(Vector vector) {
|
||||
public boolean test(BlockVector3 vector) {
|
||||
return !mask.test(vector);
|
||||
}
|
||||
|
||||
@ -104,7 +104,7 @@ public final class Masks {
|
||||
checkNotNull(mask);
|
||||
return new AbstractMask2D() {
|
||||
@Override
|
||||
public boolean test(Vector2D vector) {
|
||||
public boolean test(BlockVector2 vector) {
|
||||
return !mask.test(vector);
|
||||
}
|
||||
};
|
||||
@ -119,8 +119,8 @@ public final class Masks {
|
||||
public static Mask asMask(final Mask2D mask) {
|
||||
return new AbstractMask() {
|
||||
@Override
|
||||
public boolean test(Vector vector) {
|
||||
return mask.test(vector.toVector2D());
|
||||
public boolean test(BlockVector3 vector) {
|
||||
return mask.test(vector.toBlockVector2());
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@ -133,12 +133,12 @@ public final class Masks {
|
||||
|
||||
private static class AlwaysTrue implements Mask, Mask2D {
|
||||
@Override
|
||||
public boolean test(Vector vector) {
|
||||
public boolean test(BlockVector3 vector) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean test(Vector2D vector) {
|
||||
public boolean test(BlockVector2 vector) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -151,12 +151,12 @@ public final class Masks {
|
||||
|
||||
private static class AlwaysFalse implements Mask, Mask2D {
|
||||
@Override
|
||||
public boolean test(Vector vector) {
|
||||
public boolean test(BlockVector3 vector) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean test(Vector2D vector) {
|
||||
public boolean test(BlockVector2 vector) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -22,7 +22,7 @@ package com.sk89q.worldedit.function.mask;
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.math.noise.NoiseGenerator;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
@ -85,8 +85,8 @@ public class NoiseFilter extends AbstractMask {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean test(Vector vector) {
|
||||
return noiseGenerator.noise(vector) <= density;
|
||||
public boolean test(BlockVector3 vector) {
|
||||
return noiseGenerator.noise(vector.toVector3()) <= density;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
@ -22,7 +22,7 @@ package com.sk89q.worldedit.function.mask;
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.sk89q.worldedit.Vector2D;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.math.noise.NoiseGenerator;
|
||||
|
||||
/**
|
||||
@ -83,8 +83,8 @@ public class NoiseFilter2D extends AbstractMask2D {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean test(Vector2D pos) {
|
||||
return noiseGenerator.noise(pos) <= density;
|
||||
public boolean test(BlockVector2 pos) {
|
||||
return noiseGenerator.noise(pos.toVector2()) <= density;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ package com.sk89q.worldedit.function.mask;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
@ -32,7 +32,7 @@ import javax.annotation.Nullable;
|
||||
public class OffsetMask extends AbstractMask {
|
||||
|
||||
private Mask mask;
|
||||
private Vector offset;
|
||||
private BlockVector3 offset;
|
||||
|
||||
/**
|
||||
* Create a new instance.
|
||||
@ -40,7 +40,7 @@ public class OffsetMask extends AbstractMask {
|
||||
* @param mask the mask
|
||||
* @param offset the offset
|
||||
*/
|
||||
public OffsetMask(Mask mask, Vector offset) {
|
||||
public OffsetMask(Mask mask, BlockVector3 offset) {
|
||||
checkNotNull(mask);
|
||||
checkNotNull(offset);
|
||||
this.mask = mask;
|
||||
@ -71,7 +71,7 @@ public class OffsetMask extends AbstractMask {
|
||||
*
|
||||
* @return the offset
|
||||
*/
|
||||
public Vector getOffset() {
|
||||
public BlockVector3 getOffset() {
|
||||
return offset;
|
||||
}
|
||||
|
||||
@ -80,13 +80,13 @@ public class OffsetMask extends AbstractMask {
|
||||
*
|
||||
* @param offset the offset
|
||||
*/
|
||||
public void setOffset(Vector offset) {
|
||||
public void setOffset(BlockVector3 offset) {
|
||||
checkNotNull(offset);
|
||||
this.offset = offset;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean test(Vector vector) {
|
||||
public boolean test(BlockVector3 vector) {
|
||||
return getMask().test(vector.add(offset));
|
||||
}
|
||||
|
||||
@ -95,7 +95,7 @@ public class OffsetMask extends AbstractMask {
|
||||
public Mask2D toMask2D() {
|
||||
Mask2D childMask = getMask().toMask2D();
|
||||
if (childMask != null) {
|
||||
return new OffsetMask2D(childMask, getOffset().toVector2D());
|
||||
return new OffsetMask2D(childMask, getOffset().toBlockVector2());
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ package com.sk89q.worldedit.function.mask;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.sk89q.worldedit.Vector2D;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
|
||||
/**
|
||||
* Checks whether another mask tests true for a position that is offset
|
||||
@ -30,7 +30,7 @@ import com.sk89q.worldedit.Vector2D;
|
||||
public class OffsetMask2D extends AbstractMask2D {
|
||||
|
||||
private Mask2D mask;
|
||||
private Vector2D offset;
|
||||
private BlockVector2 offset;
|
||||
|
||||
/**
|
||||
* Create a new instance.
|
||||
@ -38,7 +38,7 @@ public class OffsetMask2D extends AbstractMask2D {
|
||||
* @param mask the mask
|
||||
* @param offset the offset
|
||||
*/
|
||||
public OffsetMask2D(Mask2D mask, Vector2D offset) {
|
||||
public OffsetMask2D(Mask2D mask, BlockVector2 offset) {
|
||||
checkNotNull(mask);
|
||||
checkNotNull(offset);
|
||||
this.mask = mask;
|
||||
@ -69,7 +69,7 @@ public class OffsetMask2D extends AbstractMask2D {
|
||||
*
|
||||
* @return the offset
|
||||
*/
|
||||
public Vector2D getOffset() {
|
||||
public BlockVector2 getOffset() {
|
||||
return offset;
|
||||
}
|
||||
|
||||
@ -78,13 +78,13 @@ public class OffsetMask2D extends AbstractMask2D {
|
||||
*
|
||||
* @param offset the offset
|
||||
*/
|
||||
public void setOffset(Vector2D offset) {
|
||||
public void setOffset(BlockVector2 offset) {
|
||||
checkNotNull(offset);
|
||||
this.offset = offset;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean test(Vector2D vector) {
|
||||
public boolean test(BlockVector2 vector) {
|
||||
return getMask().test(vector.add(offset));
|
||||
}
|
||||
|
||||
|
@ -21,7 +21,7 @@ package com.sk89q.worldedit.function.mask;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
@ -62,7 +62,7 @@ public class RegionMask extends AbstractMask {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean test(Vector vector) {
|
||||
public boolean test(BlockVector3 vector) {
|
||||
return region.contains(vector);
|
||||
}
|
||||
|
||||
|
@ -19,8 +19,8 @@
|
||||
|
||||
package com.sk89q.worldedit.function.mask;
|
||||
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
@ -32,7 +32,7 @@ public class SolidBlockMask extends AbstractExtentMask {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean test(Vector vector) {
|
||||
public boolean test(BlockVector3 vector) {
|
||||
Extent extent = getExtent();
|
||||
BlockState block = extent.getBlock(vector);
|
||||
return block.getBlockType().getMaterial().isMovementBlocker();
|
||||
|
@ -23,7 +23,6 @@ import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.entity.Entity;
|
||||
import com.sk89q.worldedit.entity.metadata.EntityProperties;
|
||||
@ -37,6 +36,8 @@ import com.sk89q.worldedit.function.mask.Mask;
|
||||
import com.sk89q.worldedit.function.mask.Masks;
|
||||
import com.sk89q.worldedit.function.visitor.EntityVisitor;
|
||||
import com.sk89q.worldedit.function.visitor.RegionVisitor;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.math.Vector3;
|
||||
import com.sk89q.worldedit.math.transform.Identity;
|
||||
import com.sk89q.worldedit.math.transform.Transform;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
@ -55,8 +56,8 @@ public class ForwardExtentCopy implements Operation {
|
||||
private final Extent source;
|
||||
private final Extent destination;
|
||||
private final Region region;
|
||||
private final Vector from;
|
||||
private final Vector to;
|
||||
private final BlockVector3 from;
|
||||
private final BlockVector3 to;
|
||||
private int repetitions = 1;
|
||||
private Mask sourceMask = Masks.alwaysTrue();
|
||||
private boolean removingEntities;
|
||||
@ -75,9 +76,9 @@ public class ForwardExtentCopy implements Operation {
|
||||
* @param region the region to copy
|
||||
* @param destination the destination extent
|
||||
* @param to the destination position
|
||||
* @see #ForwardExtentCopy(Extent, Region, Vector, Extent, Vector) the main constructor
|
||||
* @see #ForwardExtentCopy(Extent, Region, BlockVector3, Extent, BlockVector3) the main constructor
|
||||
*/
|
||||
public ForwardExtentCopy(Extent source, Region region, Extent destination, Vector to) {
|
||||
public ForwardExtentCopy(Extent source, Region region, Extent destination, BlockVector3 to) {
|
||||
this(source, region, region.getMinimumPoint(), destination, to);
|
||||
}
|
||||
|
||||
@ -90,7 +91,7 @@ public class ForwardExtentCopy implements Operation {
|
||||
* @param destination the destination extent
|
||||
* @param to the destination position
|
||||
*/
|
||||
public ForwardExtentCopy(Extent source, Region region, Vector from, Extent destination, Vector to) {
|
||||
public ForwardExtentCopy(Extent source, Region region, BlockVector3 from, Extent destination, BlockVector3 to) {
|
||||
checkNotNull(source);
|
||||
checkNotNull(region);
|
||||
checkNotNull(from);
|
||||
@ -255,7 +256,7 @@ public class ForwardExtentCopy implements Operation {
|
||||
lastVisitor = blockVisitor;
|
||||
|
||||
if (copyingEntities) {
|
||||
ExtentEntityCopy entityCopy = new ExtentEntityCopy(from, destination, to, currentTransform);
|
||||
ExtentEntityCopy entityCopy = new ExtentEntityCopy(from.toVector3(), destination, to.toVector3(), currentTransform);
|
||||
entityCopy.setRemoving(removingEntities);
|
||||
List<? extends Entity> entities = Lists.newArrayList(source.getEntities(region));
|
||||
entities.removeIf(entity -> {
|
||||
|
@ -21,7 +21,7 @@ package com.sk89q.worldedit.function.pattern;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
|
||||
@ -61,7 +61,7 @@ public class BlockPattern extends AbstractPattern {
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockStateHolder apply(Vector position) {
|
||||
public BlockStateHolder apply(BlockVector3 position) {
|
||||
return block;
|
||||
}
|
||||
|
||||
|
@ -21,8 +21,8 @@ package com.sk89q.worldedit.function.pattern;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
|
||||
/**
|
||||
@ -31,7 +31,7 @@ import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
public class ClipboardPattern extends AbstractPattern {
|
||||
|
||||
private final Clipboard clipboard;
|
||||
private final Vector size;
|
||||
private final BlockVector3 size;
|
||||
|
||||
/**
|
||||
* Create a new clipboard pattern.
|
||||
@ -45,12 +45,12 @@ public class ClipboardPattern extends AbstractPattern {
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockStateHolder apply(Vector position) {
|
||||
public BlockStateHolder apply(BlockVector3 position) {
|
||||
int xp = Math.abs(position.getBlockX()) % size.getBlockX();
|
||||
int yp = Math.abs(position.getBlockY()) % size.getBlockY();
|
||||
int zp = Math.abs(position.getBlockZ()) % size.getBlockZ();
|
||||
|
||||
return clipboard.getFullBlock(clipboard.getMinimumPoint().add(new Vector(xp, yp, zp)));
|
||||
return clipboard.getFullBlock(clipboard.getMinimumPoint().add(xp, yp, zp));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
package com.sk89q.worldedit.function.pattern;
|
||||
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
|
||||
/**
|
||||
@ -33,6 +33,6 @@ public interface Pattern {
|
||||
* @param position the position
|
||||
* @return a block
|
||||
*/
|
||||
BlockStateHolder apply(Vector position);
|
||||
BlockStateHolder apply(BlockVector3 position);
|
||||
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ package com.sk89q.worldedit.function.pattern;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@ -53,7 +53,7 @@ public class RandomPattern extends AbstractPattern {
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockStateHolder apply(Vector position) {
|
||||
public BlockStateHolder apply(BlockVector3 position) {
|
||||
double r = random.nextDouble();
|
||||
double offset = 0;
|
||||
|
||||
|
@ -21,8 +21,8 @@ package com.sk89q.worldedit.function.pattern;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
|
||||
/**
|
||||
@ -31,7 +31,7 @@ import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
public class RepeatingExtentPattern extends AbstractPattern {
|
||||
|
||||
private Extent extent;
|
||||
private Vector offset;
|
||||
private BlockVector3 offset;
|
||||
|
||||
/**
|
||||
* Create a new instance.
|
||||
@ -39,7 +39,7 @@ public class RepeatingExtentPattern extends AbstractPattern {
|
||||
* @param extent the extent
|
||||
* @param offset the offset
|
||||
*/
|
||||
public RepeatingExtentPattern(Extent extent, Vector offset) {
|
||||
public RepeatingExtentPattern(Extent extent, BlockVector3 offset) {
|
||||
setExtent(extent);
|
||||
setOffset(offset);
|
||||
}
|
||||
@ -68,7 +68,7 @@ public class RepeatingExtentPattern extends AbstractPattern {
|
||||
*
|
||||
* @return the offset
|
||||
*/
|
||||
public Vector getOffset() {
|
||||
public BlockVector3 getOffset() {
|
||||
return offset;
|
||||
}
|
||||
|
||||
@ -77,19 +77,19 @@ public class RepeatingExtentPattern extends AbstractPattern {
|
||||
*
|
||||
* @param offset the offset
|
||||
*/
|
||||
public void setOffset(Vector offset) {
|
||||
public void setOffset(BlockVector3 offset) {
|
||||
checkNotNull(offset);
|
||||
this.offset = offset;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockStateHolder apply(Vector position) {
|
||||
Vector base = position.add(offset);
|
||||
Vector size = extent.getMaximumPoint().subtract(extent.getMinimumPoint()).add(1, 1, 1);
|
||||
public BlockStateHolder apply(BlockVector3 position) {
|
||||
BlockVector3 base = position.add(offset);
|
||||
BlockVector3 size = extent.getMaximumPoint().subtract(extent.getMinimumPoint()).add(1, 1, 1);
|
||||
int x = base.getBlockX() % size.getBlockX();
|
||||
int y = base.getBlockY() % size.getBlockY();
|
||||
int z = base.getBlockZ() % size.getBlockZ();
|
||||
return extent.getFullBlock(new Vector(x, y, z));
|
||||
return extent.getFullBlock(new BlockVector3(x, y, z));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -21,16 +21,16 @@ package com.sk89q.worldedit.function.util;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.sk89q.worldedit.Vector2D;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.function.FlatRegionFunction;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
|
||||
/**
|
||||
* Offsets the position parameter by adding a given offset vector.
|
||||
*/
|
||||
public class FlatRegionOffset implements FlatRegionFunction {
|
||||
|
||||
private Vector2D offset;
|
||||
private BlockVector2 offset;
|
||||
private final FlatRegionFunction function;
|
||||
|
||||
/**
|
||||
@ -39,7 +39,7 @@ public class FlatRegionOffset implements FlatRegionFunction {
|
||||
* @param offset the offset
|
||||
* @param function the function that is called with the offset position
|
||||
*/
|
||||
public FlatRegionOffset(Vector2D offset, FlatRegionFunction function) {
|
||||
public FlatRegionOffset(BlockVector2 offset, FlatRegionFunction function) {
|
||||
checkNotNull(function);
|
||||
setOffset(offset);
|
||||
this.function = function;
|
||||
@ -50,7 +50,7 @@ public class FlatRegionOffset implements FlatRegionFunction {
|
||||
*
|
||||
* @return the offset
|
||||
*/
|
||||
public Vector2D getOffset() {
|
||||
public BlockVector2 getOffset() {
|
||||
return offset;
|
||||
}
|
||||
|
||||
@ -59,13 +59,13 @@ public class FlatRegionOffset implements FlatRegionFunction {
|
||||
*
|
||||
* @param offset the offset
|
||||
*/
|
||||
public void setOffset(Vector2D offset) {
|
||||
public void setOffset(BlockVector2 offset) {
|
||||
checkNotNull(offset);
|
||||
this.offset = offset;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Vector2D position) throws WorldEditException {
|
||||
public boolean apply(BlockVector2 position) throws WorldEditException {
|
||||
return function.apply(position.add(offset));
|
||||
}
|
||||
}
|
||||
|
@ -21,16 +21,16 @@ package com.sk89q.worldedit.function.util;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.function.RegionFunction;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
|
||||
/**
|
||||
* Offsets the position parameter by adding a given offset vector.
|
||||
*/
|
||||
public class RegionOffset implements RegionFunction {
|
||||
|
||||
private Vector offset;
|
||||
private BlockVector3 offset;
|
||||
private final RegionFunction function;
|
||||
|
||||
/**
|
||||
@ -39,7 +39,7 @@ public class RegionOffset implements RegionFunction {
|
||||
* @param offset the offset
|
||||
* @param function the function that is called with the offset position
|
||||
*/
|
||||
public RegionOffset(Vector offset, RegionFunction function) {
|
||||
public RegionOffset(BlockVector3 offset, RegionFunction function) {
|
||||
checkNotNull(function);
|
||||
setOffset(offset);
|
||||
this.function = function;
|
||||
@ -50,7 +50,7 @@ public class RegionOffset implements RegionFunction {
|
||||
*
|
||||
* @return the offset
|
||||
*/
|
||||
public Vector getOffset() {
|
||||
public BlockVector3 getOffset() {
|
||||
return offset;
|
||||
}
|
||||
|
||||
@ -59,13 +59,13 @@ public class RegionOffset implements RegionFunction {
|
||||
*
|
||||
* @param offset the offset
|
||||
*/
|
||||
public void setOffset(Vector offset) {
|
||||
public void setOffset(BlockVector3 offset) {
|
||||
checkNotNull(offset);
|
||||
this.offset = offset;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Vector position) throws WorldEditException {
|
||||
public boolean apply(BlockVector3 position) throws WorldEditException {
|
||||
return function.apply(position.add(offset));
|
||||
}
|
||||
|
||||
|
@ -21,12 +21,11 @@ package com.sk89q.worldedit.function.visitor;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.sk89q.worldedit.BlockVector;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
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 java.util.ArrayDeque;
|
||||
import java.util.ArrayList;
|
||||
@ -38,9 +37,9 @@ import java.util.Set;
|
||||
|
||||
/**
|
||||
* Performs a breadth-first search starting from points added with
|
||||
* {@link #visit(com.sk89q.worldedit.Vector)}. The search continues
|
||||
* {@link #visit(BlockVector3)}. The search continues
|
||||
* to a certain adjacent point provided that the method
|
||||
* {@link #isVisitable(com.sk89q.worldedit.Vector, com.sk89q.worldedit.Vector)}
|
||||
* {@link #isVisitable(BlockVector3, BlockVector3)}
|
||||
* returns true for that point.
|
||||
*
|
||||
* <p>As an abstract implementation, this class can be used to implement
|
||||
@ -50,9 +49,9 @@ import java.util.Set;
|
||||
public abstract class BreadthFirstSearch implements Operation {
|
||||
|
||||
private final RegionFunction function;
|
||||
private final Queue<BlockVector> queue = new ArrayDeque<>();
|
||||
private final Set<BlockVector> visited = new HashSet<>();
|
||||
private final List<Vector> directions = new ArrayList<>();
|
||||
private final Queue<BlockVector3> queue = new ArrayDeque<>();
|
||||
private final Set<BlockVector3> visited = new HashSet<>();
|
||||
private final List<BlockVector3> directions = new ArrayList<>();
|
||||
private int affected = 0;
|
||||
|
||||
/**
|
||||
@ -69,16 +68,16 @@ public abstract class BreadthFirstSearch implements Operation {
|
||||
/**
|
||||
* Get the list of directions will be visited.
|
||||
*
|
||||
* <p>Directions are {@link com.sk89q.worldedit.Vector}s that determine
|
||||
* <p>Directions are {@link BlockVector3}s that determine
|
||||
* what adjacent points area available. Vectors should not be
|
||||
* unit vectors. An example of a valid direction is
|
||||
* {@code new Vector(1, 0, 1)}.</p>
|
||||
* {@code new BlockVector3(1, 0, 1)}.</p>
|
||||
*
|
||||
* <p>The list of directions can be cleared.</p>
|
||||
*
|
||||
* @return the list of directions
|
||||
*/
|
||||
protected Collection<Vector> getDirections() {
|
||||
protected Collection<BlockVector3> getDirections() {
|
||||
return directions;
|
||||
}
|
||||
|
||||
@ -86,29 +85,29 @@ public abstract class BreadthFirstSearch implements Operation {
|
||||
* Add the directions along the axes as directions to visit.
|
||||
*/
|
||||
protected void addAxes() {
|
||||
directions.add(new Vector(0, -1, 0));
|
||||
directions.add(new Vector(0, 1, 0));
|
||||
directions.add(new Vector(-1, 0, 0));
|
||||
directions.add(new Vector(1, 0, 0));
|
||||
directions.add(new Vector(0, 0, -1));
|
||||
directions.add(new Vector(0, 0, 1));
|
||||
directions.add(new BlockVector3(0, -1, 0));
|
||||
directions.add(new BlockVector3(0, 1, 0));
|
||||
directions.add(new BlockVector3(-1, 0, 0));
|
||||
directions.add(new BlockVector3(1, 0, 0));
|
||||
directions.add(new BlockVector3(0, 0, -1));
|
||||
directions.add(new BlockVector3(0, 0, 1));
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the diagonal directions as directions to visit.
|
||||
*/
|
||||
protected void addDiagonal() {
|
||||
directions.add(new Vector(1, 0, 1));
|
||||
directions.add(new Vector(-1, 0, -1));
|
||||
directions.add(new Vector(1, 0, -1));
|
||||
directions.add(new Vector(-1, 0, 1));
|
||||
directions.add(new BlockVector3(1, 0, 1));
|
||||
directions.add(new BlockVector3(-1, 0, -1));
|
||||
directions.add(new BlockVector3(1, 0, -1));
|
||||
directions.add(new BlockVector3(-1, 0, 1));
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the given location to the list of locations to visit, provided
|
||||
* that it has not been visited. The position passed to this method
|
||||
* will still be visited even if it fails
|
||||
* {@link #isVisitable(com.sk89q.worldedit.Vector, com.sk89q.worldedit.Vector)}.
|
||||
* {@link #isVisitable(BlockVector3, BlockVector3)}.
|
||||
*
|
||||
* <p>This method should be used before the search begins, because if
|
||||
* the position <em>does</em> fail the test, and the search has already
|
||||
@ -118,8 +117,8 @@ public abstract class BreadthFirstSearch implements Operation {
|
||||
*
|
||||
* @param position the position
|
||||
*/
|
||||
public void visit(Vector position) {
|
||||
BlockVector blockVector = position.toBlockVector();
|
||||
public void visit(BlockVector3 position) {
|
||||
BlockVector3 blockVector = position;
|
||||
if (!visited.contains(blockVector)) {
|
||||
queue.add(blockVector);
|
||||
visited.add(blockVector);
|
||||
@ -132,8 +131,8 @@ public abstract class BreadthFirstSearch implements Operation {
|
||||
* @param from the origin block
|
||||
* @param to the block under question
|
||||
*/
|
||||
private void visit(Vector from, Vector to) {
|
||||
BlockVector blockVector = to.toBlockVector();
|
||||
private void visit(BlockVector3 from, BlockVector3 to) {
|
||||
BlockVector3 blockVector = to;
|
||||
if (!visited.contains(blockVector)) {
|
||||
visited.add(blockVector);
|
||||
if (isVisitable(from, to)) {
|
||||
@ -150,7 +149,7 @@ public abstract class BreadthFirstSearch implements Operation {
|
||||
* @param to the block under question
|
||||
* @return true if the 'to' block should be visited
|
||||
*/
|
||||
protected abstract boolean isVisitable(Vector from, Vector to);
|
||||
protected abstract boolean isVisitable(BlockVector3 from, BlockVector3 to);
|
||||
|
||||
/**
|
||||
* Get the number of affected objects.
|
||||
@ -163,14 +162,14 @@ public abstract class BreadthFirstSearch implements Operation {
|
||||
|
||||
@Override
|
||||
public Operation resume(RunContext run) throws WorldEditException {
|
||||
Vector position;
|
||||
BlockVector3 position;
|
||||
|
||||
while ((position = queue.poll()) != null) {
|
||||
if (function.apply(position)) {
|
||||
affected++;
|
||||
}
|
||||
|
||||
for (Vector dir : directions) {
|
||||
for (BlockVector3 dir : directions) {
|
||||
visit(position, position.add(dir));
|
||||
}
|
||||
}
|
||||
|
@ -21,9 +21,9 @@ package com.sk89q.worldedit.function.visitor;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.function.RegionFunction;
|
||||
import com.sk89q.worldedit.function.mask.Mask;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
@ -51,17 +51,17 @@ public class DownwardVisitor extends RecursiveVisitor {
|
||||
|
||||
this.baseY = baseY;
|
||||
|
||||
Collection<Vector> directions = getDirections();
|
||||
Collection<BlockVector3> directions = getDirections();
|
||||
directions.clear();
|
||||
directions.add(new Vector(1, 0, 0));
|
||||
directions.add(new Vector(-1, 0, 0));
|
||||
directions.add(new Vector(0, 0, 1));
|
||||
directions.add(new Vector(0, 0, -1));
|
||||
directions.add(new Vector(0, -1, 0));
|
||||
directions.add(new BlockVector3(1, 0, 0));
|
||||
directions.add(new BlockVector3(-1, 0, 0));
|
||||
directions.add(new BlockVector3(0, 0, 1));
|
||||
directions.add(new BlockVector3(0, 0, -1));
|
||||
directions.add(new BlockVector3(0, -1, 0));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isVisitable(Vector from, Vector to) {
|
||||
protected boolean isVisitable(BlockVector3 from, BlockVector3 to) {
|
||||
int fromY = from.getBlockY();
|
||||
return (fromY == baseY || to.subtract(from).getBlockY() < 0) && super.isVisitable(from, to);
|
||||
}
|
||||
|
@ -21,11 +21,11 @@ package com.sk89q.worldedit.function.visitor;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.sk89q.worldedit.Vector2D;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.function.FlatRegionFunction;
|
||||
import com.sk89q.worldedit.function.operation.Operation;
|
||||
import com.sk89q.worldedit.function.operation.RunContext;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.regions.FlatRegion;
|
||||
|
||||
import java.util.List;
|
||||
@ -64,7 +64,7 @@ public class FlatRegionVisitor implements Operation {
|
||||
|
||||
@Override
|
||||
public Operation resume(RunContext run) throws WorldEditException {
|
||||
for (Vector2D pt : flatRegion.asFlatRegion()) {
|
||||
for (BlockVector2 pt : flatRegion.asFlatRegion()) {
|
||||
if (function.apply(pt)) {
|
||||
affected++;
|
||||
}
|
||||
|
@ -22,14 +22,14 @@ package com.sk89q.worldedit.function.visitor;
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.Vector2D;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.function.LayerFunction;
|
||||
import com.sk89q.worldedit.function.mask.Mask2D;
|
||||
import com.sk89q.worldedit.function.mask.Masks;
|
||||
import com.sk89q.worldedit.function.operation.Operation;
|
||||
import com.sk89q.worldedit.function.operation.RunContext;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.regions.FlatRegion;
|
||||
|
||||
import java.util.List;
|
||||
@ -92,20 +92,20 @@ public class LayerVisitor implements Operation {
|
||||
|
||||
@Override
|
||||
public Operation resume(RunContext run) throws WorldEditException {
|
||||
for (Vector2D column : flatRegion.asFlatRegion()) {
|
||||
for (BlockVector2 column : flatRegion.asFlatRegion()) {
|
||||
if (!mask.test(column)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Abort if we are underground
|
||||
if (function.isGround(column.toVector(maxY + 1))) {
|
||||
if (function.isGround(column.toBlockVector3(maxY + 1))) {
|
||||
return null;
|
||||
}
|
||||
|
||||
boolean found = false;
|
||||
int groundY = 0;
|
||||
for (int y = maxY; y >= minY; --y) {
|
||||
Vector test = column.toVector(y);
|
||||
BlockVector3 test = column.toBlockVector3(y);
|
||||
if (!found) {
|
||||
if (function.isGround(test)) {
|
||||
found = true;
|
||||
|
@ -19,9 +19,9 @@
|
||||
|
||||
package com.sk89q.worldedit.function.visitor;
|
||||
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.function.RegionFunction;
|
||||
import com.sk89q.worldedit.function.mask.Mask;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
@ -38,13 +38,13 @@ public class NonRisingVisitor extends RecursiveVisitor {
|
||||
*/
|
||||
public NonRisingVisitor(Mask mask, RegionFunction function) {
|
||||
super(mask, function);
|
||||
Collection<Vector> directions = getDirections();
|
||||
Collection<BlockVector3> directions = getDirections();
|
||||
directions.clear();
|
||||
directions.add(new Vector(1, 0, 0));
|
||||
directions.add(new Vector(-1, 0, 0));
|
||||
directions.add(new Vector(0, 0, 1));
|
||||
directions.add(new Vector(0, 0, -1));
|
||||
directions.add(new Vector(0, -1, 0));
|
||||
directions.add(new BlockVector3(1, 0, 0));
|
||||
directions.add(new BlockVector3(-1, 0, 0));
|
||||
directions.add(new BlockVector3(0, 0, 1));
|
||||
directions.add(new BlockVector3(0, 0, -1));
|
||||
directions.add(new BlockVector3(0, -1, 0));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -21,9 +21,9 @@ package com.sk89q.worldedit.function.visitor;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.function.RegionFunction;
|
||||
import com.sk89q.worldedit.function.mask.Mask;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
|
||||
/**
|
||||
* An implementation of an {@link BreadthFirstSearch} that uses a mask to
|
||||
@ -46,7 +46,7 @@ public class RecursiveVisitor extends BreadthFirstSearch {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isVisitable(Vector from, Vector to) {
|
||||
protected boolean isVisitable(BlockVector3 from, BlockVector3 to) {
|
||||
return mask.test(to);
|
||||
}
|
||||
}
|
||||
|
@ -19,11 +19,11 @@
|
||||
|
||||
package com.sk89q.worldedit.function.visitor;
|
||||
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
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.regions.Region;
|
||||
|
||||
import java.util.List;
|
||||
@ -53,7 +53,7 @@ public class RegionVisitor implements Operation {
|
||||
|
||||
@Override
|
||||
public Operation resume(RunContext run) throws WorldEditException {
|
||||
for (Vector pt : region) {
|
||||
for (BlockVector3 pt : region) {
|
||||
if (function.apply(pt)) {
|
||||
affected++;
|
||||
}
|
||||
|
Reference in New Issue
Block a user