@Command( aliases = {"/curve"}, usage = "<block> [thickness]", desc = "Draws a spline through selected points", help = "Draws a spline through selected points.\n" + "Can only be used with convex polyhedral selections.\n" + "Flags:\n" + " -h generates only a shell", flags = "h", min = 1, max = 2) @CommandPermissions("worldedit.region.curve") @Logging(REGION) public void curve( Player player, EditSession editSession, @Selection Region region, Pattern pattern, @Optional("0") @Range(min = 0) int thickness, @Switch('h') boolean shell) throws WorldEditException { if (!(region instanceof ConvexPolyhedralRegion)) { player.printError("//curve only works with convex polyhedral selections"); return; } ConvexPolyhedralRegion cpregion = (ConvexPolyhedralRegion) region; List<Vector> vectors = new ArrayList<Vector>(cpregion.getVertices()); int blocksChanged = editSession.drawSpline(Patterns.wrap(pattern), vectors, 0, 0, 0, 10, thickness, !shell); BBC.VISITOR_BLOCK.send(player, blocksChanged); }
@Command( aliases = {"/line"}, usage = "<block> [thickness]", desc = "Draws a line segment between cuboid selection corners", help = "Draws a line segment between cuboid selection corners.\n" + "Can only be used with cuboid selections.\n" + "Flags:\n" + " -h generates only a shell", flags = "h", min = 1, max = 2) @CommandPermissions("worldedit.region.line") @Logging(REGION) public void line( Player player, EditSession editSession, @Selection Region region, Pattern pattern, @Optional("0") @Range(min = 0) int thickness, @Switch('h') boolean shell) throws WorldEditException { if (!(region instanceof CuboidRegion)) { player.printError("//line only works with cuboid selections"); return; } CuboidRegion cuboidregion = (CuboidRegion) region; Vector pos1 = cuboidregion.getPos1(); Vector pos2 = cuboidregion.getPos2(); int blocksChanged = editSession.drawLine(Patterns.wrap(pattern), pos1, pos2, thickness, !shell); BBC.VISITOR_BLOCK.send(player, blocksChanged); }
@SuppressWarnings("deprecation") @Override protected void execute(Event e) { Location pos1 = location1.getSingle(e); Location pos2 = location2.getSingle(e); EditSession session = editSession.getSingle(e); ItemStack[] blocks = blockList.getAll(e); RandomPattern random = new RandomPattern(); if (session == null) return; for (ItemStack b : blocks) { if (b.getType().isBlock()) { random.add(new BlockPattern(new BaseBlock(b.getTypeId(), b.getDurability())), 50); } } try { session.makeWalls( new CuboidRegion( (World) BukkitUtil.getLocalWorld(pos1.getWorld()), BukkitUtil.toVector(pos1), BukkitUtil.toVector(pos2)), Patterns.wrap(random)); session.flushQueue(); } catch (WorldEditException ex) { if (ex instanceof MaxChangedBlocksException) return; else ex.printStackTrace(); } }
@Command( aliases = {"/faces", "/outline"}, usage = "<block>", desc = "Build the walls, ceiling, and floor of a selection", min = 1, max = 1) @CommandPermissions("worldedit.region.faces") @Logging(REGION) public void faces( Player player, EditSession editSession, @Selection Region region, Pattern pattern) throws WorldEditException { int affected = editSession.makeCuboidFaces(region, Patterns.wrap(pattern)); BBC.VISITOR_BLOCK.send(player, affected); }
@Command( aliases = {"/walls"}, usage = "<block>", desc = "Build the four sides of the selection", min = 1, max = 1) @CommandPermissions("worldedit.region.walls") @Logging(REGION) public void walls( Player player, EditSession editSession, @Selection Region region, Pattern pattern) throws WorldEditException { int affected = editSession.makeCuboidWalls(region, Patterns.wrap(pattern)); BBC.VISITOR_BLOCK.send(player, affected); }
@Command( aliases = {"/center", "/middle"}, usage = "<block>", desc = "Set the center block(s)", min = 1, max = 1) @Logging(REGION) @CommandPermissions("worldedit.region.center") public void center( Player player, EditSession editSession, @Selection Region region, Pattern pattern) throws WorldEditException { int affected = editSession.center(region, Patterns.wrap(pattern)); BBC.VISITOR_BLOCK.send(player, affected); }
@Command( aliases = {"/overlay"}, usage = "<block>", desc = "Set a block on top of blocks in the region", min = 1, max = 1) @CommandPermissions("worldedit.region.overlay") @Logging(REGION) public void overlay( Player player, EditSession editSession, @Selection Region region, Pattern pattern) throws WorldEditException { int affected = editSession.overlayCuboidBlocks(region, Patterns.wrap(pattern)); BBC.VISITOR_BLOCK.send(player, affected); }
@Command( aliases = {"/mapreplace", "/mr", "/maprep"}, usage = "<from-block-1,from-block-2> <to-block-1,to-block-2>", desc = "Replace all blocks in a selection 1:1 with the ", flags = "f", min = 1, max = 2) @CommandPermissions("worldedit.region.mapreplace") @Logging(REGION) public void mapreplace( Player player, EditSession editSession, @Selection Region region, @Optional Mask from, Pattern to) throws WorldEditException { if (from == null) { from = new ExistingBlockMask(editSession); } int affected = editSession.replaceBlocks(region, from, Patterns.wrap(to)); BBC.VISITOR_BLOCK.send(player, affected); }
@Command( aliases = {"/hollow"}, usage = "[<thickness>[ <block>]]", desc = "Hollows out the object contained in this selection", help = "Hollows out the object contained in this selection.\n" + "Optionally fills the hollowed out part with the given block.\n" + "Thickness is measured in manhattan distance.", min = 0, max = 2) @CommandPermissions("worldedit.region.hollow") @Logging(REGION) public void hollow( Player player, EditSession editSession, @Selection Region region, @Optional("0") @Range(min = 0) int thickness, @Optional("air") Pattern pattern) throws WorldEditException { int affected = editSession.hollowOutRegion(region, thickness, Patterns.wrap(pattern)); BBC.VISITOR_BLOCK.send(player, affected); }
@Command( aliases = {"/set"}, usage = "[pattern]", desc = "Set all blocks within selection", min = 1, max = 1) @CommandPermissions("worldedit.region.set") @Logging(REGION) public void set( Player player, EditSession editSession, LocalSession session, @Selection Region selection, Pattern to) throws WorldEditException { if (selection instanceof CuboidRegion && editSession.hasFastMode() && to instanceof BlockPattern) { try { CuboidRegion cuboid = (CuboidRegion) selection; RegionWrapper current = new RegionWrapper(cuboid.getMinimumPoint(), cuboid.getMaximumPoint()); BaseBlock block = ((BlockPattern) to).getBlock(); final FaweQueue queue = editSession.getQueue(); final int minY = cuboid.getMinimumY(); final int maxY = cuboid.getMaximumY(); final int id = block.getId(); final byte data = (byte) block.getData(); final FaweChunk<?> fc = queue.getFaweChunk(0, 0); fc.fillCuboid(0, 15, minY, maxY, 0, 15, id, data); fc.optimize(); int bcx = (current.minX) >> 4; int bcz = (current.minZ) >> 4; int tcx = (current.maxX) >> 4; int tcz = (current.maxZ) >> 4; // [chunkx, chunkz, pos1x, pos1z, pos2x, pos2z, isedge] MainUtil.chunkTaskSync( current, new RunnableVal<int[]>() { @Override public void run(int[] value) { FaweChunk newChunk; if (value[6] == 0) { newChunk = fc.copy(true); newChunk.setLoc(queue, value[0], value[1]); } else { int bx = value[2] & 15; int tx = value[4] & 15; int bz = value[3] & 15; int tz = value[5] & 15; if (bx == 0 && tx == 15 && bz == 0 && tz == 15) { newChunk = fc.copy(true); newChunk.setLoc(queue, value[0], value[1]); } else { newChunk = queue.getFaweChunk(value[0], value[1]); newChunk.fillCuboid( value[2] & 15, value[4] & 15, minY, maxY, value[3] & 15, value[5] & 15, id, data); } } newChunk.addToQueue(); } }); queue.enqueue(); long start = System.currentTimeMillis(); BBC.OPERATION.send(player, BBC.VISITOR_BLOCK.format(cuboid.getArea())); queue.flush(); BBC.ACTION_COMPLETE.send(player, (System.currentTimeMillis() - start) / 1000d); return; } catch (Throwable e) { MainUtil.handleError(e); } } int affected = editSession.setBlocks(selection, Patterns.wrap(to)); BBC.OPERATION.send(player, affected); }