mirror of
https://github.com/YouHaveTrouble/BlockEdit.git
synced 2026-06-29 13:36:19 +00:00
fix issues with rotate
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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..."));
|
||||
|
||||
|
||||
@@ -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<Vector, BlockState> blocks = new HashMap<>();
|
||||
private HashMap<Vector, BlockState> 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<Vector, BlockState> entry : this.blocks.entrySet()) {
|
||||
HashMap<Vector, BlockState> newBlocks = new HashMap<>();
|
||||
Iterator<Map.Entry<Vector, BlockState>> iterator = this.blocks.entrySet().iterator();
|
||||
while (iterator.hasNext()) {
|
||||
Map.Entry<Vector, BlockState> 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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user