Use more MutableBlockVector3s

This commit is contained in:
dordsor21 2021-08-11 14:56:10 +01:00
parent 6f5430a940
commit 3ba42df321
No known key found for this signature in database
GPG Key ID: 1E53E88969FFCF0B
17 changed files with 206 additions and 98 deletions

View File

@ -24,12 +24,20 @@ public class BlockTranslateExtent extends AbstractDelegateExtent {
@Override
public <T extends BlockStateHolder<T>> boolean setBlock(BlockVector3 location, T block) throws WorldEditException {
<<<<<<< Updated upstream
return getExtent().setBlock(location.getX(), location.getY(), location.getZ(), block);
=======
return getExtent().setBlock(location.getX() + dx, location.getY() + dy, location.getZ() + dz, block);
>>>>>>> Stashed changes
}
@Override
public <T extends BlockStateHolder<T>> boolean setBlock(int x, int y, int z, T block) throws WorldEditException {
<<<<<<< Updated upstream
return getExtent().setBlock(x, y, z, block);
=======
return getExtent().setBlock(x + dx, y + dy, z + dz, block);
>>>>>>> Stashed changes
}
@Override

View File

@ -1,6 +1,7 @@
package com.fastasyncworldedit.core.extent;
import com.fastasyncworldedit.core.history.changeset.AbstractChangeSet;
import com.fastasyncworldedit.core.math.MutableBlockVector3;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.entity.BaseEntity;
import com.sk89q.worldedit.entity.Entity;
@ -25,6 +26,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
*/
public class HistoryExtent extends AbstractDelegateExtent {
private final MutableBlockVector3 mutable = new MutableBlockVector3();
private AbstractChangeSet changeSet;
/**
@ -97,7 +99,7 @@ public class HistoryExtent extends AbstractDelegateExtent {
@Override
public boolean setBiome(BlockVector3 position, BiomeType newBiome) {
BiomeType oldBiome = this.getBiome(position);
if (oldBiome.getId() != newBiome.getId()) {
if (!oldBiome.getId().equals(newBiome.getId())) {
this.changeSet.addBiomeChange(position.getBlockX(), position.getBlockY(), position.getBlockZ(), oldBiome, newBiome);
return getExtent().setBiome(position, newBiome);
} else {
@ -107,8 +109,8 @@ public class HistoryExtent extends AbstractDelegateExtent {
@Override
public boolean setBiome(int x, int y, int z, BiomeType newBiome) {
BiomeType oldBiome = this.getBiome(BlockVector3.at(x, y, z));
if (oldBiome.getId() != newBiome.getId()) {
BiomeType oldBiome = this.getBiome(mutable.setComponents(x, y, z));
if (!oldBiome.getId().equals(newBiome.getId())) {
this.changeSet.addBiomeChange(x, y, z, oldBiome, newBiome);
return getExtent().setBiome(x, y, z, newBiome);
} else {

View File

@ -45,9 +45,20 @@ public class PositionTransformExtent extends ResettableExtent {
return min.add(tmp.roundHalfUp().toBlockPoint());
}
private BlockVector3 getPos(int x, int y, int z) {
if (min == null) {
min = BlockVector3.at(x, y, z);
}
mutable.mutX(x - min.getX());
mutable.mutY(y - min.getY());
mutable.mutZ(z - min.getZ());
MutableVector3 tmp = new MutableVector3(transform.apply(mutable.toVector3()));
return min.add(tmp.roundHalfUp().toBlockPoint());
}
@Override
public BlockState getBlock(int x, int y, int z) {
return super.getBlock(getPos(BlockVector3.at(x, y, z)));
return super.getBlock(getPos(x, y, z));
}
@Override
@ -65,12 +76,12 @@ public class PositionTransformExtent extends ResettableExtent {
mutable.mutX(position.getBlockX());
mutable.mutZ(position.getBlockZ());
mutable.mutY(position.getBlockY());
return super.getBiome(getPos(mutable));
return super.getBiome(getPos(mutable.getX(), mutable.getY(), mutable.getZ()));
}
@Override
public <B extends BlockStateHolder<B>> boolean setBlock(int x, int y, int z, B block) throws WorldEditException {
return this.setBlock(getPos(BlockVector3.at(x, y, z)), block);
return this.setBlock(getPos(x, y, z), block);
}
@ -84,7 +95,7 @@ public class PositionTransformExtent extends ResettableExtent {
mutable.mutX(position.getBlockX());
mutable.mutZ(position.getBlockZ());
mutable.mutY(position.getBlockY());
return super.setBiome(getPos(mutable), biome);
return super.setBiome(getPos(mutable.getX(), mutable.getY(), mutable.getZ()), biome);
}
public void setTransform(Transform transform) {

View File

@ -4,6 +4,7 @@ import com.fastasyncworldedit.core.Fawe;
import com.fastasyncworldedit.core.function.visitor.Order;
import com.fastasyncworldedit.core.internal.io.FaweOutputStream;
import com.fastasyncworldedit.core.jnbt.streamer.IntValueReader;
import com.fastasyncworldedit.core.math.MutableBlockVector3;
import com.fastasyncworldedit.core.util.IOUtil;
import com.sk89q.jnbt.CompoundTag;
import com.sk89q.jnbt.IntArrayTag;
@ -278,12 +279,12 @@ public class FastSchematicWriter implements ClipboardWriter {
BlockVector3 min = clipboard.getMinimumPoint();
int width = clipboard.getRegion().getWidth();
int length = clipboard.getRegion().getLength();
MutableBlockVector3 mutable = new MutableBlockVector3();
for (int z = 0, i = 0; z < length; z++) {
int z0 = min.getBlockZ() + z;
for (int x = 0; x < width; x++, i++) {
int x0 = min.getBlockX() + x;
BlockVector3 pt = BlockVector3.at(x0, min.getBlockY(), z0);
BiomeType biome = clipboard.getBiome(pt);
BiomeType biome = clipboard.getBiome(mutable.setComponents(x0, min.getY(), z0));
task.applyInt(i, biome.getInternalId());
}
}

View File

@ -1,6 +1,7 @@
package com.fastasyncworldedit.core.extent.transform;
import com.fastasyncworldedit.core.extent.ResettableExtent;
import com.fastasyncworldedit.core.math.MutableBlockVector3;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.function.pattern.Pattern;
@ -10,6 +11,7 @@ import com.sk89q.worldedit.world.block.BlockStateHolder;
public class PatternTransform extends ResettableExtent {
private final Pattern pattern;
private final MutableBlockVector3 mutable = new MutableBlockVector3();
public PatternTransform(Extent parent, Pattern pattern) {
super(parent);
@ -22,4 +24,14 @@ public class PatternTransform extends ResettableExtent {
return pattern.apply(getExtent(), location, location);
}
<<<<<<< Updated upstream
=======
@Override
public <B extends BlockStateHolder<B>> boolean setBlock(int x, int y, int z, B block)
throws WorldEditException {
mutable.setComponents(x, y, z);
return pattern.apply(extent, mutable, mutable);
}
>>>>>>> Stashed changes
}

View File

@ -2,6 +2,7 @@ package com.fastasyncworldedit.core.function.visitor;
import com.fastasyncworldedit.core.configuration.Caption;
import com.fastasyncworldedit.core.math.IntTriple;
import com.fastasyncworldedit.core.math.MutableBlockVector3;
import com.google.common.collect.Lists;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.function.RegionFunction;
@ -40,12 +41,12 @@ public abstract class DFSVisitor implements Operation {
this.hashQueue = new LinkedHashSet<>();
this.visited = new LinkedHashMap<>();
this.function = function;
this.directions.add(BlockVector3.at(0, -1, 0));
this.directions.add(BlockVector3.at(0, 1, 0));
this.directions.add(BlockVector3.at(-1, 0, 0));
this.directions.add(BlockVector3.at(1, 0, 0));
this.directions.add(BlockVector3.at(0, 0, -1));
this.directions.add(BlockVector3.at(0, 0, 1));
this.directions.add(BlockVector3.UNIT_MINUS_Y);
this.directions.add(BlockVector3.UNIT_Y);
this.directions.add(BlockVector3.UNIT_MINUS_X);
this.directions.add(BlockVector3.UNIT_X);
this.directions.add(BlockVector3.UNIT_MINUS_Z);
this.directions.add(BlockVector3.UNIT_Z);
this.maxDepth = maxDepth;
this.maxBranch = maxBranching;
}
@ -76,8 +77,8 @@ public abstract class DFSVisitor implements Operation {
@Override
public Operation resume(RunContext run) throws WorldEditException {
// MutableBlockVector3 mutable = new MutableBlockVector3();
// MutableBlockVector3 mutable2 = new MutableBlockVector3();
MutableBlockVector3 mutable = new MutableBlockVector3();
MutableBlockVector3 mutable2 = new MutableBlockVector3();
IntTriple[] dirs = getIntDirections();
while (!queue.isEmpty()) {
@ -87,23 +88,18 @@ public abstract class DFSVisitor implements Operation {
if (visited.containsKey(from)) {
continue;
}
// mutable.mutX(from.getX());
// mutable.mutY(from.getY());
// mutable.mutZ(from.getZ());
BlockVector3 bv = BlockVector3.at(from.getX(), from.getY(), from.getZ());
function.apply(bv);
mutable.mutX(from.getX());
mutable.mutY(from.getY());
mutable.mutZ(from.getZ());
function.apply(mutable);
int countAdd = 0;
int countAttempt = 0;
for (IntTriple direction : dirs) {
// mutable2.mutX(from.getX() + direction.x);
// mutable2.mutY(from.getY() + direction.y);
// mutable2.mutZ(from.getZ() + direction.z);
BlockVector3 bv2 = BlockVector3
.at(from.getX() + direction.getX(), from.getY() + direction.getY(),
from.getZ() + direction.getZ()
);
if (isVisitable(bv, bv2)) {
Node adjacent = new Node(bv2.getBlockX(), bv2.getBlockY(), bv2.getBlockZ());
mutable2.mutX(from.getX() + direction.getX());
mutable2.mutY(from.getY() + direction.getY());
mutable2.mutZ(from.getZ() + direction.getZ());
if (isVisitable(mutable, mutable2)) {
Node adjacent = new Node(mutable2.getBlockX(), mutable2.getBlockY(), mutable2.getBlockZ());
if (!adjacent.equals(current.from)) {
AtomicInteger adjacentCount = visited.get(adjacent);
if (adjacentCount == null) {

View File

@ -29,13 +29,14 @@ public class DirectionalVisitor extends RecursiveVisitor {
this.origin = origin;
this.dirVec = direction;
setDirections(
BlockVector3.at(1, 0, 0),
BlockVector3.at(-1, 0, 0),
BlockVector3.at(0, 0, 1),
BlockVector3.at(0, 0, -1),
BlockVector3.at(0, -1, 0),
BlockVector3.at(0, 1, 0)
BlockVector3.UNIT_MINUS_X,
BlockVector3.UNIT_X,
BlockVector3.UNIT_MINUS_Y,
BlockVector3.UNIT_Y,
BlockVector3.UNIT_MINUS_Z,
BlockVector3.UNIT_Z
);
}

View File

@ -1,6 +1,7 @@
package com.fastasyncworldedit.core.wrappers;
import com.fastasyncworldedit.core.Fawe;
import com.fastasyncworldedit.core.math.MutableBlockVector3;
import com.fastasyncworldedit.core.util.EditSessionBuilder;
import com.fastasyncworldedit.core.util.TaskManager;
import com.fastasyncworldedit.core.util.task.RunnableVal;
@ -89,14 +90,16 @@ public class AsyncPlayer extends PlayerProxy {
int z = pos.getBlockZ();
Extent world = getLocation().getExtent();
MutableBlockVector3 mutable = new MutableBlockVector3();
// No free space above
if (!world.getBlock(BlockVector3.at(x, y, z)).getBlockType().getMaterial().isAir()) {
if (!world.getBlock(mutable.setComponents(x, y, z)).getBlockType().getMaterial().isAir()) {
return false;
}
while (y <= world.getMaximumPoint().getY()) {
// Found a ceiling!
if (world.getBlock(BlockVector3.at(x, y, z)).getBlockType().getMaterial()
if (world.getBlock(mutable.mutY(y)).getBlockType().getMaterial()
.isMovementBlocker()) {
int platformY = Math.max(initialY, y - 3 - clearance);
floatAt(x, platformY + 1, z, alwaysGlass);
@ -124,8 +127,10 @@ public class AsyncPlayer extends PlayerProxy {
final int maxY = Math.min(getWorld().getMaxY() + 1, initialY + distance);
final Extent world = getLocation().getExtent();
MutableBlockVector3 mutable = new MutableBlockVector3(x, y, z);
while (y <= world.getMaximumPoint().getY() + 2) {
if (world.getBlock(BlockVector3.at(x, y, z)).getBlockType().getMaterial()
if (world.getBlock(mutable.mutY(y)).getBlockType().getMaterial()
.isMovementBlocker()) {
break; // Hit something
} else if (y > maxY + 1) {
@ -211,9 +216,11 @@ public class AsyncPlayer extends PlayerProxy {
int freeToFind = 2;
boolean inFree = false;
MutableBlockVector3 mutable = new MutableBlockVector3();
while ((block = hitBlox.getNextBlock()) != null) {
boolean free = !world.getBlock(
BlockVector3.at(block.getBlockX(), block.getBlockY(), block.getBlockZ()))
mutable.setComponents(block.getBlockX(), block.getBlockY(), block.getBlockZ()))
.getBlockType().getMaterial().isMovementBlocker();
if (firstBlock) {

View File

@ -1333,7 +1333,7 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
checkNotNull(pattern);
checkArgument(radius >= 0, "radius >= 0");
checkArgument(depth >= 1, "depth >= 1");
if (direction.equals(BlockVector3.at(0, -1, 0))) {
if (direction.equals(BlockVector3.UNIT_MINUS_Y)) {
return fillXZ(origin, pattern, radius, depth, false);
}
Mask mask = new MaskIntersection(
@ -2493,29 +2493,36 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
int minY = Math.max(getWorld().getMinY(), centerY - height);
int maxY = Math.min(getWorld().getMaxY(), centerY + height);
//FAWE start - mutable
MutableBlockVector3 mutable = new MutableBlockVector3();
MutableBlockVector3 mutable2 = new MutableBlockVector3();
//FAWE end
int ceilRadius = (int) Math.ceil(radius);
for (int x = ox - ceilRadius; x <= ox + ceilRadius; ++x) {
for (int z = oz - ceilRadius; z <= oz + ceilRadius; ++z) {
if ((BlockVector3.at(x, oy, z)).distanceSq(position) > radiusSq) {
//FAWE start - mutable
if ((mutable.setComponents(x, oy, z)).distanceSq(position) > radiusSq) {
//FAWE end
continue;
}
for (int y = maxY; y > minY; --y) {
BlockVector3 pt = BlockVector3.at(x, y, z);
BlockVector3 below = BlockVector3.at(x, y - 1, z);
BlockType id = getBlock(pt).getBlockType();
//FAWE start - mutable
mutable.setComponents(x, y, z);
mutable2.setComponents(x, y - 1, z);
BlockType id = getBlock(mutable).getBlockType();
if (id == BlockTypes.ICE) {
if (setBlock(pt, water)) {
if (setBlock(mutable, water)) {
++affected;
}
} else if (id == BlockTypes.SNOW) {
//FAWE start
if (setBlock(pt, air)) {
if (setBlock(mutable, air)) {
if (y > 0) {
BlockState block = getBlock(below);
BlockState block = getBlock(mutable2);
if (block.getStates().containsKey(snowy)) {
if (setBlock(below, block.with(snowy, false))) {
if (setBlock(mutable2, block.with(snowy, false))) {
affected++;
}
}
@ -2627,20 +2634,29 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
final int minY = Math.max(getWorld().getMinY(), centerY - height);
final int maxY = Math.min(getWorld().getMaxY(), centerY + height);
//FAWE start - mutable
MutableBlockVector3 mutable = new MutableBlockVector3();
//FAWE end
final int ceilRadius = (int) Math.ceil(radius);
for (int x = ox - ceilRadius; x <= ox + ceilRadius; ++x) {
for (int z = oz - ceilRadius; z <= oz + ceilRadius; ++z) {
if ((BlockVector3.at(x, oy, z)).distanceSq(position) > radiusSq) {
//FAWE start - mutable
if (mutable.setComponents(x, oy, z).distanceSq(position) > radiusSq) {
//FAWE end
continue;
}
for (int y = maxY; y > minY; --y) {
final BlockVector3 pt = BlockVector3.at(x, y, z);
final BlockState block = getBlock(pt);
//FAWE start - mutable
final BlockState block = getBlock(mutable.mutY(y));
//FAWE end
if (block.getBlockType() == BlockTypes.DIRT
|| (!onlyNormalDirt && block.getBlockType() == BlockTypes.COARSE_DIRT)) {
if (setBlock(pt, grass)) {
//FAWE start - mutable
if (setBlock(mutable.mutY(y), grass)) {
//FAWE end
++affected;
}
break;
@ -2958,24 +2974,34 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
final int maxY = max.getBlockY();
final int maxZ = max.getBlockZ();
//FAWE start - mutable
MutableBlockVector3 mutable = new MutableBlockVector3();
//FAWE end
for (int x = minX; x <= maxX; ++x) {
for (int y = minY; y <= maxY; ++y) {
recurseHollow(region, BlockVector3.at(x, y, minZ), outside, mask);
recurseHollow(region, BlockVector3.at(x, y, maxZ), outside, mask);
//FAWE start - mutable
recurseHollow(region, mutable.setComponents(x, y, minZ), outside, mask);
recurseHollow(region, mutable.setComponents(x, y, maxZ), outside, mask);
//FAWE end
}
}
for (int y = minY; y <= maxY; ++y) {
for (int z = minZ; z <= maxZ; ++z) {
recurseHollow(region, BlockVector3.at(minX, y, z), outside, mask);
recurseHollow(region, BlockVector3.at(maxX, y, z), outside, mask);
//FAWE start - mutable
recurseHollow(region, mutable.setComponents(minX, y, z), outside, mask);
recurseHollow(region, mutable.setComponents(maxX, y, z), outside, mask);
//FAWE end
}
}
for (int z = minZ; z <= maxZ; ++z) {
for (int x = minX; x <= maxX; ++x) {
recurseHollow(region, BlockVector3.at(x, minY, z), outside, mask);
recurseHollow(region, BlockVector3.at(x, maxY, z), outside, mask);
//FAWE start - mutable
recurseHollow(region, mutable.setComponents(x, minY, z), outside, mask);
recurseHollow(region, mutable.setComponents(x, maxY, z), outside, mask);
//FAWE end
}
}
@ -3035,8 +3061,8 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
public int drawLine(Pattern pattern, BlockVector3 pos1, BlockVector3 pos2, double radius, boolean filled, boolean flat)
throws MaxChangedBlocksException {
//FAWE start - LocalBlockVectorSet
LocalBlockVectorSet vset = new LocalBlockVectorSet();
//FAWE start
boolean notdrawn = true;
//FAWE end
@ -3054,8 +3080,8 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
int dz = Math.abs(z2 - z1);
if (dx + dy + dz == 0) {
vset.add(BlockVector3.at(tipx, tipy, tipz));
//FAWE start
//FAWE start - LocalBlockVectorSet
vset.add(tipx, tipy, tipz);
notdrawn = false;
//FAWE end
}
@ -3069,7 +3095,9 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
tipy = (int) Math.round(y1 + domstep * (double) dy / (double) dx * (y2 - y1 > 0 ? 1 : -1));
tipz = (int) Math.round(z1 + domstep * (double) dz / (double) dx * (z2 - z1 > 0 ? 1 : -1));
vset.add(BlockVector3.at(tipx, tipy, tipz));
//FAWE start - LocalBlockVectorSet
vset.add(tipx, tipy, tipz);
//FAWE end
}
//FAWE start - notdrawn
} else if (dMax == dy && notdrawn) {
@ -3079,7 +3107,9 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
tipx = (int) Math.round(x1 + domstep * (double) dx / (double) dy * (x2 - x1 > 0 ? 1 : -1));
tipz = (int) Math.round(z1 + domstep * (double) dz / (double) dy * (z2 - z1 > 0 ? 1 : -1));
vset.add(BlockVector3.at(tipx, tipy, tipz));
//FAWE start - LocalBlockVectorSet
vset.add(tipx, tipy, tipz);
//FAWE end
}
//FAWE start - notdrawn
} else if (dMax == dz && notdrawn) {
@ -3089,7 +3119,9 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
tipy = (int) Math.round(y1 + domstep * (double) dy / (double) dz * (y2 - y1 > 0 ? 1 : -1));
tipx = (int) Math.round(x1 + domstep * (double) dx / (double) dz * (x2 - x1 > 0 ? 1 : -1));
vset.add(BlockVector3.at(tipx, tipy, tipz));
//FAWE start - LocalBlockVectorSet
vset.add(tipx, tipy, tipz);
//FAWE end
}
}
//FAWE start - set BV3
@ -3457,6 +3489,7 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
}
final Set<BlockVector2> chunks = region.getChunks();
MutableBlockVector3 mutable = new MutableBlockVector3();
MutableBlockVector3 mutable2 = new MutableBlockVector3();
MutableBlockVector2 mutable2D = new MutableBlockVector2();
for (BlockVector2 chunk : chunks) {
final int cx = chunk.getBlockX();
@ -3493,13 +3526,13 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
}
} else {
if (!conNextX) {
setExistingBlocks(BlockVector3.at(bx + 16, 0, bz), BlockVector3.at(bx + 31, maxY, bz + 15));
setExistingBlocks(mutable.setComponents(bx + 16, 0, bz), mutable2.setComponents(bx + 31, maxY, bz + 15));
}
if (!conNextZ) {
setExistingBlocks(BlockVector3.at(bx, 0, bz + 16), BlockVector3.at(bx + 15, maxY, bz + 31));
setExistingBlocks(mutable.setComponents(bx, 0, bz + 16), mutable2.setComponents(bx + 15, maxY, bz + 31));
}
if (!chunks.contains(mutable2D.setComponents(cx + 1, cz + 1)) && !conNextX && !conNextZ) {
setExistingBlocks(BlockVector3.at(bx + 16, 0, bz + 16), BlockVector3.at(bx + 31, maxY, bz + 31));
setExistingBlocks(mutable.setComponents(bx + 16, 0, bz + 16), mutable2.setComponents(bx + 31, maxY, bz + 31));
}
for (int x = 0; x < 16; x++) {
int xx = x + bx;

View File

@ -86,9 +86,9 @@ public class ClipboardPatternParser extends InputParser<Pattern> {
throw new InputParseException(Caption.of("worldedit.error.parser.clipboard.missing-coordinates"));
}
offset = BlockVector3.at(
Integer.valueOf(offsetSplit[0]),
Integer.valueOf(offsetSplit[1]),
Integer.valueOf(offsetSplit[2])
Integer.parseInt(offsetSplit[0]),
Integer.parseInt(offsetSplit[1]),
Integer.parseInt(offsetSplit[2])
);
}

View File

@ -173,7 +173,7 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
byte free = 0;
BlockVector3 mutablePos = MutableBlockVector3.ZERO;
BlockVector3 mutablePos = new MutableBlockVector3();
while (y <= maxY) {
if (!world.getBlock(mutablePos.setComponents(x, y, z)).getBlockType().getMaterial().isMovementBlocker()) {
++free;
@ -209,9 +209,14 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
int yLessSearchHeight = y - WorldEdit.getInstance().getConfiguration().defaultVerticalHeight;
int minY = Math.min(worldMinY, yLessSearchHeight) + 2;
//FAWE start - mutable
MutableBlockVector3 mutable = new MutableBlockVector3(x, y, z);
//FAWE end
while (y >= minY) {
final BlockVector3 pos = BlockVector3.at(x, y, z);
final BlockState id = world.getBlock(pos);
//FAWE start - mutable
final BlockState id = world.getBlock(mutable.mutY(y));
//FAWE end
if (id.getBlockType().getMaterial().isMovementBlocker()
&& trySetPosition(Vector3.at(x + 0.5, y + 1, z + 0.5))) {
return;
@ -263,8 +268,14 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
int yPlusSearchHeight = y + WorldEdit.getInstance().getConfiguration().defaultVerticalHeight;
int maxY = Math.min(world.getMaxY(), yPlusSearchHeight) + 2;
//FAWE start - mutable
MutableBlockVector3 mutable = new MutableBlockVector3(x, y, z);
//FAWE end
while (y <= maxY) {
if (isLocationGoodForStanding(BlockVector3.at(x, y, z))
//FAWE start - mutable
if (isLocationGoodForStanding(mutable.mutY(y))
//FAWE end
&& trySetPosition(Vector3.at(x + 0.5, y, z + 0.5))) {
return true;
}
@ -285,8 +296,14 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
int yLessSearchHeight = y - WorldEdit.getInstance().getConfiguration().defaultVerticalHeight;
int minY = Math.min(world.getMinY() + 1, yLessSearchHeight);
//FAWE start - mutable
MutableBlockVector3 mutable = new MutableBlockVector3(x, y, z);
//FAWE end
while (y >= minY) {
if (isLocationGoodForStanding(BlockVector3.at(x, y, z))
//FAWE start - mutable
if (isLocationGoodForStanding(mutable.mutY(y))
//FAWE end
&& trySetPosition(Vector3.at(x + 0.5, y, z + 0.5))) {
return true;
}
@ -311,8 +328,12 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
int y = Math.max(world.getMinY(), pos.getBlockY() + 2);
int z = pos.getBlockZ();
//FAWE start - mutable
MutableBlockVector3 mutable = new MutableBlockVector3(x, y, z);
// No free space above
if (!world.getBlock(BlockVector3.at(x, y, z)).getBlockType().getMaterial().isAir()) {
if (!world.getBlock(mutable).getBlockType().getMaterial().isAir()) {
//FAWE end
return false;
}
@ -321,7 +342,9 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
while (y <= maxY) {
// Found a ceiling!
if (world.getBlock(BlockVector3.at(x, y, z)).getBlockType().getMaterial().isMovementBlocker()) {
//FAWE start - mutable
if (world.getBlock(mutable.mutY(y)).getBlockType().getMaterial().isMovementBlocker()) {
//FAWE end
int platformY = Math.max(initialY, y - 3 - clearance);
if (platformY < initialY) { // if ==, they already have the given clearance, if <, clearance is too large
return false;
@ -353,8 +376,14 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
final int z = pos.getBlockZ();
final int maxY = Math.min(world.getMaxY() + 1, initialY + distance);
//FAWE start - mutable
MutableBlockVector3 mutable = new MutableBlockVector3(x, y, z);
//FAWE end
while (y <= world.getMaxY() + 2) {
if (world.getBlock(BlockVector3.at(x, y, z)).getBlockType().getMaterial().isMovementBlocker()) {
//FAWE start - mutable
if (world.getBlock(mutable.mutY(y)).getBlockType().getMaterial().isMovementBlocker()) {
//FAWE end
break; // Hit something
} else if (y > maxY + 1) {
break;

View File

@ -213,11 +213,13 @@ public interface Extent extends InputExtent, OutputExtent {
}
default int getHighestTerrainBlock(final int x, final int z, int minY, int maxY, Mask filter) {
maxY = Math.min(maxY, getMaxY());
minY = Math.max(getMinY(), minY);
BlockVector3 pos = MutableBlockVector3.at(x, minY, z);
maxY = Math.min(maxY, Math.max(0, maxY));
minY = Math.max(0, minY);
MutableBlockVector3 mutable = new MutableBlockVector3();
for (int y = maxY; y >= minY; --y) {
if (filter.test(pos.mutY(y))) {
if (filter.test(mutable.setComponents(x, y, z))) {
return y;
}
}

View File

@ -157,8 +157,9 @@ public class ForgetfulExtentBuffer extends AbstractDelegateExtent implements Pat
max = max.getMaximum(BlockVector3.at(x, y, z));
}
if (mask.test(BlockVector3.at(x, y, z))) {
biomeBuffer.put(BlockVector3.at(x, y, z), biome);
BlockVector3 pos = BlockVector3.at(x, y, z);
if (mask.test(pos)) {
biomeBuffer.put(pos, biome);
return true;
} else {
return getExtent().setBiome(x, y, z, biome);

View File

@ -342,7 +342,7 @@ public interface Clipboard extends Extent, Iterable<BlockVector3>, Closeable {
int yy = pos.getY() + rely;
int zz = pos.getZ() + relz;
if (pasteBiomes) {
extent.setBiome(xx, yy, zz, Clipboard.this.getBiome(BlockVector3.at(pos.getX(), pos.getY(), pos.getZ())));
extent.setBiome(xx, yy, zz, Clipboard.this.getBiome(pos));
}
if (!pasteAir && block.getBlockType().getMaterial().isAir()) {
continue;

View File

@ -59,12 +59,12 @@ public abstract class BreadthFirstSearch implements Operation {
public static final BlockVector3[] DIAGONAL_DIRECTIONS;
static {
DEFAULT_DIRECTIONS[0] = (BlockVector3.at(0, -1, 0));
DEFAULT_DIRECTIONS[1] = (BlockVector3.at(0, 1, 0));
DEFAULT_DIRECTIONS[2] = (BlockVector3.at(-1, 0, 0));
DEFAULT_DIRECTIONS[3] = (BlockVector3.at(1, 0, 0));
DEFAULT_DIRECTIONS[4] = (BlockVector3.at(0, 0, -1));
DEFAULT_DIRECTIONS[5] = (BlockVector3.at(0, 0, 1));
DEFAULT_DIRECTIONS[0] = (BlockVector3.UNIT_MINUS_Y);
DEFAULT_DIRECTIONS[1] = (BlockVector3.UNIT_Y);
DEFAULT_DIRECTIONS[2] = (BlockVector3.UNIT_MINUS_X);
DEFAULT_DIRECTIONS[3] = (BlockVector3.UNIT_X);
DEFAULT_DIRECTIONS[4] = (BlockVector3.UNIT_MINUS_Z);
DEFAULT_DIRECTIONS[5] = (BlockVector3.UNIT_Z);
List<BlockVector3> list = new ArrayList<>();
for (int x = -1; x <= 1; x++) {
for (int y = -1; y <= 1; y++) {

View File

@ -122,7 +122,9 @@ public class RequestExtent implements Extent {
@Override
public boolean setBiome(int x, int y, int z, BiomeType biome) {
return getExtent().setBiome(BlockVector3.at(x, y, z), biome);
//FAWE start - no BV3
return getExtent().setBiome(x, y, z, biome);
//FAWE end
}
@Override

View File

@ -19,6 +19,7 @@
package com.sk89q.worldedit.util.collection;
import com.fastasyncworldedit.core.math.MutableBlockVector3;
import com.google.common.collect.AbstractIterator;
import com.sk89q.worldedit.math.BlockVector3;
import it.unimi.dsi.fastutil.ints.IntArrayList;
@ -64,18 +65,19 @@ class VectorPositionList implements PositionList {
@Override
public Iterator<BlockVector3> iterator() {
return new AbstractIterator<BlockVector3>() {
return new AbstractIterator<>() {
private final IntIterator iteratorX = delegateX.iterator();
private final IntIterator iteratorY = delegateY.iterator();
private final IntIterator iteratorZ = delegateZ.iterator();
private final MutableBlockVector3 mutable = new MutableBlockVector3();
@Override
protected BlockVector3 computeNext() {
if (!iteratorX.hasNext()) {
return endOfData();
}
return BlockVector3.at(
return mutable.setComponents(
iteratorX.nextInt(),
iteratorY.nextInt(),
iteratorZ.nextInt()
@ -91,13 +93,14 @@ class VectorPositionList implements PositionList {
private final IntListIterator iteratorX = delegateX.listIterator(delegateX.size());
private final IntListIterator iteratorY = delegateY.listIterator(delegateY.size());
private final IntListIterator iteratorZ = delegateZ.listIterator(delegateZ.size());
private final MutableBlockVector3 mutable = new MutableBlockVector3();
@Override
protected BlockVector3 computeNext() {
if (!iteratorX.hasPrevious()) {
return endOfData();
}
return BlockVector3.at(
return mutable.setComponents(
iteratorX.previousInt(),
iteratorY.previousInt(),
iteratorZ.previousInt()