mirror of
https://github.com/boy0001/FastAsyncWorldedit.git
synced 2024-11-25 03:55:35 +01:00
Fix rotate
This commit is contained in:
parent
043da6668d
commit
57c908bdae
@ -0,0 +1,105 @@
|
|||||||
|
package com.boydti.fawe.object.extent;
|
||||||
|
|
||||||
|
import com.sk89q.worldedit.Vector;
|
||||||
|
import com.sk89q.worldedit.Vector2D;
|
||||||
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
|
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||||
|
import com.sk89q.worldedit.extent.Extent;
|
||||||
|
import com.sk89q.worldedit.math.transform.Transform;
|
||||||
|
import com.sk89q.worldedit.world.biome.BaseBiome;
|
||||||
|
|
||||||
|
public class PositionTransformExtent extends ResettableExtent {
|
||||||
|
|
||||||
|
private final Vector mutable = new Vector();
|
||||||
|
private Transform transform;
|
||||||
|
private Vector min;
|
||||||
|
|
||||||
|
public PositionTransformExtent(Extent parent, Transform transform) {
|
||||||
|
super(parent);
|
||||||
|
this.transform = transform;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ResettableExtent setExtent(Extent extent) {
|
||||||
|
min = null;
|
||||||
|
return super.setExtent(extent);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOrigin(Vector pos) {
|
||||||
|
this.min = pos;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Vector getPos(Vector pos) {
|
||||||
|
if (min == null) {
|
||||||
|
min = new Vector(pos);
|
||||||
|
}
|
||||||
|
mutable.x = (pos.x - min.x);
|
||||||
|
mutable.y = (pos.y - min.y);
|
||||||
|
mutable.z = (pos.z - min.z);
|
||||||
|
Vector tmp = transform.apply(mutable);
|
||||||
|
tmp.x += min.x;
|
||||||
|
tmp.y += min.y;
|
||||||
|
tmp.z += min.z;
|
||||||
|
return tmp;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Vector getPos(int x, int y, int z) {
|
||||||
|
if (min == null) {
|
||||||
|
min = new Vector(x, y, z);
|
||||||
|
}
|
||||||
|
mutable.x = (x - min.x);
|
||||||
|
mutable.y = (y - min.y);
|
||||||
|
mutable.z = (z - min.z);
|
||||||
|
Vector tmp = transform.apply(mutable);
|
||||||
|
tmp.x += min.x;
|
||||||
|
tmp.y += min.y;
|
||||||
|
tmp.z += min.z;
|
||||||
|
return tmp;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BaseBlock getLazyBlock(int x, int y, int z) {
|
||||||
|
return super.getLazyBlock(getPos(x, y, z));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BaseBlock getLazyBlock(Vector position) {
|
||||||
|
return super.getLazyBlock(getPos(position));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BaseBlock getBlock(Vector position) {
|
||||||
|
return super.getBlock(getPos(position));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BaseBiome getBiome(Vector2D position) {
|
||||||
|
mutable.x = position.getBlockX();
|
||||||
|
mutable.z = position.getBlockZ();
|
||||||
|
mutable.y = 0;
|
||||||
|
return super.getBiome(getPos(mutable).toVector2D());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean setBlock(int x, int y, int z, BaseBlock block) throws WorldEditException {
|
||||||
|
return super.setBlock(getPos(x, y, z), block);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean setBlock(Vector location, BaseBlock block) throws WorldEditException {
|
||||||
|
return super.setBlock(getPos(location), block);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean setBiome(Vector2D position, BaseBiome biome) {
|
||||||
|
mutable.x = position.getBlockX();
|
||||||
|
mutable.z = position.getBlockZ();
|
||||||
|
mutable.y = 0;
|
||||||
|
return super.setBiome(getPos(mutable).toVector2D(), biome);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTransform(Transform transform) {
|
||||||
|
this.transform = transform;
|
||||||
|
}
|
||||||
|
}
|
@ -31,7 +31,7 @@ public class TransformExtent extends BlockTransformExtent {
|
|||||||
this.min = pos;
|
this.min = pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Vector getPos(Vector pos) {
|
public Vector getPos(Vector pos) {
|
||||||
if (min == null) {
|
if (min == null) {
|
||||||
min = new Vector(pos);
|
min = new Vector(pos);
|
||||||
}
|
}
|
||||||
@ -45,7 +45,7 @@ public class TransformExtent extends BlockTransformExtent {
|
|||||||
return tmp;
|
return tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Vector getPos(int x, int y, int z) {
|
public Vector getPos(int x, int y, int z) {
|
||||||
if (min == null) {
|
if (min == null) {
|
||||||
min = new Vector(x, y, z);
|
min = new Vector(x, y, z);
|
||||||
}
|
}
|
||||||
|
@ -20,10 +20,9 @@
|
|||||||
package com.sk89q.worldedit.function.operation;
|
package com.sk89q.worldedit.function.operation;
|
||||||
|
|
||||||
import com.boydti.fawe.object.extent.BlockTranslateExtent;
|
import com.boydti.fawe.object.extent.BlockTranslateExtent;
|
||||||
import com.boydti.fawe.object.extent.TransformExtent;
|
import com.boydti.fawe.object.extent.PositionTransformExtent;
|
||||||
import com.boydti.fawe.object.function.block.SimpleBlockCopy;
|
import com.boydti.fawe.object.function.block.SimpleBlockCopy;
|
||||||
import com.sk89q.worldedit.Vector;
|
import com.sk89q.worldedit.Vector;
|
||||||
import com.sk89q.worldedit.WorldEdit;
|
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
import com.sk89q.worldedit.entity.Entity;
|
import com.sk89q.worldedit.entity.Entity;
|
||||||
import com.sk89q.worldedit.extent.Extent;
|
import com.sk89q.worldedit.extent.Extent;
|
||||||
@ -38,9 +37,6 @@ import com.sk89q.worldedit.function.visitor.RegionVisitor;
|
|||||||
import com.sk89q.worldedit.math.transform.Identity;
|
import com.sk89q.worldedit.math.transform.Identity;
|
||||||
import com.sk89q.worldedit.math.transform.Transform;
|
import com.sk89q.worldedit.math.transform.Transform;
|
||||||
import com.sk89q.worldedit.regions.Region;
|
import com.sk89q.worldedit.regions.Region;
|
||||||
import com.sk89q.worldedit.world.World;
|
|
||||||
import com.sk89q.worldedit.world.registry.BlockRegistry;
|
|
||||||
import com.sk89q.worldedit.world.registry.WorldData;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
@ -222,28 +218,18 @@ public class ForwardExtentCopy implements Operation {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Extent finalDest = destination;
|
Extent finalDest = destination;
|
||||||
TransformExtent transExt;
|
Vector translation = to.subtract(from);
|
||||||
if (!currentTransform.isIdentity()) {
|
if (!translation.equals(Vector.ZERO)) {
|
||||||
WorldData wd;
|
finalDest = new BlockTranslateExtent(finalDest, translation.getBlockX(), translation.getBlockY(), translation.getBlockZ());
|
||||||
if (destination instanceof World) {
|
|
||||||
wd = ((World) destination).getWorldData();
|
|
||||||
} else if (source instanceof World) {
|
|
||||||
wd = ((World) source).getWorldData();
|
|
||||||
} else {
|
|
||||||
wd = WorldEdit.getInstance().getServer().getWorlds().get(0).getWorldData();
|
|
||||||
}
|
}
|
||||||
BlockRegistry registry = wd.getBlockRegistry();
|
PositionTransformExtent transExt;
|
||||||
transExt = new TransformExtent(finalDest, registry);
|
if (!currentTransform.isIdentity()) {
|
||||||
transExt.setTransform(currentTransform);
|
transExt = new PositionTransformExtent(finalDest, currentTransform);
|
||||||
transExt.setOrigin(from);
|
transExt.setOrigin(from);
|
||||||
finalDest = transExt;
|
finalDest = transExt;
|
||||||
} else {
|
} else {
|
||||||
transExt = null;
|
transExt = null;
|
||||||
}
|
}
|
||||||
Vector translation = to.subtract(from);
|
|
||||||
if (!translation.equals(Vector.ZERO)) {
|
|
||||||
finalDest = new BlockTranslateExtent(finalDest, translation.getBlockX(), translation.getBlockY(), translation.getBlockZ());
|
|
||||||
}
|
|
||||||
RegionFunction copy = new SimpleBlockCopy(source, finalDest);
|
RegionFunction copy = new SimpleBlockCopy(source, finalDest);
|
||||||
if (sourceMask != Masks.alwaysTrue()) {
|
if (sourceMask != Masks.alwaysTrue()) {
|
||||||
copy = new RegionMaskingFilter(sourceMask, copy);
|
copy = new RegionMaskingFilter(sourceMask, copy);
|
||||||
|
Loading…
Reference in New Issue
Block a user