mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-07-12 04:38:35 +00:00
Refactor vector system to be cleaner
- Move Vector, etc. into `.math` package - Drop many methods that will be auto-promoted anyways, eg. with `divide(int)` and `divide(double)` the first is now gone. - Take Block vectors into their own class hierarchy - Make it clear throughout the API what takes blockvectors - many more improvements
This commit is contained in:
@ -21,17 +21,17 @@ package com.sk89q.worldedit.extent;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.Vector2D;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.entity.BaseEntity;
|
||||
import com.sk89q.worldedit.entity.Entity;
|
||||
import com.sk89q.worldedit.function.operation.Operation;
|
||||
import com.sk89q.worldedit.function.operation.OperationQueue;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
import com.sk89q.worldedit.world.biome.BaseBiome;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
|
||||
@ -66,17 +66,17 @@ public abstract class AbstractDelegateExtent implements Extent {
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getBlock(Vector position) {
|
||||
public BlockState getBlock(BlockVector3 position) {
|
||||
return extent.getBlock(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseBlock getFullBlock(Vector position) {
|
||||
public BaseBlock getFullBlock(BlockVector3 position) {
|
||||
return extent.getFullBlock(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBlock(Vector location, BlockStateHolder block) throws WorldEditException {
|
||||
public boolean setBlock(BlockVector3 location, BlockStateHolder block) throws WorldEditException {
|
||||
return extent.setBlock(location, block);
|
||||
}
|
||||
|
||||
@ -97,22 +97,22 @@ public abstract class AbstractDelegateExtent implements Extent {
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseBiome getBiome(Vector2D position) {
|
||||
public BaseBiome getBiome(BlockVector2 position) {
|
||||
return extent.getBiome(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBiome(Vector2D position, BaseBiome biome) {
|
||||
public boolean setBiome(BlockVector2 position, BaseBiome biome) {
|
||||
return extent.setBiome(position, biome);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector getMinimumPoint() {
|
||||
public BlockVector3 getMinimumPoint() {
|
||||
return extent.getMinimumPoint();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector getMaximumPoint() {
|
||||
public BlockVector3 getMaximumPoint() {
|
||||
return extent.getMaximumPoint();
|
||||
}
|
||||
|
||||
|
@ -21,17 +21,17 @@ package com.sk89q.worldedit.extent;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.entity.BaseEntity;
|
||||
import com.sk89q.worldedit.entity.Entity;
|
||||
import com.sk89q.worldedit.history.change.BlockChange;
|
||||
import com.sk89q.worldedit.history.change.EntityCreate;
|
||||
import com.sk89q.worldedit.history.change.EntityRemove;
|
||||
import com.sk89q.worldedit.history.changeset.ChangeSet;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@ -59,9 +59,9 @@ public class ChangeSetExtent extends AbstractDelegateExtent {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBlock(Vector location, BlockStateHolder block) throws WorldEditException {
|
||||
public boolean setBlock(BlockVector3 location, BlockStateHolder block) throws WorldEditException {
|
||||
BaseBlock previous = getFullBlock(location);
|
||||
changeSet.add(new BlockChange(location.toBlockVector(), previous, block));
|
||||
changeSet.add(new BlockChange(location, previous, block));
|
||||
return super.setBlock(location, block);
|
||||
}
|
||||
|
||||
|
@ -19,9 +19,9 @@
|
||||
|
||||
package com.sk89q.worldedit.extent;
|
||||
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.entity.BaseEntity;
|
||||
import com.sk89q.worldedit.entity.Entity;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
|
||||
@ -46,7 +46,7 @@ public interface Extent extends InputExtent, OutputExtent {
|
||||
*
|
||||
* @return the minimum point
|
||||
*/
|
||||
Vector getMinimumPoint();
|
||||
BlockVector3 getMinimumPoint();
|
||||
|
||||
/**
|
||||
* Get the maximum point in the extent.
|
||||
@ -56,7 +56,7 @@ public interface Extent extends InputExtent, OutputExtent {
|
||||
*
|
||||
* @return the maximum point
|
||||
*/
|
||||
Vector getMaximumPoint();
|
||||
BlockVector3 getMaximumPoint();
|
||||
|
||||
/**
|
||||
* Get a list of all entities within the given region.
|
||||
|
@ -19,11 +19,11 @@
|
||||
|
||||
package com.sk89q.worldedit.extent;
|
||||
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.Vector2D;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.world.biome.BaseBiome;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
|
||||
/**
|
||||
@ -45,7 +45,7 @@ public interface InputExtent {
|
||||
* @param position position of the block
|
||||
* @return the block
|
||||
*/
|
||||
BlockState getBlock(Vector position);
|
||||
BlockState getBlock(BlockVector3 position);
|
||||
|
||||
/**
|
||||
* Get a immutable snapshot of the block at the given location.
|
||||
@ -53,7 +53,7 @@ public interface InputExtent {
|
||||
* @param position position of the block
|
||||
* @return the block
|
||||
*/
|
||||
BaseBlock getFullBlock(Vector position);
|
||||
BaseBlock getFullBlock(BlockVector3 position);
|
||||
|
||||
/**
|
||||
* Get the biome at the given location.
|
||||
@ -64,6 +64,6 @@ public interface InputExtent {
|
||||
* @param position the (x, z) location to check the biome at
|
||||
* @return the biome at the location
|
||||
*/
|
||||
BaseBiome getBiome(Vector2D position);
|
||||
BaseBiome getBiome(BlockVector2 position);
|
||||
|
||||
}
|
||||
|
@ -21,9 +21,9 @@ package com.sk89q.worldedit.extent;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.function.mask.Mask;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
|
||||
/**
|
||||
@ -65,7 +65,7 @@ public class MaskingExtent extends AbstractDelegateExtent {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBlock(Vector location, BlockStateHolder block) throws WorldEditException {
|
||||
public boolean setBlock(BlockVector3 location, BlockStateHolder block) throws WorldEditException {
|
||||
return mask.test(location) && super.setBlock(location, block);
|
||||
}
|
||||
|
||||
|
@ -19,16 +19,16 @@
|
||||
|
||||
package com.sk89q.worldedit.extent;
|
||||
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.Vector2D;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.entity.BaseEntity;
|
||||
import com.sk89q.worldedit.entity.Entity;
|
||||
import com.sk89q.worldedit.function.operation.Operation;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
import com.sk89q.worldedit.world.biome.BaseBiome;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
@ -44,16 +44,14 @@ import javax.annotation.Nullable;
|
||||
*/
|
||||
public class NullExtent implements Extent {
|
||||
|
||||
private final Vector nullPoint = new Vector(0, 0, 0);
|
||||
|
||||
@Override
|
||||
public Vector getMinimumPoint() {
|
||||
return nullPoint;
|
||||
public BlockVector3 getMinimumPoint() {
|
||||
return BlockVector3.ZERO;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector getMaximumPoint() {
|
||||
return nullPoint;
|
||||
public BlockVector3 getMaximumPoint() {
|
||||
return BlockVector3.ZERO;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -73,28 +71,28 @@ public class NullExtent implements Extent {
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getBlock(Vector position) {
|
||||
public BlockState getBlock(BlockVector3 position) {
|
||||
return BlockTypes.AIR.getDefaultState();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseBlock getFullBlock(Vector position) {
|
||||
public BaseBlock getFullBlock(BlockVector3 position) {
|
||||
return getBlock(position).toBaseBlock();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public BaseBiome getBiome(Vector2D position) {
|
||||
public BaseBiome getBiome(BlockVector2 position) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBlock(Vector position, BlockStateHolder block) throws WorldEditException {
|
||||
public boolean setBlock(BlockVector3 position, BlockStateHolder block) throws WorldEditException {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBiome(Vector2D position, BaseBiome biome) {
|
||||
public boolean setBiome(BlockVector2 position, BaseBiome biome) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -19,10 +19,10 @@
|
||||
|
||||
package com.sk89q.worldedit.extent;
|
||||
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.Vector2D;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.function.operation.Operation;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.world.biome.BaseBiome;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
|
||||
@ -50,7 +50,7 @@ public interface OutputExtent {
|
||||
* @return true if the block was successfully set (return value may not be accurate)
|
||||
* @throws WorldEditException thrown on an error
|
||||
*/
|
||||
boolean setBlock(Vector position, BlockStateHolder block) throws WorldEditException;
|
||||
boolean setBlock(BlockVector3 position, BlockStateHolder block) throws WorldEditException;
|
||||
|
||||
/**
|
||||
* Set the biome.
|
||||
@ -59,7 +59,7 @@ public interface OutputExtent {
|
||||
* @param biome the biome to set to
|
||||
* @return true if the biome was successfully set (return value may not be accurate)
|
||||
*/
|
||||
boolean setBiome(Vector2D position, BaseBiome biome);
|
||||
boolean setBiome(BlockVector2 position, BaseBiome biome);
|
||||
|
||||
/**
|
||||
* Return an {@link Operation} that should be called to tie up loose ends
|
||||
|
@ -21,14 +21,14 @@ package com.sk89q.worldedit.extent.buffer;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.sk89q.worldedit.BlockVector;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.extent.AbstractDelegateExtent;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.function.mask.Mask;
|
||||
import com.sk89q.worldedit.function.mask.Masks;
|
||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.math.Vector3;
|
||||
import com.sk89q.worldedit.regions.AbstractRegion;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.regions.RegionOperationException;
|
||||
@ -44,19 +44,19 @@ import java.util.Map;
|
||||
* actual application of the changes.
|
||||
*
|
||||
* <p>This buffer will not attempt to return results from the buffer when
|
||||
* accessor methods (such as {@link #getBlock(Vector)}) are called.</p>
|
||||
* accessor methods (such as {@link #getBlock(BlockVector3)}) are called.</p>
|
||||
*/
|
||||
public class ForgetfulExtentBuffer extends AbstractDelegateExtent implements Pattern {
|
||||
|
||||
private final Map<BlockVector, BlockStateHolder> buffer = new LinkedHashMap<>();
|
||||
private final Map<BlockVector3, BlockStateHolder> buffer = new LinkedHashMap<>();
|
||||
private final Mask mask;
|
||||
private Vector min = null;
|
||||
private Vector max = null;
|
||||
private BlockVector3 min = null;
|
||||
private BlockVector3 max = null;
|
||||
|
||||
/**
|
||||
* Create a new extent buffer that will buffer every change.
|
||||
*
|
||||
* @param delegate the delegate extent for {@link Extent#getBlock(Vector)}, etc. calls
|
||||
* @param delegate the delegate extent for {@link Extent#getBlock(BlockVector3)}, etc. calls
|
||||
*/
|
||||
public ForgetfulExtentBuffer(Extent delegate) {
|
||||
this(delegate, Masks.alwaysTrue());
|
||||
@ -66,7 +66,7 @@ public class ForgetfulExtentBuffer extends AbstractDelegateExtent implements Pat
|
||||
* Create a new extent buffer that will buffer changes that meet the criteria
|
||||
* of the given mask.
|
||||
*
|
||||
* @param delegate the delegate extent for {@link Extent#getBlock(Vector)}, etc. calls
|
||||
* @param delegate the delegate extent for {@link Extent#getBlock(BlockVector3)}, etc. calls
|
||||
* @param mask the mask
|
||||
*/
|
||||
public ForgetfulExtentBuffer(Extent delegate, Mask mask) {
|
||||
@ -77,22 +77,22 @@ public class ForgetfulExtentBuffer extends AbstractDelegateExtent implements Pat
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBlock(Vector location, BlockStateHolder block) throws WorldEditException {
|
||||
public boolean setBlock(BlockVector3 location, BlockStateHolder block) throws WorldEditException {
|
||||
// Update minimum
|
||||
if (min == null) {
|
||||
min = location;
|
||||
} else {
|
||||
min = Vector.getMinimum(min, location);
|
||||
min = min.getMinimum(location);
|
||||
}
|
||||
|
||||
// Update maximum
|
||||
if (max == null) {
|
||||
max = location;
|
||||
} else {
|
||||
max = Vector.getMaximum(max, location);
|
||||
max = max.getMaximum(location);
|
||||
}
|
||||
|
||||
BlockVector blockVector = location.toBlockVector();
|
||||
BlockVector3 blockVector = location;
|
||||
if (mask.test(blockVector)) {
|
||||
buffer.put(blockVector, block);
|
||||
return true;
|
||||
@ -102,8 +102,8 @@ public class ForgetfulExtentBuffer extends AbstractDelegateExtent implements Pat
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockStateHolder apply(Vector pos) {
|
||||
BlockStateHolder block = buffer.get(pos.toBlockVector());
|
||||
public BlockStateHolder apply(BlockVector3 pos) {
|
||||
BlockStateHolder block = buffer.get(pos);
|
||||
if (block != null) {
|
||||
return block;
|
||||
} else {
|
||||
@ -119,32 +119,32 @@ public class ForgetfulExtentBuffer extends AbstractDelegateExtent implements Pat
|
||||
public Region asRegion() {
|
||||
return new AbstractRegion(null) {
|
||||
@Override
|
||||
public Vector getMinimumPoint() {
|
||||
return min != null ? min : new Vector();
|
||||
public BlockVector3 getMinimumPoint() {
|
||||
return min != null ? min : BlockVector3.ZERO;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector getMaximumPoint() {
|
||||
return max != null ? max : new Vector();
|
||||
public BlockVector3 getMaximumPoint() {
|
||||
return max != null ? max : BlockVector3.ZERO;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void expand(Vector... changes) throws RegionOperationException {
|
||||
public void expand(BlockVector3... changes) throws RegionOperationException {
|
||||
throw new UnsupportedOperationException("Cannot change the size of this region");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void contract(Vector... changes) throws RegionOperationException {
|
||||
public void contract(BlockVector3... changes) throws RegionOperationException {
|
||||
throw new UnsupportedOperationException("Cannot change the size of this region");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contains(Vector position) {
|
||||
return buffer.containsKey(position.toBlockVector());
|
||||
public boolean contains(BlockVector3 position) {
|
||||
return buffer.containsKey(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<BlockVector> iterator() {
|
||||
public Iterator<BlockVector3> iterator() {
|
||||
return buffer.keySet().iterator();
|
||||
}
|
||||
};
|
||||
|
@ -19,15 +19,15 @@
|
||||
|
||||
package com.sk89q.worldedit.extent.cache;
|
||||
|
||||
import com.sk89q.worldedit.BlockVector;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.extent.AbstractDelegateExtent;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.math.Vector3;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
|
||||
/**
|
||||
* Returns the same cached {@link BlockState} for repeated calls to
|
||||
* {@link #getBlock(Vector)} with the same position.
|
||||
* {@link #getBlock(BlockVector3)} with the same position.
|
||||
*/
|
||||
public class LastAccessExtentCache extends AbstractDelegateExtent {
|
||||
|
||||
@ -43,23 +43,22 @@ public class LastAccessExtentCache extends AbstractDelegateExtent {
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getBlock(Vector position) {
|
||||
BlockVector blockVector = position.toBlockVector();
|
||||
public BlockState getBlock(BlockVector3 position) {
|
||||
CachedBlock lastBlock = this.lastBlock;
|
||||
if (lastBlock != null && lastBlock.position.equals(blockVector)) {
|
||||
if (lastBlock != null && lastBlock.position.equals(position)) {
|
||||
return lastBlock.block;
|
||||
} else {
|
||||
BlockState block = super.getBlock(position);
|
||||
this.lastBlock = new CachedBlock(blockVector, block);
|
||||
this.lastBlock = new CachedBlock(position, block);
|
||||
return block;
|
||||
}
|
||||
}
|
||||
|
||||
private static class CachedBlock {
|
||||
private final BlockVector position;
|
||||
private final BlockVector3 position;
|
||||
private final BlockState block;
|
||||
|
||||
private CachedBlock(BlockVector position, BlockState block) {
|
||||
private CachedBlock(BlockVector3 position, BlockState block) {
|
||||
this.position = position;
|
||||
this.block = block;
|
||||
}
|
||||
|
@ -21,16 +21,16 @@ package com.sk89q.worldedit.extent.clipboard;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.Vector2D;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.entity.BaseEntity;
|
||||
import com.sk89q.worldedit.entity.Entity;
|
||||
import com.sk89q.worldedit.function.operation.Operation;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
import com.sk89q.worldedit.world.biome.BaseBiome;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
@ -48,7 +48,7 @@ import javax.annotation.Nullable;
|
||||
public class BlockArrayClipboard implements Clipboard {
|
||||
|
||||
private final Region region;
|
||||
private Vector origin;
|
||||
private BlockVector3 origin;
|
||||
private final BlockStateHolder[][][] blocks;
|
||||
private final List<ClipboardEntity> entities = new ArrayList<>();
|
||||
|
||||
@ -64,7 +64,7 @@ public class BlockArrayClipboard implements Clipboard {
|
||||
this.region = region.clone();
|
||||
this.origin = region.getMinimumPoint();
|
||||
|
||||
Vector dimensions = getDimensions();
|
||||
BlockVector3 dimensions = getDimensions();
|
||||
blocks = new BlockStateHolder[dimensions.getBlockX()][dimensions.getBlockY()][dimensions.getBlockZ()];
|
||||
}
|
||||
|
||||
@ -74,27 +74,27 @@ public class BlockArrayClipboard implements Clipboard {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector getOrigin() {
|
||||
public BlockVector3 getOrigin() {
|
||||
return origin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOrigin(Vector origin) {
|
||||
public void setOrigin(BlockVector3 origin) {
|
||||
this.origin = origin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector getDimensions() {
|
||||
public BlockVector3 getDimensions() {
|
||||
return region.getMaximumPoint().subtract(region.getMinimumPoint()).add(1, 1, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector getMinimumPoint() {
|
||||
public BlockVector3 getMinimumPoint() {
|
||||
return region.getMinimumPoint();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector getMaximumPoint() {
|
||||
public BlockVector3 getMaximumPoint() {
|
||||
return region.getMaximumPoint();
|
||||
}
|
||||
|
||||
@ -102,7 +102,7 @@ public class BlockArrayClipboard implements Clipboard {
|
||||
public List<? extends Entity> getEntities(Region region) {
|
||||
List<Entity> filtered = new ArrayList<>();
|
||||
for (Entity entity : entities) {
|
||||
if (region.contains(entity.getLocation().toVector())) {
|
||||
if (region.contains(entity.getLocation().toVector().toBlockPoint())) {
|
||||
filtered.add(entity);
|
||||
}
|
||||
}
|
||||
@ -123,9 +123,9 @@ public class BlockArrayClipboard implements Clipboard {
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getBlock(Vector position) {
|
||||
public BlockState getBlock(BlockVector3 position) {
|
||||
if (region.contains(position)) {
|
||||
Vector v = position.subtract(region.getMinimumPoint());
|
||||
BlockVector3 v = position.subtract(region.getMinimumPoint());
|
||||
BlockStateHolder block = blocks[v.getBlockX()][v.getBlockY()][v.getBlockZ()];
|
||||
if (block != null) {
|
||||
return block.toImmutableState();
|
||||
@ -136,9 +136,9 @@ public class BlockArrayClipboard implements Clipboard {
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseBlock getFullBlock(Vector position) {
|
||||
public BaseBlock getFullBlock(BlockVector3 position) {
|
||||
if (region.contains(position)) {
|
||||
Vector v = position.subtract(region.getMinimumPoint());
|
||||
BlockVector3 v = position.subtract(region.getMinimumPoint());
|
||||
BlockStateHolder block = blocks[v.getBlockX()][v.getBlockY()][v.getBlockZ()];
|
||||
if (block != null) {
|
||||
return block.toBaseBlock();
|
||||
@ -149,9 +149,9 @@ public class BlockArrayClipboard implements Clipboard {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBlock(Vector position, BlockStateHolder block) throws WorldEditException {
|
||||
public boolean setBlock(BlockVector3 position, BlockStateHolder block) throws WorldEditException {
|
||||
if (region.contains(position)) {
|
||||
Vector v = position.subtract(region.getMinimumPoint());
|
||||
BlockVector3 v = position.subtract(region.getMinimumPoint());
|
||||
blocks[v.getBlockX()][v.getBlockY()][v.getBlockZ()] = block;
|
||||
return true;
|
||||
} else {
|
||||
@ -160,12 +160,12 @@ public class BlockArrayClipboard implements Clipboard {
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseBiome getBiome(Vector2D position) {
|
||||
public BaseBiome getBiome(BlockVector2 position) {
|
||||
return new BaseBiome(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBiome(Vector2D position, BaseBiome biome) {
|
||||
public boolean setBiome(BlockVector2 position, BaseBiome biome) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -19,8 +19,8 @@
|
||||
|
||||
package com.sk89q.worldedit.extent.clipboard;
|
||||
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
|
||||
/**
|
||||
@ -42,20 +42,20 @@ public interface Clipboard extends Extent {
|
||||
*
|
||||
* @return the dimensions
|
||||
*/
|
||||
Vector getDimensions();
|
||||
BlockVector3 getDimensions();
|
||||
|
||||
/**
|
||||
* Get the origin point from which the copy was made from.
|
||||
*
|
||||
* @return the origin
|
||||
*/
|
||||
Vector getOrigin();
|
||||
BlockVector3 getOrigin();
|
||||
|
||||
/**
|
||||
* Set the origin point from which the copy was made from.
|
||||
*
|
||||
* @param origin the origin
|
||||
*/
|
||||
void setOrigin(Vector origin);
|
||||
void setOrigin(BlockVector3 origin);
|
||||
|
||||
}
|
||||
|
@ -30,14 +30,13 @@ import com.sk89q.jnbt.NamedTag;
|
||||
import com.sk89q.jnbt.ShortTag;
|
||||
import com.sk89q.jnbt.StringTag;
|
||||
import com.sk89q.jnbt.Tag;
|
||||
import com.sk89q.worldedit.BlockVector;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.entity.BaseEntity;
|
||||
import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard;
|
||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||
import com.sk89q.worldedit.extent.clipboard.io.legacycompat.NBTCompatibilityHandler;
|
||||
import com.sk89q.worldedit.extent.clipboard.io.legacycompat.SignCompatibilityHandler;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
@ -105,7 +104,7 @@ public class MCEditSchematicReader extends NBTSchematicReader {
|
||||
// Metadata
|
||||
// ====================================================================
|
||||
|
||||
Vector origin;
|
||||
BlockVector3 origin;
|
||||
Region region;
|
||||
|
||||
// Get information
|
||||
@ -117,18 +116,18 @@ public class MCEditSchematicReader extends NBTSchematicReader {
|
||||
int originX = requireTag(schematic, "WEOriginX", IntTag.class).getValue();
|
||||
int originY = requireTag(schematic, "WEOriginY", IntTag.class).getValue();
|
||||
int originZ = requireTag(schematic, "WEOriginZ", IntTag.class).getValue();
|
||||
Vector min = new Vector(originX, originY, originZ);
|
||||
BlockVector3 min = new BlockVector3(originX, originY, originZ);
|
||||
|
||||
int offsetX = requireTag(schematic, "WEOffsetX", IntTag.class).getValue();
|
||||
int offsetY = requireTag(schematic, "WEOffsetY", IntTag.class).getValue();
|
||||
int offsetZ = requireTag(schematic, "WEOffsetZ", IntTag.class).getValue();
|
||||
Vector offset = new Vector(offsetX, offsetY, offsetZ);
|
||||
BlockVector3 offset = new BlockVector3(offsetX, offsetY, offsetZ);
|
||||
|
||||
origin = min.subtract(offset);
|
||||
region = new CuboidRegion(min, min.add(width, height, length).subtract(Vector.ONE));
|
||||
region = new CuboidRegion(min, min.add(width, height, length).subtract(BlockVector3.ONE));
|
||||
} catch (IOException ignored) {
|
||||
origin = new Vector(0, 0, 0);
|
||||
region = new CuboidRegion(origin, origin.add(width, height, length).subtract(Vector.ONE));
|
||||
origin = BlockVector3.ZERO;
|
||||
region = new CuboidRegion(origin, origin.add(width, height, length).subtract(BlockVector3.ONE));
|
||||
}
|
||||
|
||||
// ====================================================================
|
||||
@ -162,7 +161,7 @@ public class MCEditSchematicReader extends NBTSchematicReader {
|
||||
|
||||
// Need to pull out tile entities
|
||||
List<Tag> tileEntities = requireTag(schematic, "TileEntities", ListTag.class).getValue();
|
||||
Map<BlockVector, Map<String, Tag>> tileEntitiesMap = new HashMap<>();
|
||||
Map<BlockVector3, Map<String, Tag>> tileEntitiesMap = new HashMap<>();
|
||||
|
||||
for (Tag tag : tileEntities) {
|
||||
if (!(tag instanceof CompoundTag)) continue;
|
||||
@ -206,7 +205,7 @@ public class MCEditSchematicReader extends NBTSchematicReader {
|
||||
}
|
||||
}
|
||||
|
||||
BlockVector vec = new BlockVector(x, y, z);
|
||||
BlockVector3 vec = new BlockVector3(x, y, z);
|
||||
tileEntitiesMap.put(vec, values);
|
||||
}
|
||||
|
||||
@ -220,7 +219,7 @@ public class MCEditSchematicReader extends NBTSchematicReader {
|
||||
for (int y = 0; y < height; ++y) {
|
||||
for (int z = 0; z < length; ++z) {
|
||||
int index = y * width * length + z * width + x;
|
||||
BlockVector pt = new BlockVector(x, y, z);
|
||||
BlockVector3 pt = new BlockVector3(x, y, z);
|
||||
BlockState state = LegacyMapper.getInstance().getBlockFromLegacy(blocks[index], blockData[index]);
|
||||
|
||||
try {
|
||||
|
@ -31,8 +31,6 @@ import com.sk89q.jnbt.NBTInputStream;
|
||||
import com.sk89q.jnbt.NamedTag;
|
||||
import com.sk89q.jnbt.ShortTag;
|
||||
import com.sk89q.jnbt.Tag;
|
||||
import com.sk89q.worldedit.BlockVector;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.extension.input.InputParseException;
|
||||
@ -40,6 +38,7 @@ import com.sk89q.worldedit.extension.input.ParserContext;
|
||||
import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard;
|
||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||
import com.sk89q.worldedit.extent.clipboard.io.legacycompat.NBTCompatibilityHandler;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
@ -96,7 +95,7 @@ public class SpongeSchematicReader extends NBTSchematicReader {
|
||||
}
|
||||
|
||||
private Clipboard readVersion1(Map<String, Tag> schematic) throws IOException {
|
||||
Vector origin;
|
||||
BlockVector3 origin;
|
||||
Region region;
|
||||
|
||||
Map<String, Tag> metadata = requireTag(schematic, "Metadata", CompoundTag.class).getValue();
|
||||
@ -110,19 +109,19 @@ public class SpongeSchematicReader extends NBTSchematicReader {
|
||||
throw new IOException("Invalid offset specified in schematic.");
|
||||
}
|
||||
|
||||
Vector min = new Vector(offsetParts[0], offsetParts[1], offsetParts[2]);
|
||||
BlockVector3 min = new BlockVector3(offsetParts[0], offsetParts[1], offsetParts[2]);
|
||||
|
||||
if (metadata.containsKey("WEOffsetX")) {
|
||||
// We appear to have WorldEdit Metadata
|
||||
int offsetX = requireTag(metadata, "WEOffsetX", IntTag.class).getValue();
|
||||
int offsetY = requireTag(metadata, "WEOffsetY", IntTag.class).getValue();
|
||||
int offsetZ = requireTag(metadata, "WEOffsetZ", IntTag.class).getValue();
|
||||
Vector offset = new Vector(offsetX, offsetY, offsetZ);
|
||||
BlockVector3 offset = new BlockVector3(offsetX, offsetY, offsetZ);
|
||||
origin = min.subtract(offset);
|
||||
region = new CuboidRegion(min, min.add(width, height, length).subtract(Vector.ONE));
|
||||
region = new CuboidRegion(min, min.add(width, height, length).subtract(BlockVector3.ONE));
|
||||
} else {
|
||||
origin = min;
|
||||
region = new CuboidRegion(origin, origin.add(width, height, length).subtract(Vector.ONE));
|
||||
region = new CuboidRegion(origin, origin.add(width, height, length).subtract(BlockVector3.ONE));
|
||||
}
|
||||
|
||||
int paletteMax = requireTag(schematic, "PaletteMax", IntTag.class).getValue();
|
||||
@ -151,7 +150,7 @@ public class SpongeSchematicReader extends NBTSchematicReader {
|
||||
|
||||
byte[] blocks = requireTag(schematic, "BlockData", ByteArrayTag.class).getValue();
|
||||
|
||||
Map<BlockVector, Map<String, Tag>> tileEntitiesMap = new HashMap<>();
|
||||
Map<BlockVector3, Map<String, Tag>> tileEntitiesMap = new HashMap<>();
|
||||
try {
|
||||
List<Map<String, Tag>> tileEntityTags = requireTag(schematic, "TileEntities", ListTag.class).getValue().stream()
|
||||
.map(tag -> (CompoundTag) tag)
|
||||
@ -160,7 +159,7 @@ public class SpongeSchematicReader extends NBTSchematicReader {
|
||||
|
||||
for (Map<String, Tag> tileEntity : tileEntityTags) {
|
||||
int[] pos = requireTag(tileEntity, "Pos", IntArrayTag.class).getValue();
|
||||
tileEntitiesMap.put(new BlockVector(pos[0], pos[1], pos[2]).toBlockVector(), tileEntity);
|
||||
tileEntitiesMap.put(new BlockVector3(pos[0], pos[1], pos[2]), tileEntity);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new IOException("Failed to load Tile Entities: " + e.getMessage());
|
||||
@ -193,7 +192,7 @@ public class SpongeSchematicReader extends NBTSchematicReader {
|
||||
int z = (index % (width * length)) / width;
|
||||
int x = (index % (width * length)) % width;
|
||||
BlockState state = palette.get(value);
|
||||
BlockVector pt = new BlockVector(x, y, z);
|
||||
BlockVector3 pt = new BlockVector3(x, y, z);
|
||||
try {
|
||||
if (tileEntitiesMap.containsKey(pt)) {
|
||||
Map<String, Tag> values = Maps.newHashMap(tileEntitiesMap.get(pt));
|
||||
|
@ -30,11 +30,10 @@ import com.sk89q.jnbt.NBTOutputStream;
|
||||
import com.sk89q.jnbt.ShortTag;
|
||||
import com.sk89q.jnbt.StringTag;
|
||||
import com.sk89q.jnbt.Tag;
|
||||
import com.sk89q.worldedit.BlockVector;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
@ -76,9 +75,9 @@ public class SpongeSchematicWriter implements ClipboardWriter {
|
||||
*/
|
||||
private Map<String, Tag> write1(Clipboard clipboard) throws IOException {
|
||||
Region region = clipboard.getRegion();
|
||||
Vector origin = clipboard.getOrigin();
|
||||
Vector min = region.getMinimumPoint();
|
||||
Vector offset = min.subtract(origin);
|
||||
BlockVector3 origin = clipboard.getOrigin();
|
||||
BlockVector3 min = region.getMinimumPoint();
|
||||
BlockVector3 offset = min.subtract(origin);
|
||||
int width = region.getWidth();
|
||||
int height = region.getHeight();
|
||||
int length = region.getLength();
|
||||
@ -127,7 +126,7 @@ public class SpongeSchematicWriter implements ClipboardWriter {
|
||||
int z0 = min.getBlockZ() + z;
|
||||
for (int x = 0; x < width; x++) {
|
||||
int x0 = min.getBlockX() + x;
|
||||
BlockVector point = new BlockVector(x0, y0, z0);
|
||||
BlockVector3 point = new BlockVector3(x0, y0, z0);
|
||||
BaseBlock block = clipboard.getFullBlock(point);
|
||||
if (block.getNbtData() != null) {
|
||||
Map<String, Tag> values = new HashMap<>();
|
||||
|
@ -19,10 +19,10 @@
|
||||
|
||||
package com.sk89q.worldedit.extent.inventory;
|
||||
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.extent.AbstractDelegateExtent;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.world.block.BlockType;
|
||||
@ -82,7 +82,7 @@ public class BlockBagExtent extends AbstractDelegateExtent {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBlock(Vector position, BlockStateHolder block) throws WorldEditException {
|
||||
public boolean setBlock(BlockVector3 position, BlockStateHolder block) throws WorldEditException {
|
||||
if (blockBag != null) {
|
||||
BlockState existing = getExtent().getBlock(position);
|
||||
|
||||
|
@ -19,15 +19,14 @@
|
||||
|
||||
package com.sk89q.worldedit.extent.reorder;
|
||||
|
||||
import com.sk89q.worldedit.BlockVector2D;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.Vector2D;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.extent.AbstractDelegateExtent;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.function.operation.Operation;
|
||||
import com.sk89q.worldedit.function.operation.RunContext;
|
||||
import com.sk89q.worldedit.function.operation.SetLocatedBlocks;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.util.collection.LocatedBlockList;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
|
||||
@ -49,11 +48,11 @@ public class ChunkBatchingExtent extends AbstractDelegateExtent {
|
||||
* Comparator optimized for sorting chunks by the region file they reside
|
||||
* in. This allows for file caches to be used while loading the chunk.
|
||||
*/
|
||||
private static final Comparator<Vector2D> REGION_OPTIMIZED_SORT =
|
||||
Comparator.<Vector2D, Vector2D>comparing(vec -> vec.divide(32).floor(), Vector2D.COMPARING_GRID_ARRANGEMENT)
|
||||
.thenComparing(Vector2D.COMPARING_GRID_ARRANGEMENT);
|
||||
private static final Comparator<BlockVector2> REGION_OPTIMIZED_SORT =
|
||||
Comparator.comparing((BlockVector2 vec) -> vec.divide(32), BlockVector2.COMPARING_GRID_ARRANGEMENT)
|
||||
.thenComparing(BlockVector2.COMPARING_GRID_ARRANGEMENT);
|
||||
|
||||
private final SortedMap<BlockVector2D, LocatedBlockList> batches = new TreeMap<>(REGION_OPTIMIZED_SORT);
|
||||
private final SortedMap<BlockVector2, LocatedBlockList> batches = new TreeMap<>(REGION_OPTIMIZED_SORT);
|
||||
private boolean enabled;
|
||||
|
||||
public ChunkBatchingExtent(Extent extent) {
|
||||
@ -74,11 +73,11 @@ public class ChunkBatchingExtent extends AbstractDelegateExtent {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBlock(Vector location, BlockStateHolder block) throws WorldEditException {
|
||||
public boolean setBlock(BlockVector3 location, BlockStateHolder block) throws WorldEditException {
|
||||
if (!enabled) {
|
||||
return getExtent().setBlock(location, block);
|
||||
}
|
||||
BlockVector2D chunkPos = new BlockVector2D(location.getBlockX() >> 4, location.getBlockZ() >> 4);
|
||||
BlockVector2 chunkPos = new BlockVector2(location.getBlockX() >> 4, location.getBlockZ() >> 4);
|
||||
batches.computeIfAbsent(chunkPos, k -> new LocatedBlockList()).add(location, block);
|
||||
return true;
|
||||
}
|
||||
|
@ -20,8 +20,6 @@
|
||||
package com.sk89q.worldedit.extent.reorder;
|
||||
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.sk89q.worldedit.BlockVector;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.blocks.Blocks;
|
||||
import com.sk89q.worldedit.extent.AbstractDelegateExtent;
|
||||
@ -30,6 +28,7 @@ import com.sk89q.worldedit.function.operation.Operation;
|
||||
import com.sk89q.worldedit.function.operation.OperationQueue;
|
||||
import com.sk89q.worldedit.function.operation.RunContext;
|
||||
import com.sk89q.worldedit.function.operation.SetLocatedBlocks;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.registry.state.Property;
|
||||
import com.sk89q.worldedit.util.LocatedBlock;
|
||||
import com.sk89q.worldedit.util.collection.LocatedBlockList;
|
||||
@ -95,7 +94,7 @@ public class MultiStageReorder extends AbstractDelegateExtent implements Reorder
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBlock(Vector location, BlockStateHolder block) throws WorldEditException {
|
||||
public boolean setBlock(BlockVector3 location, BlockStateHolder block) throws WorldEditException {
|
||||
BlockState existing = getBlock(location);
|
||||
|
||||
if (!enabled) {
|
||||
@ -104,18 +103,18 @@ public class MultiStageReorder extends AbstractDelegateExtent implements Reorder
|
||||
|
||||
if (Blocks.shouldPlaceLast(block.getBlockType())) {
|
||||
// Place torches, etc. last
|
||||
stage2.add(location.toBlockVector(), block);
|
||||
stage2.add(location, block);
|
||||
return !existing.equalsFuzzy(block);
|
||||
} else if (Blocks.shouldPlaceFinal(block.getBlockType())) {
|
||||
// Place signs, reed, etc even later
|
||||
stage3.add(location.toBlockVector(), block);
|
||||
stage3.add(location, block);
|
||||
return !existing.equalsFuzzy(block);
|
||||
} else if (Blocks.shouldPlaceLast(existing.getBlockType())) {
|
||||
// Destroy torches, etc. first
|
||||
super.setBlock(location, BlockTypes.AIR.getDefaultState());
|
||||
return super.setBlock(location, block);
|
||||
} else {
|
||||
stage1.add(location.toBlockVector(), block);
|
||||
stage1.add(location, block);
|
||||
return !existing.equalsFuzzy(block);
|
||||
}
|
||||
}
|
||||
@ -135,21 +134,21 @@ public class MultiStageReorder extends AbstractDelegateExtent implements Reorder
|
||||
public Operation resume(RunContext run) throws WorldEditException {
|
||||
Extent extent = getExtent();
|
||||
|
||||
final Set<BlockVector> blocks = new HashSet<>();
|
||||
final Map<BlockVector, BlockStateHolder> blockTypes = new HashMap<>();
|
||||
final Set<BlockVector3> blocks = new HashSet<>();
|
||||
final Map<BlockVector3, BlockStateHolder> blockTypes = new HashMap<>();
|
||||
for (LocatedBlock entry : stage3) {
|
||||
final BlockVector pt = entry.getLocation().toBlockVector();
|
||||
final BlockVector3 pt = entry.getLocation();
|
||||
blocks.add(pt);
|
||||
blockTypes.put(pt, entry.getBlock());
|
||||
}
|
||||
|
||||
while (!blocks.isEmpty()) {
|
||||
BlockVector current = blocks.iterator().next();
|
||||
BlockVector3 current = blocks.iterator().next();
|
||||
if (!blocks.contains(current)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
final Deque<BlockVector> walked = new LinkedList<>();
|
||||
final Deque<BlockVector3> walked = new LinkedList<>();
|
||||
|
||||
while (true) {
|
||||
walked.addFirst(current);
|
||||
@ -162,13 +161,13 @@ public class MultiStageReorder extends AbstractDelegateExtent implements Reorder
|
||||
Property<Object> halfProperty = blockStateHolder.getBlockType().getProperty("half");
|
||||
if (blockStateHolder.getState(halfProperty).equals("lower")) {
|
||||
// Deal with lower door halves being attached to the floor AND the upper half
|
||||
BlockVector upperBlock = current.add(0, 1, 0).toBlockVector();
|
||||
BlockVector3 upperBlock = current.add(0, 1, 0);
|
||||
if (blocks.contains(upperBlock) && !walked.contains(upperBlock)) {
|
||||
walked.addFirst(upperBlock);
|
||||
}
|
||||
}
|
||||
} else if (BlockCategories.RAILS.contains(blockStateHolder.getBlockType())) {
|
||||
BlockVector lowerBlock = current.add(0, -1, 0).toBlockVector();
|
||||
BlockVector3 lowerBlock = current.add(0, -1, 0);
|
||||
if (blocks.contains(lowerBlock) && !walked.contains(lowerBlock)) {
|
||||
walked.addFirst(lowerBlock);
|
||||
}
|
||||
@ -192,7 +191,7 @@ public class MultiStageReorder extends AbstractDelegateExtent implements Reorder
|
||||
}
|
||||
}
|
||||
|
||||
for (BlockVector pt : walked) {
|
||||
for (BlockVector3 pt : walked) {
|
||||
extent.setBlock(pt, blockTypes.get(pt));
|
||||
blocks.remove(pt);
|
||||
}
|
||||
|
@ -22,16 +22,17 @@ package com.sk89q.worldedit.extent.transform;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.registry.state.BooleanProperty;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.extent.AbstractDelegateExtent;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.math.Vector3;
|
||||
import com.sk89q.worldedit.math.transform.Transform;
|
||||
import com.sk89q.worldedit.registry.state.BooleanProperty;
|
||||
import com.sk89q.worldedit.registry.state.DirectionalProperty;
|
||||
import com.sk89q.worldedit.registry.state.Property;
|
||||
import com.sk89q.worldedit.util.Direction;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
|
||||
@ -84,17 +85,17 @@ public class BlockTransformExtent extends AbstractDelegateExtent {
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getBlock(Vector position) {
|
||||
public BlockState getBlock(BlockVector3 position) {
|
||||
return transformBlock(super.getBlock(position), false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseBlock getFullBlock(Vector position) {
|
||||
public BaseBlock getFullBlock(BlockVector3 position) {
|
||||
return transformBlock(super.getFullBlock(position), false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBlock(Vector location, BlockStateHolder block) throws WorldEditException {
|
||||
public boolean setBlock(BlockVector3 location, BlockStateHolder block) throws WorldEditException {
|
||||
return super.setBlock(location, transformBlock(block, true));
|
||||
}
|
||||
|
||||
@ -132,7 +133,7 @@ public class BlockTransformExtent extends AbstractDelegateExtent {
|
||||
if (property instanceof DirectionalProperty) {
|
||||
Direction value = (Direction) block.getState(property);
|
||||
if (value != null) {
|
||||
Vector newValue = getNewStateValue((DirectionalProperty) property, transform, value.toVector());
|
||||
Vector3 newValue = getNewStateValue((DirectionalProperty) property, transform, value.toVector());
|
||||
if (newValue != null) {
|
||||
changedBlock = (T) changedBlock.with(property, Direction.findClosest(newValue, Direction.Flag.ALL));
|
||||
}
|
||||
@ -171,9 +172,9 @@ public class BlockTransformExtent extends AbstractDelegateExtent {
|
||||
* @return a new state or null if none could be found
|
||||
*/
|
||||
@Nullable
|
||||
private static Vector getNewStateValue(DirectionalProperty state, Transform transform, Vector oldDirection) {
|
||||
Vector newDirection = transform.apply(oldDirection).subtract(transform.apply(Vector.ZERO)).normalize();
|
||||
Vector newValue = null;
|
||||
private static Vector3 getNewStateValue(DirectionalProperty state, Transform transform, Vector3 oldDirection) {
|
||||
Vector3 newDirection = transform.apply(oldDirection).subtract(transform.apply(Vector3.ZERO)).normalize();
|
||||
Vector3 newValue = null;
|
||||
double closest = -2;
|
||||
boolean found = false;
|
||||
|
||||
|
@ -22,10 +22,10 @@ package com.sk89q.worldedit.extent.validation;
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
|
||||
import com.sk89q.worldedit.MaxChangedBlocksException;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.extent.AbstractDelegateExtent;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
|
||||
/**
|
||||
@ -77,7 +77,7 @@ public class BlockChangeLimiter extends AbstractDelegateExtent {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBlock(Vector location, BlockStateHolder block) throws WorldEditException {
|
||||
public boolean setBlock(BlockVector3 location, BlockStateHolder block) throws WorldEditException {
|
||||
if (limit >= 0) {
|
||||
if (count >= limit) {
|
||||
throw new MaxChangedBlocksException(limit);
|
||||
|
@ -21,10 +21,10 @@ package com.sk89q.worldedit.extent.validation;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.extent.AbstractDelegateExtent;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.world.block.BlockType;
|
||||
@ -49,7 +49,7 @@ public class DataValidatorExtent extends AbstractDelegateExtent {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBlock(Vector location, BlockStateHolder block) throws WorldEditException {
|
||||
public boolean setBlock(BlockVector3 location, BlockStateHolder block) throws WorldEditException {
|
||||
final int y = location.getBlockY();
|
||||
final BlockType type = block.getBlockType();
|
||||
if (y < 0 || y > world.getMaxY()) {
|
||||
|
@ -21,10 +21,10 @@ package com.sk89q.worldedit.extent.world;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.extent.AbstractDelegateExtent;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.world.block.BlockType;
|
||||
@ -51,7 +51,7 @@ public class BlockQuirkExtent extends AbstractDelegateExtent {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBlock(Vector position, BlockStateHolder block) throws WorldEditException {
|
||||
public boolean setBlock(BlockVector3 position, BlockStateHolder block) throws WorldEditException {
|
||||
BlockType existing = getExtent().getBlock(position).getBlockType();
|
||||
|
||||
if (existing.getMaterial().hasContainer()) {
|
||||
|
@ -21,10 +21,10 @@ package com.sk89q.worldedit.extent.world;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.extent.AbstractDelegateExtent;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
|
||||
@ -61,7 +61,7 @@ public class ChunkLoadingExtent extends AbstractDelegateExtent {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBlock(Vector location, BlockStateHolder block) throws WorldEditException {
|
||||
public boolean setBlock(BlockVector3 location, BlockStateHolder block) throws WorldEditException {
|
||||
world.checkLoadedChunk(location);
|
||||
return super.setBlock(location, block);
|
||||
}
|
||||
|
@ -21,12 +21,12 @@ package com.sk89q.worldedit.extent.world;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.sk89q.worldedit.BlockVector2D;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.extent.AbstractDelegateExtent;
|
||||
import com.sk89q.worldedit.function.operation.Operation;
|
||||
import com.sk89q.worldedit.function.operation.RunContext;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
|
||||
@ -40,7 +40,7 @@ import java.util.Set;
|
||||
public class FastModeExtent extends AbstractDelegateExtent {
|
||||
|
||||
private final World world;
|
||||
private final Set<BlockVector2D> dirtyChunks = new HashSet<>();
|
||||
private final Set<BlockVector2> dirtyChunks = new HashSet<>();
|
||||
private boolean enabled = true;
|
||||
|
||||
/**
|
||||
@ -84,9 +84,9 @@ public class FastModeExtent extends AbstractDelegateExtent {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBlock(Vector location, BlockStateHolder block) throws WorldEditException {
|
||||
public boolean setBlock(BlockVector3 location, BlockStateHolder block) throws WorldEditException {
|
||||
if (enabled) {
|
||||
dirtyChunks.add(new BlockVector2D(location.getBlockX() >> 4, location.getBlockZ() >> 4));
|
||||
dirtyChunks.add(new BlockVector2(location.getBlockX() >> 4, location.getBlockZ() >> 4));
|
||||
return world.setBlock(location, block, false);
|
||||
} else {
|
||||
return world.setBlock(location, block, true);
|
||||
|
@ -21,10 +21,10 @@ package com.sk89q.worldedit.extent.world;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.extent.AbstractDelegateExtent;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
|
||||
@ -79,7 +79,7 @@ public class SurvivalModeExtent extends AbstractDelegateExtent {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBlock(Vector location, BlockStateHolder block) throws WorldEditException {
|
||||
public boolean setBlock(BlockVector3 location, BlockStateHolder block) throws WorldEditException {
|
||||
if (toolUse && block.getBlockType().getMaterial().isAir()) {
|
||||
world.simulateBlockMine(location);
|
||||
return true;
|
||||
|
Reference in New Issue
Block a user