mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-07-02 11:26:42 +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,7 +21,7 @@ package com.sk89q.worldedit.function.pattern;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
|
||||
@ -61,7 +61,7 @@ public class BlockPattern extends AbstractPattern {
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockStateHolder apply(Vector position) {
|
||||
public BlockStateHolder apply(BlockVector3 position) {
|
||||
return block;
|
||||
}
|
||||
|
||||
|
@ -21,8 +21,8 @@ package com.sk89q.worldedit.function.pattern;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
|
||||
/**
|
||||
@ -31,7 +31,7 @@ import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
public class ClipboardPattern extends AbstractPattern {
|
||||
|
||||
private final Clipboard clipboard;
|
||||
private final Vector size;
|
||||
private final BlockVector3 size;
|
||||
|
||||
/**
|
||||
* Create a new clipboard pattern.
|
||||
@ -45,12 +45,12 @@ public class ClipboardPattern extends AbstractPattern {
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockStateHolder apply(Vector position) {
|
||||
public BlockStateHolder apply(BlockVector3 position) {
|
||||
int xp = Math.abs(position.getBlockX()) % size.getBlockX();
|
||||
int yp = Math.abs(position.getBlockY()) % size.getBlockY();
|
||||
int zp = Math.abs(position.getBlockZ()) % size.getBlockZ();
|
||||
|
||||
return clipboard.getFullBlock(clipboard.getMinimumPoint().add(new Vector(xp, yp, zp)));
|
||||
return clipboard.getFullBlock(clipboard.getMinimumPoint().add(xp, yp, zp));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
package com.sk89q.worldedit.function.pattern;
|
||||
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
|
||||
/**
|
||||
@ -33,6 +33,6 @@ public interface Pattern {
|
||||
* @param position the position
|
||||
* @return a block
|
||||
*/
|
||||
BlockStateHolder apply(Vector position);
|
||||
BlockStateHolder apply(BlockVector3 position);
|
||||
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ package com.sk89q.worldedit.function.pattern;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@ -53,7 +53,7 @@ public class RandomPattern extends AbstractPattern {
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockStateHolder apply(Vector position) {
|
||||
public BlockStateHolder apply(BlockVector3 position) {
|
||||
double r = random.nextDouble();
|
||||
double offset = 0;
|
||||
|
||||
|
@ -21,8 +21,8 @@ package com.sk89q.worldedit.function.pattern;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
|
||||
/**
|
||||
@ -31,7 +31,7 @@ import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
public class RepeatingExtentPattern extends AbstractPattern {
|
||||
|
||||
private Extent extent;
|
||||
private Vector offset;
|
||||
private BlockVector3 offset;
|
||||
|
||||
/**
|
||||
* Create a new instance.
|
||||
@ -39,7 +39,7 @@ public class RepeatingExtentPattern extends AbstractPattern {
|
||||
* @param extent the extent
|
||||
* @param offset the offset
|
||||
*/
|
||||
public RepeatingExtentPattern(Extent extent, Vector offset) {
|
||||
public RepeatingExtentPattern(Extent extent, BlockVector3 offset) {
|
||||
setExtent(extent);
|
||||
setOffset(offset);
|
||||
}
|
||||
@ -68,7 +68,7 @@ public class RepeatingExtentPattern extends AbstractPattern {
|
||||
*
|
||||
* @return the offset
|
||||
*/
|
||||
public Vector getOffset() {
|
||||
public BlockVector3 getOffset() {
|
||||
return offset;
|
||||
}
|
||||
|
||||
@ -77,19 +77,19 @@ public class RepeatingExtentPattern extends AbstractPattern {
|
||||
*
|
||||
* @param offset the offset
|
||||
*/
|
||||
public void setOffset(Vector offset) {
|
||||
public void setOffset(BlockVector3 offset) {
|
||||
checkNotNull(offset);
|
||||
this.offset = offset;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockStateHolder apply(Vector position) {
|
||||
Vector base = position.add(offset);
|
||||
Vector size = extent.getMaximumPoint().subtract(extent.getMinimumPoint()).add(1, 1, 1);
|
||||
public BlockStateHolder apply(BlockVector3 position) {
|
||||
BlockVector3 base = position.add(offset);
|
||||
BlockVector3 size = extent.getMaximumPoint().subtract(extent.getMinimumPoint()).add(1, 1, 1);
|
||||
int x = base.getBlockX() % size.getBlockX();
|
||||
int y = base.getBlockY() % size.getBlockY();
|
||||
int z = base.getBlockZ() % size.getBlockZ();
|
||||
return extent.getFullBlock(new Vector(x, y, z));
|
||||
return extent.getFullBlock(new BlockVector3(x, y, z));
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user