Minor vector optimizations

For the MutableBlockVector, use int instead of double
- Should reduce how quickly memory is used/collected
This commit is contained in:
Jesse Boyd 2017-01-13 06:05:32 +11:00
parent 4dc6cadc5d
commit 90e381a132
No known key found for this signature in database
GPG Key ID: 59F1DE6293AF6E1F
62 changed files with 717 additions and 381 deletions

View File

@ -10,7 +10,7 @@ import com.boydti.fawe.object.number.LongAdder;
import com.sk89q.minecraft.util.commands.Command; import com.sk89q.minecraft.util.commands.Command;
import com.sk89q.minecraft.util.commands.CommandPermissions; import com.sk89q.minecraft.util.commands.CommandPermissions;
import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.MutableBlockVector;
import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.blocks.BaseBlock; import com.sk89q.worldedit.blocks.BaseBlock;
@ -95,14 +95,14 @@ public class AnvilCommands {
MCAQueue queue = new MCAQueue(folder, root, true); MCAQueue queue = new MCAQueue(folder, root, true);
final LongAdder count = new LongAdder(); final LongAdder count = new LongAdder();
queue.filterWorld(new MCAFilter() { queue.filterWorld(new MCAFilter() {
private final Vector mutable = new Vector(0, 0, 0); private final MutableBlockVector mutable = new MutableBlockVector(0, 0, 0);
@Override @Override
public void applyBlock(int x, int y, int z, BaseBlock block) { public void applyBlock(int x, int y, int z, BaseBlock block) {
if (matchFrom.apply(block)) { if (matchFrom.apply(block)) {
mutable.x = x; mutable.mutX(x);
mutable.y = y; mutable.mutY(y);
mutable.z = z; mutable.mutZ(z);
BaseBlock newBlock = to.apply(mutable); BaseBlock newBlock = to.apply(mutable);
int currentId = block.getId(); int currentId = block.getId();
if (FaweCache.hasNBT(currentId)) { if (FaweCache.hasNBT(currentId)) {

View File

@ -372,7 +372,7 @@ public abstract class FawePlayer<T> extends Metadatable {
public void setSelection(final RegionWrapper region) { public void setSelection(final RegionWrapper region) {
final Player player = this.getPlayer(); final Player player = this.getPlayer();
Vector top = region.getTopVector(); Vector top = region.getTopVector();
top.y = getWorld().getMaxY(); top.mutY(getWorld().getMaxY());
final RegionSelector selector = new CuboidRegionSelector(player.getWorld(), region.getBottomVector(), top); final RegionSelector selector = new CuboidRegionSelector(player.getWorld(), region.getBottomVector(), top);
this.getSession().setRegionSelector(player.getWorld(), selector); this.getSession().setRegionSelector(player.getWorld(), selector);
} }

View File

@ -14,6 +14,7 @@ import com.boydti.fawe.util.MemUtil;
import com.boydti.fawe.util.SetQueue; import com.boydti.fawe.util.SetQueue;
import com.sk89q.jnbt.CompoundTag; import com.sk89q.jnbt.CompoundTag;
import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.MutableBlockVector;
import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.blocks.BaseBlock; import com.sk89q.worldedit.blocks.BaseBlock;
import com.sk89q.worldedit.blocks.BlockMaterial; import com.sk89q.worldedit.blocks.BlockMaterial;
@ -218,20 +219,20 @@ public abstract class FaweQueue {
public void forEachBlockInChunk(int cx, int cz, RunnableVal2<Vector, BaseBlock> onEach) { public void forEachBlockInChunk(int cx, int cz, RunnableVal2<Vector, BaseBlock> onEach) {
int bx = cx << 4; int bx = cx << 4;
int bz = cz << 4; int bz = cz << 4;
Vector mutable = new Vector(0, 0, 0); MutableBlockVector mutable = new MutableBlockVector(0, 0, 0);
for (int x = 0; x < 16; x++) { for (int x = 0; x < 16; x++) {
int xx = x + bx; int xx = x + bx;
mutable.x = xx; mutable.mutX(xx);
for (int z = 0; z < 16; z++) { for (int z = 0; z < 16; z++) {
int zz = z + bz; int zz = z + bz;
mutable.z = zz; mutable.mutZ(zz);
for (int y = 0; y <= getMaxY(); y++) { for (int y = 0; y <= getMaxY(); y++) {
int combined = getCombinedId4Data(xx, y, zz); int combined = getCombinedId4Data(xx, y, zz);
if (combined == 0) { if (combined == 0) {
continue; continue;
} }
int id = FaweCache.getId(combined); int id = FaweCache.getId(combined);
mutable.y = y; mutable.mutY(y);
if (FaweCache.hasNBT(id)) { if (FaweCache.hasNBT(id)) {
CompoundTag tile = getTileEntity(x, y, z); CompoundTag tile = getTileEntity(x, y, z);
BaseBlock block = new BaseBlock(id, FaweCache.getData(combined), tile); BaseBlock block = new BaseBlock(id, FaweCache.getData(combined), tile);
@ -247,7 +248,7 @@ public abstract class FaweQueue {
public void forEachTileInChunk(int cx, int cz, RunnableVal2<Vector, BaseBlock> onEach) { public void forEachTileInChunk(int cx, int cz, RunnableVal2<Vector, BaseBlock> onEach) {
int bx = cx << 4; int bx = cx << 4;
int bz = cz << 4; int bz = cz << 4;
Vector mutable = new Vector(0, 0, 0); MutableBlockVector mutable = new MutableBlockVector(0, 0, 0);
for (int x = 0; x < 16; x++) { for (int x = 0; x < 16; x++) {
int xx = x + bx; int xx = x + bx;
for (int z = 0; z < 16; z++) { for (int z = 0; z < 16; z++) {
@ -259,9 +260,9 @@ public abstract class FaweQueue {
} }
int id = FaweCache.getId(combined); int id = FaweCache.getId(combined);
if (FaweCache.hasNBT(id)) { if (FaweCache.hasNBT(id)) {
mutable.x = xx; mutable.mutX(xx);
mutable.z = zz; mutable.mutZ(zz);
mutable.y = y; mutable.mutY(y);
CompoundTag tile = getTileEntity(x, y, z); CompoundTag tile = getTileEntity(x, y, z);
BaseBlock block = new BaseBlock(id, FaweCache.getData(combined), tile); BaseBlock block = new BaseBlock(id, FaweCache.getData(combined), tile);
onEach.run(mutable, block); onEach.run(mutable, block);

View File

@ -6,8 +6,6 @@ import com.boydti.fawe.object.exception.FaweException;
import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.MaxChangedBlocksException; import com.sk89q.worldedit.MaxChangedBlocksException;
import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.command.tool.BrushTool;
import com.sk89q.worldedit.command.tool.brush.Brush;
import com.sk89q.worldedit.extent.clipboard.Clipboard; import com.sk89q.worldedit.extent.clipboard.Clipboard;
import com.sk89q.worldedit.function.mask.Mask; import com.sk89q.worldedit.function.mask.Mask;
import com.sk89q.worldedit.function.mask.Masks; import com.sk89q.worldedit.function.mask.Masks;
@ -15,14 +13,14 @@ import com.sk89q.worldedit.function.pattern.Pattern;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
public class HeightBrush implements Brush { public class HeightBrush implements DoubleActionBrush {
public final ScalableHeightMap heightMap; public final ScalableHeightMap heightMap;
private final int rotation; private final int rotation;
double yscale = 1; double yscale = 1;
private final BrushTool tool; private final DoubleActionBrushTool tool;
public HeightBrush(File file, int rotation, double yscale, BrushTool tool, Clipboard clipboard) { public HeightBrush(File file, int rotation, double yscale, DoubleActionBrushTool tool, Clipboard clipboard) {
this.tool = tool; this.tool = tool;
this.rotation = (rotation / 90) % 4; this.rotation = (rotation / 90) % 4;
this.yscale = yscale; this.yscale = yscale;
@ -43,12 +41,12 @@ public class HeightBrush implements Brush {
} }
@Override @Override
public void build(EditSession editSession, Vector position, Pattern pattern, double sizeDouble) throws MaxChangedBlocksException { public void build(DoubleActionBrushTool.BrushAction action, EditSession editSession, Vector position, Pattern pattern, double sizeDouble) throws MaxChangedBlocksException {
int size = (int) (action == DoubleActionBrushTool.BrushAction.PRIMARY ? sizeDouble : -sizeDouble);
Mask mask = tool.getMask(); Mask mask = tool.getMask();
if (mask == Masks.alwaysTrue() || mask == Masks.alwaysTrue2D()) { if (mask == Masks.alwaysTrue() || mask == Masks.alwaysTrue2D()) {
mask = null; mask = null;
} }
int size = (int) sizeDouble;
heightMap.setSize(size); heightMap.setSize(size);
heightMap.apply(editSession, mask, position, size, rotation, yscale, true); heightMap.apply(editSession, mask, position, size, rotation, yscale, true);
} }

View File

@ -0,0 +1,20 @@
package com.boydti.fawe.object.brush;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.MaxChangedBlocksException;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.function.pattern.Pattern;
public class RaiseBrush implements DoubleActionBrush {
@Override
public void build(DoubleActionBrushTool.BrushAction action, EditSession editSession, Vector position, Pattern pattern, double size) throws MaxChangedBlocksException {
switch (action) {
case PRIMARY:
break;
case SECONDARY:
break;
}
}
}

View File

@ -123,9 +123,9 @@ public class SplineBrush implements DoubleActionBrush {
private Vector getCentroid(Collection<Vector> points) { private Vector getCentroid(Collection<Vector> points) {
Vector sum = new Vector(); Vector sum = new Vector();
for (Vector p : points) { for (Vector p : points) {
sum.x += p.getX(); sum.mutX(sum.getX() + p.getX());
sum.y += p.getY(); sum.mutY(sum.getY() + p.getY());
sum.z += p.getZ(); sum.mutZ(sum.getZ() + p.getZ());
} }
return sum.multiply(1.0 / points.size()); return sum.multiply(1.0 / points.size());
} }
@ -147,9 +147,9 @@ public class SplineBrush implements DoubleActionBrush {
Vector r = new Vector(); Vector r = new Vector();
for (Vector p : points) { for (Vector p : points) {
r.x = (p.getX() - centroid.getX()); r.mutX((p.getX() - centroid.getX()));
r.y = (p.getY() - centroid.getY()); r.mutY((p.getY() - centroid.getY()));
r.z = (p.getZ() - centroid.getZ()); r.mutZ((p.getZ() - centroid.getZ()));
xx += r.getX() * r.getX(); xx += r.getX() * r.getX();
xy += r.getX() * r.getY(); xy += r.getX() * r.getY();
xz += r.getX() * r.getZ(); xz += r.getX() * r.getZ();

View File

@ -70,7 +70,7 @@ public class ScalableHeightMap {
int zz = pos.getBlockZ(); int zz = pos.getBlockZ();
int highestY = minY; int highestY = minY;
for (int y = minY; y <= maxY; y++) { for (int y = minY; y <= maxY; y++) {
pos.y = y; pos.mutY(y);
BaseBlock block = clipboard.getBlock(pos); BaseBlock block = clipboard.getBlock(pos);
if (block != EditSession.nullBlock) { if (block != EditSession.nullBlock) {
highestY = y + 1; highestY = y + 1;
@ -115,7 +115,7 @@ public class ScalableHeightMap {
Vector mutablePos = new Vector(0, 0, 0); Vector mutablePos = new Vector(0, 0, 0);
for (int x = -size; x <= size; x++) { for (int x = -size; x <= size; x++) {
int xx = centerX + x; int xx = centerX + x;
mutablePos.x = xx; mutablePos.mutX(xx);
for (int z = -size; z <= size; z++) { for (int z = -size; z <= size; z++) {
int index = (z + size) * diameter + (x + size); int index = (z + size) * diameter + (x + size);
int zz = centerZ + z; int zz = centerZ + z;

View File

@ -165,9 +165,9 @@ public class CPUOptimizedClipboard extends FaweClipboard {
if (!air && task.value2.getId() == 0) { if (!air && task.value2.getId() == 0) {
continue; continue;
} }
task.value1.x = x; task.value1.mutX(x);
task.value1.y = y; task.value1.mutY(y);
task.value1.z = z; task.value1.mutZ(z);
task.run(); task.run();
} }
} }

View File

@ -277,9 +277,9 @@ public class DiskOptimizedClipboard extends FaweClipboard implements Closeable {
block.setNbtData(nbt); block.setNbtData(nbt);
} }
} }
pos.x = x; pos.mutX(x);
pos.y = y; pos.mutY(y);
pos.z = z; pos.mutZ(z);
task.run(pos, block); task.run(pos, block);
} }
} }
@ -299,9 +299,9 @@ public class DiskOptimizedClipboard extends FaweClipboard implements Closeable {
block.setNbtData(nbt); block.setNbtData(nbt);
} }
} }
pos.x = x; pos.mutX(x);
pos.y = y; pos.mutY(y);
pos.z = z; pos.mutZ(z);
task.run(pos, block); task.run(pos, block);
} }
} }

View File

@ -387,9 +387,9 @@ public class MemoryOptimizedClipboard extends FaweClipboard {
if (!air && task.value2.getId() == 0) { if (!air && task.value2.getId() == 0) {
continue; continue;
} }
task.value1.x = x; task.value1.mutX(x);
task.value1.y = y; task.value1.mutY(y);
task.value1.z = z; task.value1.mutZ(z);
task.run(); task.run();
} }
} }

View File

@ -39,9 +39,9 @@ public class OffsetFaweClipboard extends AbstractDelegateFaweClipboard {
super.forEach(new RunnableVal2<Vector, BaseBlock>() { super.forEach(new RunnableVal2<Vector, BaseBlock>() {
@Override @Override
public void run(Vector value, BaseBlock block) { public void run(Vector value, BaseBlock block) {
value.x -= ox; value.mutX(value.getX() - ox);
value.y -= oy; value.mutY(value.getY() - oy);
value.z -= oz; value.mutZ(value.getZ() - oz);
task.run(value, block); task.run(value, block);
} }
}, air); }, air);

View File

@ -53,9 +53,9 @@ public class WorldCopyClipboard extends ReadOnlyClipboard {
for (int z = min.getBlockZ(); z <= max.getBlockZ(); z++) { for (int z = min.getBlockZ(); z <= max.getBlockZ(); z++) {
for (int x = min.getBlockX(); x <= max.getBlockX(); x++) { for (int x = min.getBlockX(); x <= max.getBlockX(); x++) {
BaseBlock block = getBlockAbs(x, y, z); BaseBlock block = getBlockAbs(x, y, z);
pos.x = x - mx; pos.mutX(x - mx);
pos.y = y - my; pos.mutY(y - my);
pos.z = z - mz; pos.mutZ(z - mz);
CompoundTag tag = block.getNbtData(); CompoundTag tag = block.getNbtData();
if (tag != null) { if (tag != null) {
Map<String, Tag> values = ReflectionUtils.getMap(tag.getValue()); Map<String, Tag> values = ReflectionUtils.getMap(tag.getValue());
@ -75,9 +75,9 @@ public class WorldCopyClipboard extends ReadOnlyClipboard {
if (block == EditSession.nullBlock) { if (block == EditSession.nullBlock) {
continue; continue;
} }
pos.x = x - mx; pos.mutX(x - mx);
pos.y = y - my; pos.mutY(y - my);
pos.z = z - mz; pos.mutZ(z - mz);
CompoundTag tag = block.getNbtData(); CompoundTag tag = block.getNbtData();
if (tag != null) { if (tag != null) {
Map<String, Tag> values = ReflectionUtils.getMap(tag.getValue()); Map<String, Tag> values = ReflectionUtils.getMap(tag.getValue());
@ -94,17 +94,17 @@ public class WorldCopyClipboard extends ReadOnlyClipboard {
for (int y = min.getBlockY(); y <= max.getBlockY(); y++) { for (int y = min.getBlockY(); y <= max.getBlockY(); y++) {
for (int z = min.getBlockZ(); z <= max.getBlockZ(); z++) { for (int z = min.getBlockZ(); z <= max.getBlockZ(); z++) {
for (int x = min.getBlockX(); x <= max.getBlockX(); x++) { for (int x = min.getBlockX(); x <= max.getBlockX(); x++) {
pos.x = x; pos.mutX(x);
pos.y = y; pos.mutY(y);
pos.z = z; pos.mutZ(z);
if (region.contains(pos)) { if (region.contains(pos)) {
BaseBlock block = getBlockAbs(x, y, z); BaseBlock block = getBlockAbs(x, y, z);
if (!air && block == EditSession.nullBlock) { if (!air && block == EditSession.nullBlock) {
continue; continue;
} }
pos.x -= mx; pos.mutX(pos.getX() - mx);
pos.y -= my; pos.mutY(pos.getY() - my);
pos.z -= mz; pos.mutZ(pos.getZ() - mz);
CompoundTag tag = block.getNbtData(); CompoundTag tag = block.getNbtData();
if (tag != null) { if (tag != null) {
Map<String, Tag> values = ReflectionUtils.getMap(tag.getValue()); Map<String, Tag> values = ReflectionUtils.getMap(tag.getValue());
@ -114,9 +114,9 @@ public class WorldCopyClipboard extends ReadOnlyClipboard {
} }
task.run(pos, block); task.run(pos, block);
} else if (air) { } else if (air) {
pos.x -= mx; pos.mutX(pos.getX() - mx);
pos.y -= my; pos.mutY(pos.getY() - my);
pos.z -= mz; pos.mutZ(pos.getZ() - mz);
task.run(pos, EditSession.nullBlock); task.run(pos, EditSession.nullBlock);
} }
} }

View File

@ -2,6 +2,7 @@ package com.boydti.fawe.object.collection;
import com.boydti.fawe.util.MathMan; import com.boydti.fawe.util.MathMan;
import com.sk89q.worldedit.BlockVector; import com.sk89q.worldedit.BlockVector;
import com.sk89q.worldedit.MutableBlockVector;
import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.Vector;
import java.util.Collection; import java.util.Collection;
import java.util.Iterator; import java.util.Iterator;
@ -49,7 +50,7 @@ public class LocalBlockVectorSet implements Set<Vector> {
return new Iterator<Vector>() { return new Iterator<Vector>() {
int index = set.nextSetBit(0); int index = set.nextSetBit(0);
int previous = -1; int previous = -1;
BlockVector mutable = new BlockVector(0, 0, 0); MutableBlockVector mutable = new MutableBlockVector(0, 0, 0);
@Override @Override
public void remove() { public void remove() {
set.clear(previous); set.clear(previous);
@ -65,9 +66,9 @@ public class LocalBlockVectorSet implements Set<Vector> {
int b2 = ((byte) (index >> 8)) & 0x7F; int b2 = ((byte) (index >> 8)) & 0x7F;
int b3 = ((byte)(index >> 15)) & 0xFF; int b3 = ((byte)(index >> 15)) & 0xFF;
int b4 = ((byte) (index >> 23)) & 0xFF; int b4 = ((byte) (index >> 23)) & 0xFF;
mutable.x = offsetX + (((b3 + ((MathMan.unpair8x(b2)) << 8)) << 21) >> 21); mutable.mutX(offsetX + (((b3 + ((MathMan.unpair8x(b2)) << 8)) << 21) >> 21));
mutable.y = b1; mutable.mutY(b1);
mutable.z = offsetZ + (((b4 + ((MathMan.unpair8y(b2)) << 8)) << 21) >> 21); mutable.mutZ(offsetZ + (((b4 + ((MathMan.unpair8y(b2)) << 8)) << 21) >> 21));
previous = index; previous = index;
index = set.nextSetBit(index + 1); index = set.nextSetBit(index + 1);
return mutable; return mutable;
@ -172,9 +173,9 @@ public class LocalBlockVectorSet implements Set<Vector> {
int b2 = ((byte) (index >> 8)) & 0x7F; int b2 = ((byte) (index >> 8)) & 0x7F;
int b3 = ((byte)(index >> 15)) & 0xFF; int b3 = ((byte)(index >> 15)) & 0xFF;
int b4 = ((byte) (index >> 23)) & 0xFF; int b4 = ((byte) (index >> 23)) & 0xFF;
mVec.x = offsetX + (((b3 + ((MathMan.unpair8x(b2)) << 8)) << 21) >> 21); mVec.mutX(offsetX + (((b3 + ((MathMan.unpair8x(b2)) << 8)) << 21) >> 21));
mVec.y = b1; mVec.mutY(b1);
mVec.z = offsetZ + (((b4 + ((MathMan.unpair8y(b2)) << 8)) << 21) >> 21); mVec.mutZ(offsetZ + (((b4 + ((MathMan.unpair8y(b2)) << 8)) << 21) >> 21));
if (!c.contains(mVec)) { if (!c.contains(mVec)) {
result = true; result = true;
set.clear(index); set.clear(index);

View File

@ -1,5 +1,6 @@
package com.boydti.fawe.object.extent; package com.boydti.fawe.object.extent;
import com.sk89q.worldedit.MutableBlockVector;
import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.Vector2D; import com.sk89q.worldedit.Vector2D;
import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.WorldEditException;
@ -11,7 +12,7 @@ import com.sk89q.worldedit.world.biome.BaseBiome;
public class BlockTranslateExtent extends AbstractDelegateExtent { public class BlockTranslateExtent extends AbstractDelegateExtent {
private final int dx,dy,dz; private final int dx,dy,dz;
private final Extent extent; private final Extent extent;
private Vector mutable = new Vector(); private MutableBlockVector mutable = new MutableBlockVector();
public BlockTranslateExtent(Extent extent, int dx, int dy, int dz) { public BlockTranslateExtent(Extent extent, int dx, int dy, int dz) {
super(extent); super(extent);
@ -23,17 +24,17 @@ public class BlockTranslateExtent extends AbstractDelegateExtent {
@Override @Override
public boolean setBlock(Vector location, BaseBlock block) throws WorldEditException { public boolean setBlock(Vector location, BaseBlock block) throws WorldEditException {
mutable.x = (location.getX() + dx); mutable.mutX((location.getX() + dx));
mutable.y = (location.getY() + dy); mutable.mutY((location.getY() + dy));
mutable.z = (location.getZ() + dz); mutable.mutZ((location.getZ() + dz));
return extent.setBlock(mutable, block); return extent.setBlock(mutable, block);
} }
@Override @Override
public boolean setBlock(int x, int y, int z, BaseBlock block) throws WorldEditException { public boolean setBlock(int x, int y, int z, BaseBlock block) throws WorldEditException {
mutable.x = x + dx; mutable.mutX(x + dx);
mutable.y = y + dy; mutable.mutY(y + dy);
mutable.z = z + dz; mutable.mutZ(z + dz);
return extent.setBlock(mutable, block); return extent.setBlock(mutable, block);
} }

View File

@ -1,5 +1,6 @@
package com.boydti.fawe.object.extent; package com.boydti.fawe.object.extent;
import com.sk89q.worldedit.MutableBlockVector;
import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.blocks.BaseBlock; import com.sk89q.worldedit.blocks.BaseBlock;
@ -20,7 +21,7 @@ public class ClipboardExtent extends ResettableExtent {
private final boolean ignoreAir; private final boolean ignoreAir;
private Extent extent; private Extent extent;
private final Vector mutable = new Vector(); private final MutableBlockVector mutable = new MutableBlockVector();
public ClipboardExtent(Extent parent, Clipboard clipboard, boolean ignoreAir) { public ClipboardExtent(Extent parent, Clipboard clipboard, boolean ignoreAir) {
super(parent); super(parent);
@ -44,9 +45,9 @@ public class ClipboardExtent extends ResettableExtent {
@Override @Override
public boolean setBlock(int x, int y, int z, BaseBlock block) throws WorldEditException { public boolean setBlock(int x, int y, int z, BaseBlock block) throws WorldEditException {
mutable.x = x; mutable.mutX(x);
mutable.y = y; mutable.mutY(y);
mutable.z = z; mutable.mutZ(z);
return setBlock(mutable, block); return setBlock(mutable, block);
} }

View File

@ -1,5 +1,6 @@
package com.boydti.fawe.object.extent; package com.boydti.fawe.object.extent;
import com.sk89q.worldedit.MutableBlockVector;
import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.Vector2D; import com.sk89q.worldedit.Vector2D;
import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.WorldEditException;
@ -10,7 +11,7 @@ import com.sk89q.worldedit.world.biome.BaseBiome;
public class PositionTransformExtent extends ResettableExtent { public class PositionTransformExtent extends ResettableExtent {
private final Vector mutable = new Vector(); private final MutableBlockVector mutable = new MutableBlockVector();
private Transform transform; private Transform transform;
private Vector min; private Vector min;
@ -33,13 +34,13 @@ public class PositionTransformExtent extends ResettableExtent {
if (min == null) { if (min == null) {
min = new Vector(pos); min = new Vector(pos);
} }
mutable.x = ((pos.getX() - min.getX())); mutable.mutX(((pos.getX() - min.getX())));
mutable.y = ((pos.getY() - min.getY())); mutable.mutY(((pos.getY() - min.getY())));
mutable.z = ((pos.getZ() - min.getZ())); mutable.mutZ(((pos.getZ() - min.getZ())));
Vector tmp = transform.apply(mutable); Vector tmp = transform.apply(mutable);
tmp.x = (tmp.getX() + min.getX()); tmp.mutX((tmp.getX() + min.getX()));
tmp.y = (tmp.getY() + min.getY()); tmp.mutY((tmp.getY() + min.getY()));
tmp.z = (tmp.getZ() + min.getZ()); tmp.mutZ((tmp.getZ() + min.getZ()));
return tmp; return tmp;
} }
@ -47,13 +48,13 @@ public class PositionTransformExtent extends ResettableExtent {
if (min == null) { if (min == null) {
min = new Vector(x, y, z); min = new Vector(x, y, z);
} }
mutable.x = ((x - min.getX())); mutable.mutX(((x - min.getX())));
mutable.y = ((y - min.getY())); mutable.mutY(((y - min.getY())));
mutable.z = ((z - min.getZ())); mutable.mutZ(((z - min.getZ())));
Vector tmp = transform.apply(mutable); Vector tmp = transform.apply(mutable);
tmp.x = (tmp.getX() + min.getX()); tmp.mutX((tmp.getX() + min.getX()));
tmp.y = (tmp.getY() + min.getY()); tmp.mutY((tmp.getY() + min.getY()));
tmp.z = (tmp.getZ() + min.getZ()); tmp.mutZ((tmp.getZ() + min.getZ()));
return tmp; return tmp;
} }
@ -74,9 +75,9 @@ public class PositionTransformExtent extends ResettableExtent {
@Override @Override
public BaseBiome getBiome(Vector2D position) { public BaseBiome getBiome(Vector2D position) {
mutable.x = position.getBlockX(); mutable.mutX(position.getBlockX());
mutable.z = position.getBlockZ(); mutable.mutZ(position.getBlockZ());
mutable.y = 0; mutable.mutY(0);
return super.getBiome(getPos(mutable).toVector2D()); return super.getBiome(getPos(mutable).toVector2D());
} }
@ -93,9 +94,9 @@ public class PositionTransformExtent extends ResettableExtent {
@Override @Override
public boolean setBiome(Vector2D position, BaseBiome biome) { public boolean setBiome(Vector2D position, BaseBiome biome) {
mutable.x = position.getBlockX(); mutable.mutX(position.getBlockX());
mutable.z = position.getBlockZ(); mutable.mutZ(position.getBlockZ());
mutable.y = 0; mutable.mutY(0);
return super.setBiome(getPos(mutable).toVector2D(), biome); return super.setBiome(getPos(mutable).toVector2D(), biome);
} }

View File

@ -1,5 +1,6 @@
package com.boydti.fawe.object.extent; package com.boydti.fawe.object.extent;
import com.sk89q.worldedit.MutableBlockVector;
import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.Vector2D; import com.sk89q.worldedit.Vector2D;
import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.WorldEditException;
@ -12,7 +13,7 @@ import com.sk89q.worldedit.world.biome.BaseBiome;
import javax.annotation.Nullable; import javax.annotation.Nullable;
public class ScaleTransform extends ResettableExtent { public class ScaleTransform extends ResettableExtent {
private final Vector mutable = new Vector(); private final MutableBlockVector mutable = new MutableBlockVector();
private final double dx,dy,dz; private final double dx,dy,dz;
private int maxy; private int maxy;
@ -37,9 +38,9 @@ public class ScaleTransform extends ResettableExtent {
if (min == null) { if (min == null) {
min = new Vector(pos); min = new Vector(pos);
} }
mutable.x = (min.getX() + (pos.getX() - min.getX()) * dx); mutable.mutX((min.getX() + (pos.getX() - min.getX()) * dx));
mutable.y = (min.getY() + (pos.getY() - min.getY()) * dy); mutable.mutY((min.getY() + (pos.getY() - min.getY()) * dy));
mutable.z = (min.getZ() + (pos.getZ() - min.getZ()) * dz); mutable.mutZ((min.getZ() + (pos.getZ() - min.getZ()) * dz));
return mutable; return mutable;
} }
@ -47,9 +48,9 @@ public class ScaleTransform extends ResettableExtent {
if (min == null) { if (min == null) {
min = new Vector(x, y, z); min = new Vector(x, y, z);
} }
mutable.x = (min.getX() + (x - min.getX()) * dx); mutable.mutX((min.getX() + (x - min.getX()) * dx));
mutable.y = (min.getY() + (y - min.getY()) * dy); mutable.mutY((min.getY() + (y - min.getY()) * dy));
mutable.z = (min.getZ() + (z - min.getZ()) * dz); mutable.mutZ((min.getZ() + (z - min.getZ()) * dz));
return mutable; return mutable;
} }
@ -64,9 +65,9 @@ public class ScaleTransform extends ResettableExtent {
double ex = sx + dx; double ex = sx + dx;
double ey = Math.min(maxy, sy + dy); double ey = Math.min(maxy, sy + dy);
double ez = sz + dz; double ez = sz + dz;
for (pos.y = sy; pos.y < ey; pos.y++) { for (pos.mutY(sy); pos.getY() < ey; pos.mutY(pos.getY() + 1)) {
for (pos.z = sz; pos.z < ez; pos.z++) { for (pos.mutZ(sz); pos.getZ() < ez; pos.mutZ(pos.getZ() + 1)) {
for (pos.x = sx; pos.x < ex; pos.x++) { for (pos.mutX(sx); pos.getX() < ex; pos.mutX(pos.getX() + 1)) {
result |= super.setBlock(pos, block); result |= super.setBlock(pos, block);
} }
} }
@ -82,8 +83,8 @@ public class ScaleTransform extends ResettableExtent {
double sz = pos.getZ(); double sz = pos.getZ();
double ex = pos.getX() + dx; double ex = pos.getX() + dx;
double ez = pos.getZ() + dz; double ez = pos.getZ() + dz;
for (pos.z = sz; pos.z < ez; pos.z++) { for (pos.mutZ(sz); pos.getZ() < ez; pos.mutZ(pos.getZ() + 1)) {
for (pos.x = sx; pos.x < ex; pos.x++) { for (pos.mutX(sx); pos.getX() < ex; pos.mutX(pos.getX() + 1)) {
result |= super.setBiome(pos.toVector2D(), biome); result |= super.setBiome(pos.toVector2D(), biome);
} }
} }
@ -100,9 +101,9 @@ public class ScaleTransform extends ResettableExtent {
double ex = pos.getX() + dx; double ex = pos.getX() + dx;
double ey = Math.min(maxy, sy + dy); double ey = Math.min(maxy, sy + dy);
double ez = pos.getZ() + dz; double ez = pos.getZ() + dz;
for (pos.y = sy; pos.y < ey; pos.y++) { for (pos.mutY(sy); pos.getY() < ey; pos.mutY(pos.getY() + 1)) {
for (pos.z = sz; pos.z < ez; pos.z++) { for (pos.mutZ(sz); pos.getZ() < ez; pos.mutZ(pos.getZ() + 1)) {
for (pos.x = sx; pos.x < ex; pos.x++) { for (pos.mutX(sx); pos.getX() < ex; pos.mutX(pos.getX() + 1)) {
result |= super.setBlock(pos, block); result |= super.setBlock(pos, block);
} }
} }

View File

@ -1,5 +1,6 @@
package com.boydti.fawe.object.extent; package com.boydti.fawe.object.extent;
import com.sk89q.worldedit.MutableBlockVector;
import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.blocks.BaseBlock; import com.sk89q.worldedit.blocks.BaseBlock;
@ -11,7 +12,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
public class SourceMaskExtent extends TemporalExtent { public class SourceMaskExtent extends TemporalExtent {
private Mask mask; private Mask mask;
private Vector mutable = new Vector(); private MutableBlockVector mutable = new MutableBlockVector();
/** /**
@ -47,9 +48,9 @@ public class SourceMaskExtent extends TemporalExtent {
@Override @Override
public boolean setBlock(int x, int y, int z, BaseBlock block) throws WorldEditException { public boolean setBlock(int x, int y, int z, BaseBlock block) throws WorldEditException {
set(x, y, z, block); set(x, y, z, block);
mutable.x = x; mutable.mutX(x);
mutable.y = y; mutable.mutY(y);
mutable.z = z; mutable.mutZ(z);
return mask.test(mutable) && super.setBlock(x, y, z, block); return mask.test(mutable) && super.setBlock(x, y, z, block);
} }
} }

View File

@ -1,5 +1,6 @@
package com.boydti.fawe.object.extent; package com.boydti.fawe.object.extent;
import com.sk89q.worldedit.MutableBlockVector;
import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.Vector2D; import com.sk89q.worldedit.Vector2D;
import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.WorldEditException;
@ -11,7 +12,7 @@ import com.sk89q.worldedit.world.registry.BlockRegistry;
public class TransformExtent extends BlockTransformExtent { public class TransformExtent extends BlockTransformExtent {
private final Vector mutable = new Vector(); private final MutableBlockVector mutable = new MutableBlockVector();
private Vector min; private Vector min;
private int maxy; private int maxy;
@ -35,13 +36,13 @@ public class TransformExtent extends BlockTransformExtent {
if (min == null) { if (min == null) {
min = new Vector(pos); min = new Vector(pos);
} }
mutable.x = ((pos.getX() - min.getX())); mutable.mutX(((pos.getX() - min.getX())));
mutable.y = ((pos.getY() - min.getY())); mutable.mutY(((pos.getY() - min.getY())));
mutable.z = ((pos.getZ() - min.getZ())); mutable.mutZ(((pos.getZ() - min.getZ())));
Vector tmp = getTransform().apply(mutable); Vector tmp = getTransform().apply(mutable);
tmp.x = (tmp.getX() + min.getX()); tmp.mutX((tmp.getX() + min.getX()));
tmp.y = (tmp.getY() + min.getY()); tmp.mutY((tmp.getY() + min.getY()));
tmp.z = (tmp.getZ() + min.getZ()); tmp.mutZ((tmp.getZ() + min.getZ()));
return tmp; return tmp;
} }
@ -49,13 +50,13 @@ public class TransformExtent extends BlockTransformExtent {
if (min == null) { if (min == null) {
min = new Vector(x, y, z); min = new Vector(x, y, z);
} }
mutable.x = ((x - min.getX())); mutable.mutX(((x - min.getX())));
mutable.y = ((y - min.getY())); mutable.mutY(((y - min.getY())));
mutable.z = ((z - min.getZ())); mutable.mutZ(((z - min.getZ())));
Vector tmp = getTransform().apply(mutable); Vector tmp = getTransform().apply(mutable);
tmp.x = (tmp.getX() + min.getX()); tmp.mutX((tmp.getX() + min.getX()));
tmp.y = (tmp.getY() + min.getY()); tmp.mutY((tmp.getY() + min.getY()));
tmp.z = (tmp.getZ() + min.getZ()); tmp.mutZ((tmp.getZ() + min.getZ()));
return tmp; return tmp;
} }
@ -76,9 +77,9 @@ public class TransformExtent extends BlockTransformExtent {
@Override @Override
public BaseBiome getBiome(Vector2D position) { public BaseBiome getBiome(Vector2D position) {
mutable.x = position.getBlockX(); mutable.mutX(position.getBlockX());
mutable.z = position.getBlockZ(); mutable.mutZ(position.getBlockZ());
mutable.y = 0; mutable.mutY(0);
return super.getBiome(getPos(mutable).toVector2D()); return super.getBiome(getPos(mutable).toVector2D());
} }
@ -95,9 +96,9 @@ public class TransformExtent extends BlockTransformExtent {
@Override @Override
public boolean setBiome(Vector2D position, BaseBiome biome) { public boolean setBiome(Vector2D position, BaseBiome biome) {
mutable.x = position.getBlockX(); mutable.mutX(position.getBlockX());
mutable.z = position.getBlockZ(); mutable.mutZ(position.getBlockZ());
mutable.y = 0; mutable.mutY(0);
return super.setBiome(getPos(mutable).toVector2D(), biome); return super.setBiome(getPos(mutable).toVector2D(), biome);
} }
} }

View File

@ -21,21 +21,21 @@ public class AdjacentMask extends BlockMask {
double x = v.getX(); double x = v.getX();
double y = v.getY(); double y = v.getY();
double z = v.getZ(); double z = v.getZ();
v.x = x + 1; v.mutX(x + 1);
if (super.test(v) && ++count == min && max >= 8) { v.x = x; return true; } if (super.test(v) && ++count == min && max >= 8) { v.mutX(x); return true; }
v.x = x - 1; v.mutX(x - 1);
if (super.test(v) && ++count == min && max >= 8) { v.x = x; return true; } if (super.test(v) && ++count == min && max >= 8) { v.mutX(x); return true; }
v.x = x; v.mutX(x);
v.y = y + 1; v.mutY(y + 1);
if (super.test(v) && ++count == min && max >= 8) { v.y = y; return true; } if (super.test(v) && ++count == min && max >= 8) { v.mutY(y); return true; }
v.y = y - 1; v.mutY(y - 1);
if (super.test(v) && ++count == min && max >= 8) { v.y = y; return true; } if (super.test(v) && ++count == min && max >= 8) { v.mutY(y); return true; }
v.y = y; v.mutY(y);
v.z = z + 1; v.mutZ(z + 1);
if (super.test(v) && ++count == min && max >= 8) { v.z = z; return true; } if (super.test(v) && ++count == min && max >= 8) { v.mutZ(z); return true; }
v.z = z - 1; v.mutZ(z - 1);
if (super.test(v) && ++count == min && max >= 8) { v.z = z; return true; } if (super.test(v) && ++count == min && max >= 8) { v.mutZ(z); return true; }
v.z = z; v.mutZ(z);
return count >= min && count <= max; return count >= min && count <= max;
} }
} }

View File

@ -2,6 +2,7 @@ package com.boydti.fawe.object.mask;
import com.boydti.fawe.Fawe; import com.boydti.fawe.Fawe;
import com.boydti.fawe.util.MathMan; import com.boydti.fawe.util.MathMan;
import com.sk89q.worldedit.MutableBlockVector;
import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.function.mask.Mask2D; import com.sk89q.worldedit.function.mask.Mask2D;
@ -65,7 +66,7 @@ public class AngleMask extends SolidBlockMask implements ResettableMask {
return false; return false;
} }
private Vector mutable = new Vector(); private MutableBlockVector mutable = new MutableBlockVector();
private int getHighestTerrainBlock(final int x, final int z, int minY, int maxY) { private int getHighestTerrainBlock(final int x, final int z, int minY, int maxY) {
long pair = MathMan.pairInt(x, z); long pair = MathMan.pairInt(x, z);
@ -79,15 +80,15 @@ public class AngleMask extends SolidBlockMask implements ResettableMask {
} }
int maxSearchY = Math.min(this.maxY, Math.max(0, maxY)); int maxSearchY = Math.min(this.maxY, Math.max(0, maxY));
int minSearchY = Math.min(this.maxY, Math.max(0, minY)); int minSearchY = Math.min(this.maxY, Math.max(0, minY));
mutable.x = x; mutable.mutX(x);
mutable.z = z; mutable.mutZ(z);
boolean air = false; boolean air = false;
if (maxSearchY != this.maxY) { if (maxSearchY != this.maxY) {
mutable.y = maxSearchY + 1; mutable.mutY(maxSearchY + 1);
air = !super.test(mutable); air = !super.test(mutable);
} }
for (int y = maxSearchY; y >= minSearchY; --y) { for (int y = maxSearchY; y >= minSearchY; --y) {
mutable.y = y; mutable.mutY(y);
if (super.test(mutable)) { if (super.test(mutable)) {
if (!air) { if (!air) {
break; break;

View File

@ -0,0 +1,69 @@
package com.boydti.fawe.object.mask;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.function.mask.Mask;
import com.sk89q.worldedit.function.mask.Mask2D;
import javax.annotation.Nullable;
/**
* Restricts the
*/
public class PlaneMask implements Mask, ResettableMask {
private int mode = -1;
private int originX = Integer.MAX_VALUE,originY = Integer.MAX_VALUE,originZ = Integer.MAX_VALUE;
@Override
public boolean test(Vector vector) {
switch (mode) {
case -1:
originX = vector.getBlockX();
originY = vector.getBlockY();
originZ = vector.getBlockZ();
mode = 0;
return true;
case 0:
case 1:
case 2:
case 4:
int original = mode;
if (originX != vector.getBlockX()) {
mode &= 1;
}
if (originY != vector.getBlockY()) {
mode &= 2;
}
if (originZ != vector.getBlockZ()) {
mode &= 4;
}
if (Integer.bitCount(mode) >= 3) {
mode = original;
return false;
}
default:
if (originX != vector.getBlockX() && (mode & 1) == 0) {
return false;
}
if (originZ != vector.getBlockZ() && (mode & 4) == 0) {
return false;
}
if (originY != vector.getBlockY() && (mode & 2) == 0) {
return false;
}
return true;
}
}
@Override
public void reset() {
mode = -1;
}
@Nullable
@Override
public Mask2D toMask2D() {
return null;
}
}

View File

@ -0,0 +1,94 @@
package com.boydti.fawe.object.mask;
import com.sk89q.worldedit.MutableBlockVector;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.function.mask.Mask2D;
import com.sk89q.worldedit.function.mask.SolidBlockMask;
import javax.annotation.Nullable;
/**
* Restricts the
*/
public class SolidPlaneMask extends SolidBlockMask implements ResettableMask {
private int mode = -1;
private MutableBlockVector mutable = new MutableBlockVector();
private int originX = Integer.MAX_VALUE,originY = Integer.MAX_VALUE,originZ = Integer.MAX_VALUE;
public SolidPlaneMask(Extent extent) {
super(extent);
}
@Override
public boolean test(Vector vector) {
switch (mode) {
case -1:
if (!super.test(vector)) {
return false;
}
originX = vector.getBlockX();
originY = vector.getBlockY();
originZ = vector.getBlockZ();
mode = 0;
Extent extent = getExtent();
if (extent.getBlock(mutable.setComponents(originX - 1, originY, originZ)).getId() != 0 && extent.getBlock(mutable.setComponents(originX + 1, originY, originZ)).getId() != 0) {
mode &= 1;
}
if (extent.getBlock(mutable.setComponents(originX, originY, originZ - 1)).getId() != 0 && extent.getBlock(mutable.setComponents(originX, originY, originZ + 1)).getId() != 0) {
mode &= 4;
}
if (extent.getBlock(mutable.setComponents(originX, originY - 1, originZ + 1)).getId() != 0 && extent.getBlock(mutable.setComponents(originX, originY + 1, originZ + 1)).getId() != 0) {
mode &= 2;
}
if (Integer.bitCount(mode) >= 3) {
return false;
}
case 0:
case 1:
case 2:
case 4:
if (!super.test(vector)) {
return false;
}
int original = mode;
if (originX != vector.getBlockX()) {
mode &= 1;
}
if (originY != vector.getBlockY()) {
mode &= 2;
}
if (originZ != vector.getBlockZ()) {
mode &= 4;
}
if (Integer.bitCount(mode) >= 3) {
mode = original;
return false;
}
default:
if (originX != vector.getBlockX() && (mode & 1) == 0) {
return false;
}
if (originZ != vector.getBlockZ() && (mode & 4) == 0) {
return false;
}
if (originY != vector.getBlockY() && (mode & 2) == 0) {
return false;
}
return super.test(vector);
}
}
@Override
public void reset() {
mode = -1;
}
@Nullable
@Override
public Mask2D toMask2D() {
return null;
}
}

View File

@ -21,16 +21,16 @@ public class WallMask extends BlockMask {
double x = v.getX(); double x = v.getX();
double y = v.getY(); double y = v.getY();
double z = v.getZ(); double z = v.getZ();
v.x = x + 1; v.mutX(x + 1);
if (super.test(v) && ++count == min && max >= 8) { v.x = x; return true; } if (super.test(v) && ++count == min && max >= 8) { v.mutX(x); return true; }
v.x = x - 1; v.mutX(x - 1);
if (super.test(v) && ++count == min && max >= 8) { v.x = x; return true; } if (super.test(v) && ++count == min && max >= 8) { v.mutX(x); return true; }
v.x = x; v.mutX(x);
v.z = z + 1; v.mutZ(z + 1);
if (super.test(v) && ++count == min && max >= 8) { v.z = z; return true; } if (super.test(v) && ++count == min && max >= 8) { v.mutZ(z); return true; }
v.z = z - 1; v.mutZ(z - 1);
if (super.test(v) && ++count == min && max >= 8) { v.z = z; return true; } if (super.test(v) && ++count == min && max >= 8) { v.mutZ(z); return true; }
v.z = z; v.mutZ(z);
return count >= min && count <= max; return count >= min && count <= max;
} }
} }

View File

@ -1,5 +1,6 @@
package com.boydti.fawe.object.pattern; package com.boydti.fawe.object.pattern;
import com.sk89q.worldedit.MutableBlockVector;
import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.blocks.BaseBlock; import com.sk89q.worldedit.blocks.BaseBlock;
import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.extent.Extent;
@ -21,7 +22,7 @@ public class FullClipboardPattern extends AbstractPattern {
private final Clipboard clipboard; private final Clipboard clipboard;
private final BaseBlock block; private final BaseBlock block;
private final Vector mutable = new Vector(); private final MutableBlockVector mutable = new MutableBlockVector();
/** /**
* Create a new clipboard pattern. * Create a new clipboard pattern.

View File

@ -1,5 +1,6 @@
package com.boydti.fawe.object.pattern; package com.boydti.fawe.object.pattern;
import com.sk89q.worldedit.MutableBlockVector;
import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.blocks.BaseBlock; import com.sk89q.worldedit.blocks.BaseBlock;
import com.sk89q.worldedit.function.pattern.AbstractPattern; import com.sk89q.worldedit.function.pattern.AbstractPattern;
@ -13,12 +14,12 @@ public class NoXPattern extends AbstractPattern {
this.pattern = pattern; this.pattern = pattern;
} }
private Vector mutable = new Vector(); private MutableBlockVector mutable = new MutableBlockVector();
@Override @Override
public BaseBlock apply(Vector pos) { public BaseBlock apply(Vector pos) {
mutable.y = (pos.getY()); mutable.mutY((pos.getY()));
mutable.z = (pos.getZ()); mutable.mutZ((pos.getZ()));
return pattern.apply(mutable); return pattern.apply(mutable);
} }
} }

View File

@ -1,5 +1,6 @@
package com.boydti.fawe.object.pattern; package com.boydti.fawe.object.pattern;
import com.sk89q.worldedit.MutableBlockVector;
import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.blocks.BaseBlock; import com.sk89q.worldedit.blocks.BaseBlock;
import com.sk89q.worldedit.function.pattern.AbstractPattern; import com.sk89q.worldedit.function.pattern.AbstractPattern;
@ -13,12 +14,12 @@ public class NoYPattern extends AbstractPattern {
this.pattern = pattern; this.pattern = pattern;
} }
private Vector mutable = new Vector(); private MutableBlockVector mutable = new MutableBlockVector();
@Override @Override
public BaseBlock apply(Vector pos) { public BaseBlock apply(Vector pos) {
mutable.x = (pos.getX()); mutable.mutX((pos.getX()));
mutable.z = (pos.getZ()); mutable.mutZ((pos.getZ()));
return pattern.apply(mutable); return pattern.apply(mutable);
} }
} }

View File

@ -1,5 +1,6 @@
package com.boydti.fawe.object.pattern; package com.boydti.fawe.object.pattern;
import com.sk89q.worldedit.MutableBlockVector;
import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.blocks.BaseBlock; import com.sk89q.worldedit.blocks.BaseBlock;
import com.sk89q.worldedit.function.pattern.AbstractPattern; import com.sk89q.worldedit.function.pattern.AbstractPattern;
@ -13,12 +14,12 @@ public class NoZPattern extends AbstractPattern {
this.pattern = pattern; this.pattern = pattern;
} }
private Vector mutable = new Vector(); private MutableBlockVector mutable = new MutableBlockVector();
@Override @Override
public BaseBlock apply(Vector pos) { public BaseBlock apply(Vector pos) {
mutable.x = (pos.getX()); mutable.mutX((pos.getX()));
mutable.y = (pos.getY()); mutable.mutY((pos.getY()));
return pattern.apply(mutable); return pattern.apply(mutable);
} }
} }

View File

@ -1,5 +1,6 @@
package com.boydti.fawe.object.pattern; package com.boydti.fawe.object.pattern;
import com.sk89q.worldedit.MutableBlockVector;
import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.blocks.BaseBlock; import com.sk89q.worldedit.blocks.BaseBlock;
import com.sk89q.worldedit.function.pattern.AbstractPattern; import com.sk89q.worldedit.function.pattern.AbstractPattern;
@ -8,7 +9,7 @@ import com.sk89q.worldedit.function.pattern.Pattern;
public class OffsetPattern extends AbstractPattern { public class OffsetPattern extends AbstractPattern {
private final int dx,dy,dz; private final int dx,dy,dz;
private final Vector mutable = new Vector(); private final MutableBlockVector mutable = new MutableBlockVector();
private final Pattern pattern; private final Pattern pattern;
public OffsetPattern(Pattern pattern, int dx, int dy, int dz) { public OffsetPattern(Pattern pattern, int dx, int dy, int dz) {
@ -20,9 +21,9 @@ public class OffsetPattern extends AbstractPattern {
@Override @Override
public BaseBlock apply(Vector position) { public BaseBlock apply(Vector position) {
mutable.x = (position.getX() + dx); mutable.mutX((position.getX() + dx));
mutable.y = (position.getY() + dy); mutable.mutY((position.getY() + dy));
mutable.z = (position.getZ() + dz); mutable.mutZ((position.getZ() + dz));
return pattern.apply(mutable); return pattern.apply(mutable);
} }
} }

View File

@ -1,6 +1,7 @@
package com.boydti.fawe.object.pattern; package com.boydti.fawe.object.pattern;
import com.boydti.fawe.object.PseudoRandom; import com.boydti.fawe.object.PseudoRandom;
import com.sk89q.worldedit.MutableBlockVector;
import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.blocks.BaseBlock; import com.sk89q.worldedit.blocks.BaseBlock;
import com.sk89q.worldedit.function.pattern.AbstractPattern; import com.sk89q.worldedit.function.pattern.AbstractPattern;
@ -10,7 +11,7 @@ public class RandomOffsetPattern extends AbstractPattern {
private final PseudoRandom r = new PseudoRandom(); private final PseudoRandom r = new PseudoRandom();
private final int dx, dy, dz, dx2, dy2, dz2; private final int dx, dy, dz, dx2, dy2, dz2;
private final Pattern pattern; private final Pattern pattern;
private final Vector mutable = new Vector(); private final MutableBlockVector mutable = new MutableBlockVector();
public RandomOffsetPattern(Pattern pattern, int dx, int dy, int dz) { public RandomOffsetPattern(Pattern pattern, int dx, int dy, int dz) {
this.pattern = pattern; this.pattern = pattern;
@ -25,9 +26,9 @@ public class RandomOffsetPattern extends AbstractPattern {
@Override @Override
public BaseBlock apply(Vector position) { public BaseBlock apply(Vector position) {
mutable.x = (position.getX() + r.nextInt(dx2) - dx); mutable.mutX((position.getX() + r.nextInt(dx2) - dx));
mutable.y = (position.getY() + r.nextInt(dy2) - dy); mutable.mutY((position.getY() + r.nextInt(dy2) - dy));
mutable.z = (position.getZ() + r.nextInt(dz2) - dz); mutable.mutZ((position.getZ() + r.nextInt(dz2) - dz));
return pattern.apply(mutable); return pattern.apply(mutable);
} }
} }

View File

@ -1,5 +1,6 @@
package com.boydti.fawe.object.pattern; package com.boydti.fawe.object.pattern;
import com.sk89q.worldedit.MutableBlockVector;
import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.blocks.BaseBlock; import com.sk89q.worldedit.blocks.BaseBlock;
import com.sk89q.worldedit.function.pattern.AbstractPattern; import com.sk89q.worldedit.function.pattern.AbstractPattern;
@ -14,16 +15,16 @@ public class RelativePattern extends AbstractPattern implements ResettablePatter
} }
private Vector origin; private Vector origin;
private Vector mutable = new Vector(); private MutableBlockVector mutable = new MutableBlockVector();
@Override @Override
public BaseBlock apply(Vector pos) { public BaseBlock apply(Vector pos) {
if (origin == null) { if (origin == null) {
origin = new Vector(pos); origin = new Vector(pos);
} }
mutable.x = (pos.getX() - origin.getX()); mutable.mutX((pos.getX() - origin.getX()));
mutable.y = (pos.getY() - origin.getY()); mutable.mutY((pos.getY() - origin.getY()));
mutable.z = (pos.getZ() - origin.getZ()); mutable.mutZ((pos.getZ() - origin.getZ()));
return pattern.apply(mutable); return pattern.apply(mutable);
} }

View File

@ -2,6 +2,7 @@ package com.boydti.fawe.object.pattern;
import com.boydti.fawe.FaweCache; import com.boydti.fawe.FaweCache;
import com.boydti.fawe.object.PseudoRandom; import com.boydti.fawe.object.PseudoRandom;
import com.sk89q.worldedit.MutableBlockVector;
import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.blocks.BaseBlock; import com.sk89q.worldedit.blocks.BaseBlock;
import com.sk89q.worldedit.blocks.BlockType; import com.sk89q.worldedit.blocks.BlockType;
@ -12,7 +13,7 @@ public class SolidRandomOffsetPattern extends AbstractPattern {
private final PseudoRandom r = new PseudoRandom(); private final PseudoRandom r = new PseudoRandom();
private final int dx, dy, dz, dx2, dy2, dz2; private final int dx, dy, dz, dx2, dy2, dz2;
private final Pattern pattern; private final Pattern pattern;
private final Vector mutable = new Vector(); private final MutableBlockVector mutable = new MutableBlockVector();
boolean[] solid; boolean[] solid;
public SolidRandomOffsetPattern(Pattern pattern, int dx, int dy, int dz) { public SolidRandomOffsetPattern(Pattern pattern, int dx, int dy, int dz) {
@ -35,9 +36,9 @@ public class SolidRandomOffsetPattern extends AbstractPattern {
@Override @Override
public BaseBlock apply(Vector position) { public BaseBlock apply(Vector position) {
mutable.x = (position.getX() + r.nextInt(dx2) - dx); mutable.mutX((position.getX() + r.nextInt(dx2) - dx));
mutable.y = (position.getY() + r.nextInt(dy2) - dy); mutable.mutY((position.getY() + r.nextInt(dy2) - dy));
mutable.z = (position.getZ() + r.nextInt(dz2) - dz); mutable.mutZ((position.getZ() + r.nextInt(dz2) - dz));
BaseBlock block = pattern.apply(mutable); BaseBlock block = pattern.apply(mutable);
if (solid[FaweCache.getCombined(block)]) { if (solid[FaweCache.getCombined(block)]) {
return block; return block;

View File

@ -2,6 +2,7 @@ package com.boydti.fawe.object.pattern;
import com.boydti.fawe.FaweCache; import com.boydti.fawe.FaweCache;
import com.boydti.fawe.object.PseudoRandom; import com.boydti.fawe.object.PseudoRandom;
import com.sk89q.worldedit.MutableBlockVector;
import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.blocks.BaseBlock; import com.sk89q.worldedit.blocks.BaseBlock;
import com.sk89q.worldedit.blocks.BlockType; import com.sk89q.worldedit.blocks.BlockType;
@ -12,7 +13,7 @@ public class SurfaceRandomOffsetPattern extends AbstractPattern {
private final PseudoRandom r = new PseudoRandom(); private final PseudoRandom r = new PseudoRandom();
private final int dx, dy, dz, dx2, dy2, dz2; private final int dx, dy, dz, dx2, dy2, dz2;
private final Pattern pattern; private final Pattern pattern;
private final Vector mutable = new Vector(); private final MutableBlockVector mutable = new MutableBlockVector();
boolean[] solid; boolean[] solid;
public SurfaceRandomOffsetPattern(Pattern pattern, int dx, int dy, int dz) { public SurfaceRandomOffsetPattern(Pattern pattern, int dx, int dy, int dz) {
@ -35,12 +36,12 @@ public class SurfaceRandomOffsetPattern extends AbstractPattern {
@Override @Override
public BaseBlock apply(Vector position) { public BaseBlock apply(Vector position) {
mutable.x = (position.getX() + r.nextInt(dx2) - dx); mutable.mutX((position.getX() + r.nextInt(dx2) - dx));
mutable.y = (position.getY() + r.nextInt(dy2) - dy); mutable.mutY((position.getY() + r.nextInt(dy2) - dy));
mutable.z = (position.getZ() + r.nextInt(dz2) - dz); mutable.mutZ((position.getZ() + r.nextInt(dz2) - dz));
BaseBlock block = pattern.apply(mutable); BaseBlock block = pattern.apply(mutable);
if (solid[FaweCache.getCombined(block)]) { if (solid[FaweCache.getCombined(block)]) {
mutable.y++; mutable.mutY(mutable.getY() + 1);
if (!solid[FaweCache.getCombined(pattern.apply(mutable))]) { if (!solid[FaweCache.getCombined(pattern.apply(mutable))]) {
return block; return block;
} }

View File

@ -68,9 +68,9 @@ public class FuzzyRegion extends AbstractRegion {
int b2 = ((byte) (index >> 8)) & 0x7F; int b2 = ((byte) (index >> 8)) & 0x7F;
int b3 = ((byte)(index >> 15)) & 0xFF; int b3 = ((byte)(index >> 15)) & 0xFF;
int b4 = ((byte) (index >> 23)) & 0xFF; int b4 = ((byte) (index >> 23)) & 0xFF;
pos.x = offsetX + (((b3 + ((MathMan.unpair8x(b2)) << 8)) << 21) >> 21); pos.mutX(offsetX + (((b3 + ((MathMan.unpair8x(b2)) << 8)) << 21) >> 21));
pos.y = offsetY + b1; pos.mutY(offsetY + b1);
pos.z = offsetZ + (((b4 + ((MathMan.unpair8y(b2)) << 8)) << 21) >> 21); pos.mutZ(offsetZ + (((b4 + ((MathMan.unpair8y(b2)) << 8)) << 21) >> 21));
return pos; return pos;
} }

View File

@ -17,6 +17,7 @@ import com.sk89q.jnbt.NamedTag;
import com.sk89q.jnbt.StringTag; import com.sk89q.jnbt.StringTag;
import com.sk89q.jnbt.Tag; import com.sk89q.jnbt.Tag;
import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.MutableBlockVector;
import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.blocks.BaseBlock; import com.sk89q.worldedit.blocks.BaseBlock;
@ -311,13 +312,13 @@ public class FaweFormat implements ClipboardReader, ClipboardWriter {
out.writeShort((short) origin.getBlockX()); out.writeShort((short) origin.getBlockX());
out.writeShort((short) origin.getBlockY()); out.writeShort((short) origin.getBlockY());
out.writeShort((short) origin.getBlockZ()); out.writeShort((short) origin.getBlockZ());
Vector mutable = new Vector(0, 0, 0); MutableBlockVector mutable = new MutableBlockVector(0, 0, 0);
for (int y = min.getBlockY(); y <= max.getBlockY(); y++) { for (int y = min.getBlockY(); y <= max.getBlockY(); y++) {
mutable.y = y; mutable.mutY(y);
for (int x = min.getBlockX(); x <= max.getBlockX(); x++) { for (int x = min.getBlockX(); x <= max.getBlockX(); x++) {
mutable.x = x; mutable.mutX(x);
for (int z = min.getBlockZ(); z <= max.getBlockZ(); z++) { for (int z = min.getBlockZ(); z <= max.getBlockZ(); z++) {
mutable.z = z; mutable.mutZ(z);
BaseBlock block = clipboard.getBlock(mutable); BaseBlock block = clipboard.getBlock(mutable);
if (block == EditSession.nullBlock) { if (block == EditSession.nullBlock) {
out.writeShort((short) 0); out.writeShort((short) 0);

View File

@ -2,6 +2,7 @@ package com.boydti.fawe.object.schematic;
import com.boydti.fawe.FaweCache; import com.boydti.fawe.FaweCache;
import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.MutableBlockVector;
import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.blocks.BaseBlock; import com.sk89q.worldedit.blocks.BaseBlock;
import com.sk89q.worldedit.extent.clipboard.Clipboard; import com.sk89q.worldedit.extent.clipboard.Clipboard;
@ -80,7 +81,7 @@ public class PNGWriter implements ClipboardWriter {
boolean fill = length * 4 < imageSize && width * 4 < imageSize; boolean fill = length * 4 < imageSize && width * 4 < imageSize;
Vector mutable = new Vector(0, 0, 0); MutableBlockVector mutable = new MutableBlockVector(0, 0, 0);
Vector mutableTop = new Vector(0, 0, 0); Vector mutableTop = new Vector(0, 0, 0);
Vector mutableRight = new Vector(0, 0, 0); Vector mutableRight = new Vector(0, 0, 0);
Vector mutableLeft = new Vector(0, 0, 0); Vector mutableLeft = new Vector(0, 0, 0);
@ -90,30 +91,30 @@ public class PNGWriter implements ClipboardWriter {
int z0 = min.getBlockZ(); int z0 = min.getBlockZ();
int x0 = min.getBlockX(); int x0 = min.getBlockX();
for (int x = x0; x < x0 + width; x++) { for (int x = x0; x < x0 + width; x++) {
mutable.x = x; mutable.mutX(x);
mutableTop.x = x; mutableTop.mutX(x);
mutableRight.x = x; mutableRight.mutX(x);
mutableLeft.x = x + 1; mutableLeft.mutX(x + 1);
int xx = x - x0; int xx = x - x0;
double cpx1 = -dpxi[xx]; double cpx1 = -dpxi[xx];
double cpy1 = dpyi[xx]; double cpy1 = dpyi[xx];
for (int z = z0; z < z0 + length; z++) { for (int z = z0; z < z0 + length; z++) {
mutable.z = z; mutable.mutZ(z);
mutableTop.z = z; mutableTop.mutZ(z);
mutableRight.z = z + 1; mutableRight.mutZ(z + 1);
mutableLeft.z = z; mutableLeft.mutZ(z);
int zz = z - z0; int zz = z - z0;
double cpx = cpx1 + dpxj[zz]; double cpx = cpx1 + dpxj[zz];
double cpy2 = cpy1 + dpyj[zz]; double cpy2 = cpy1 + dpyj[zz];
for (int y = y0; y < y0 + height; y++) { for (int y = y0; y < y0 + height; y++) {
mutable.y = y; mutable.mutY(y);
BaseBlock block = clipboard.getBlock(mutable); BaseBlock block = clipboard.getBlock(mutable);
if (block == EditSession.nullBlock) { if (block == EditSession.nullBlock) {
continue; continue;
} }
mutableTop.y = y + 1; mutableTop.mutY(y + 1);
mutableRight.y = y; mutableRight.mutY(y);
mutableLeft.y = y; mutableLeft.mutY(y);
if (clipboard.getBlock(mutableTop) != EditSession.nullBlock && clipboard.getBlock(mutableRight) != EditSession.nullBlock && clipboard.getBlock(mutableLeft) != EditSession.nullBlock) { if (clipboard.getBlock(mutableTop) != EditSession.nullBlock && clipboard.getBlock(mutableRight) != EditSession.nullBlock && clipboard.getBlock(mutableLeft) != EditSession.nullBlock) {
continue; continue;
} }

View File

@ -13,6 +13,7 @@ import com.sk89q.jnbt.NBTOutputStream;
import com.sk89q.jnbt.NamedTag; import com.sk89q.jnbt.NamedTag;
import com.sk89q.jnbt.StringTag; import com.sk89q.jnbt.StringTag;
import com.sk89q.jnbt.Tag; import com.sk89q.jnbt.Tag;
import com.sk89q.worldedit.MutableBlockVector;
import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.blocks.BaseBlock; import com.sk89q.worldedit.blocks.BaseBlock;
import com.sk89q.worldedit.entity.BaseEntity; import com.sk89q.worldedit.entity.BaseEntity;
@ -171,7 +172,7 @@ public class StructureFormat implements ClipboardReader, ClipboardWriter {
Map<String, Object> structure = FaweCache.asMap("version", 1, "author", owner); Map<String, Object> structure = FaweCache.asMap("version", 1, "author", owner);
// ignored: version / owner // ignored: version / owner
Vector mutable = new Vector(0, 0, 0); MutableBlockVector mutable = new MutableBlockVector(0, 0, 0);
int[] indexes = new int[MAX_SIZE]; int[] indexes = new int[MAX_SIZE];
// Size // Size
structure.put("size", Arrays.asList(width, height, length)); structure.put("size", Arrays.asList(width, height, length));

View File

@ -2,6 +2,7 @@ package com.boydti.fawe.object.visitor;
import com.boydti.fawe.config.BBC; import com.boydti.fawe.config.BBC;
import com.boydti.fawe.object.IntegerTrio; import com.boydti.fawe.object.IntegerTrio;
import com.sk89q.worldedit.MutableBlockVector;
import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.function.RegionFunction; import com.sk89q.worldedit.function.RegionFunction;
@ -76,7 +77,7 @@ public abstract class DFSVisitor implements Operation {
NodePair current; NodePair current;
Node from; Node from;
Node adjacent; Node adjacent;
Vector mutable = new Vector(); MutableBlockVector mutable = new MutableBlockVector();
Vector mutable2 = new Vector(); Vector mutable2 = new Vector();
int countAdd,countAttempt; int countAdd,countAttempt;
IntegerTrio[] dirs = getIntDirections(); IntegerTrio[] dirs = getIntDirections();
@ -88,16 +89,16 @@ public abstract class DFSVisitor implements Operation {
if (visited.containsKey(from)) { if (visited.containsKey(from)) {
continue; continue;
} }
mutable.x = from.getX(); mutable.mutX(from.getX());
mutable.y = from.getY(); mutable.mutY(from.getY());
mutable.z = from.getZ(); mutable.mutZ(from.getZ());
function.apply(mutable); function.apply(mutable);
countAdd = 0; countAdd = 0;
countAttempt = 0; countAttempt = 0;
for (IntegerTrio direction : dirs) { for (IntegerTrio direction : dirs) {
mutable2.x = from.getX() + direction.x; mutable2.mutX(from.getX() + direction.x);
mutable2.y = from.getY() + direction.y; mutable2.mutY(from.getY() + direction.y);
mutable2.z = from.getZ() + direction.z; mutable2.mutZ(from.getZ() + direction.z);
if (isVisitable(mutable, mutable2)) { if (isVisitable(mutable, mutable2)) {
adjacent = new Node(mutable2.getBlockX(), mutable2.getBlockY(), mutable2.getBlockZ()); adjacent = new Node(mutable2.getBlockX(), mutable2.getBlockY(), mutable2.getBlockZ());
if ((current.from == null || !adjacent.equals(current.from))) { if ((current.from == null || !adjacent.equals(current.from))) {

View File

@ -72,9 +72,9 @@ public class FuzzySearch implements Operation {
int x = offsetX + (((b3 + ((MathMan.unpair8x(b2)) << 8)) << 21) >> 21); int x = offsetX + (((b3 + ((MathMan.unpair8x(b2)) << 8)) << 21) >> 21);
int y = b1; int y = b1;
int z = offsetZ + (((b4 + ((MathMan.unpair8y(b2)) << 8)) << 21) >> 21); int z = offsetZ + (((b4 + ((MathMan.unpair8y(b2)) << 8)) << 21) >> 21);
pos.x = x; pos.mutX(x);
pos.y = y; pos.mutY(y);
pos.z = z; pos.mutZ(z);
if (mask.test(pos)) { if (mask.test(pos)) {
affected++; affected++;
region.set(x, y, z); region.set(x, y, z);

View File

@ -531,7 +531,7 @@ public class CuboidClipboard {
} }
if (aroundPlayer) { if (aroundPlayer) {
offset.x = 1 - offset.x - width; offset.mutX(1 - offset.getX() - width);
} }
break; break;
@ -565,7 +565,7 @@ public class CuboidClipboard {
} }
if (aroundPlayer) { if (aroundPlayer) {
offset.z = 1 - offset.getZ() - length; offset.mutZ(1 - offset.getZ() - length);
} }
break; break;
@ -597,7 +597,7 @@ public class CuboidClipboard {
} }
if (aroundPlayer) { if (aroundPlayer) {
offset.y = 1 - offset.getY() - height; offset.mutY(1 - offset.getY() - height);
} }
break; break;
@ -697,11 +697,11 @@ public class CuboidClipboard {
int oy = newOrigin.getBlockY(); int oy = newOrigin.getBlockY();
int oz = newOrigin.getBlockZ(); int oz = newOrigin.getBlockZ();
for (int x = 0; x < size.getBlockX(); ++x) { for (int x = 0; x < size.getBlockX(); ++x) {
v.x = x + ox; v.mutX(x + ox);
for (int y = 0; y < size.getBlockY(); ++y) { for (int y = 0; y < size.getBlockY(); ++y) {
v.y = y + oy; v.mutY(y + oy);
for (int z = 0; z < size.getBlockZ(); ++z) { for (int z = 0; z < size.getBlockZ(); ++z) {
v.z = z + oz; v.mutZ(z + oz);
final BaseBlock block = getBlock(x,y,z); final BaseBlock block = getBlock(x,y,z);
if (block == null) { if (block == null) {
continue; continue;

View File

@ -182,7 +182,7 @@ public class EditSession extends AbstractWorld implements HasFaweQueue, Lighting
private int changes = 0; private int changes = 0;
private BlockBag blockBag; private BlockBag blockBag;
private Vector mutable = new Vector(); private MutableBlockVector mutable = new MutableBlockVector();
private final int maxY; private final int maxY;
@ -1956,9 +1956,9 @@ public class EditSession extends AbstractWorld implements HasFaweQueue, Lighting
@Override @Override
// Only copy what's necessary // Only copy what's necessary
public boolean apply(Vector position) throws WorldEditException { public boolean apply(Vector position) throws WorldEditException {
mutable.x = (position.getX() - displace.getX()); mutable.mutX((position.getX() - displace.getX()));
mutable.y = (position.getY() - displace.getY()); mutable.mutY((position.getY() - displace.getY()));
mutable.z = (position.getZ() - displace.getZ()); mutable.mutZ((position.getZ() - displace.getZ()));
if (region.contains(mutable)) { if (region.contains(mutable)) {
return false; return false;
} }
@ -2157,11 +2157,11 @@ public class EditSession extends AbstractWorld implements HasFaweQueue, Lighting
return this.changes; return this.changes;
} else if (height < 0) { } else if (height < 0) {
height = -height; height = -height;
pos.y -= height; pos.mutY(pos.getY() - height);
} }
if (pos.getBlockY() < 0) { if (pos.getBlockY() < 0) {
pos.y = 0; pos.mutY(0);
} else if (((pos.getBlockY() + height) - 1) > maxY) { } else if (((pos.getBlockY() + height) - 1) > maxY) {
height = (maxY - pos.getBlockY()) + 1; height = (maxY - pos.getBlockY()) + 1;
} }
@ -3198,15 +3198,15 @@ public class EditSession extends AbstractWorld implements HasFaweQueue, Lighting
if (!chunks.contains(new Vector2D(cx + 1, cz + 1)) && !conNextX && !conNextZ) { if (!chunks.contains(new Vector2D(cx + 1, cz + 1)) && !conNextX && !conNextZ) {
setExistingBlocks(new Vector(bx + 16, 0, bz + 16), new Vector(bx + 31, getMaxY(), bz + 31)); setExistingBlocks(new Vector(bx + 16, 0, bz + 16), new Vector(bx + 31, getMaxY(), bz + 31));
} }
Vector mutable = new Vector(0,0,0); MutableBlockVector mutable = new MutableBlockVector(0,0,0);
for (int x = 0; x < tx; x++) { for (int x = 0; x < tx; x++) {
int xx = x + bx; int xx = x + bx;
mutable.x = xx; mutable.mutX(xx);
for (int z = 0; z < tz; z++) { for (int z = 0; z < tz; z++) {
int zz = z + bz; int zz = z + bz;
mutable.z = zz; mutable.mutZ(zz);
for (int y = 0; y < getMaxY() + 1; y++) { for (int y = 0; y < getMaxY() + 1; y++) {
mutable.y = y; mutable.mutY(y);
int from = queue.getCombinedId4Data(xx, y, zz); int from = queue.getCombinedId4Data(xx, y, zz);
boolean contains = (fe == null || fe.contains(xx, y, zz)) && region.contains(mutable); boolean contains = (fe == null || fe.contains(xx, y, zz)) && region.contains(mutable);
if (contains) { if (contains) {

View File

@ -0,0 +1,81 @@
package com.sk89q.worldedit;
public class MutableBlockVector extends BlockVector {
private int x,y,z;
public MutableBlockVector(int x, int y, int z) {
super(0, 0, 0);
this.x = x;
this.y = y;
this.z = z;
}
public MutableBlockVector() {
super(0, 0, 0);
}
@Override
public Vector setComponents(double x, double y, double z) {
return this.setComponents((int) x, (int) y, (int) z);
}
@Override
public final void mutX(double x) {
this.x = (int) x;
}
@Override
public final void mutY(double y) {
this.y = (int) y;
}
@Override
public final void mutZ(double z) {
this.z = (int) z;
}
@Override
public final void mutX(int x) {
this.x = x;
}
@Override
public final void mutY(int y) {
this.y = y;
}
@Override
public final void mutZ(int z) {
this.z = z;
}
@Override
public final double getX() {
return x;
}
@Override
public final double getY() {
return y;
}
@Override
public final double getZ() {
return z;
}
@Override
public int getBlockX() {
return this.x;
}
@Override
public int getBlockY() {
return this.y;
}
@Override
public int getBlockZ() {
return this.z;
}
}

View File

@ -34,9 +34,9 @@ public class Vector implements Comparable<Vector> {
public static final Vector UNIT_Z = new Vector(0, 0, 1); public static final Vector UNIT_Z = new Vector(0, 0, 1);
public static final Vector ONE = new Vector(1, 1, 1); public static final Vector ONE = new Vector(1, 1, 1);
public double x; private double x;
public double y; private double y;
public double z; private double z;
/** /**
* Construct an instance. * Construct an instance.
@ -46,9 +46,9 @@ public class Vector implements Comparable<Vector> {
* @param z the Z coordinate * @param z the Z coordinate
*/ */
public Vector(double x, double y, double z) { public Vector(double x, double y, double z) {
this.x = x; this.mutX(x);
this.y = y; this.mutY(y);
this.z = z; this.mutZ(z);
} }
/** /**
@ -59,9 +59,9 @@ public class Vector implements Comparable<Vector> {
* @param z the Z coordinate * @param z the Z coordinate
*/ */
public Vector(int x, int y, int z) { public Vector(int x, int y, int z) {
this.x = x; this.mutX(x);
this.y = y; this.mutY(y);
this.z = z; this.mutZ(z);
} }
/** /**
@ -72,9 +72,9 @@ public class Vector implements Comparable<Vector> {
* @param z the Z coordinate * @param z the Z coordinate
*/ */
public Vector(float x, float y, float z) { public Vector(float x, float y, float z) {
this.x = x; this.mutX(x);
this.y = y; this.mutY(y);
this.z = z; this.mutZ(z);
} }
/** /**
@ -83,9 +83,9 @@ public class Vector implements Comparable<Vector> {
* @param other another vector to make a copy of * @param other another vector to make a copy of
*/ */
public Vector(Vector other) { public Vector(Vector other) {
this.x = other.x; this.mutX(other.getX());
this.y = other.y; this.mutY(other.getY());
this.z = other.z; this.mutZ(other.getZ());
} }
/** /**
@ -94,9 +94,47 @@ public class Vector implements Comparable<Vector> {
* <p>One can also refer to a static {@link #ZERO}.</p> * <p>One can also refer to a static {@link #ZERO}.</p>
*/ */
public Vector() { public Vector() {
this.x = 0; this.mutX(0);
this.y = 0; this.mutY(0);
this.z = 0; this.mutZ(0);
}
public Vector setComponents(int x, int y, int z) {
this.mutX(x);
this.mutY(y);
this.mutZ(z);
return this;
}
public Vector setComponents(double x, double y, double z) {
this.mutX(x);
this.mutY(y);
this.mutZ(z);
return this;
}
public void mutX(int x) {
this.x = x;
}
public void mutY(int y) {
this.y = y;
}
public void mutZ(int z) {
this.z = z;
}
public void mutX(double x) {
this.x = x;
}
public void mutY(double y) {
this.y = y;
}
public void mutZ(double z) {
this.z = z;
} }
/** /**
@ -104,7 +142,7 @@ public class Vector implements Comparable<Vector> {
* *
* @return the x coordinate * @return the x coordinate
*/ */
public final double getX() { public double getX() {
return x; return x;
} }
@ -142,7 +180,7 @@ public class Vector implements Comparable<Vector> {
* *
* @return the y coordinate * @return the y coordinate
*/ */
public final double getY() { public double getY() {
return y; return y;
} }
@ -180,7 +218,7 @@ public class Vector implements Comparable<Vector> {
* *
* @return the z coordinate * @return the z coordinate
*/ */
public final double getZ() { public double getZ() {
return z; return z;
} }

View File

@ -360,7 +360,7 @@ public class BrushCommands {
public void heightBrush(Player player, LocalSession session, @Optional("5") double radius, @Optional("") final String filename, @Optional("0") final int rotation, @Optional("1") final double yscale) throws WorldEditException { public void heightBrush(Player player, LocalSession session, @Optional("5") double radius, @Optional("") final String filename, @Optional("0") final int rotation, @Optional("1") final double yscale) throws WorldEditException {
worldEdit.checkMaxBrushRadius(radius); worldEdit.checkMaxBrushRadius(radius);
File file = new File(Fawe.imp().getDirectory(), "heightmap" + File.separator + (filename.endsWith(".png") ? filename : filename + ".png")); File file = new File(Fawe.imp().getDirectory(), "heightmap" + File.separator + (filename.endsWith(".png") ? filename : filename + ".png"));
BrushTool tool = session.getBrushTool(player.getItemInHand()); DoubleActionBrushTool tool = session.getDoubleActionBrushTool(player.getItemInHand());
tool.setSize(radius); tool.setSize(radius);
try { try {
tool.setBrush(new HeightBrush(file, rotation, yscale, tool, session.getClipboard().getClipboard()), "worldedit.brush.height"); tool.setBrush(new HeightBrush(file, rotation, yscale, tool, session.getClipboard().getClipboard()), "worldedit.brush.height");

View File

@ -363,12 +363,12 @@ public class ClipboardCommands {
BlockArrayClipboard bac = (BlockArrayClipboard) clipboard; BlockArrayClipboard bac = (BlockArrayClipboard) clipboard;
bac.IMP.forEach(new RunnableVal2<Vector, BaseBlock>() { bac.IMP.forEach(new RunnableVal2<Vector, BaseBlock>() {
@Override @Override
public void run(Vector pos, BaseBlock block) { public void run(Vector mutable, BaseBlock block) {
pos.x += relx; mutable.mutX(mutable.getX() + relx);
pos.y += rely; mutable.mutY(mutable.getY() + rely);
pos.z += relz; mutable.mutZ(mutable.getZ() + relz);
if (pos.getY() >= 0 && pos.getY() <= maxY) { if (mutable.getY() >= 0 && mutable.getY() <= maxY) {
editSession.setBlockFast(pos, block); editSession.setBlockFast(mutable, block);
} }
} }
}, !ignoreAirBlocks); }, !ignoreAirBlocks);
@ -379,16 +379,16 @@ public class ClipboardCommands {
final int relz = to.getBlockZ() - origin.getBlockZ(); final int relz = to.getBlockZ() - origin.getBlockZ();
Iterator<BlockVector> iter = region.iterator(); Iterator<BlockVector> iter = region.iterator();
while (iter.hasNext()) { while (iter.hasNext()) {
BlockVector loc = iter.next(); BlockVector mutable = iter.next();
BaseBlock block = clipboard.getBlock(loc); BaseBlock block = clipboard.getBlock(mutable);
if (block == EditSession.nullBlock && ignoreAirBlocks) { if (block == EditSession.nullBlock && ignoreAirBlocks) {
continue; continue;
} }
loc.x += relx; mutable.mutX(mutable.getX() + relx);
loc.y += rely; mutable.mutY(mutable.getY() + rely);
loc.z += relz; mutable.mutZ(mutable.getZ() + relz);
if (loc.getY() >= 0 && loc.getY() <= maxY) { if (mutable.getY() >= 0 && mutable.getY() <= maxY) {
editSession.setBlockFast(loc, block); editSession.setBlockFast(mutable, block);
} }
} }
} }

View File

@ -80,15 +80,17 @@ public class FlattenedClipboardTransform {
transform, transform,
new AffineTransform().translate(original.getOrigin())); new AffineTransform().translate(original.getOrigin()));
// new Vector(minimum.getX(), minimum.getY(), minimum.getZ())
// new Vector(maximum.getX(), maximum.getY(), maximum.getZ())
Vector[] corners = new Vector[] { Vector[] corners = new Vector[] {
minimum, minimum,
maximum, maximum,
minimum.setX(maximum.getX()), new Vector(maximum.getX(), minimum.getY(), minimum.getZ()),
minimum.setY(maximum.getY()), new Vector(minimum.getX(), maximum.getY(), minimum.getZ()),
minimum.setZ(maximum.getZ()), new Vector(minimum.getX(), minimum.getY(), maximum.getZ()),
maximum.setX(minimum.getX()), new Vector(minimum.getX(), maximum.getY(), maximum.getZ()),
maximum.setY(minimum.getY()), new Vector(maximum.getX(), minimum.getY(), maximum.getZ()),
maximum.setZ(minimum.getZ()) }; new Vector(maximum.getX(), maximum.getY(), minimum.getZ()) };
for (int i = 0; i < corners.length; i++) { for (int i = 0; i < corners.length; i++) {
corners[i] = transformAround.apply(new Vector(corners[i])); corners[i] = transformAround.apply(new Vector(corners[i]));
@ -104,13 +106,9 @@ public class FlattenedClipboardTransform {
// After transformation, the points may not really sit on a block, // After transformation, the points may not really sit on a block,
// so we should expand the region for edge cases // so we should expand the region for edge cases
newMinimum = newMinimum.setX(Math.floor(newMinimum.getX())); newMinimum.mutX(Math.ceil(Math.floor(newMinimum.getX())));
newMinimum = newMinimum.setY(Math.floor(newMinimum.getY())); newMinimum.mutY(Math.ceil(Math.floor(newMinimum.getY())));
newMinimum = newMinimum.setZ(Math.floor(newMinimum.getZ())); newMinimum.mutZ(Math.ceil(Math.floor(newMinimum.getZ())));
newMaximum = newMaximum.setX(Math.ceil(newMaximum.getX()));
newMaximum = newMaximum.setY(Math.ceil(newMaximum.getY()));
newMaximum = newMaximum.setZ(Math.ceil(newMaximum.getZ()));
return new CuboidRegion(newMinimum, newMaximum); return new CuboidRegion(newMinimum, newMaximum);
} }

View File

@ -301,9 +301,9 @@ public class GenerationCommands {
zero = max.add(min).multiply(0.5); zero = max.add(min).multiply(0.5);
unit = max.subtract(zero); unit = max.subtract(zero);
if (unit.getX() == 0) unit.x = 1; if (unit.getX() == 0) unit.mutX(1);
if (unit.getY() == 0) unit.y = 1; if (unit.getY() == 0) unit.mutY(1);
if (unit.getZ() == 0) unit.z = 1; if (unit.getZ() == 0) unit.mutZ(1);
} }
try { try {
@ -366,9 +366,9 @@ public class GenerationCommands {
zero = max.add(min).multiply(0.5); zero = max.add(min).multiply(0.5);
unit = max.subtract(zero); unit = max.subtract(zero);
if (unit.getX() == 0) unit.x = 1; if (unit.getX() == 0) unit.mutX(1);
if (unit.getY() == 0) unit.y = 1; if (unit.getY() == 0) unit.mutY(1);
if (unit.getZ() == 0) unit.z = 1; if (unit.getZ() == 0) unit.mutZ(1);
} }
try { try {

View File

@ -170,9 +170,9 @@ public class HistoryCommands {
final World world = player.getWorld(); final World world = player.getWorld();
WorldVector origin = player.getPosition(); WorldVector origin = player.getPosition();
Vector bot = origin.subtract(radius, radius, radius); Vector bot = origin.subtract(radius, radius, radius);
bot.y = Math.max(0, bot.getY()); bot.mutY(Math.max(0, bot.getY()));
Vector top = origin.add(radius, radius, radius); Vector top = origin.add(radius, radius, radius);
top.y = Math.min(255, top.getY()); top.mutY(Math.min(255, top.getY()));
RollbackDatabase database = DBHandler.IMP.getDatabase(world); RollbackDatabase database = DBHandler.IMP.getDatabase(world);
final AtomicInteger count = new AtomicInteger(); final AtomicInteger count = new AtomicInteger();
final FawePlayer fp = FawePlayer.wrap(player); final FawePlayer fp = FawePlayer.wrap(player);

View File

@ -595,9 +595,9 @@ public class RegionCommands {
zero = max.add(min).multiply(0.5); zero = max.add(min).multiply(0.5);
unit = max.subtract(zero); unit = max.subtract(zero);
if (unit.getX() == 0) unit.x = 1; if (unit.getX() == 0) unit.mutX(1);
if (unit.getY() == 0) unit.y = 1; if (unit.getY() == 0) unit.mutY(1);
if (unit.getZ() == 0) unit.z = 1; if (unit.getZ() == 0) unit.mutZ(1);
} }
try { try {

View File

@ -60,14 +60,14 @@ public class GravityBrush implements Brush {
continue; continue;
} }
BaseBlock block = editSession.getLazyBlock(x, y, z); BaseBlock block = editSession.getLazyBlock(x, y, z);
mutablePos.x = x; mutablePos.mutX(x);
mutablePos.y = y; mutablePos.mutY(y);
mutablePos.z = z; mutablePos.mutZ(z);
if (block != EditSession.nullBlock && (mask == null || mask.test(mutablePos))) { if (block != EditSession.nullBlock && (mask == null || mask.test(mutablePos))) {
if (freeSpot != y) { if (freeSpot != y) {
mutablePos.y = freeSpot; mutablePos.mutY(freeSpot);
editSession.setBlockFast(mutablePos, block); editSession.setBlockFast(mutablePos, block);
mutablePos.y = y; mutablePos.mutY(y);
editSession.setBlockFast(mutablePos, EditSession.nullBlock); editSession.setBlockFast(mutablePos, EditSession.nullBlock);
} }
freeSpot++; freeSpot++;

View File

@ -74,7 +74,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
*/ */
public class PlatformManager { public class PlatformManager {
private static final Logger logger = Logger.getLogger(PlatformManager.class.getCanonicalName()); private final Logger logger = Logger.getLogger(PlatformManager.class.getCanonicalName());
private final WorldEdit worldEdit; private final WorldEdit worldEdit;
private final CommandManager commandManager; private final CommandManager commandManager;
@ -337,6 +337,10 @@ public class PlatformManager {
return tool; return tool;
} }
public void handleMove() {
}
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
@Subscribe @Subscribe
public void handleBlockInteract(BlockInteractEvent event) { public void handleBlockInteract(BlockInteractEvent event) {

View File

@ -20,6 +20,7 @@
package com.sk89q.worldedit.extent; package com.sk89q.worldedit.extent;
import com.boydti.fawe.object.extent.LightingExtent; import com.boydti.fawe.object.extent.LightingExtent;
import com.sk89q.worldedit.MutableBlockVector;
import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.Vector2D; import com.sk89q.worldedit.Vector2D;
import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.WorldEditException;
@ -114,12 +115,12 @@ public abstract class AbstractDelegateExtent implements LightingExtent {
return extent.getLazyBlock(position); return extent.getLazyBlock(position);
} }
private Vector mutable = new Vector(0,0,0); private MutableBlockVector mutable = new MutableBlockVector(0,0,0);
public BaseBlock getLazyBlock(int x, int y, int z) { public BaseBlock getLazyBlock(int x, int y, int z) {
mutable.x = x; mutable.mutX(x);
mutable.y = y; mutable.mutY(y);
mutable.z = z; mutable.mutZ(z);
return extent.getLazyBlock(mutable); return extent.getLazyBlock(mutable);
} }
@ -129,9 +130,9 @@ public abstract class AbstractDelegateExtent implements LightingExtent {
} }
public boolean setBlock(int x, int y, int z, BaseBlock block) throws WorldEditException { public boolean setBlock(int x, int y, int z, BaseBlock block) throws WorldEditException {
mutable.x = x; mutable.mutX(x);
mutable.y = y; mutable.mutY(y);
mutable.z = z; mutable.mutZ(z);
return setBlock(mutable, block); return setBlock(mutable, block);
} }

View File

@ -26,6 +26,7 @@ import com.boydti.fawe.object.clipboard.MemoryOptimizedClipboard;
import com.boydti.fawe.object.extent.LightingExtent; import com.boydti.fawe.object.extent.LightingExtent;
import com.sk89q.jnbt.CompoundTag; import com.sk89q.jnbt.CompoundTag;
import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.MutableBlockVector;
import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.Vector2D; import com.sk89q.worldedit.Vector2D;
import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.WorldEditException;
@ -60,7 +61,7 @@ public class BlockArrayClipboard implements Clipboard, LightingExtent {
private int my; private int my;
private int mz; private int mz;
private Vector origin; private Vector origin;
private Vector mutable = new Vector(); private MutableBlockVector mutable = new MutableBlockVector();
public BlockArrayClipboard(Region region) { public BlockArrayClipboard(Region region) {
checkNotNull(region); checkNotNull(region);
@ -249,9 +250,9 @@ public class BlockArrayClipboard implements Clipboard, LightingExtent {
@Override @Override
public int getOpacity(int x, int y, int z) { public int getOpacity(int x, int y, int z) {
mutable.x = x; mutable.mutX(x);
mutable.y = y; mutable.mutY(y);
mutable.z = z; mutable.mutZ(z);
BlockMaterial block = BundledBlockData.getInstance().getMaterialById(getBlock(mutable).getId()); BlockMaterial block = BundledBlockData.getInstance().getMaterialById(getBlock(mutable).getId());
if (block == null) { if (block == null) {
return 15; return 15;
@ -261,9 +262,9 @@ public class BlockArrayClipboard implements Clipboard, LightingExtent {
@Override @Override
public int getBrightness(int x, int y, int z) { public int getBrightness(int x, int y, int z) {
mutable.x = x; mutable.mutX(x);
mutable.y = y; mutable.mutY(y);
mutable.z = z; mutable.mutZ(z);
BlockMaterial block = BundledBlockData.getInstance().getMaterialById(getBlock(mutable).getId()); BlockMaterial block = BundledBlockData.getInstance().getMaterialById(getBlock(mutable).getId());
if (block == null) { if (block == null) {
return 15; return 15;

View File

@ -16,6 +16,7 @@ import com.sk89q.jnbt.NBTOutputStream;
import com.sk89q.jnbt.ShortTag; import com.sk89q.jnbt.ShortTag;
import com.sk89q.jnbt.StringTag; import com.sk89q.jnbt.StringTag;
import com.sk89q.jnbt.Tag; import com.sk89q.jnbt.Tag;
import com.sk89q.worldedit.MutableBlockVector;
import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.blocks.BaseBlock; import com.sk89q.worldedit.blocks.BaseBlock;
import com.sk89q.worldedit.entity.BaseEntity; import com.sk89q.worldedit.entity.BaseEntity;
@ -286,12 +287,12 @@ public class SchematicWriter implements ClipboardWriter {
final int mx = min.getBlockX(); final int mx = min.getBlockX();
final int my = min.getBlockY(); final int my = min.getBlockY();
final int mz = min.getBlockZ(); final int mz = min.getBlockZ();
Vector mutable = new Vector(0, 0, 0); MutableBlockVector mutable = new MutableBlockVector(0, 0, 0);
ForEach forEach = new ForEach(yarea, zwidth, blocks, blockData, tileEntities); ForEach forEach = new ForEach(yarea, zwidth, blocks, blockData, tileEntities);
for (Vector point : region) { for (Vector point : region) {
mutable.x = (point.getX() - mx); mutable.mutX((point.getX() - mx));
mutable.y = (point.getY() - my); mutable.mutY((point.getY() - my));
mutable.z = (point.getZ() - mz); mutable.mutZ((point.getZ() - mz));
forEach.run(mutable, clipboard.getBlock(point)); forEach.run(mutable, clipboard.getBlock(point));
} }
addBlocks = forEach.addBlocks; addBlocks = forEach.addBlocks;

View File

@ -101,9 +101,9 @@ public class ExtentBlockCopy implements RegionFunction {
if (direction != null) { if (direction != null) {
Vector applyAbsolute = transform.apply(direction.toVector()); Vector applyAbsolute = transform.apply(direction.toVector());
Vector applyOrigin = transform.apply(Vector.ZERO); Vector applyOrigin = transform.apply(Vector.ZERO);
applyAbsolute.x -= applyOrigin.getX(); applyAbsolute.mutX(applyAbsolute.getX() - applyOrigin.getX());
applyAbsolute.y -= applyOrigin.getY(); applyAbsolute.mutY(applyAbsolute.getY() - applyOrigin.getY());
applyAbsolute.z -= applyOrigin.getZ(); applyAbsolute.mutZ(applyAbsolute.getZ() - applyOrigin.getZ());
Direction newDirection = Direction.findClosest(applyAbsolute, Flag.CARDINAL | Flag.ORDINAL | Flag.SECONDARY_ORDINAL); Direction newDirection = Direction.findClosest(applyAbsolute, Flag.CARDINAL | Flag.ORDINAL | Flag.SECONDARY_ORDINAL);

View File

@ -1,9 +1,10 @@
package com.sk89q.worldedit.function.mask; package com.sk89q.worldedit.function.mask;
import com.sk89q.worldedit.MutableBlockVector;
import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.Vector;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
/** /**
@ -14,7 +15,7 @@ public class OffsetMask extends AbstractMask {
private Mask mask; private Mask mask;
private Vector offset; private Vector offset;
private Vector mutable = new Vector(); private MutableBlockVector mutable = new MutableBlockVector();
/** /**
* Create a new instance. * Create a new instance.
@ -69,9 +70,9 @@ public class OffsetMask extends AbstractMask {
@Override @Override
public boolean test(Vector vector) { public boolean test(Vector vector) {
mutable.x = (vector.getX() + offset.getX()); mutable.mutX((vector.getX() + offset.getX()));
mutable.y = (vector.getY() + offset.getY()); mutable.mutY((vector.getY() + offset.getY()));
mutable.z = (vector.getZ() + offset.getZ()); mutable.mutZ((vector.getZ() + offset.getZ()));
return getMask().test(mutable); return getMask().test(mutable);
} }

View File

@ -1,9 +1,11 @@
package com.sk89q.worldedit.function.pattern; package com.sk89q.worldedit.function.pattern;
import com.sk89q.worldedit.MutableBlockVector;
import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.blocks.BaseBlock; import com.sk89q.worldedit.blocks.BaseBlock;
import com.sk89q.worldedit.extent.clipboard.Clipboard; import com.sk89q.worldedit.extent.clipboard.Clipboard;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
/** /**
@ -30,7 +32,7 @@ public class ClipboardPattern extends AbstractPattern {
this.min = clipboard.getMinimumPoint(); this.min = clipboard.getMinimumPoint();
} }
private Vector mutable = new Vector(); private MutableBlockVector mutable = new MutableBlockVector();
@Override @Override
public BaseBlock apply(Vector position) { public BaseBlock apply(Vector position) {
@ -40,9 +42,9 @@ public class ClipboardPattern extends AbstractPattern {
if (xp < 0) xp += sx; if (xp < 0) xp += sx;
if (yp < 0) yp += sy; if (yp < 0) yp += sy;
if (zp < 0) zp += sz; if (zp < 0) zp += sz;
mutable.x = (min.getX() + xp); mutable.mutX((min.getX() + xp));
mutable.y = (min.getY() + yp); mutable.mutY((min.getY() + yp));
mutable.z = (min.getZ() + zp); mutable.mutZ((min.getZ() + zp));
return clipboard.getBlock(mutable); return clipboard.getBlock(mutable);
} }

View File

@ -1,8 +1,10 @@
package com.sk89q.worldedit.function.pattern; package com.sk89q.worldedit.function.pattern;
import com.sk89q.worldedit.MutableBlockVector;
import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.blocks.BaseBlock; import com.sk89q.worldedit.blocks.BaseBlock;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
/** /**
@ -38,7 +40,7 @@ public final class Patterns {
public static com.sk89q.worldedit.patterns.Pattern wrap(final Pattern pattern) { public static com.sk89q.worldedit.patterns.Pattern wrap(final Pattern pattern) {
checkNotNull(pattern); checkNotNull(pattern);
return new com.sk89q.worldedit.patterns.Pattern() { return new com.sk89q.worldedit.patterns.Pattern() {
private Vector mutable = new Vector(0, 0, 0); private MutableBlockVector mutable = new MutableBlockVector(0, 0, 0);
@Override @Override
public BaseBlock next(Vector position) { public BaseBlock next(Vector position) {
return pattern.apply(position); return pattern.apply(position);
@ -46,9 +48,9 @@ public final class Patterns {
@Override @Override
public BaseBlock next(int x, int y, int z) { public BaseBlock next(int x, int y, int z) {
mutable.x = x; mutable.mutX(x);
mutable.y = y; mutable.mutY(y);
mutable.z = z; mutable.mutZ(z);
return next(mutable); return next(mutable);
} }
}; };

View File

@ -2,6 +2,7 @@ package com.sk89q.worldedit.function.visitor;
import com.boydti.fawe.config.BBC; import com.boydti.fawe.config.BBC;
import com.boydti.fawe.object.IntegerTrio; import com.boydti.fawe.object.IntegerTrio;
import com.sk89q.worldedit.MutableBlockVector;
import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.function.RegionFunction; import com.sk89q.worldedit.function.RegionFunction;
@ -97,7 +98,7 @@ public abstract class BreadthFirstSearch implements Operation {
public Operation resume(RunContext run) throws WorldEditException { public Operation resume(RunContext run) throws WorldEditException {
Node from; Node from;
Node adjacent; Node adjacent;
Vector mutable = new Vector(); MutableBlockVector mutable = new MutableBlockVector();
Vector mutable2 = new Vector(); Vector mutable2 = new Vector();
boolean shouldTrim = false; boolean shouldTrim = false;
IntegerTrio[] dirs = getIntDirections(); IntegerTrio[] dirs = getIntDirections();
@ -106,9 +107,9 @@ public abstract class BreadthFirstSearch implements Operation {
if (layer == maxDepth) { if (layer == maxDepth) {
cleanVisited(Integer.MAX_VALUE); cleanVisited(Integer.MAX_VALUE);
for (Node current : queue) { for (Node current : queue) {
mutable.x = current.getX(); mutable.mutX(current.getX());
mutable.y = current.getY(); mutable.mutY(current.getY());
mutable.z = current.getZ(); mutable.mutZ(current.getZ());
function.apply(mutable); function.apply(mutable);
affected++; affected++;
} }
@ -116,15 +117,15 @@ public abstract class BreadthFirstSearch implements Operation {
} }
for (int i = 0; i < size; i++) { for (int i = 0; i < size; i++) {
from = queue.poll(); from = queue.poll();
mutable.x = from.getX(); mutable.mutX(from.getX());
mutable.y = from.getY(); mutable.mutY(from.getY());
mutable.z = from.getZ(); mutable.mutZ(from.getZ());
function.apply(mutable); function.apply(mutable);
affected++; affected++;
for (IntegerTrio direction : dirs) { for (IntegerTrio direction : dirs) {
mutable2.x = from.getX() + direction.x; mutable2.mutX(from.getX() + direction.x);
mutable2.y = from.getY() + direction.y; mutable2.mutY(from.getY() + direction.y);
mutable2.z = from.getZ() + direction.z; mutable2.mutZ(from.getZ() + direction.z);
if (isVisitable(mutable, mutable2)) { if (isVisitable(mutable, mutable2)) {
adjacent = new Node(mutable2.getBlockX(), mutable2.getBlockY(), mutable2.getBlockZ()); adjacent = new Node(mutable2.getBlockX(), mutable2.getBlockY(), mutable2.getBlockZ());
if (!isVisited(adjacent)) { if (!isVisited(adjacent)) {

View File

@ -21,11 +21,12 @@
package com.sk89q.worldedit.math.interpolation; package com.sk89q.worldedit.math.interpolation;
import com.sk89q.worldedit.MutableBlockVector;
import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.Vector;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
/** /**
@ -136,7 +137,7 @@ public class KochanekBartelsInterpolation implements Interpolation {
return nodes.get(index).getPosition(); return nodes.get(index).getPosition();
} }
private Vector mutable = new Vector(); private MutableBlockVector mutable = new MutableBlockVector();
@Override @Override
public Vector getPosition(double position) { public Vector getPosition(double position) {
@ -158,9 +159,9 @@ public class KochanekBartelsInterpolation implements Interpolation {
double r2 = remainder * remainder; double r2 = remainder * remainder;
double r3 = r2 * remainder; double r3 = r2 * remainder;
mutable.x = (a.getX() * r3 + b.getX() * r2 + c.getX() * remainder + d.getX()); mutable.mutX((a.getX() * r3 + b.getX() * r2 + c.getX() * remainder + d.getX()));
mutable.y = (a.getY() * r3 + b.getY() * r2 + c.getY() * remainder + d.getY()); mutable.mutY((a.getY() * r3 + b.getY() * r2 + c.getY() * remainder + d.getY()));
mutable.z = (a.getZ() * r3 + b.getZ() * r2 + c.getZ() * remainder + d.getZ()); mutable.mutZ((a.getZ() * r3 + b.getZ() * r2 + c.getZ() * remainder + d.getZ()));
return mutable; return mutable;
} }

View File

@ -1,5 +1,6 @@
package com.sk89q.worldedit.math.transform; package com.sk89q.worldedit.math.transform;
import com.sk89q.worldedit.MutableBlockVector;
import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.math.MathUtils; import com.sk89q.worldedit.math.MathUtils;
@ -12,7 +13,7 @@ import com.sk89q.worldedit.math.MathUtils;
*/ */
public class AffineTransform implements Transform { public class AffineTransform implements Transform {
private Vector mutable = new Vector(); private MutableBlockVector mutable = new MutableBlockVector();
/** /**
* coefficients for x coordinate. * coefficients for x coordinate.
@ -274,9 +275,9 @@ public class AffineTransform implements Transform {
// vector.getX() * m00 + vector.getY() * m01 + vector.getZ() * m02 + m03 // vector.getX() * m00 + vector.getY() * m01 + vector.getZ() * m02 + m03
// vector.getX() * m10 + vector.getY() * m11 + vector.getZ() * m12 + m13 // vector.getX() * m10 + vector.getY() * m11 + vector.getZ() * m12 + m13
// vector.getX() * m20 + vector.getY() * m21 + vector.getZ() * m22 + m23 // vector.getX() * m20 + vector.getY() * m21 + vector.getZ() * m22 + m23
mutable.x = (vector.getX() * m00 + vector.getY() * m01 + vector.getZ() * m02 + m03); mutable.mutX((vector.getX() * m00 + vector.getY() * m01 + vector.getZ() * m02 + m03));
mutable.y = (vector.getX() * m10 + vector.getY() * m11 + vector.getZ() * m12 + m13); mutable.mutY((vector.getX() * m10 + vector.getY() * m11 + vector.getZ() * m12 + m13));
mutable.z = (vector.getX() * m20 + vector.getY() * m21 + vector.getZ() * m22 + m23); mutable.mutZ((vector.getX() * m20 + vector.getY() * m21 + vector.getZ() * m22 + m23));
return mutable; return mutable;
// return new Vector( // return new Vector(
// vector.getX() * m00 + vector.getY() * m01 + vector.getZ() * m02 + m03, // vector.getX() * m00 + vector.getY() * m01 + vector.getZ() * m02 + m03,

View File

@ -23,6 +23,7 @@ import com.boydti.fawe.config.Settings;
import com.boydti.fawe.object.collection.LocalBlockVectorSet; import com.boydti.fawe.object.collection.LocalBlockVectorSet;
import com.sk89q.worldedit.BlockVector; import com.sk89q.worldedit.BlockVector;
import com.sk89q.worldedit.LocalWorld; import com.sk89q.worldedit.LocalWorld;
import com.sk89q.worldedit.MutableBlockVector;
import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.Vector2D; import com.sk89q.worldedit.Vector2D;
import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.World;
@ -146,16 +147,16 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion {
return new RegionIntersection( return new RegionIntersection(
// Project to Z-Y plane // Project to Z-Y plane
new CuboidRegion(pos1.setX(min.getX()), pos2.setX(min.getX())), new CuboidRegion(new Vector(min.getX(), pos1.getY(), pos1.getZ()), new Vector(min.getX(), pos2.getY(), pos2.getZ())),
new CuboidRegion(pos1.setX(max.getX()), pos2.setX(max.getX())), new CuboidRegion(new Vector(max.getX(), pos1.getY(), pos1.getZ()), new Vector(max.getX(), pos2.getY(), pos2.getZ())),
// Project to X-Y plane // Project to X-Y plane
new CuboidRegion(pos1.setZ(min.getZ()), pos2.setZ(min.getZ())), new CuboidRegion(new Vector(pos1.getX(), pos1.getY(), min.getZ()), new Vector(pos2.getX(), pos2.getY(), min.getZ())),
new CuboidRegion(pos1.setZ(max.getZ()), pos2.setZ(max.getZ())), new CuboidRegion(new Vector(pos1.getX(), pos1.getY(), max.getZ()), new Vector(pos2.getX(), pos2.getY(), max.getZ())),
// Project to the X-Z plane // Project to the X-Z plane
new CuboidRegion(pos1.setY(min.getY()), pos2.setY(min.getY())), new CuboidRegion(new Vector(pos1.getX(), min.getY(), pos1.getZ()), new Vector(pos2.getX(), min.getY(), pos2.getZ())),
new CuboidRegion(pos1.setY(max.getY()), pos2.setY(max.getY()))); new CuboidRegion(new Vector(pos1.getX(), max.getY(), pos1.getZ()), new Vector(pos2.getX(), max.getY(), pos2.getZ())));
} }
/** /**
@ -170,12 +171,12 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion {
return new RegionIntersection( return new RegionIntersection(
// Project to Z-Y plane // Project to Z-Y plane
new CuboidRegion(pos1.setX(min.getX()), pos2.setX(min.getX())), new CuboidRegion(new Vector(min.getX(), pos1.getY(), pos1.getZ()), new Vector(min.getX(), pos2.getY(), pos2.getZ())),
new CuboidRegion(pos1.setX(max.getX()), pos2.setX(max.getX())), new CuboidRegion(new Vector(max.getX(), pos1.getY(), pos1.getZ()), new Vector(max.getX(), pos2.getY(), pos2.getZ())),
// Project to X-Y plane // Project to X-Y plane
new CuboidRegion(pos1.setZ(min.getZ()), pos2.setZ(min.getZ())), new CuboidRegion(new Vector(pos1.getX(), pos1.getY(), min.getZ()), new Vector(pos2.getX(), pos2.getY(), min.getZ())),
new CuboidRegion(pos1.setZ(max.getZ()), pos2.setZ(max.getZ()))); new CuboidRegion(new Vector(pos1.getX(), pos1.getY(), max.getZ()), new Vector(pos2.getX(), pos2.getY(), max.getZ())));
} }
@Override @Override
@ -359,7 +360,7 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion {
if (Settings.HISTORY.COMPRESSION_LEVEL >= 9) { if (Settings.HISTORY.COMPRESSION_LEVEL >= 9) {
return iterator_old(); return iterator_old();
} }
final BlockVector v = new BlockVector(0,0,0); final MutableBlockVector mutable = new MutableBlockVector(0,0,0);
return new Iterator<BlockVector>() { return new Iterator<BlockVector>() {
private Vector min = getMinimumPoint(); private Vector min = getMinimumPoint();
private Vector max = getMaximumPoint(); private Vector max = getMaximumPoint();
@ -392,9 +393,9 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion {
@Override @Override
public BlockVector next() { public BlockVector next() {
v.x = x; mutable.mutX(x);
v.y = y; mutable.mutY(y);
v.z = z; mutable.mutZ(z);
if (++x > ctx) { if (++x > ctx) {
if (++z > ctz) { if (++z > ctz) {
if (++y > ty) { if (++y > ty) {
@ -403,7 +404,7 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion {
x = bx; x = bx;
if (z > tz) { if (z > tz) {
hasNext = false; hasNext = false;
return v; return mutable;
} }
} else { } else {
z = cbz; z = cbz;
@ -422,7 +423,7 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion {
x = cbx; x = cbx;
} }
} }
return v; return mutable;
} }
@Override @Override
@ -433,7 +434,7 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion {
} }
public Iterator<BlockVector> iterator_old() { public Iterator<BlockVector> iterator_old() {
final BlockVector v = new BlockVector(0,0,0); final MutableBlockVector mutable = new MutableBlockVector(0,0,0);
return new Iterator<BlockVector>() { return new Iterator<BlockVector>() {
private Vector min = getMinimumPoint(); private Vector min = getMinimumPoint();
private Vector max = getMaximumPoint(); private Vector max = getMaximumPoint();
@ -448,9 +449,9 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion {
@Override @Override
public BlockVector next() { public BlockVector next() {
v.x = nextX; mutable.mutX(nextX);
v.y = nextY; mutable.mutY(nextY);
v.z = nextZ; mutable.mutZ(nextZ);
if (++nextX > max.getBlockX()) { if (++nextX > max.getBlockX()) {
nextX = min.getBlockX(); nextX = min.getBlockX();
if (++nextY > max.getBlockY()) { if (++nextY > max.getBlockY()) {
@ -460,7 +461,7 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion {
} }
} }
} }
return v; return mutable;
} }
@Override @Override