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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
selection = BoundingBox.of(selectionPoint1, selectionPoint2);
|
selection = BoundingBox.of(selectionPoint1.toBlockLocation(), selectionPoint2.toBlockLocation());
|
||||||
// bounding boxes are dumb.
|
|
||||||
selection.expand(0.5, 0.5, 0.5);
|
|
||||||
selection.shift(0.5,0.5,0.5);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSelectionPoint1(Location selectionPoint1) {
|
public void setSelectionPoint1(Location selectionPoint1) {
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ public class PasteCommand extends Command {
|
|||||||
});
|
});
|
||||||
|
|
||||||
Selection selection = Selection.fromClipboard(absoluteBlocks.keySet(), player.getWorld());
|
Selection selection = Selection.fromClipboard(absoluteBlocks.keySet(), player.getWorld());
|
||||||
|
selection.expand(1);
|
||||||
BlockEditAPI.runOperation(selection, 1, new PasteOperation(absoluteBlocks));
|
BlockEditAPI.runOperation(selection, 1, new PasteOperation(absoluteBlocks));
|
||||||
player.sendMessage(Component.text("Pasting clipboard..."));
|
player.sendMessage(Component.text("Pasting clipboard..."));
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import org.bukkit.block.BlockState;
|
|||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.Iterator;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class Clipboard {
|
public class Clipboard {
|
||||||
@@ -13,7 +14,7 @@ public class Clipboard {
|
|||||||
/**
|
/**
|
||||||
* Map of locations relative to the center of the clipboard and their block states
|
* 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 Location baseLocation;
|
||||||
private Vector baseLocationVector;
|
private Vector baseLocationVector;
|
||||||
|
|
||||||
@@ -56,12 +57,18 @@ public class Clipboard {
|
|||||||
*/
|
*/
|
||||||
public void rotate(double angle) {
|
public void rotate(double angle) {
|
||||||
double radians = Math.toRadians(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();
|
Vector relativeLocation = entry.getKey();
|
||||||
relativeLocation.rotateAroundY(radians);
|
relativeLocation.rotateAroundY(radians);
|
||||||
relativeLocation.setX(Math.round(relativeLocation.getX()));
|
relativeLocation.setX(Math.round(relativeLocation.getX()));
|
||||||
relativeLocation.setZ(Math.round(relativeLocation.getZ()));
|
relativeLocation.setZ(Math.round(relativeLocation.getZ()));
|
||||||
|
newBlocks.put(relativeLocation, entry.getValue());
|
||||||
|
iterator.remove();
|
||||||
}
|
}
|
||||||
|
this.blocks = newBlocks;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user