mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-07-02 19:36:41 +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:
@ -19,10 +19,10 @@
|
||||
|
||||
package com.sk89q.worldedit.function.block;
|
||||
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.function.RegionFunction;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.util.Countable;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
@ -47,7 +47,7 @@ public class BlockDistributionCounter implements RegionFunction {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Vector position) throws WorldEditException {
|
||||
public boolean apply(BlockVector3 position) throws WorldEditException {
|
||||
BlockStateHolder blk = extent.getBlock(position);
|
||||
if (fuzzy) {
|
||||
blk = ((BlockState) blk).toFuzzy();
|
||||
|
@ -21,11 +21,11 @@ package com.sk89q.worldedit.function.block;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.function.RegionFunction;
|
||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
|
||||
/**
|
||||
* Replaces blocks with a given pattern.
|
||||
@ -49,7 +49,7 @@ public class BlockReplace implements RegionFunction {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Vector position) throws WorldEditException {
|
||||
public boolean apply(BlockVector3 position) throws WorldEditException {
|
||||
return extent.setBlock(position, pattern.apply(position));
|
||||
}
|
||||
|
||||
|
@ -19,17 +19,18 @@
|
||||
|
||||
package com.sk89q.worldedit.function.block;
|
||||
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.function.RegionFunction;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
|
||||
/**
|
||||
* Keeps a count of the number of times that {@link #apply(Vector)} is called.
|
||||
* Keeps a count of the number of times that {@link #apply(BlockVector3)} is
|
||||
* called.
|
||||
*/
|
||||
public class Counter implements RegionFunction {
|
||||
public class Counter implements RegionFunction {
|
||||
|
||||
private int count;
|
||||
|
||||
|
||||
/**
|
||||
* Returns the number of blocks that have been counted.
|
||||
*
|
||||
@ -40,7 +41,7 @@ import com.sk89q.worldedit.function.RegionFunction;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Vector position) throws WorldEditException {
|
||||
public boolean apply(BlockVector3 position) throws WorldEditException {
|
||||
count++;
|
||||
return false;
|
||||
}
|
||||
|
@ -23,15 +23,16 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.sk89q.jnbt.CompoundTag;
|
||||
import com.sk89q.jnbt.CompoundTagBuilder;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.function.RegionFunction;
|
||||
import com.sk89q.worldedit.internal.helper.MCDirections;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.math.Vector3;
|
||||
import com.sk89q.worldedit.math.transform.Transform;
|
||||
import com.sk89q.worldedit.util.Direction;
|
||||
import com.sk89q.worldedit.util.Direction.Flag;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
|
||||
/**
|
||||
* Copies blocks from one extent to another.
|
||||
@ -40,8 +41,8 @@ public class ExtentBlockCopy implements RegionFunction {
|
||||
|
||||
private final Extent source;
|
||||
private final Extent destination;
|
||||
private final Vector from;
|
||||
private final Vector to;
|
||||
private final BlockVector3 from;
|
||||
private final BlockVector3 to;
|
||||
private final Transform transform;
|
||||
|
||||
/**
|
||||
@ -53,7 +54,7 @@ public class ExtentBlockCopy implements RegionFunction {
|
||||
* @param to the destination offset
|
||||
* @param transform a transform to apply to positions (after source offset, before destination offset)
|
||||
*/
|
||||
public ExtentBlockCopy(Extent source, Vector from, Extent destination, Vector to, Transform transform) {
|
||||
public ExtentBlockCopy(Extent source, BlockVector3 from, Extent destination, BlockVector3 to, Transform transform) {
|
||||
checkNotNull(source);
|
||||
checkNotNull(from);
|
||||
checkNotNull(destination);
|
||||
@ -67,10 +68,10 @@ public class ExtentBlockCopy implements RegionFunction {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Vector position) throws WorldEditException {
|
||||
public boolean apply(BlockVector3 position) throws WorldEditException {
|
||||
BaseBlock block = source.getFullBlock(position);
|
||||
Vector orig = position.subtract(from);
|
||||
Vector transformed = transform.apply(orig);
|
||||
BlockVector3 orig = position.subtract(from);
|
||||
BlockVector3 transformed = transform.apply(orig.toVector3()).toBlockPoint();
|
||||
|
||||
// Apply transformations to NBT data if necessary
|
||||
block = transformNbtData(block);
|
||||
@ -96,7 +97,7 @@ public class ExtentBlockCopy implements RegionFunction {
|
||||
Direction direction = MCDirections.fromRotation(rot);
|
||||
|
||||
if (direction != null) {
|
||||
Vector vector = transform.apply(direction.toVector()).subtract(transform.apply(Vector.ZERO)).normalize();
|
||||
Vector3 vector = transform.apply(direction.toVector()).subtract(transform.apply(Vector3.ZERO)).normalize();
|
||||
Direction newDirection = Direction.findClosest(vector, Flag.CARDINAL | Flag.ORDINAL | Flag.SECONDARY_ORDINAL);
|
||||
|
||||
if (newDirection != null) {
|
||||
|
@ -22,11 +22,11 @@ package com.sk89q.worldedit.function.block;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.function.LayerFunction;
|
||||
import com.sk89q.worldedit.function.mask.BlockTypeMask;
|
||||
import com.sk89q.worldedit.function.mask.Mask;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
|
||||
/**
|
||||
@ -61,12 +61,12 @@ public class Naturalizer implements LayerFunction {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isGround(Vector position) {
|
||||
public boolean isGround(BlockVector3 position) {
|
||||
return mask.test(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Vector position, int depth) throws WorldEditException {
|
||||
public boolean apply(BlockVector3 position, int depth) throws WorldEditException {
|
||||
if (mask.test(position)) {
|
||||
affected++;
|
||||
switch (depth) {
|
||||
|
Reference in New Issue
Block a user