Current Progress #3

This commit is contained in:
IronApollo
2019-01-09 02:13:44 -05:00
parent d4157b7e0e
commit 842b1307c7
221 changed files with 3173 additions and 3041 deletions

View File

@ -1,10 +1,10 @@
package com.sk89q.worldedit.function.operation;
import com.sk89q.worldedit.MutableBlockVector;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.function.RegionFunction;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.math.Vector3;
import com.sk89q.worldedit.math.transform.Transform;
import com.sk89q.worldedit.regions.CuboidRegion;
import com.sk89q.worldedit.regions.Region;
@ -16,11 +16,11 @@ public class BackwardsExtentBlockCopy implements Operation {
private final Extent destination;
private final Extent source;
private final RegionFunction function;
private final Vector origin;
private final BlockVector3 origin;
private Vector mutable = new MutableBlockVector();
// private Vector mutable = new MutableBlockVector();
public BackwardsExtentBlockCopy(Extent source, Region region, Extent destination, Vector origin, Transform transform, RegionFunction function) {
public BackwardsExtentBlockCopy(Extent source, Region region, Extent destination, BlockVector3 origin, Transform transform, RegionFunction function) {
this.source = source;
this.region = region;
this.destination = destination;
@ -33,8 +33,8 @@ public class BackwardsExtentBlockCopy implements Operation {
public Operation resume(RunContext run) throws WorldEditException {
CuboidRegion destRegion = transform(this.transform, this.region);
Transform inverse = this.transform.inverse();
for (Vector pt : destRegion) {
Vector copyFrom = transform(inverse, pt);
for (BlockVector3 pt : destRegion) {
BlockVector3 copyFrom = transform(inverse, pt);
if (region.contains(copyFrom)) {
function.apply(pt);
}
@ -43,31 +43,32 @@ public class BackwardsExtentBlockCopy implements Operation {
}
private CuboidRegion transform(Transform transform, Region region) {
Vector min = new MutableBlockVector(Integer.MAX_VALUE, Integer.MAX_VALUE, Integer.MAX_VALUE);
Vector max = new MutableBlockVector(Integer.MIN_VALUE, Integer.MIN_VALUE, Integer.MIN_VALUE);
Vector pos1 = region.getMinimumPoint();
Vector pos2 = region.getMaximumPoint();
BlockVector3 min = new BlockVector3(Integer.MAX_VALUE, Integer.MAX_VALUE, Integer.MAX_VALUE);
BlockVector3 max = new BlockVector3(Integer.MIN_VALUE, Integer.MIN_VALUE, Integer.MIN_VALUE);
BlockVector3 pos1 = region.getMinimumPoint();
BlockVector3 pos2 = region.getMaximumPoint();
for (int x : new int[] { pos1.getBlockX(), pos2.getBlockX() }) {
for (int y : new int[] { pos1.getBlockY(), pos2.getBlockY() }) {
for (int z : new int[] { pos1.getBlockZ(), pos2.getBlockZ() }) {
Vector pt = transform(transform, new Vector(x, y, z)).toBlockVector();
min = Vector.getMinimum(min, pt);
max = Vector.getMaximum(max, pt);
BlockVector3 pt = transform(transform, new BlockVector3(x, y, z));
min = min.getMinimum(pt);
max = max.getMaximum(pt);
}
}
}
return new CuboidRegion(min, max);
}
private Vector transform(Transform transform, Vector pt) {
mutable.mutX(((pt.getBlockX() - origin.getBlockX())));
mutable.mutY(((pt.getBlockY() - origin.getBlockY())));
mutable.mutZ(((pt.getBlockZ() - origin.getBlockZ())));
Vector tmp = transform.apply(mutable);
tmp.mutX((tmp.getBlockX() + origin.getBlockX()));
tmp.mutY((tmp.getBlockY() + origin.getBlockY()));
tmp.mutZ((tmp.getBlockZ() + origin.getBlockZ()));
return tmp;
private BlockVector3 transform(Transform transform, BlockVector3 pt) {
// mutable.mutX(((pt.getBlockX() - origin.getBlockX())));
// mutable.mutY(((pt.getBlockY() - origin.getBlockY())));
// mutable.mutZ(((pt.getBlockZ() - origin.getBlockZ())));
// BlockVector3 tmp = transform.apply(new Vector3(pt.getBlockX() - origin.getBlockX(), pt.getBlockY() - origin.getBlockY(), pt.getBlockZ() - origin.getBlockZ())).toBlockPoint();
// tmp.mutX((tmp.getBlockX() + origin.getBlockX()));
// tmp.mutY((tmp.getBlockY() + origin.getBlockY()));
// tmp.mutZ((tmp.getBlockZ() + origin.getBlockZ()));
// return tmp;
return transform.apply(new Vector3(pt.getBlockX() - origin.getBlockX(), pt.getBlockY() - origin.getBlockY(), pt.getBlockZ() - origin.getBlockZ())).toBlockPoint().add(origin.getBlockX(), origin.getBlockY(), origin.getBlockZ());
}
@Override

View File

@ -19,13 +19,13 @@
package com.sk89q.worldedit.function.operation;
import com.sk89q.worldedit.BlockVector;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.blocks.BaseBlock;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockStateHolder;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.math.BlockVector3;
import java.util.Iterator;
import java.util.List;
@ -40,7 +40,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
public class BlockMapEntryPlacer implements Operation {
private final Extent extent;
private final Iterator<Map.Entry<BlockVector, BlockStateHolder>> iterator;
private final Iterator<Map.Entry<BlockVector3, BlockStateHolder>> iterator;
/**
* Create a new instance.
@ -48,7 +48,7 @@ public class BlockMapEntryPlacer implements Operation {
* @param extent the extent to set the blocks on
* @param iterator the iterator
*/
public BlockMapEntryPlacer(Extent extent, Iterator<Map.Entry<BlockVector, BlockStateHolder>> iterator) {
public BlockMapEntryPlacer(Extent extent, Iterator<Map.Entry<BlockVector3, BlockStateHolder>> iterator) {
checkNotNull(extent);
checkNotNull(iterator);
this.extent = extent;
@ -58,7 +58,7 @@ public class BlockMapEntryPlacer implements Operation {
@Override
public Operation resume(RunContext run) throws WorldEditException {
while (iterator.hasNext()) {
Map.Entry<BlockVector, BlockStateHolder> entry = iterator.next();
Map.Entry<BlockVector3, BlockStateHolder> entry = iterator.next();
extent.setBlock(entry.getKey(), entry.getValue());
}

View File

@ -19,7 +19,6 @@
package com.sk89q.worldedit.function.operation;
<<<<<<< HEAD
import com.boydti.fawe.example.MappedFaweQueue;
import com.boydti.fawe.object.FaweQueue;
import com.boydti.fawe.object.extent.BlockTranslateExtent;
@ -29,14 +28,10 @@ import com.boydti.fawe.object.function.block.CombinedBlockCopy;
import com.boydti.fawe.object.function.block.SimpleBlockCopy;
import com.boydti.fawe.util.MaskTraverser;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.MutableBlockVector;
import com.sk89q.worldedit.Vector;
=======
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import com.google.common.collect.Lists;
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.entity.Entity;
import com.sk89q.worldedit.extent.Extent;
@ -51,12 +46,9 @@ import com.sk89q.worldedit.function.mask.Masks;
import com.sk89q.worldedit.function.visitor.EntityVisitor;
import com.sk89q.worldedit.function.visitor.IntersectRegionFunction;
import com.sk89q.worldedit.function.visitor.RegionVisitor;
<<<<<<< HEAD
import com.sk89q.worldedit.math.transform.AffineTransform;
=======
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.math.Vector3;
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
import com.sk89q.worldedit.math.transform.Identity;
import com.sk89q.worldedit.math.transform.Transform;
import com.sk89q.worldedit.regions.Region;
@ -279,9 +271,9 @@ public class ForwardExtentCopy implements Operation {
}
Extent finalDest = destination;
Vector translation = to.subtract(from);
BlockVector3 translation = to.subtract(from);
if (!translation.equals(Vector.ZERO)) {
if (!translation.equals(BlockVector3.ZERO)) {
finalDest = new BlockTranslateExtent(finalDest, translation.getBlockX(), translation.getBlockY(), translation.getBlockZ());
}
@ -318,30 +310,28 @@ public class ForwardExtentCopy implements Operation {
RegionFunction maskFunc = null;
if (sourceFunction != null) {
Vector disAbs = translation.positive();
Vector size = region.getMaximumPoint().subtract(region.getMinimumPoint()).add(1, 1, 1);
BlockVector3 disAbs = translation.abs();
BlockVector3 size = region.getMaximumPoint().subtract(region.getMinimumPoint()).add(1, 1, 1);
boolean overlap = (disAbs.getBlockX() < size.getBlockX() && disAbs.getBlockY() < size.getBlockY() && disAbs.getBlockZ() < size.getBlockZ());
RegionFunction copySrcFunc = sourceFunction;
if (overlap && translation.length() != 0) {
MutableBlockVector mutable = new MutableBlockVector();
int x = translation.getBlockX();
int y = translation.getBlockY();
int z = translation.getBlockZ();
<<<<<<< HEAD
maskFunc = position -> {
mutable.setComponents(position.getBlockX() + x, position.getBlockY() + y, position.getBlockZ() + z);
if (region.contains(mutable)) {
return sourceFunction.apply(mutable);
BlockVector3 bv = new BlockVector3(position.getBlockX() + x, position.getBlockY() + y, position.getBlockZ() + z);
if (region.contains(bv)) {
return sourceFunction.apply(bv);
}
return false;
};
copySrcFunc = position -> {
mutable.setComponents(position.getBlockX() - x, position.getBlockY() - y, position.getBlockZ() - z);
if (!region.contains(mutable)) {
BlockVector3 bv = new BlockVector3(position.getBlockX() - x, position.getBlockY() - y, position.getBlockZ() - z);
if (!region.contains(bv)) {
return sourceFunction.apply(position);
}
return false;
@ -371,11 +361,9 @@ public class ForwardExtentCopy implements Operation {
Operations.completeBlindly(blockCopy);
if (!entities.isEmpty()) {
ExtentEntityCopy entityCopy = new ExtentEntityCopy(from, destination, to, currentTransform);
=======
if (copyingEntities) {
ExtentEntityCopy entityCopy = new ExtentEntityCopy(from.toVector3(), destination, to.toVector3(), currentTransform);
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
// if (copyingEntities) {
// ExtentEntityCopy entityCopy = new ExtentEntityCopy(from.toVector3(), destination, to.toVector3(), currentTransform);
entityCopy.setRemoving(removingEntities);
EntityVisitor entityVisitor = new EntityVisitor(entities.iterator(), entityCopy);
Operations.completeBlindly(entityVisitor);