Skip to content
Permalink
Browse files

Apply transforms to clipboard masks.

Also make a copy of the clipboard holder for clipboard brush.
  • Loading branch information...
wizjany committed Aug 7, 2019
1 parent c461c60 commit 98df745daac7f315a3c7b48c1cc7ebf27667fc9b
@@ -160,7 +160,10 @@ public void clipboardBrush(Player player, LocalSession session,
@ClipboardMask
Mask sourceMask) throws WorldEditException {
ClipboardHolder holder = session.getClipboard();

Clipboard clipboard = holder.getClipboard();
ClipboardHolder newHolder = new ClipboardHolder(clipboard);
newHolder.setTransform(holder.getTransform());

BlockVector3 size = clipboard.getDimensions();

@@ -169,7 +172,7 @@ public void clipboardBrush(Player player, LocalSession session,
worldEdit.checkMaxBrushRadius(size.getBlockZ() / 2D - 1);

BrushTool tool = session.getBrushTool(player.getItemInHand(HandSide.MAIN_HAND).getType());
tool.setBrush(new ClipboardBrush(holder, ignoreAir, usingOrigin, pasteEntities, pasteBiomes, sourceMask), "worldedit.brush.clipboard");
tool.setBrush(new ClipboardBrush(newHolder, ignoreAir, usingOrigin, pasteEntities, pasteBiomes, sourceMask), "worldedit.brush.clipboard");

player.print("Clipboard brush shape equipped.");
}
@@ -29,10 +29,13 @@
import com.sk89q.worldedit.extension.input.ParserContext;
import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.extent.transform.BlockTransformExtent;
import com.sk89q.worldedit.function.mask.Mask;
import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.internal.annotation.ClipboardMask;
import com.sk89q.worldedit.internal.registry.AbstractFactory;
import com.sk89q.worldedit.math.transform.Transform;
import com.sk89q.worldedit.session.ClipboardHolder;
import com.sk89q.worldedit.session.request.RequestExtent;
import com.sk89q.worldedit.util.formatting.text.Component;
import com.sk89q.worldedit.util.formatting.text.TextComponent;
@@ -68,7 +71,15 @@ public static void register(WorldEdit worldEdit, CommandManager commandManager)
new FactoryConverter<>(worldEdit, WorldEdit::getMaskFactory, "mask",
context -> {
try {
context.setExtent(context.getSession().getClipboard().getClipboard());
ClipboardHolder holder = context.getSession().getClipboard();
Transform transform = holder.getTransform();
Extent target;
if (transform.isIdentity()) {
target = holder.getClipboard();
} else {
target = new BlockTransformExtent(holder.getClipboard(), transform);
}
context.setExtent(target);
} catch (EmptyClipboardException e) {
throw new IllegalStateException(e);
}

0 comments on commit 98df745

Please sign in to comment.
You can’t perform that action at this time.