/** * Get a region that contains the walls (all faces but the ones parallel to the X-Z plane) of this * cuboid. * * @return a new complex region */ public Region getWalls() { Vector min = getMinimumPoint(); Vector max = getMaximumPoint(); return new RegionIntersection( // Project to Z-Y plane new CuboidRegion(pos1.setX(min.getX()), pos2.setX(min.getX())), new CuboidRegion(pos1.setX(max.getX()), pos2.setX(max.getX())), // Project to X-Y plane new CuboidRegion(pos1.setZ(min.getZ()), pos2.setZ(min.getZ())), new CuboidRegion(pos1.setZ(max.getZ()), pos2.setZ(max.getZ()))); }
@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()); } }
@Override public Vector setZ(int z) { return wrap(m_parent.setZ(z)); }