From 0bfb1dbdd1fe75e9479a592cae1adfd965520fa8 Mon Sep 17 00:00:00 2001 From: Jesse Boyd Date: Tue, 5 Nov 2019 15:08:44 +0000 Subject: [PATCH] Fix BlockArrayClipboard offset --- .../fawe/bukkit/wrapper/AsyncChunk.java | 6 +- .../worldedit/command/ClipboardCommands.java | 2 +- .../extent/clipboard/BlockArrayClipboard.java | 68 +++++++++---------- 3 files changed, 37 insertions(+), 39 deletions(-) diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/wrapper/AsyncChunk.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/wrapper/AsyncChunk.java index 4829b18bf..d3537b1e4 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/wrapper/AsyncChunk.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/wrapper/AsyncChunk.java @@ -86,10 +86,8 @@ public class AsyncChunk implements Chunk { } if (world.isWorld()) { if (world.isChunkLoaded(x, z)) { - if (world.isChunkLoaded(x, z)) { - task.run(); - return task.value; - } + task.run(); + return task.value; } } return TaskManager.IMP.sync(task); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/ClipboardCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/ClipboardCommands.java index 184706dee..26518716b 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/ClipboardCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/ClipboardCommands.java @@ -139,7 +139,7 @@ public class ClipboardCommands { actor.checkConfirmationRegion(() -> { session.setClipboard(null); - BlockArrayClipboard clipboard = new BlockArrayClipboard(region, actor.getUniqueId()); + Clipboard clipboard = new BlockArrayClipboard(region, actor.getUniqueId()); session.setClipboard(new ClipboardHolder(clipboard)); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/BlockArrayClipboard.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/BlockArrayClipboard.java index 8c4b6bee3..a9a31ff64 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/BlockArrayClipboard.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/BlockArrayClipboard.java @@ -50,7 +50,7 @@ import static com.google.common.base.Preconditions.checkNotNull; public class BlockArrayClipboard extends DelegateClipboard implements Clipboard, Closeable { private Region region; - private BlockVector3 origin; + private BlockVector3 offset; public BlockArrayClipboard(Region region) { this(region, UUID.randomUUID()); @@ -67,14 +67,14 @@ public class BlockArrayClipboard extends DelegateClipboard implements Clipboard, this(region, Clipboard.create(region.getDimensions(), clipboardId)); checkNotNull(region); this.region = region.clone(); - this.origin = region.getMinimumPoint(); + this.offset = region.getMinimumPoint(); } public BlockArrayClipboard(Region region, Clipboard clipboard) { super(clipboard); checkNotNull(region); this.region = region.clone(); - this.origin = region.getMinimumPoint(); + this.offset = region.getMinimumPoint(); } @Override @@ -88,12 +88,12 @@ public class BlockArrayClipboard extends DelegateClipboard implements Clipboard, @Override public BlockVector3 getOrigin() { - return origin; + return getParent().getOrigin().add(region.getMinimumPoint()); } @Override public void setOrigin(BlockVector3 origin) { - this.origin = origin; +// this.origin = origin; getParent().setOrigin(origin.subtract(region.getMinimumPoint())); } @@ -110,9 +110,9 @@ public class BlockArrayClipboard extends DelegateClipboard implements Clipboard, @Override public BlockState getBlock(BlockVector3 position) { if (region.contains(position)) { - int x = position.getBlockX()- origin.getX(); - int y = position.getBlockY()- origin.getY(); - int z = position.getBlockZ()- origin.getZ(); + int x = position.getBlockX()- offset.getX(); + int y = position.getBlockY()- offset.getY(); + int z = position.getBlockZ()- offset.getZ(); return getParent().getBlock(x, y, z); } @@ -122,9 +122,9 @@ public class BlockArrayClipboard extends DelegateClipboard implements Clipboard, @Override public BaseBlock getFullBlock(BlockVector3 position) { if(region.contains(position)) { - int x = position.getBlockX()- origin.getX(); - int y = position.getBlockY()- origin.getY(); - int z = position.getBlockZ()- origin.getZ(); + int x = position.getBlockX()- offset.getX(); + int y = position.getBlockY()- offset.getY(); + int z = position.getBlockZ()- offset.getZ(); return getParent().getFullBlock(x, y, z); } return BlockTypes.AIR.getDefaultState().toBaseBlock(); @@ -143,9 +143,9 @@ public class BlockArrayClipboard extends DelegateClipboard implements Clipboard, @Override public boolean setTile(int x, int y, int z, CompoundTag tag) { - x -= origin.getX(); - y -= origin.getY(); - z -= origin.getZ(); + x -= offset.getX(); + y -= offset.getY(); + z -= offset.getZ(); return getParent().setTile(x, y, z, tag); } @@ -155,9 +155,9 @@ public class BlockArrayClipboard extends DelegateClipboard implements Clipboard, @Override public > boolean setBlock(int x, int y, int z, B block) throws WorldEditException { - x -= origin.getX(); - y -= origin.getY(); - z -= origin.getZ(); + x -= offset.getX(); + y -= offset.getY(); + z -= offset.getZ(); return getParent().setBlock(x, y, z, block); } @@ -174,23 +174,23 @@ public class BlockArrayClipboard extends DelegateClipboard implements Clipboard, @Override public boolean setBiome(BlockVector2 position, BiomeType biome) { - int x = position.getBlockX() - origin.getX(); - int z = position.getBlockZ() - origin.getZ(); + int x = position.getBlockX() - offset.getX(); + int z = position.getBlockZ() - offset.getZ(); return getParent().setBiome(x, 0, z, biome); } @Override public boolean setBiome(int x, int y, int z, BiomeType biome) { - x -= origin.getX(); - y -= origin.getY(); - z -= origin.getZ(); + x -= offset.getX(); + y -= offset.getY(); + z -= offset.getZ(); return getParent().setBiome(x, y, z, biome); } @Override public List getEntities(Region region) { region = region.clone(); - region.shift(origin); + region.shift(BlockVector3.ZERO.subtract(offset)); return getParent().getEntities(region); } @@ -203,32 +203,32 @@ public class BlockArrayClipboard extends DelegateClipboard implements Clipboard, @Override @Nullable public void removeEntity(int x, int y, int z, UUID uuid) { - x -= origin.getX(); - y -= origin.getY(); - z -= origin.getZ(); + x -= offset.getX(); + y -= offset.getY(); + z -= offset.getZ(); getParent().removeEntity(x, y, z, uuid); } @Override public BlockState getBlock(int x, int y, int z) { - x -= origin.getX(); - y -= origin.getY(); - z -= origin.getZ(); + x -= offset.getX(); + y -= offset.getY(); + z -= offset.getZ(); return getParent().getBlock(x, y, z); } @Override public BaseBlock getFullBlock(int x, int y, int z) { - x -= origin.getX(); - y -= origin.getY(); - z -= origin.getZ(); + x -= offset.getX(); + y -= offset.getY(); + z -= offset.getZ(); return getParent().getFullBlock(x, y, z); } @Override public BiomeType getBiomeType(int x, int z) { - x -= origin.getX(); - z -= origin.getZ(); + x -= offset.getX(); + z -= offset.getZ(); return getParent().getBiomeType(x, z); }