Add entity, biome, and mask flags to clipboard brush.

Dieser Commit ist enthalten in:
wizjany 2019-04-25 20:48:15 -04:00 committet von Matthew Miller
Ursprung 31a8328fb5
Commit 648ecf2153
5 geänderte Dateien mit 36 neuen und 14 gelöschten Zeilen

Datei anzeigen

@ -131,7 +131,7 @@ public class BrushCommands {
@Command(
aliases = { "clipboard", "copy" },
usage = "",
flags = "ap",
flags = "aoebm",
desc = "Choose the clipboard brush",
help =
"Chooses the clipboard brush.\n" +
@ -141,7 +141,8 @@ public class BrushCommands {
"stood relative to the copied area when you copied it."
)
@CommandPermissions("worldedit.brush.clipboard")
public void clipboardBrush(Player player, LocalSession session, @Switch('a') boolean ignoreAir, @Switch('p') boolean usingOrigin) throws WorldEditException {
public void clipboardBrush(Player player, LocalSession session, @Switch('a') boolean ignoreAir, @Switch('o') boolean usingOrigin,
@Switch('e') boolean pasteEntities, @Switch('b') boolean pasteBiomes, @Switch('m') Mask sourceMask) throws WorldEditException {
ClipboardHolder holder = session.getClipboard();
Clipboard clipboard = holder.getClipboard();
@ -152,7 +153,7 @@ public class BrushCommands {
worldEdit.checkMaxBrushRadius(size.getBlockZ() / 2D - 1);
BrushTool tool = session.getBrushTool(player.getItemInHand(HandSide.MAIN_HAND).getType());
tool.setBrush(new ClipboardBrush(holder, ignoreAir, usingOrigin), "worldedit.brush.clipboard");
tool.setBrush(new ClipboardBrush(holder, ignoreAir, usingOrigin, pasteEntities, pasteBiomes, sourceMask), "worldedit.brush.clipboard");
player.print("Clipboard brush shape equipped.");
}

Datei anzeigen

@ -170,16 +170,14 @@ public class ClipboardCommands {
Region region = clipboard.getRegion();
BlockVector3 to = atOrigin ? clipboard.getOrigin() : session.getPlacementPosition(player);
PasteBuilder builder = holder
Operation operation = holder
.createPaste(editSession)
.to(to)
.ignoreAirBlocks(ignoreAirBlocks)
.copyBiomes(pasteBiomes)
.copyEntities(pasteEntities);
if (sourceMask != null) {
builder.maskSource(sourceMask);
}
Operation operation = builder.build();
.copyEntities(pasteEntities)
.maskSource(sourceMask)
.build();
Operations.completeLegacy(operation);
if (selectPasted) {

Datei anzeigen

@ -22,6 +22,7 @@ package com.sk89q.worldedit.command.tool.brush;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.MaxChangedBlocksException;
import com.sk89q.worldedit.extent.clipboard.Clipboard;
import com.sk89q.worldedit.function.mask.Mask;
import com.sk89q.worldedit.function.operation.Operation;
import com.sk89q.worldedit.function.operation.Operations;
import com.sk89q.worldedit.function.pattern.Pattern;
@ -31,14 +32,30 @@ import com.sk89q.worldedit.session.ClipboardHolder;
public class ClipboardBrush implements Brush {
private ClipboardHolder holder;
private boolean ignoreAirBlocks;
private boolean usingOrigin;
private final ClipboardHolder holder;
private final boolean ignoreAirBlocks;
private final boolean usingOrigin;
private final boolean pasteEntities;
private final boolean pasteBiomes;
private final Mask sourceMask;
public ClipboardBrush(ClipboardHolder holder, boolean ignoreAirBlocks, boolean usingOrigin) {
this.holder = holder;
this.ignoreAirBlocks = ignoreAirBlocks;
this.usingOrigin = usingOrigin;
this.pasteBiomes = false;
this.pasteEntities = false;
this.sourceMask = null;
}
public ClipboardBrush(ClipboardHolder holder, boolean ignoreAirBlocks, boolean usingOrigin, boolean pasteEntities,
boolean pasteBiomes, Mask sourceMask) {
this.holder = holder;
this.ignoreAirBlocks = ignoreAirBlocks;
this.usingOrigin = usingOrigin;
this.pasteEntities = pasteEntities;
this.pasteBiomes = pasteBiomes;
this.sourceMask = sourceMask;
}
@Override
@ -51,6 +68,9 @@ public class ClipboardBrush implements Brush {
.createPaste(editSession)
.to(usingOrigin ? position : position.subtract(centerOffset))
.ignoreAirBlocks(ignoreAirBlocks)
.copyEntities(pasteEntities)
.copyBiomes(pasteBiomes)
.maskSource(sourceMask)
.build();
Operations.completeLegacy(operation);

Datei anzeigen

@ -23,7 +23,6 @@ import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.function.FlatRegionFunction;
import com.sk89q.worldedit.math.BlockVector2;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.math.transform.Transform;
import com.sk89q.worldedit.world.biome.BiomeType;
@ -32,7 +31,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
/**
* Copies the biome from one extent to another.
*/
public class ExtentBiomeCopy implements FlatRegionFunction {
public class ExtentBiomeCopy implements FlatRegionFunction {
private final Extent source;
private final Extent destination;

Datei anzeigen

@ -83,6 +83,10 @@ public class PasteBuilder {
* @return this builder instance
*/
public PasteBuilder maskSource(Mask sourceMask) {
if (sourceMask == null) {
this.sourceMask = Masks.alwaysTrue();
return this;
}
this.sourceMask = sourceMask;
return this;
}