mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-07-10 06:38:35 +00:00
Current progress with update
This commit is contained in:
@ -19,8 +19,10 @@
|
||||
|
||||
package com.sk89q.worldedit.function;
|
||||
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@ -95,7 +97,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;
|
||||
|
||||
}
|
||||
|
@ -19,14 +19,20 @@
|
||||
|
||||
package com.sk89q.worldedit.function;
|
||||
|
||||
<<<<<<< HEAD
|
||||
import com.sk89q.worldedit.Vector2D;
|
||||
=======
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.function.mask.Mask2D;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
/**
|
||||
* 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 +56,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);
|
||||
}
|
||||
|
||||
|
@ -19,9 +19,15 @@
|
||||
|
||||
package com.sk89q.worldedit.function;
|
||||
|
||||
<<<<<<< HEAD
|
||||
import com.sk89q.worldedit.Vector;
|
||||
=======
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.function.mask.Mask;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
@ -77,12 +83,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;
|
||||
|
||||
}
|
||||
|
@ -19,14 +19,20 @@
|
||||
|
||||
package com.sk89q.worldedit.function;
|
||||
|
||||
<<<<<<< HEAD
|
||||
import com.sk89q.worldedit.Vector;
|
||||
=======
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.function.mask.Mask;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
/**
|
||||
* 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 +55,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);
|
||||
}
|
||||
|
||||
|
@ -19,10 +19,16 @@
|
||||
|
||||
package com.sk89q.worldedit.function.biome;
|
||||
|
||||
<<<<<<< HEAD
|
||||
import com.sk89q.worldedit.Vector2D;
|
||||
=======
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
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;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
@ -49,7 +55,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);
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,77 @@
|
||||
/*
|
||||
* WorldEdit, a Minecraft world manipulation toolkit
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldEdit team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldedit.function.block;
|
||||
|
||||
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;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class BlockDistributionCounter implements RegionFunction {
|
||||
|
||||
private Extent extent;
|
||||
private boolean fuzzy;
|
||||
|
||||
private List<Countable<BlockStateHolder>> distribution = new ArrayList<>();
|
||||
private Map<BlockStateHolder, Countable<BlockStateHolder>> map = new HashMap<>();
|
||||
|
||||
public BlockDistributionCounter(Extent extent, boolean fuzzy) {
|
||||
this.extent = extent;
|
||||
this.fuzzy = fuzzy;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(BlockVector3 position) throws WorldEditException {
|
||||
BlockStateHolder blk = extent.getBlock(position);
|
||||
if (fuzzy) {
|
||||
blk = ((BlockState) blk).toFuzzy();
|
||||
}
|
||||
|
||||
if (map.containsKey(blk)) {
|
||||
map.get(blk).increment();
|
||||
} else {
|
||||
Countable<BlockStateHolder> c = new Countable<>(blk, 1);
|
||||
map.put(blk, c);
|
||||
distribution.add(c);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the distribution list.
|
||||
*
|
||||
* @return The distribution
|
||||
*/
|
||||
public List<Countable<BlockStateHolder>> getDistribution() {
|
||||
Collections.sort(distribution);
|
||||
Collections.reverse(distribution);
|
||||
return this.distribution;
|
||||
}
|
||||
}
|
@ -19,11 +19,17 @@
|
||||
|
||||
package com.sk89q.worldedit.function.block;
|
||||
|
||||
<<<<<<< HEAD
|
||||
import com.sk89q.worldedit.Vector;
|
||||
=======
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
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;
|
||||
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
@ -50,8 +56,13 @@ public class BlockReplace implements RegionFunction {
|
||||
}
|
||||
|
||||
@Override
|
||||
<<<<<<< HEAD
|
||||
public boolean apply(Vector position) throws WorldEditException {
|
||||
return pattern.apply(extent, position, position);
|
||||
=======
|
||||
public boolean apply(BlockVector3 position) throws WorldEditException {
|
||||
return extent.setBlock(position, pattern.apply(position));
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
}
|
||||
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -22,23 +22,34 @@ package com.sk89q.worldedit.function.block;
|
||||
import com.boydti.fawe.util.ReflectionUtils;
|
||||
import com.sk89q.jnbt.ByteTag;
|
||||
import com.sk89q.jnbt.CompoundTag;
|
||||
<<<<<<< HEAD
|
||||
import com.sk89q.jnbt.Tag;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
=======
|
||||
import com.sk89q.jnbt.CompoundTagBuilder;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
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;
|
||||
<<<<<<< HEAD
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
=======
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
|
||||
/**
|
||||
* Copies blocks from one extent to another.
|
||||
@ -47,8 +58,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;
|
||||
|
||||
/**
|
||||
@ -60,7 +71,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);
|
||||
@ -74,9 +85,16 @@ public class ExtentBlockCopy implements RegionFunction {
|
||||
}
|
||||
|
||||
@Override
|
||||
<<<<<<< HEAD
|
||||
public boolean apply(Vector position) throws WorldEditException {
|
||||
Vector orig = position.subtract(from);
|
||||
Vector transformed = transform.apply(orig);
|
||||
=======
|
||||
public boolean apply(BlockVector3 position) throws WorldEditException {
|
||||
BaseBlock block = source.getFullBlock(position);
|
||||
BlockVector3 orig = position.subtract(from);
|
||||
BlockVector3 transformed = transform.apply(orig.toVector3()).toBlockPoint();
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
|
||||
// Apply transformations to NBT data if necessary
|
||||
BlockStateHolder block = transformNbtData(source.getBlock(position));
|
||||
@ -101,11 +119,16 @@ public class ExtentBlockCopy implements RegionFunction {
|
||||
Direction direction = MCDirections.fromRotation(rot);
|
||||
|
||||
if (direction != null) {
|
||||
<<<<<<< HEAD
|
||||
Vector applyAbsolute = transform.apply(direction.toVector());
|
||||
Vector applyOrigin = transform.apply(Vector.ZERO);
|
||||
applyAbsolute.mutX(applyAbsolute.getX() - applyOrigin.getX());
|
||||
applyAbsolute.mutY(applyAbsolute.getY() - applyOrigin.getY());
|
||||
applyAbsolute.mutZ(applyAbsolute.getZ() - applyOrigin.getZ());
|
||||
=======
|
||||
Vector3 vector = transform.apply(direction.toVector()).subtract(transform.apply(Vector3.ZERO)).normalize();
|
||||
Direction newDirection = Direction.findClosest(vector, Flag.CARDINAL | Flag.ORDINAL | Flag.SECONDARY_ORDINAL);
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
|
||||
Direction newDirection = Direction.findClosest(applyAbsolute, Flag.CARDINAL | Flag.ORDINAL | Flag.SECONDARY_ORDINAL);
|
||||
|
||||
|
@ -21,7 +21,6 @@ package com.sk89q.worldedit.function.block;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.function.mask.BlockTypeMask;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
@ -30,8 +29,13 @@ import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
import com.sk89q.worldedit.function.LayerFunction;
|
||||
import com.sk89q.worldedit.function.mask.BlockTypeMask;
|
||||
import com.sk89q.worldedit.function.mask.Mask;
|
||||
<<<<<<< HEAD
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
=======
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
|
||||
/**
|
||||
* Makes a layer of grass on top, three layers of dirt below, and smooth stone
|
||||
@ -65,12 +69,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) {
|
||||
|
@ -22,17 +22,23 @@ package com.sk89q.worldedit.function.entity;
|
||||
import com.boydti.fawe.util.ReflectionUtils;
|
||||
import com.sk89q.jnbt.ByteTag;
|
||||
import com.sk89q.jnbt.CompoundTag;
|
||||
<<<<<<< HEAD
|
||||
import com.sk89q.jnbt.FloatTag;
|
||||
import com.sk89q.jnbt.IntTag;
|
||||
import com.sk89q.jnbt.ListTag;
|
||||
import com.sk89q.jnbt.Tag;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
=======
|
||||
import com.sk89q.jnbt.CompoundTagBuilder;
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
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;
|
||||
@ -50,8 +56,8 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
||||
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;
|
||||
|
||||
@ -63,7 +69,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);
|
||||
@ -99,6 +105,7 @@ public class ExtentEntityCopy implements EntityFunction {
|
||||
Location newLocation;
|
||||
Location location = entity.getLocation();
|
||||
|
||||
<<<<<<< HEAD
|
||||
Vector pivot = from.round().add(0.5, 0.5, 0.5);
|
||||
Vector newPosition = transform.apply(location.toVector().subtract(pivot));
|
||||
Vector newDirection;
|
||||
@ -110,6 +117,19 @@ public class ExtentEntityCopy implements EntityFunction {
|
||||
newLocation = new Location(destination, newPosition.add(to.round().add(0.5, 0.5, 0.5)), newDirection);
|
||||
state = transformNbtData(state);
|
||||
}
|
||||
=======
|
||||
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(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
|
||||
state = transformNbtData(state);
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
|
||||
boolean success = destination.createEntity(newLocation, state) != null;
|
||||
|
||||
@ -147,9 +167,14 @@ public class ExtentEntityCopy implements EntityFunction {
|
||||
boolean hasFacing = tag.containsKey("Facing");
|
||||
|
||||
if (hasTilePosition) {
|
||||
<<<<<<< HEAD
|
||||
changed = true;
|
||||
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();
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
|
||||
values.put("TileX", new IntTag(newTilePosition.getBlockX()));
|
||||
values.put("TileY", new IntTag(newTilePosition.getBlockY()));
|
||||
@ -168,7 +193,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) {
|
||||
|
@ -20,7 +20,6 @@
|
||||
package com.sk89q.worldedit.function.factory;
|
||||
|
||||
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;
|
||||
@ -29,6 +28,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,7 +20,6 @@
|
||||
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.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
@ -28,6 +27,12 @@ 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;
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
|
||||
/**
|
||||
* Generates flora (which may include tall grass, flowers, etc.).
|
||||
@ -103,7 +108,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,8 +20,13 @@
|
||||
package com.sk89q.worldedit.function.generator;
|
||||
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
import com.sk89q.worldedit.function.RegionFunction;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.util.TreeGenerator;
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.world.block.BlockType;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
@ -49,7 +54,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,15 @@ 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;
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
@ -84,12 +88,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 +106,7 @@ public class GardenPatchGenerator implements RegionFunction {
|
||||
|
||||
int t = random.nextInt(4);
|
||||
int h = random.nextInt(3) - 1;
|
||||
Vector p;
|
||||
BlockVector3 p;
|
||||
|
||||
BlockStateHolder log = BlockTypes.OAK_LOG.getDefaultState();
|
||||
|
||||
@ -158,7 +162,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 +202,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);
|
||||
}
|
||||
|
||||
|
@ -19,8 +19,14 @@
|
||||
|
||||
package com.sk89q.worldedit.function.mask;
|
||||
|
||||
<<<<<<< HEAD
|
||||
import com.sk89q.worldedit.Vector2D;
|
||||
=======
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
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 +96,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));
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.sk89q.worldedit.function.mask;
|
||||
|
||||
<<<<<<< HEAD
|
||||
import com.boydti.fawe.object.collection.FastBitSet;
|
||||
import com.boydti.fawe.util.MainUtil;
|
||||
import com.boydti.fawe.util.StringMan;
|
||||
@ -10,6 +11,12 @@ import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.registry.state.AbstractProperty;
|
||||
import com.sk89q.worldedit.registry.state.Property;
|
||||
=======
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.world.block.BlockType;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
@ -75,6 +82,7 @@ public class BlockMask extends AbstractExtentMask {
|
||||
}
|
||||
|
||||
@Override
|
||||
<<<<<<< HEAD
|
||||
public Mask optimize() {
|
||||
Map<Object, Integer> states = new HashMap<>();
|
||||
int indexFound = -1;
|
||||
@ -94,6 +102,13 @@ public class BlockMask extends AbstractExtentMask {
|
||||
} else {
|
||||
return this;
|
||||
}
|
||||
=======
|
||||
public boolean test(BlockVector3 vector) {
|
||||
BlockStateHolder block = getExtent().getBlock(vector);
|
||||
for (BlockStateHolder testBlock : blocks) {
|
||||
if (testBlock.equalsFuzzy(block)) {
|
||||
return true;
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
}
|
||||
// Only types, no states
|
||||
if (indexFound == -1) {
|
||||
|
@ -1,7 +1,13 @@
|
||||
package com.sk89q.worldedit.function.mask;
|
||||
|
||||
<<<<<<< HEAD
|
||||
import com.sk89q.worldedit.Vector;
|
||||
=======
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.world.block.BlockType;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
|
||||
@ -75,7 +81,18 @@ public class BlockTypeMask extends AbstractExtentMask {
|
||||
}
|
||||
|
||||
@Override
|
||||
<<<<<<< HEAD
|
||||
public boolean test(Vector vector) {
|
||||
return types[getExtent().getBlockType(vector).getInternalId()];
|
||||
=======
|
||||
public boolean test(BlockVector3 vector) {
|
||||
return blocks.contains(getExtent().getBlock(vector).getBlockType());
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Mask2D toMask2D() {
|
||||
return null;
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
}
|
||||
}
|
||||
|
@ -19,7 +19,13 @@
|
||||
|
||||
package com.sk89q.worldedit.function.mask;
|
||||
|
||||
<<<<<<< HEAD
|
||||
import com.sk89q.worldedit.Vector;
|
||||
=======
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
@ -47,7 +53,7 @@ public class BoundedHeightMask extends AbstractMask {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean test(Vector vector) {
|
||||
public boolean test(BlockVector3 vector) {
|
||||
return vector.getY() >= minY && vector.getY() <= maxY;
|
||||
}
|
||||
|
||||
|
@ -20,7 +20,11 @@
|
||||
package com.sk89q.worldedit.function.mask;
|
||||
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
<<<<<<< HEAD
|
||||
import com.sk89q.worldedit.Vector;
|
||||
=======
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
@ -40,8 +44,13 @@ public class ExistingBlockMask extends AbstractExtentMask {
|
||||
}
|
||||
|
||||
@Override
|
||||
<<<<<<< HEAD
|
||||
public boolean test(Vector vector) {
|
||||
return !getExtent().getBlock(vector).getMaterial().isAir();
|
||||
=======
|
||||
public boolean test(BlockVector3 vector) {
|
||||
return !getExtent().getBlock(vector).getBlockType().getMaterial().isAir();
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
@ -19,10 +19,16 @@
|
||||
|
||||
package com.sk89q.worldedit.function.mask;
|
||||
|
||||
<<<<<<< HEAD
|
||||
import com.sk89q.worldedit.Vector;
|
||||
=======
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
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 +67,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) {
|
||||
|
@ -19,10 +19,16 @@
|
||||
|
||||
package com.sk89q.worldedit.function.mask;
|
||||
|
||||
<<<<<<< HEAD
|
||||
import com.sk89q.worldedit.Vector2D;
|
||||
=======
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
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;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
@ -52,7 +58,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) {
|
||||
|
@ -20,8 +20,8 @@
|
||||
package com.sk89q.worldedit.function.mask;
|
||||
|
||||
import com.sk89q.minecraft.util.commands.Link;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.command.UtilityCommands;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
@ -40,7 +40,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);
|
||||
|
||||
}
|
||||
|
@ -19,8 +19,14 @@
|
||||
|
||||
package com.sk89q.worldedit.function.mask;
|
||||
|
||||
<<<<<<< HEAD
|
||||
import com.google.common.base.Function;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
=======
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.*;
|
||||
@ -166,8 +172,17 @@ public class MaskIntersection extends AbstractMask {
|
||||
}
|
||||
|
||||
@Override
|
||||
<<<<<<< HEAD
|
||||
public boolean test(Vector vector) {
|
||||
for (Mask mask : masksArray) {
|
||||
=======
|
||||
public boolean test(BlockVector3 vector) {
|
||||
if (masks.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (Mask mask : masks) {
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
if (!mask.test(vector)) {
|
||||
return false;
|
||||
}
|
||||
|
@ -19,7 +19,13 @@
|
||||
|
||||
package com.sk89q.worldedit.function.mask;
|
||||
|
||||
<<<<<<< HEAD
|
||||
import com.sk89q.worldedit.Vector2D;
|
||||
=======
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
@ -83,7 +89,7 @@ public class MaskIntersection2D implements Mask2D {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean test(Vector2D vector) {
|
||||
public boolean test(BlockVector2 vector) {
|
||||
if (masks.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
@ -19,8 +19,13 @@
|
||||
|
||||
package com.sk89q.worldedit.function.mask;
|
||||
|
||||
<<<<<<< HEAD
|
||||
import com.google.common.base.Function;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
=======
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
@ -53,9 +58,14 @@ public class MaskUnion extends MaskIntersection {
|
||||
}
|
||||
|
||||
@Override
|
||||
<<<<<<< HEAD
|
||||
public Function<Map.Entry<Mask, Mask>, Mask> pairingFunction() {
|
||||
return input -> input.getKey().or(input.getValue());
|
||||
}
|
||||
=======
|
||||
public boolean test(BlockVector3 vector) {
|
||||
Collection<Mask> masks = getMasks();
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
|
||||
@Override
|
||||
public boolean test(Vector vector) {
|
||||
|
@ -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) {
|
||||
|
@ -1,7 +1,14 @@
|
||||
package com.sk89q.worldedit.function.mask;
|
||||
|
||||
<<<<<<< HEAD
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.Vector2D;
|
||||
=======
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
@ -50,8 +57,36 @@ public final class Masks {
|
||||
* @param finalMask the mask
|
||||
* @return a new mask
|
||||
*/
|
||||
<<<<<<< HEAD
|
||||
public static Mask negate(final Mask finalMask) {
|
||||
return finalMask.inverse();
|
||||
=======
|
||||
public static Mask negate(final Mask mask) {
|
||||
if (mask instanceof AlwaysTrue) {
|
||||
return ALWAYS_FALSE;
|
||||
} else if (mask instanceof AlwaysFalse) {
|
||||
return ALWAYS_TRUE;
|
||||
}
|
||||
|
||||
checkNotNull(mask);
|
||||
return new AbstractMask() {
|
||||
@Override
|
||||
public boolean test(BlockVector3 vector) {
|
||||
return !mask.test(vector);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Mask2D toMask2D() {
|
||||
Mask2D mask2d = mask.toMask2D();
|
||||
if (mask2d != null) {
|
||||
return negate(mask2d);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
};
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
}
|
||||
|
||||
/**
|
||||
@ -70,7 +105,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);
|
||||
}
|
||||
};
|
||||
@ -85,8 +120,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
|
||||
@ -99,12 +134,12 @@ public final class Masks {
|
||||
|
||||
protected 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;
|
||||
}
|
||||
|
||||
@ -127,12 +162,12 @@ public final class Masks {
|
||||
|
||||
protected 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;
|
||||
}
|
||||
|
||||
|
@ -19,7 +19,14 @@
|
||||
|
||||
package com.sk89q.worldedit.function.mask;
|
||||
|
||||
<<<<<<< HEAD
|
||||
import com.sk89q.worldedit.Vector;
|
||||
=======
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
import com.sk89q.worldedit.math.noise.NoiseGenerator;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
@ -85,8 +92,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
|
||||
|
@ -19,7 +19,14 @@
|
||||
|
||||
package com.sk89q.worldedit.function.mask;
|
||||
|
||||
<<<<<<< HEAD
|
||||
import com.sk89q.worldedit.Vector2D;
|
||||
=======
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
import com.sk89q.worldedit.math.noise.NoiseGenerator;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
@ -83,8 +90,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;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,7 +1,14 @@
|
||||
package com.sk89q.worldedit.function.mask;
|
||||
|
||||
<<<<<<< HEAD
|
||||
import com.sk89q.worldedit.MutableBlockVector;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
=======
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
|
||||
@ -14,8 +21,12 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
||||
public class OffsetMask extends AbstractMask {
|
||||
|
||||
private Mask mask;
|
||||
<<<<<<< HEAD
|
||||
private Vector offset;
|
||||
private MutableBlockVector mutable = new MutableBlockVector();
|
||||
=======
|
||||
private BlockVector3 offset;
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
|
||||
/**
|
||||
* Create a new instance.
|
||||
@ -23,7 +34,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;
|
||||
@ -54,7 +65,7 @@ public class OffsetMask extends AbstractMask {
|
||||
*
|
||||
* @return the offset
|
||||
*/
|
||||
public Vector getOffset() {
|
||||
public BlockVector3 getOffset() {
|
||||
return offset;
|
||||
}
|
||||
|
||||
@ -63,17 +74,22 @@ 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
|
||||
<<<<<<< HEAD
|
||||
public boolean test(Vector vector) {
|
||||
mutable.mutX((vector.getX() + offset.getX()));
|
||||
mutable.mutY((vector.getY() + offset.getY()));
|
||||
mutable.mutZ((vector.getZ() + offset.getZ()));
|
||||
return getMask().test(mutable);
|
||||
=======
|
||||
public boolean test(BlockVector3 vector) {
|
||||
return getMask().test(vector.add(offset));
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@ -81,7 +97,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;
|
||||
}
|
||||
|
@ -19,7 +19,13 @@
|
||||
|
||||
package com.sk89q.worldedit.function.mask;
|
||||
|
||||
<<<<<<< HEAD
|
||||
import com.sk89q.worldedit.Vector2D;
|
||||
=======
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
@ -30,7 +36,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
||||
public class OffsetMask2D extends AbstractMask2D {
|
||||
|
||||
private Mask2D mask;
|
||||
private Vector2D offset;
|
||||
private BlockVector2 offset;
|
||||
|
||||
/**
|
||||
* Create a new instance.
|
||||
@ -38,7 +44,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 +75,7 @@ public class OffsetMask2D extends AbstractMask2D {
|
||||
*
|
||||
* @return the offset
|
||||
*/
|
||||
public Vector2D getOffset() {
|
||||
public BlockVector2 getOffset() {
|
||||
return offset;
|
||||
}
|
||||
|
||||
@ -78,13 +84,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));
|
||||
}
|
||||
|
||||
|
@ -19,7 +19,13 @@
|
||||
|
||||
package com.sk89q.worldedit.function.mask;
|
||||
|
||||
<<<<<<< HEAD
|
||||
import com.sk89q.worldedit.Vector;
|
||||
=======
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
@ -62,7 +68,7 @@ public class RegionMask extends AbstractMask {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean test(Vector vector) {
|
||||
public boolean test(BlockVector3 vector) {
|
||||
return region.contains(vector);
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,11 @@
|
||||
package com.sk89q.worldedit.function.mask;
|
||||
|
||||
<<<<<<< HEAD
|
||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||
=======
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.blocks.BlockType;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
@ -18,8 +23,16 @@ public class SolidBlockMask extends BlockTypeMask {
|
||||
return types;
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
public SolidBlockMask(Extent extent) {
|
||||
super(extent, getTypes());
|
||||
=======
|
||||
@Override
|
||||
public boolean test(BlockVector3 vector) {
|
||||
Extent extent = getExtent();
|
||||
BlockState block = extent.getBlock(vector);
|
||||
return block.getBlockType().getMaterial().isMovementBlocker();
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
package com.sk89q.worldedit.function.operation;
|
||||
|
||||
<<<<<<< HEAD
|
||||
import com.boydti.fawe.example.MappedFaweQueue;
|
||||
import com.boydti.fawe.object.FaweQueue;
|
||||
import com.boydti.fawe.object.extent.BlockTranslateExtent;
|
||||
@ -30,6 +31,12 @@ import com.boydti.fawe.util.MaskTraverser;
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.MutableBlockVector;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
=======
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.entity.Entity;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
@ -44,7 +51,12 @@ import com.sk89q.worldedit.function.mask.Masks;
|
||||
import com.sk89q.worldedit.function.visitor.EntityVisitor;
|
||||
import com.sk89q.worldedit.function.visitor.IntersectRegionFunction;
|
||||
import com.sk89q.worldedit.function.visitor.RegionVisitor;
|
||||
<<<<<<< HEAD
|
||||
import com.sk89q.worldedit.math.transform.AffineTransform;
|
||||
=======
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.math.Vector3;
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
import com.sk89q.worldedit.math.transform.Identity;
|
||||
import com.sk89q.worldedit.math.transform.Transform;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
@ -67,8 +79,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;
|
||||
@ -87,10 +99,15 @@ public class ForwardExtentCopy implements Operation {
|
||||
* @param source the source extent
|
||||
* @param region the region to copy
|
||||
* @param destination the destination extent
|
||||
<<<<<<< HEAD
|
||||
* @param to the destination position
|
||||
* @see #ForwardExtentCopy(Extent, Region, Vector, Extent, Vector) the main constructor
|
||||
=======
|
||||
* @param to the destination position
|
||||
* @see #ForwardExtentCopy(Extent, Region, BlockVector3, Extent, BlockVector3) the main constructor
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
*/
|
||||
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);
|
||||
}
|
||||
|
||||
@ -103,7 +120,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);
|
||||
@ -313,6 +330,7 @@ public class ForwardExtentCopy implements Operation {
|
||||
int y = translation.getBlockY();
|
||||
int z = translation.getBlockZ();
|
||||
|
||||
<<<<<<< HEAD
|
||||
maskFunc = position -> {
|
||||
mutable.setComponents(position.getBlockX() + x, position.getBlockY() + y, position.getBlockZ() + z);
|
||||
if (region.contains(mutable)) {
|
||||
@ -354,6 +372,10 @@ public class ForwardExtentCopy implements Operation {
|
||||
|
||||
if (!entities.isEmpty()) {
|
||||
ExtentEntityCopy entityCopy = new ExtentEntityCopy(from, destination, to, currentTransform);
|
||||
=======
|
||||
if (copyingEntities) {
|
||||
ExtentEntityCopy entityCopy = new ExtentEntityCopy(from.toVector3(), destination, to.toVector3(), currentTransform);
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
entityCopy.setRemoving(removingEntities);
|
||||
EntityVisitor entityVisitor = new EntityVisitor(entities.iterator(), entityCopy);
|
||||
Operations.completeBlindly(entityVisitor);
|
||||
|
@ -1,10 +1,17 @@
|
||||
package com.sk89q.worldedit.function.pattern;
|
||||
|
||||
<<<<<<< HEAD
|
||||
import com.boydti.fawe.FaweCache;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
=======
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
|
||||
|
||||
@ -45,4 +52,13 @@ public class BlockPattern implements Pattern {
|
||||
checkNotNull(block);
|
||||
this.block = block;
|
||||
}
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
|
||||
@Override
|
||||
public BlockStateHolder apply(BlockVector3 position) {
|
||||
return block;
|
||||
}
|
||||
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
}
|
||||
|
@ -1,10 +1,16 @@
|
||||
package com.sk89q.worldedit.function.pattern;
|
||||
|
||||
<<<<<<< HEAD
|
||||
import com.sk89q.worldedit.MutableBlockVector;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
=======
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
|
||||
|
||||
@ -16,9 +22,13 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
||||
public class ClipboardPattern extends AbstractPattern {
|
||||
|
||||
private final Clipboard clipboard;
|
||||
<<<<<<< HEAD
|
||||
private final int sx, sy, sz;
|
||||
private final Vector min;
|
||||
private MutableBlockVector mutable = new MutableBlockVector();
|
||||
=======
|
||||
private final BlockVector3 size;
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
|
||||
/**
|
||||
* Create a new clipboard pattern.
|
||||
@ -36,6 +46,7 @@ public class ClipboardPattern extends AbstractPattern {
|
||||
}
|
||||
|
||||
@Override
|
||||
<<<<<<< HEAD
|
||||
public BlockStateHolder apply(Vector position) {
|
||||
int xp = position.getBlockX() % sx;
|
||||
int yp = position.getBlockY() % sy;
|
||||
@ -47,6 +58,14 @@ public class ClipboardPattern extends AbstractPattern {
|
||||
mutable.mutY((min.getY() + yp));
|
||||
mutable.mutZ((min.getZ() + zp));
|
||||
return clipboard.getBlock(mutable);
|
||||
=======
|
||||
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(xp, yp, zp));
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
}
|
||||
|
||||
|
||||
|
@ -20,8 +20,6 @@
|
||||
package com.sk89q.worldedit.function.pattern;
|
||||
|
||||
import com.sk89q.minecraft.util.commands.Link;
|
||||
import com.sk89q.worldedit.MutableBlockVector;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
@ -29,6 +27,7 @@ import com.sk89q.worldedit.command.UtilityCommands;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.extent.NullExtent;
|
||||
import com.sk89q.worldedit.internal.expression.runtime.Return;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
|
||||
@ -41,13 +40,13 @@ import com.sk89q.worldedit.world.block.BlockState;
|
||||
public interface Pattern extends com.sk89q.worldedit.patterns.Pattern{
|
||||
|
||||
@Override
|
||||
default BaseBlock next(Vector position) {
|
||||
default BaseBlock next(BlockVector3 position) {
|
||||
return new BaseBlock(apply(position));
|
||||
}
|
||||
|
||||
@Override
|
||||
default BaseBlock next(int x, int y, int z) {
|
||||
return new BaseBlock(apply(new Vector(x, y, z)));
|
||||
return new BaseBlock(apply(new BlockVector3(x, y, z)));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -56,10 +55,9 @@ public interface Pattern extends com.sk89q.worldedit.patterns.Pattern{
|
||||
* @param position the position
|
||||
* @return a block
|
||||
*/
|
||||
@Deprecated
|
||||
BlockStateHolder apply(Vector position);
|
||||
BlockStateHolder apply(BlockVector3 position);
|
||||
|
||||
default boolean apply(Extent extent, Vector get, Vector set) throws WorldEditException {
|
||||
default boolean apply(Extent extent, BlockVector3 get, BlockVector3 set) throws WorldEditException {
|
||||
return extent.setBlock(set, apply(get));
|
||||
}
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
package com.sk89q.worldedit.function.pattern;
|
||||
|
||||
<<<<<<< HEAD
|
||||
import com.boydti.fawe.object.collection.RandomCollection;
|
||||
import com.boydti.fawe.object.random.SimpleRandom;
|
||||
import com.boydti.fawe.object.random.TrueRandom;
|
||||
@ -8,6 +9,11 @@ import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
=======
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
|
||||
import java.util.HashMap;
|
||||
@ -54,8 +60,24 @@ public class RandomPattern extends AbstractPattern {
|
||||
this.patterns.add(pattern);
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
public Set<Pattern> getPatterns() {
|
||||
return patterns;
|
||||
=======
|
||||
@Override
|
||||
public BlockStateHolder apply(BlockVector3 position) {
|
||||
double r = random.nextDouble();
|
||||
double offset = 0;
|
||||
|
||||
for (Chance chance : patterns) {
|
||||
if (r <= (offset + chance.getChance()) / max) {
|
||||
return chance.getPattern().apply(position);
|
||||
}
|
||||
offset += chance.getChance();
|
||||
}
|
||||
|
||||
throw new RuntimeException("ProportionalFillPattern");
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
}
|
||||
|
||||
public RandomCollection<Pattern> getCollection() {
|
||||
|
@ -19,7 +19,14 @@
|
||||
|
||||
package com.sk89q.worldedit.function.pattern;
|
||||
|
||||
<<<<<<< HEAD
|
||||
import com.sk89q.worldedit.Vector;
|
||||
=======
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
@ -32,7 +39,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
||||
public class RepeatingExtentPattern extends AbstractPattern {
|
||||
|
||||
private Extent extent;
|
||||
private Vector offset;
|
||||
private BlockVector3 offset;
|
||||
|
||||
/**
|
||||
* Create a new instance.
|
||||
@ -40,7 +47,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);
|
||||
}
|
||||
@ -69,7 +76,7 @@ public class RepeatingExtentPattern extends AbstractPattern {
|
||||
*
|
||||
* @return the offset
|
||||
*/
|
||||
public Vector getOffset() {
|
||||
public BlockVector3 getOffset() {
|
||||
return offset;
|
||||
}
|
||||
|
||||
@ -78,18 +85,22 @@ 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();
|
||||
<<<<<<< HEAD
|
||||
return extent.getBlock(new Vector(x, y, z));
|
||||
=======
|
||||
return extent.getFullBlock(new BlockVector3(x, y, z));
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
}
|
||||
}
|
||||
|
@ -19,9 +19,15 @@
|
||||
|
||||
package com.sk89q.worldedit.function.util;
|
||||
|
||||
<<<<<<< HEAD
|
||||
import com.sk89q.worldedit.Vector2D;
|
||||
=======
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.function.FlatRegionFunction;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
@ -30,7 +36,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
||||
*/
|
||||
public class FlatRegionOffset implements FlatRegionFunction {
|
||||
|
||||
private Vector2D offset;
|
||||
private BlockVector2 offset;
|
||||
private final FlatRegionFunction function;
|
||||
|
||||
/**
|
||||
@ -39,7 +45,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 +56,7 @@ public class FlatRegionOffset implements FlatRegionFunction {
|
||||
*
|
||||
* @return the offset
|
||||
*/
|
||||
public Vector2D getOffset() {
|
||||
public BlockVector2 getOffset() {
|
||||
return offset;
|
||||
}
|
||||
|
||||
@ -59,13 +65,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));
|
||||
}
|
||||
}
|
||||
|
@ -19,9 +19,15 @@
|
||||
|
||||
package com.sk89q.worldedit.function.util;
|
||||
|
||||
<<<<<<< HEAD
|
||||
import com.sk89q.worldedit.Vector;
|
||||
=======
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.function.RegionFunction;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
@ -30,7 +36,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
||||
*/
|
||||
public class RegionOffset implements RegionFunction {
|
||||
|
||||
private Vector offset;
|
||||
private BlockVector3 offset;
|
||||
private final RegionFunction function;
|
||||
|
||||
/**
|
||||
@ -39,7 +45,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 +56,7 @@ public class RegionOffset implements RegionFunction {
|
||||
*
|
||||
* @return the offset
|
||||
*/
|
||||
public Vector getOffset() {
|
||||
public BlockVector3 getOffset() {
|
||||
return offset;
|
||||
}
|
||||
|
||||
@ -59,13 +65,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));
|
||||
}
|
||||
|
||||
|
@ -7,23 +7,41 @@ import com.boydti.fawe.object.FaweQueue;
|
||||
import com.boydti.fawe.object.HasFaweQueue;
|
||||
import com.boydti.fawe.object.IntegerTrio;
|
||||
import com.boydti.fawe.object.collection.BlockVectorSet;
|
||||
import com.sk89q.worldedit.MutableBlockVector;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
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.math.MutableBlockVector;
|
||||
import com.sk89q.worldedit.math.Vector3;
|
||||
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Queue;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Performs a breadth-first search starting from points added with
|
||||
* {@link #visit(BlockVector3)}. The search continues
|
||||
* to a certain adjacent point provided that the method
|
||||
* {@link #isVisitable(BlockVector3, BlockVector3)}
|
||||
* returns true for that point.
|
||||
*
|
||||
* <p>As an abstract implementation, this class can be used to implement
|
||||
* functionality that starts at certain points and extends outward from
|
||||
* those points.</p>
|
||||
*/
|
||||
public abstract class BreadthFirstSearch implements Operation {
|
||||
|
||||
public static final Vector[] DEFAULT_DIRECTIONS = new Vector[6];
|
||||
public static final Vector[] DIAGONAL_DIRECTIONS;
|
||||
public static final BlockVector3[] DEFAULT_DIRECTIONS = new BlockVector3[6];
|
||||
public static final BlockVector3[] DIAGONAL_DIRECTIONS;
|
||||
|
||||
static {
|
||||
DEFAULT_DIRECTIONS[0] = (new MutableBlockVector(0, -1, 0));
|
||||
@ -45,17 +63,17 @@ public abstract class BreadthFirstSearch implements Operation {
|
||||
}
|
||||
}
|
||||
}
|
||||
Collections.sort(list, new Comparator<Vector>() {
|
||||
Collections.sort(list, new Comparator<BlockVector3>() {
|
||||
@Override
|
||||
public int compare(Vector o1, Vector o2) {
|
||||
public int compare(BlockVector3 o1, BlockVector3 o2) {
|
||||
return (int) Math.signum(o1.lengthSq() - o2.lengthSq());
|
||||
}
|
||||
});
|
||||
DIAGONAL_DIRECTIONS = list.toArray(new Vector[list.size()]);
|
||||
DIAGONAL_DIRECTIONS = list.toArray(new BlockVector3[list.size()]);
|
||||
}
|
||||
|
||||
private final RegionFunction function;
|
||||
private List<Vector> directions = new ArrayList<>();
|
||||
private List<BlockVector3> directions = new ArrayList<>();
|
||||
private BlockVectorSet visited;
|
||||
private final MappedFaweQueue mFaweQueue;
|
||||
private BlockVectorSet queue;
|
||||
@ -82,26 +100,24 @@ public abstract class BreadthFirstSearch implements Operation {
|
||||
this.maxDepth = maxDepth;
|
||||
}
|
||||
|
||||
public abstract boolean isVisitable(Vector from, Vector to);
|
||||
|
||||
public Collection<Vector> getDirections() {
|
||||
public Collection<BlockVector3> getDirections() {
|
||||
return this.directions;
|
||||
}
|
||||
|
||||
public void setDirections(List<Vector> directions) {
|
||||
public void setDirections(List<BlockVector3> directions) {
|
||||
this.directions = directions;
|
||||
}
|
||||
|
||||
private IntegerTrio[] getIntDirections() {
|
||||
IntegerTrio[] array = new IntegerTrio[directions.size()];
|
||||
for (int i = 0; i < array.length; i++) {
|
||||
Vector dir = directions.get(i);
|
||||
BlockVector3 dir = directions.get(i);
|
||||
array[i] = new IntegerTrio(dir.getBlockX(), dir.getBlockY(), dir.getBlockZ());
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
||||
public void visit(final Vector pos) {
|
||||
public void visit(final BlockVector3 pos) {
|
||||
if (!isVisited(pos)) {
|
||||
isVisitable(pos, pos); // Ignore this, just to initialize mask on this point
|
||||
queue.add(pos);
|
||||
@ -123,13 +139,47 @@ public abstract class BreadthFirstSearch implements Operation {
|
||||
return visited;
|
||||
}
|
||||
|
||||
public boolean isVisited(Vector pos) {
|
||||
public boolean isVisited(BlockVector3 pos) {
|
||||
return visited.contains(pos);
|
||||
}
|
||||
|
||||
public void setMaxBranch(int maxBranch) {
|
||||
this.maxBranch = maxBranch;
|
||||
}
|
||||
/**
|
||||
* Try to visit the given 'to' location.
|
||||
*
|
||||
* @param from the origin block
|
||||
* @param to the block under question
|
||||
*/
|
||||
private void visit(BlockVector3 from, BlockVector3 to) {
|
||||
BlockVector3 blockVector = to;
|
||||
if (!visited.contains(blockVector)) {
|
||||
visited.add(blockVector);
|
||||
if (isVisitable(from, to)) {
|
||||
queue.add(blockVector);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return whether the given 'to' block should be visited, starting from the
|
||||
* 'from' block.
|
||||
*
|
||||
* @param from the origin block
|
||||
* @param to the block under question
|
||||
* @return true if the 'to' block should be visited
|
||||
*/
|
||||
protected abstract boolean isVisitable(BlockVector3 from, BlockVector3 to);
|
||||
|
||||
/**
|
||||
* Get the number of affected objects.
|
||||
*
|
||||
* @return the number of affected
|
||||
*/
|
||||
public int getAffected() {
|
||||
return affected;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Operation resume(RunContext run) throws WorldEditException {
|
||||
@ -143,7 +193,7 @@ public abstract class BreadthFirstSearch implements Operation {
|
||||
if (mFaweQueue != null && Settings.IMP.QUEUE.PRELOAD_CHUNKS > 1) {
|
||||
int cx = Integer.MIN_VALUE;
|
||||
int cz = Integer.MIN_VALUE;
|
||||
for (Vector from : queue) {
|
||||
for (BlockVector3 from : queue) {
|
||||
for (IntegerTrio direction : dirs) {
|
||||
int x = from.getBlockX() + direction.x;
|
||||
int z = from.getBlockZ() + direction.z;
|
||||
@ -158,11 +208,11 @@ public abstract class BreadthFirstSearch implements Operation {
|
||||
}
|
||||
}
|
||||
}
|
||||
for (Vector chunk : chunkLoadSet) {
|
||||
for (BlockVector3 chunk : chunkLoadSet) {
|
||||
mFaweQueue.queueChunkLoad(chunk.getBlockX(), chunk.getBlockZ());
|
||||
}
|
||||
}
|
||||
for (Vector from : queue) {
|
||||
for (BlockVector3 from : queue) {
|
||||
if (function.apply(from)) affected++;
|
||||
for (int i = 0, j = 0; i < dirs.length && j < maxBranch; i++) {
|
||||
IntegerTrio direction = dirs[i];
|
||||
@ -183,6 +233,17 @@ public abstract class BreadthFirstSearch implements Operation {
|
||||
}
|
||||
}
|
||||
}
|
||||
//=======
|
||||
// BlockVector3 position;
|
||||
//
|
||||
// while ((position = queue.poll()) != null) {
|
||||
// if (function.apply(position)) {
|
||||
// affected++;
|
||||
// }
|
||||
//
|
||||
// for (BlockVector3 dir : directions) {
|
||||
// visit(position, position.add(dir));
|
||||
//>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
}
|
||||
if (currentDepth == maxDepth) {
|
||||
break;
|
||||
@ -207,10 +268,6 @@ public abstract class BreadthFirstSearch implements Operation {
|
||||
messages.add(BBC.VISITOR_BLOCK.format(getAffected()));
|
||||
}
|
||||
|
||||
public int getAffected() {
|
||||
return this.affected;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cancel() {
|
||||
}
|
||||
|
@ -20,10 +20,11 @@
|
||||
package com.sk89q.worldedit.function.visitor;
|
||||
|
||||
import com.boydti.fawe.object.HasFaweQueue;
|
||||
import com.sk89q.worldedit.MutableBlockVector;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.math.MutableBlockVector;
|
||||
import com.sk89q.worldedit.function.RegionFunction;
|
||||
import com.sk89q.worldedit.function.mask.Mask;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
|
||||
@ -38,30 +39,30 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
||||
*/
|
||||
public class DirectionalVisitor extends RecursiveVisitor {
|
||||
|
||||
private final Vector origin;
|
||||
private final Vector dirVec;
|
||||
private final BlockVector3 origin;
|
||||
private final BlockVector3 dirVec;
|
||||
|
||||
public DirectionalVisitor(Mask mask, RegionFunction function, Vector origin, Vector direction) {
|
||||
public DirectionalVisitor(Mask mask, RegionFunction function, BlockVector3 origin, BlockVector3 direction) {
|
||||
this(mask, function, origin, direction, Integer.MAX_VALUE, null);
|
||||
}
|
||||
|
||||
public DirectionalVisitor(Mask mask, RegionFunction function, Vector origin, Vector direction, int distance, HasFaweQueue hasFaweQueue) {
|
||||
public DirectionalVisitor(Mask mask, RegionFunction function, BlockVector3 origin, BlockVector3 direction, int distance, HasFaweQueue hasFaweQueue) {
|
||||
super(mask, function, distance, hasFaweQueue);
|
||||
checkNotNull(mask);
|
||||
this.origin = origin;
|
||||
this.dirVec = new MutableBlockVector(direction);
|
||||
final Collection<Vector> directions = this.getDirections();
|
||||
final Collection<BlockVector3> directions = this.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 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));
|
||||
directions.add(new BlockVector3(0, 1, 0));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVisitable(final Vector from, final Vector to) {
|
||||
public boolean isVisitable(final BlockVector3 from, final BlockVector3 to) {
|
||||
int dx = to.getBlockX() - from.getBlockX();
|
||||
int dz = to.getBlockZ() - from.getBlockZ();
|
||||
int dy = to.getBlockY() - from.getBlockY();
|
||||
|
@ -19,10 +19,19 @@
|
||||
|
||||
package com.sk89q.worldedit.function.visitor;
|
||||
|
||||
<<<<<<< HEAD
|
||||
import com.boydti.fawe.object.HasFaweQueue;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.function.RegionFunction;
|
||||
import com.sk89q.worldedit.function.mask.Mask;
|
||||
=======
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.sk89q.worldedit.function.RegionFunction;
|
||||
import com.sk89q.worldedit.function.mask.Mask;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
import java.util.Collection;
|
||||
|
||||
|
||||
@ -54,19 +63,30 @@ public class DownwardVisitor extends RecursiveVisitor {
|
||||
super(mask, function, depth, hasFaweQueue);
|
||||
checkNotNull(mask);
|
||||
this.baseY = baseY;
|
||||
<<<<<<< HEAD
|
||||
final Collection<Vector> directions = this.getDirections();
|
||||
=======
|
||||
|
||||
Collection<BlockVector3> directions = getDirections();
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
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
|
||||
<<<<<<< HEAD
|
||||
public boolean isVisitable(final Vector from, final Vector to) {
|
||||
final int fromY = from.getBlockY();
|
||||
return ((fromY == this.baseY) || (to.getBlockY() - from.getBlockY() < 0)) && super.isVisitable(from, to);
|
||||
=======
|
||||
protected boolean isVisitable(BlockVector3 from, BlockVector3 to) {
|
||||
int fromY = from.getBlockY();
|
||||
return (fromY == baseY || to.subtract(from).getBlockY() < 0) && super.isVisitable(from, to);
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
}
|
||||
|
||||
|
||||
|
@ -19,17 +19,23 @@
|
||||
|
||||
package com.sk89q.worldedit.function.visitor;
|
||||
|
||||
<<<<<<< HEAD
|
||||
import com.boydti.fawe.config.BBC;
|
||||
import com.boydti.fawe.example.MappedFaweQueue;
|
||||
import com.boydti.fawe.object.FaweQueue;
|
||||
import com.boydti.fawe.object.HasFaweQueue;
|
||||
import com.boydti.fawe.object.visitor.Fast2DIterator;
|
||||
import com.sk89q.worldedit.Vector2D;
|
||||
=======
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.function.FlatRegionFunction;
|
||||
import com.sk89q.worldedit.function.operation.Operation;
|
||||
import com.sk89q.worldedit.function.operation.Operations;
|
||||
import com.sk89q.worldedit.function.operation.RunContext;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.regions.FlatRegion;
|
||||
import java.util.List;
|
||||
|
||||
@ -78,6 +84,7 @@ public class FlatRegionVisitor implements Operation {
|
||||
}
|
||||
|
||||
@Override
|
||||
<<<<<<< HEAD
|
||||
public Operation resume(final RunContext run) throws WorldEditException {
|
||||
if (this.queue != null) {
|
||||
for (final Vector2D pt : new Fast2DIterator(this.iterator, queue)) {
|
||||
@ -86,6 +93,12 @@ public class FlatRegionVisitor implements Operation {
|
||||
} else {
|
||||
for (final Vector2D pt : this.iterator) {
|
||||
if (this.function.apply(pt)) affected++;
|
||||
=======
|
||||
public Operation resume(RunContext run) throws WorldEditException {
|
||||
for (BlockVector2 pt : flatRegion.asFlatRegion()) {
|
||||
if (function.apply(pt)) {
|
||||
affected++;
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
@ -19,8 +19,14 @@
|
||||
|
||||
package com.sk89q.worldedit.function.visitor;
|
||||
|
||||
<<<<<<< HEAD
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.Vector2D;
|
||||
=======
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.function.LayerFunction;
|
||||
import com.sk89q.worldedit.function.mask.Mask2D;
|
||||
@ -28,6 +34,8 @@ import com.sk89q.worldedit.function.mask.Masks;
|
||||
import com.sk89q.worldedit.function.operation.Operation;
|
||||
import com.sk89q.worldedit.function.operation.Operations;
|
||||
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,21 +100,36 @@ public class LayerVisitor implements Operation {
|
||||
}
|
||||
|
||||
@Override
|
||||
<<<<<<< HEAD
|
||||
public Operation resume(final RunContext run) throws WorldEditException {
|
||||
for (final Vector2D column : this.iterator) {
|
||||
if (!this.mask.test(column)) {
|
||||
=======
|
||||
public Operation resume(RunContext run) throws WorldEditException {
|
||||
for (BlockVector2 column : flatRegion.asFlatRegion()) {
|
||||
if (!mask.test(column)) {
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
continue;
|
||||
}
|
||||
|
||||
// Abort if we are underground
|
||||
<<<<<<< HEAD
|
||||
if (this.function.isGround(column.toVector(this.maxY + 1))) {
|
||||
=======
|
||||
if (function.isGround(column.toBlockVector3(maxY + 1))) {
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
return null;
|
||||
}
|
||||
|
||||
boolean found = false;
|
||||
int groundY = 0;
|
||||
<<<<<<< HEAD
|
||||
for (int y = this.maxY; y >= this.minY; --y) {
|
||||
final Vector test = column.toVector(y);
|
||||
=======
|
||||
for (int y = maxY; y >= minY; --y) {
|
||||
BlockVector3 test = column.toBlockVector3(y);
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
if (!found) {
|
||||
if (this.function.isGround(test)) {
|
||||
found = true;
|
||||
|
@ -19,10 +19,17 @@
|
||||
|
||||
package com.sk89q.worldedit.function.visitor;
|
||||
|
||||
<<<<<<< HEAD
|
||||
import com.boydti.fawe.object.HasFaweQueue;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.function.RegionFunction;
|
||||
import com.sk89q.worldedit.function.mask.Mask;
|
||||
=======
|
||||
import com.sk89q.worldedit.function.RegionFunction;
|
||||
import com.sk89q.worldedit.function.mask.Mask;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
@ -38,18 +45,23 @@ public class NonRisingVisitor extends RecursiveVisitor {
|
||||
*/
|
||||
|
||||
public NonRisingVisitor(Mask mask, RegionFunction function) {
|
||||
<<<<<<< HEAD
|
||||
this(mask, function, Integer.MAX_VALUE, null);
|
||||
}
|
||||
|
||||
public NonRisingVisitor(Mask mask, RegionFunction function, int depth, HasFaweQueue hasFaweQueue) {
|
||||
super(mask, function, depth, hasFaweQueue);
|
||||
final Collection<Vector> directions = this.getDirections();
|
||||
=======
|
||||
super(mask, function);
|
||||
Collection<BlockVector3> directions = getDirections();
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
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));
|
||||
}
|
||||
|
||||
|
||||
|
@ -19,10 +19,16 @@
|
||||
|
||||
package com.sk89q.worldedit.function.visitor;
|
||||
|
||||
<<<<<<< HEAD
|
||||
import com.boydti.fawe.object.HasFaweQueue;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
=======
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
import com.sk89q.worldedit.function.RegionFunction;
|
||||
import com.sk89q.worldedit.function.mask.Mask;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
@ -56,8 +62,13 @@ public class RecursiveVisitor extends BreadthFirstSearch {
|
||||
}
|
||||
|
||||
@Override
|
||||
<<<<<<< HEAD
|
||||
public boolean isVisitable(final Vector from, final Vector to) {
|
||||
return this.mask.test(to);
|
||||
=======
|
||||
protected boolean isVisitable(BlockVector3 from, BlockVector3 to) {
|
||||
return mask.test(to);
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
}
|
||||
|
||||
|
||||
|
@ -25,14 +25,13 @@ import com.boydti.fawe.example.MappedFaweQueue;
|
||||
import com.boydti.fawe.object.FaweQueue;
|
||||
import com.boydti.fawe.object.HasFaweQueue;
|
||||
import com.boydti.fawe.object.exception.FaweException;
|
||||
import com.sk89q.worldedit.BlockVector;
|
||||
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.operation.Operation;
|
||||
import com.sk89q.worldedit.function.operation.Operations;
|
||||
import com.sk89q.worldedit.function.operation.RunContext;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
@ -43,7 +42,7 @@ import java.util.List;
|
||||
public class RegionVisitor implements Operation {
|
||||
|
||||
public final Region region;
|
||||
public final Iterable<? extends Vector> iterable;
|
||||
public final Iterable<? extends BlockVector3> iterable;
|
||||
public final RegionFunction function;
|
||||
private final MappedFaweQueue queue;
|
||||
private boolean useCuboidIterator = false;
|
||||
@ -65,10 +64,10 @@ public class RegionVisitor implements Operation {
|
||||
}
|
||||
|
||||
public RegionVisitor(Region region, RegionFunction function, FaweQueue queue) {
|
||||
this((Iterable<BlockVector>) region, function, queue);
|
||||
this((Iterable<BlockVector3>) region, function, queue);
|
||||
}
|
||||
|
||||
public RegionVisitor(Iterable<? extends Vector> iterable, RegionFunction function, HasFaweQueue hasQueue) {
|
||||
public RegionVisitor(Iterable<? extends BlockVector3> iterable, RegionFunction function, HasFaweQueue hasQueue) {
|
||||
region = (iterable instanceof Region) ? (Region) iterable : null;
|
||||
this.iterable = iterable;
|
||||
this.function = function;
|
||||
@ -94,8 +93,8 @@ public class RegionVisitor implements Operation {
|
||||
* - Stop iteration on exception instead of hasNext
|
||||
* - Do not calculate the stacktrace as it is expensive
|
||||
*/
|
||||
Iterator<? extends Vector> trailIter = iterable.iterator();
|
||||
Iterator<? extends Vector> leadIter = iterable.iterator();
|
||||
Iterator<? extends BlockVector3> trailIter = iterable.iterator();
|
||||
Iterator<? extends BlockVector3> leadIter = iterable.iterator();
|
||||
int lastTrailChunkX = Integer.MIN_VALUE;
|
||||
int lastTrailChunkZ = Integer.MIN_VALUE;
|
||||
int lastLeadChunkX = Integer.MIN_VALUE;
|
||||
@ -103,7 +102,7 @@ public class RegionVisitor implements Operation {
|
||||
int loadingTarget = Settings.IMP.QUEUE.PRELOAD_CHUNKS;
|
||||
try {
|
||||
for (; ; ) {
|
||||
Vector pt = trailIter.next();
|
||||
BlockVector3 pt = trailIter.next();
|
||||
apply(pt);
|
||||
int cx = pt.getBlockX() >> 4;
|
||||
int cz = pt.getBlockZ() >> 4;
|
||||
@ -119,7 +118,7 @@ public class RegionVisitor implements Operation {
|
||||
amount = 1;
|
||||
}
|
||||
for (int count = 0; count < amount; ) {
|
||||
Vector v = leadIter.next();
|
||||
BlockVector3 v = leadIter.next();
|
||||
int vcx = v.getBlockX() >> 4;
|
||||
int vcz = v.getBlockZ() >> 4;
|
||||
if (vcx != lastLeadChunkX || vcz != lastLeadChunkZ) {
|
||||
@ -176,14 +175,14 @@ public class RegionVisitor implements Operation {
|
||||
} catch (Throwable ignore) {
|
||||
}
|
||||
} else {
|
||||
for (Vector pt : iterable) {
|
||||
for (BlockVector3 pt : iterable) {
|
||||
apply(pt);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private void apply(Vector pt) throws WorldEditException {
|
||||
private void apply(BlockVector3 pt) throws WorldEditException {
|
||||
if (function.apply(pt)) {
|
||||
affected++;
|
||||
}
|
||||
|
Reference in New Issue
Block a user