diff --git a/src/main/java/me/youhavetrouble/blockedit/BEPlayer.java b/src/main/java/me/youhavetrouble/blockedit/BEPlayer.java index 9f6c233..74f6b82 100644 --- a/src/main/java/me/youhavetrouble/blockedit/BEPlayer.java +++ b/src/main/java/me/youhavetrouble/blockedit/BEPlayer.java @@ -73,10 +73,7 @@ public class BEPlayer { return; } - selection = BoundingBox.of(selectionPoint1, selectionPoint2); - // bounding boxes are dumb. - selection.expand(0.5, 0.5, 0.5); - selection.shift(0.5,0.5,0.5); + selection = BoundingBox.of(selectionPoint1.toBlockLocation(), selectionPoint2.toBlockLocation()); } public void setSelectionPoint1(Location selectionPoint1) { diff --git a/src/main/java/me/youhavetrouble/blockedit/commands/PasteCommand.java b/src/main/java/me/youhavetrouble/blockedit/commands/PasteCommand.java index 737601c..346769f 100644 --- a/src/main/java/me/youhavetrouble/blockedit/commands/PasteCommand.java +++ b/src/main/java/me/youhavetrouble/blockedit/commands/PasteCommand.java @@ -39,6 +39,7 @@ public class PasteCommand extends Command { }); Selection selection = Selection.fromClipboard(absoluteBlocks.keySet(), player.getWorld()); + selection.expand(1); BlockEditAPI.runOperation(selection, 1, new PasteOperation(absoluteBlocks)); player.sendMessage(Component.text("Pasting clipboard...")); diff --git a/src/main/java/me/youhavetrouble/blockedit/util/Clipboard.java b/src/main/java/me/youhavetrouble/blockedit/util/Clipboard.java index 28264dd..85333c5 100644 --- a/src/main/java/me/youhavetrouble/blockedit/util/Clipboard.java +++ b/src/main/java/me/youhavetrouble/blockedit/util/Clipboard.java @@ -6,6 +6,7 @@ import org.bukkit.block.BlockState; import java.util.Collections; import java.util.HashMap; +import java.util.Iterator; import java.util.Map; public class Clipboard { @@ -13,7 +14,7 @@ public class Clipboard { /** * Map of locations relative to the center of the clipboard and their block states */ - private final HashMap blocks = new HashMap<>(); + private HashMap blocks = new HashMap<>(); private Location baseLocation; private Vector baseLocationVector; @@ -56,12 +57,18 @@ public class Clipboard { */ public void rotate(double angle) { double radians = Math.toRadians(angle); - for (Map.Entry entry : this.blocks.entrySet()) { + HashMap newBlocks = new HashMap<>(); + Iterator> iterator = this.blocks.entrySet().iterator(); + while (iterator.hasNext()) { + Map.Entry entry = iterator.next(); Vector relativeLocation = entry.getKey(); relativeLocation.rotateAroundY(radians); relativeLocation.setX(Math.round(relativeLocation.getX())); relativeLocation.setZ(Math.round(relativeLocation.getZ())); + newBlocks.put(relativeLocation, entry.getValue()); + iterator.remove(); } + this.blocks = newBlocks; } }