Add flag for copy brush random rotate
This commit is contained in:
parent
8c592d1506
commit
e9250d6e7c
@ -28,7 +28,7 @@ ext {
|
|||||||
date = git.head().date.format("yy.MM.dd")
|
date = git.head().date.format("yy.MM.dd")
|
||||||
revision = "-${git.head().abbreviatedId}"
|
revision = "-${git.head().abbreviatedId}"
|
||||||
parents = git.head().parentIds;
|
parents = git.head().parentIds;
|
||||||
index = -76; // Offset to mach CI
|
index = -77; // Offset to mach CI
|
||||||
int major, minor, patch;
|
int major, minor, patch;
|
||||||
major = minor = patch = 0;
|
major = minor = patch = 0;
|
||||||
for (;parents != null && !parents.isEmpty();index++) {
|
for (;parents != null && !parents.isEmpty();index++) {
|
||||||
|
@ -2,6 +2,7 @@ package com.boydti.fawe.object.brush;
|
|||||||
|
|
||||||
import com.boydti.fawe.config.BBC;
|
import com.boydti.fawe.config.BBC;
|
||||||
import com.boydti.fawe.object.FawePlayer;
|
import com.boydti.fawe.object.FawePlayer;
|
||||||
|
import com.boydti.fawe.object.PseudoRandom;
|
||||||
import com.boydti.fawe.object.brush.visualization.VisualExtent;
|
import com.boydti.fawe.object.brush.visualization.VisualExtent;
|
||||||
import com.boydti.fawe.object.clipboard.ResizableClipboardBuilder;
|
import com.boydti.fawe.object.clipboard.ResizableClipboardBuilder;
|
||||||
import com.boydti.fawe.object.function.NullRegionFunction;
|
import com.boydti.fawe.object.function.NullRegionFunction;
|
||||||
@ -20,6 +21,7 @@ import com.sk89q.worldedit.function.operation.Operation;
|
|||||||
import com.sk89q.worldedit.function.operation.Operations;
|
import com.sk89q.worldedit.function.operation.Operations;
|
||||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||||
import com.sk89q.worldedit.function.visitor.RecursiveVisitor;
|
import com.sk89q.worldedit.function.visitor.RecursiveVisitor;
|
||||||
|
import com.sk89q.worldedit.math.transform.AffineTransform;
|
||||||
import com.sk89q.worldedit.regions.Region;
|
import com.sk89q.worldedit.regions.Region;
|
||||||
import com.sk89q.worldedit.session.ClipboardHolder;
|
import com.sk89q.worldedit.session.ClipboardHolder;
|
||||||
|
|
||||||
@ -27,11 +29,13 @@ public class CopyPastaBrush implements Brush, ResettableTool {
|
|||||||
|
|
||||||
private final BrushTool tool;
|
private final BrushTool tool;
|
||||||
private final LocalSession session;
|
private final LocalSession session;
|
||||||
|
private final boolean randomRotate;
|
||||||
|
|
||||||
public CopyPastaBrush(BrushTool tool, LocalSession session) {
|
public CopyPastaBrush(BrushTool tool, LocalSession session, boolean randomRotate) {
|
||||||
this.tool = tool;
|
this.tool = tool;
|
||||||
session.setClipboard(null);
|
session.setClipboard(null);
|
||||||
this.session = session;
|
this.session = session;
|
||||||
|
this.randomRotate = randomRotate;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -82,6 +86,10 @@ public class CopyPastaBrush implements Brush, ResettableTool {
|
|||||||
BBC.COMMAND_COPY.send(fp, blocks);
|
BBC.COMMAND_COPY.send(fp, blocks);
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
|
if (randomRotate) {
|
||||||
|
int rotate = 90 * PseudoRandom.random.nextInt(4);
|
||||||
|
clipboard.setTransform(rotate != 0 ? new AffineTransform().rotateY(rotate) : new AffineTransform());
|
||||||
|
}
|
||||||
Clipboard faweClip = clipboard.getClipboard();
|
Clipboard faweClip = clipboard.getClipboard();
|
||||||
Region region = faweClip.getRegion();
|
Region region = faweClip.getRegion();
|
||||||
Vector centerOffset = region.getCenter().subtract(faweClip.getOrigin());
|
Vector centerOffset = region.getCenter().subtract(faweClip.getOrigin());
|
||||||
|
@ -401,7 +401,7 @@ public class BrushCommands {
|
|||||||
max = 2
|
max = 2
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.brush.sphere")
|
@CommandPermissions("worldedit.brush.sphere")
|
||||||
public void circleBrush(Player player, LocalSession session, Pattern fill, @Optional("5") double radius, @Switch('h') boolean hollow) throws WorldEditException {
|
public void circleBrush(Player player, LocalSession session, Pattern fill, @Optional("5") double radius) throws WorldEditException {
|
||||||
worldEdit.checkMaxBrushRadius(radius);
|
worldEdit.checkMaxBrushRadius(radius);
|
||||||
BrushTool tool = session.getBrushTool(player.getItemInHand(), player);
|
BrushTool tool = session.getBrushTool(player.getItemInHand(), player);
|
||||||
tool.setSize(radius);
|
tool.setSize(radius);
|
||||||
@ -760,16 +760,17 @@ public class BrushCommands {
|
|||||||
desc = "Copy Paste brush",
|
desc = "Copy Paste brush",
|
||||||
help =
|
help =
|
||||||
"Left click the base of an object to copy.\n" +
|
"Left click the base of an object to copy.\n" +
|
||||||
"Right click to paste",
|
"Right click to paste\n" +
|
||||||
|
"The -r flag Will apply random rotation on paste",
|
||||||
min = 0,
|
min = 0,
|
||||||
max = 1
|
max = 1
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.brush.copy")
|
@CommandPermissions("worldedit.brush.copy")
|
||||||
public void copy(Player player, LocalSession session, @Optional("5") double radius) throws WorldEditException {
|
public void copy(Player player, LocalSession session, @Optional("5") double radius, @Switch('r') boolean rotate) throws WorldEditException {
|
||||||
worldEdit.checkMaxBrushRadius(radius);
|
worldEdit.checkMaxBrushRadius(radius);
|
||||||
BrushTool tool = session.getBrushTool(player.getItemInHand(), player);
|
BrushTool tool = session.getBrushTool(player.getItemInHand(), player);
|
||||||
tool.setSize(radius);
|
tool.setSize(radius);
|
||||||
tool.setBrush(new CopyPastaBrush(tool, session), "worldedit.brush.copy", player);
|
tool.setBrush(new CopyPastaBrush(tool, session, rotate), "worldedit.brush.copy", player);
|
||||||
player.print(BBC.getPrefix() + BBC.BRUSH_COPY.f(radius));
|
player.print(BBC.getPrefix() + BBC.BRUSH_COPY.f(radius));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user