@Command( aliases = {"/copy"}, flags = "e", desc = "Копирует выделенную территорию в буфер обмена", help = "Копирует выделенную территорию в буфер обмен\n" + "Флаги:\n" + " -e определяет, будут ли объекты копироваться в буфер обмена\n" + "ПРЕДУПРЕЖДЕНИЕ: Вставленные объекты не могут быть отменены!", min = 0, max = 0) @CommandPermissions("worldedit.clipboard.copy") public void copy( CommandContext args, LocalSession session, LocalPlayer player, EditSession editSession) throws WorldEditException { Region region = session.getSelection(player.getWorld()); Vector min = region.getMinimumPoint(); Vector max = region.getMaximumPoint(); Vector pos = session.getPlacementPosition(player); CuboidClipboard clipboard = new CuboidClipboard(max.subtract(min).add(new Vector(1, 1, 1)), min, min.subtract(pos)); clipboard.copy(editSession); if (args.hasFlag('e')) { for (LocalEntity entity : player.getWorld().getEntities(region)) { clipboard.storeEntity(entity); } } session.setClipboard(clipboard); player.print("Блок(и) скопирован(ы)."); }
@Command( aliases = {"/copy"}, flags = "em", desc = "Copy the selection to the clipboard", help = "Copy the selection to the clipboard\n" + "Flags:\n" + " -e controls whether entities are copied\n" + " -m sets a source mask so that excluded blocks become air\n" + "WARNING: Pasting entities cannot yet be undone!", min = 0, max = 0) @CommandPermissions("worldedit.clipboard.copy") public void copy( Player player, LocalSession session, EditSession editSession, @Selection Region region, @Switch('e') boolean copyEntities, @Switch('m') Mask mask) throws WorldEditException { BlockArrayClipboard clipboard = new BlockArrayClipboard(region); clipboard.setOrigin(session.getPlacementPosition(player)); ForwardExtentCopy copy = new ForwardExtentCopy(editSession, region, clipboard, region.getMinimumPoint()); if (mask != null) { copy.setSourceMask(mask); } Operations.completeLegacy(copy); session.setClipboard(new ClipboardHolder(clipboard, editSession.getWorld().getWorldData())); player.print(region.getArea() + " block(s) were copied."); }
@Command( aliases = {"/paste"}, usage = "", flags = "sao", desc = "Paste the clipboard's contents", help = "Pastes the clipboard's contents.\n" + "Flags:\n" + " -a skips air blocks\n" + " -o pastes at the original position\n" + " -s selects the region after pasting", min = 0, max = 0) @CommandPermissions("worldedit.clipboard.paste") @Logging(PLACEMENT) public void paste( Player player, LocalSession session, EditSession editSession, @Switch('a') boolean ignoreAirBlocks, @Switch('o') boolean atOrigin, @Switch('s') boolean selectPasted) throws WorldEditException { ClipboardHolder holder = session.getClipboard(); Clipboard clipboard = holder.getClipboard(); Region region = clipboard.getRegion(); Vector to = atOrigin ? clipboard.getOrigin() : session.getPlacementPosition(player); Operation operation = holder .createPaste(editSession, editSession.getWorld().getWorldData()) .to(to) .ignoreAirBlocks(ignoreAirBlocks) .build(); Operations.completeLegacy(operation); if (selectPasted) { Vector clipboardOffset = clipboard.getRegion().getMinimumPoint().subtract(clipboard.getOrigin()); Vector realTo = to.add(holder.getTransform().apply(clipboardOffset)); Vector max = realTo.add( holder .getTransform() .apply(region.getMaximumPoint().subtract(region.getMinimumPoint()))); RegionSelector selector = new CuboidRegionSelector(player.getWorld(), realTo, max); session.setRegionSelector(player.getWorld(), selector); selector.learnChanges(); selector.explainRegionAdjust(player, session); } player.print("The clipboard has been pasted at " + to); }
@Command( aliases = {"/deform"}, usage = "<expression>", desc = "Deforms a selected region with an expression", help = "Deforms a selected region with an expression\n" + "The expression is executed for each block and is expected\n" + "to modify the variables x, y and z to point to a new block\n" + "to fetch. See also tinyurl.com/wesyntax.", flags = "ro", min = 1, max = -1) @CommandPermissions("worldedit.region.deform") @Logging(ALL) public void deform( Player player, LocalSession session, EditSession editSession, @Selection Region region, @Text String expression, @Switch('r') boolean useRawCoords, @Switch('o') boolean offset) throws WorldEditException { final Vector zero; Vector unit; if (useRawCoords) { zero = Vector.ZERO; unit = Vector.ONE; } else if (offset) { zero = session.getPlacementPosition(player); unit = Vector.ONE; } else { final Vector min = region.getMinimumPoint(); final Vector max = region.getMaximumPoint(); zero = max.add(min).multiply(0.5); unit = max.subtract(zero); if (unit.getX() == 0) unit = unit.setX(1.0); if (unit.getY() == 0) unit = unit.setY(1.0); if (unit.getZ() == 0) unit = unit.setZ(1.0); } try { final int affected = editSession.deformRegion(region, zero, unit, expression); player.findFreePosition(); BBC.VISITOR_BLOCK.send(player, affected); } catch (ExpressionException e) { player.printError(e.getMessage()); } }
@Command( aliases = {"/cut"}, usage = "[leave-id]", desc = "Вырезает выделенную территорию в буфер обмена", help = "Вырезает выделенную территорию в буфер обмена\n" + "Флаги:\n" + " -e controls определяет, будут ли объекты копироваться в буфер обмена\n" + "ПРЕДУПРЕЖДЕНИЕ: Вырезанные и вставленные объекты не могут быть отменены!", flags = "e", min = 0, max = 1) @CommandPermissions("worldedit.clipboard.cut") @Logging(REGION) public void cut( CommandContext args, LocalSession session, LocalPlayer player, EditSession editSession) throws WorldEditException { BaseBlock block = new BaseBlock(BlockID.AIR); LocalWorld world = player.getWorld(); if (args.argsLength() > 0) { block = we.getBlock(player, args.getString(0)); } Region region = session.getSelection(world); Vector min = region.getMinimumPoint(); Vector max = region.getMaximumPoint(); Vector pos = session.getPlacementPosition(player); CuboidClipboard clipboard = new CuboidClipboard(max.subtract(min).add(new Vector(1, 1, 1)), min, min.subtract(pos)); clipboard.copy(editSession); if (args.hasFlag('e')) { LocalEntity[] entities = world.getEntities(region); for (LocalEntity entity : entities) { clipboard.storeEntity(entity); } world.killEntities(entities); } session.setClipboard(clipboard); int affected = editSession.setBlocks(session.getSelection(world), block); player.print( affected + " " + StringUtil.plural(affected, "блок вырезан", "блока вырезано", "блоков вырезано") + "."); }
/** * Find needed chunks in the axis-aligned bounding box of the region. * * @param region The {@link Region} to iterate */ private void findNeededCuboidChunks(Region region) { Vector min = region.getMinimumPoint(); Vector max = region.getMaximumPoint(); // First, we need to group points by chunk so that we only need // to keep one chunk in memory at any given moment for (int x = min.getBlockX(); x <= max.getBlockX(); ++x) { for (int y = min.getBlockY(); y <= max.getBlockY(); ++y) { for (int z = min.getBlockZ(); z <= max.getBlockZ(); ++z) { Vector pos = new Vector(x, y, z); checkAndAddBlock(pos); } } } }
@Command( aliases = {"/move"}, usage = "[count] [direction] [leave-id]", flags = "s", desc = "Move the contents of the selection", min = 0, max = 3) @CommandPermissions("worldedit.region.move") @Logging(ORIENTATION_REGION) public static void move( CommandContext args, WorldEdit we, LocalSession session, LocalPlayer player, EditSession editSession) throws WorldEditException { int count = args.argsLength() > 0 ? Math.max(1, args.getInteger(0)) : 1; Vector dir = we.getDirection(player, args.argsLength() > 1 ? args.getString(1).toLowerCase() : "me"); BaseBlock replace; // Replacement block argument if (args.argsLength() > 2) { replace = we.getBlock(player, args.getString(2)); } else { replace = new BaseBlock(BlockID.AIR); } int affected = editSession.moveCuboidRegion( session.getSelection(player.getWorld()), dir, count, true, replace); if (args.hasFlag('s')) { try { Region region = session.getSelection(player.getWorld()); region.expand(dir.multiply(count)); region.contract(dir.multiply(count)); session.getRegionSelector().learnChanges(); session.getRegionSelector().explainRegionAdjust(player, session); } catch (RegionOperationException e) { player.printError(e.getMessage()); } } player.print(affected + " blocks moved."); }
@Command( aliases = {"/stack"}, usage = "[count] [direction]", flags = "sa", desc = "Repeat the contents of the selection", help = "Repeats the contents of the selection.\n" + "Flags:\n" + " -s shifts the selection to the last stacked copy\n" + " -a skips air blocks", min = 0, max = 2) @CommandPermissions("worldedit.region.stack") @Logging(ORIENTATION_REGION) public void stack( Player player, EditSession editSession, LocalSession session, @Selection Region region, @Optional("1") @Range(min = 1) int count, @Optional(Direction.AIM) @Direction Vector direction, @Switch('s') boolean moveSelection, @Switch('a') boolean ignoreAirBlocks) throws WorldEditException { int affected = editSession.stackCuboidRegion(region, direction, count, !ignoreAirBlocks); if (moveSelection) { try { final Vector size = region.getMaximumPoint().subtract(region.getMinimumPoint()); final Vector shiftVector = direction.multiply(count * (Math.abs(direction.dot(size)) + 1)); region.shift(shiftVector); session.getRegionSelector(player.getWorld()).learnChanges(); session.getRegionSelector(player.getWorld()).explainRegionAdjust(player, session); } catch (RegionOperationException e) { player.printError(e.getMessage()); } } BBC.VISITOR_BLOCK.send(player, affected); }
@Command( aliases = {"/stack"}, usage = "[count] [direction]", flags = "sa", desc = "Repeat the contents of the selection", min = 0, max = 2) @CommandPermissions("worldedit.region.stack") @Logging(ORIENTATION_REGION) public static void stack( CommandContext args, WorldEdit we, LocalSession session, LocalPlayer player, EditSession editSession) throws WorldEditException { int count = args.argsLength() > 0 ? Math.max(1, args.getInteger(0)) : 1; Vector dir = we.getDiagonalDirection( player, args.argsLength() > 1 ? args.getString(1).toLowerCase() : "me"); int affected = editSession.stackCuboidRegion( session.getSelection(player.getWorld()), dir, count, !args.hasFlag('a')); if (args.hasFlag('s')) { try { Region region = session.getSelection(player.getWorld()); region.expand(dir.multiply(count)); region.contract(dir.multiply(count)); session.getRegionSelector().learnChanges(); session.getRegionSelector().explainRegionAdjust(player, session); } catch (RegionOperationException e) { player.printError(e.getMessage()); } } player.print(affected + " blocks changed. Undo with //undo"); }
/** * Find needed chunks in the cuboid of the region. * * @param region */ private void findNeededCuboidChunks(Region region) { Vector min = region.getMinimumPoint(); Vector max = region.getMaximumPoint(); // First, we need to group points by chunk so that we only need // to keep one chunk in memory at any given moment for (int x = min.getBlockX(); x <= max.getBlockX(); ++x) { for (int y = min.getBlockY(); y <= max.getBlockY(); ++y) { for (int z = min.getBlockZ(); z <= max.getBlockZ(); ++z) { Vector pos = new Vector(x, y, z); BlockVector2D chunkPos = ChunkStore.toChunk(pos); // Unidentified chunk if (!neededChunks.containsKey(chunkPos)) { neededChunks.put(chunkPos, new ArrayList<Vector>()); } neededChunks.get(chunkPos).add(pos); } } } }
@Command( aliases = {"/move"}, usage = "[count] [direction] [leave-id]", flags = "s", desc = "Move the contents of the selection", help = "Moves the contents of the selection.\n" + "The -s flag shifts the selection to the target location.\n" + "Optionally fills the old location with <leave-id>.", min = 0, max = 3) @CommandPermissions("worldedit.region.move") @Logging(ORIENTATION_REGION) public void move( Player player, EditSession editSession, LocalSession session, @Selection Region region, @Optional("1") @Range(min = 1) int count, @Optional(Direction.AIM) @Direction Vector direction, @Optional("air") BaseBlock replace, @Switch('s') boolean moveSelection) throws WorldEditException { int affected = editSession.moveRegion(region, direction, count, true, replace); if (moveSelection) { try { region.shift(direction.multiply(count)); session.getRegionSelector(player.getWorld()).learnChanges(); session.getRegionSelector(player.getWorld()).explainRegionAdjust(player, session); } catch (RegionOperationException e) { player.printError(e.getMessage()); } } BBC.VISITOR_BLOCK.send(player, affected); }
@Command( aliases = {"/setskylight"}, desc = "Set sky lighting in a selection", min = 1, max = 1) @CommandPermissions("worldedit.light.set") public void setskylighting( Player player, EditSession editSession, @Selection Region region, int value) { FawePlayer fp = FawePlayer.wrap(player); final FaweLocation loc = fp.getLocation(); final int cx = loc.x >> 4; final int cz = loc.z >> 4; final NMSMappedFaweQueue queue = (NMSMappedFaweQueue) SetQueue.IMP.getNewQueue(fp.getWorld(), true, false); for (Vector pt : region) { queue.setSkyLight((int) pt.x, (int) pt.y, (int) pt.z, value); } int count = 0; for (Vector2D chunk : region.getChunks()) { queue.sendChunk(queue.getFaweChunk(chunk.getBlockX(), chunk.getBlockZ())); count++; } BBC.UPDATED_LIGHTING_SELECTION.send(fp, count); }