private void copyCuboid(CuboidClipboard cuboid, int facing) { for (int x = 0; x < sizeX; x++) for (int y = 0; y < sizeY; y++) for (int z = 0; z < sizeZ; z++) blocks[facing][x][y][z] = cuboid.getBlock(new Vector(x, y, z)); }
private void place(EditSession editSession, int facing, Vector pos, boolean noAir) throws MaxChangedBlocksException { for (int x = 0; x < sizeX; x++) for (int y = 0; y < sizeY; y++) for (int z = 0; z < sizeZ; z++) { BaseBlock block = blocks[facing][x][y][z]; if (block != null) { if ((noAir) && (block.isAir())) { continue; } editSession.setBlock(new Vector(x, y, z).add(pos), block); } } }
Vector size = max.subtract(min).add(1, 1, 1); if (area.maxAreaSize.getValue() != -1 && size.getBlockX() * size.getBlockY() * size.getBlockZ() > area.maxAreaSize.getValue() && !area.commandSaveBypassLimitPermissions.hasPermission(src)) { src.sendMessage(Text.of(TextColors.RED, "Area is larger than allowed " + area.maxAreaSize.getValue() + " blocks.")); return CommandResult.empty();
@Override public void clear() { try { CuboidRegion region = new CuboidRegion(origin, origin.add(size.getX() - 1, size.getY() - 1, size.getZ() - 1)); EditSession editSession = WorldEdit.getInstance().getEditSessionFactory().getEditSession(SpongeWorldEdit.inst().getWorld(world), -1); editSession.enableQueue(); editSession.setBlocks(region, new BaseBlock(0)); editSession.flushQueue(); } catch (MaxChangedBlocksException e) { // is never thrown } }
private static boolean isClear(int minX, int minY, int minZ, int maxX, int maxY, int maxZ, AbstractWorld world) { for (int x = minX; x <= maxX; x++) { for (int y = minY; y <= maxY; y++) { for (int z = minZ; z <= maxZ; z++) { if (world.getBlockType(new Vector(x, y, z)) != 0) { // Material.AIR.getId() == 0 System.out.println("Not clear! block:" + world.getBlockType(new Vector(x, y, z)) + " minX:" + minX + " minY:" + minY + " minZ:" + minZ + " maxX:" + maxX + " maxY:" + maxY + " maxZ:" + maxZ); return false; } } } } System.out.println("It's clear! minX:" + minX + " minY:" + minY + " minZ:" + minZ + " maxX:" + maxX + " maxY:" + maxY + " maxZ:" + maxZ); return true; } }
private void place(EditSession editSession, int facing, Vector pos, boolean noAir, int x1, int x2, int y1, int y2, int z1, int z2) throws MaxChangedBlocksException { x1 = Math.max(x1, 0); x2 = Math.min(x2, sizeX); y1 = Math.max(y1, 0); y2 = Math.min(y2, sizeY); z1 = Math.max(z1, 0); z2 = Math.min(z2, sizeZ); for (int x = x1; x < x2; x++) for (int y = y1; y < y2; y++) for (int z = z1; z < z2; z++) { BaseBlock block = blocks[facing][x][y][z]; if (block != null) { if ((noAir) && (block.isAir())) { continue; } editSession.setBlock(new Vector(x, y, z).add(pos), block); } } } }
@Override public void paste(CityWorldGenerator generator, RealBlocks chunk, BlockFace facing, int blockX, int blockY, int blockZ) { Vector at = new Vector(blockX, blockY, blockZ); try { EditSession editSession = getEditSession(generator); // editSession.setFastMode(true); place(editSession, getFacingIndex(facing), at, true); } catch (Exception e) { generator.reportException("[WorldEdit] Place schematic " + name + " at " + at + " failed", e); } }
@Override public void paste(CityWorldGenerator generator, RealBlocks chunk, BlockFace facing, int blockX, int blockY, int blockZ, int x1, int x2, int y1, int y2, int z1, int z2) { Vector at = new Vector(blockX, blockY, blockZ); // Vector min = new Vector(x1, y1, z1); // Vector max = new Vector(x2, y2, z2); // generator.reportMessage("Partial paste: origin = " + at + " min = " + min + " max = " + max); try { EditSession editSession = getEditSession(generator); // editSession.setFastMode(true); place(editSession, getFacingIndex(facing), at, true, x1, x2, y1, y2, z1, z2); } catch (Exception e) { generator.reportException("[WorldEdit] Partial place schematic " + name + " at " + at + " failed", e); generator.reportMessage("Info: " + " facing = " + facing + " size = " + sizeX + ", " + sizeZ + " chunk = " + chunkX + ", " + chunkZ + // " origin = "+ blockX + ", " + blockY + ", " + blockZ + " min = " + x1 + ", " + y1 + ", " + z1 + " max = " + x2 + ", " + y2 + ", " + z2); e.printStackTrace(); } }
@Override public void destroyArena(final World arenaWorld, final SkyArena arena, final SkyBlockLocation target) { Validate.isTrue(target.world.equals(arenaWorld.getName()), "Destination world not arena world."); if (editWorld == null) { editWorld = new BukkitWorld(arenaWorld); } SkyBlockLocationRange clearingArea = arena.getBoundaries().getClearing(); SkyBlockLocation clearingMin = new SkyBlockLocation(target.x + clearingArea.min.x, target.y + clearingArea.min.y, target.z + clearingArea.min.z, null); SkyBlockLocation clearingMax = new SkyBlockLocation(target.x + clearingArea.max.x, target.y + clearingArea.max.y, target.z + clearingArea.max.z, null); for (int x = clearingMin.x; x <= clearingMax.x; x++) { for (int y = clearingMin.y; y <= clearingMax.y; y++) { for (int z = clearingMin.z; z <= clearingMax.z; z++) { editWorld.setBlockType(new Vector(x, y, z), 0); // 0 = hardcoded Material.AIR } } } // TODO: do this part with WorldEdit too clearEntities(arenaWorld, clearingMin, clearingMax); }
if (this.BScount > Settings.Chunk_Processor.MAX_TILES) { this.BSblocked = true; PS.debug(C.PREFIX + "&cdetected unsafe WorldEdit: " + location.getBlockX() + "," + location.getBlockZ()); if (WEManager.maskContains(this.mask, location.getBlockX(), location.getBlockY(), location.getBlockZ())) { if (this.count++ > this.max) { if (this.parent != null) { int x = location.getBlockX(); int y = location.getBlockY(); int z = location.getBlockZ(); if (WEManager.maskContains(this.mask, location.getBlockX(), location.getBlockY(), location.getBlockZ())) { if (this.count++ > this.max) { if (this.parent != null) {
public static boolean pasteSchematic(File schematicFile, Location location, boolean withAir) { try { Vector pasteLocation = new Vector(location.getX(), location.getY(), location.getZ()); World pasteWorld = new BukkitWorld(location.getWorld()); WorldData pasteWorldData = pasteWorld.getWorldData(); Clipboard clipboard = ClipboardFormat.SCHEMATIC.getReader(new FileInputStream(schematicFile)).read(pasteWorldData); ClipboardHolder clipboardHolder = new ClipboardHolder(clipboard, pasteWorldData); EditSession editSession = WorldEdit.getInstance().getEditSessionFactory().getEditSession(pasteWorld, -1); Operation operation = clipboardHolder .createPaste(editSession, pasteWorldData) .to(pasteLocation) .ignoreAirBlocks(!withAir) .build(); Operations.completeLegacy(operation); return true; } catch (IOException | MaxChangedBlocksException e) { FunnyGuildsLogger.exception(e); return false; } }
BaseBlock edge = cuboid.getBlock(new Vector(0, groundLevelY, 0)); edgeMaterial = Material.getMaterial(edge.getNbtId(), true);