com.sk89q.worldedit.MaxChangedBlocksException Java Examples
The following examples show how to use
com.sk89q.worldedit.MaxChangedBlocksException.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SchematicHelper.java From FunnyGuilds with Apache License 2.0 | 8 votes |
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) { FunnyGuilds.getInstance().getPluginLogger().error("Could not paste schematic: " + schematicFile.getAbsolutePath(), e); return false; } }
Example #2
Source File: FaweChunkManager.java From FastAsyncWorldedit with GNU General Public License v3.0 | 6 votes |
@Override public boolean copyRegion(final Location pos1, final Location pos2, final Location pos3, final Runnable whenDone) { TaskManager.IMP.async(new Runnable() { @Override public void run() { synchronized (FaweChunkManager.class) { EditSession from = new EditSessionBuilder(pos1.getWorld()).checkMemory(false).fastmode(true).limitUnlimited().changeSetNull().autoQueue(false).build(); EditSession to = new EditSessionBuilder(pos3.getWorld()).checkMemory(false).fastmode(true).limitUnlimited().changeSetNull().autoQueue(false).build(); CuboidRegion region = new CuboidRegion(new Vector(pos1.getX(), pos1.getY(), pos1.getZ()), new Vector(pos2.getX(), pos2.getY(), pos2.getZ())); ForwardExtentCopy copy = new ForwardExtentCopy(from, region, to, new Vector(pos3.getX(), pos3.getY(), pos3.getZ())); try { Operations.completeLegacy(copy); to.flushQueue(); } catch (MaxChangedBlocksException e) { e.printStackTrace(); } } TaskManager.IMP.task(whenDone); } }); return true; }
Example #3
Source File: WorldEditClear.java From uSkyBlock with GNU General Public License v3.0 | 6 votes |
@Override protected boolean execute() { while (!regions.isEmpty()) { final Region region = regions.remove(0); final EditSession editSession = WorldEditHandler.createEditSession( new BukkitWorld(world), region.getArea() * 255); editSession.setReorderMode(EditSession.ReorderMode.MULTI_STAGE); editSession.setFastMode(true); try { editSession.setBlocks(region, BlockTypes.AIR.getDefaultState()); } catch (MaxChangedBlocksException e) { log.log(Level.INFO, "Warning: we got MaxChangedBlocks from WE, please increase it!"); } editSession.flushSession(); if (!tick()) { break; } } return regions.isEmpty(); }
Example #4
Source File: LineBrush.java From FastAsyncWorldedit with GNU General Public License v3.0 | 6 votes |
@Override public void build(EditSession editSession, Vector position, final Pattern pattern, double size) throws MaxChangedBlocksException { boolean visual = (editSession.getExtent() instanceof VisualExtent); if (pos1 == null) { if (!visual) { pos1 = position; BBC.BRUSH_LINE_PRIMARY.send(editSession.getPlayer(), position); } return; } editSession.drawLine(pattern, pos1, position, size, !shell, flat); if (!visual) { BBC.BRUSH_LINE_SECONDARY.send(editSession.getPlayer()); if (!select) { pos1 = null; return; } else { pos1 = position; } } }
Example #5
Source File: ScatterCommand.java From FastAsyncWorldedit with GNU General Public License v3.0 | 6 votes |
@Override public void apply(EditSession editSession, LocalBlockVectorSet placed, Vector position, Pattern p, double size) throws MaxChangedBlocksException { int radius = getDistance(); CuboidRegionSelector selector = new CuboidRegionSelector(editSession.getWorld(), position.subtract(radius, radius, radius), position.add(radius, radius, radius)); String replaced = command.replace("{x}", position.getBlockX() + "") .replace("{y}", Integer.toString(position.getBlockY())) .replace("{z}", Integer.toString(position.getBlockZ())) .replace("{world}", editSession.getQueue().getWorldName()) .replace("{size}", Integer.toString(radius)); FawePlayer fp = editSession.getPlayer(); Player player = fp.getPlayer(); fp.setSelection(selector); PlayerWrapper wePlayer = new SilentPlayerWrapper(new LocationMaskedPlayerWrapper(player, new Location(player.getExtent(), position))); List<String> cmds = StringMan.split(replaced, ';'); for (String cmd : cmds) { CommandEvent event = new CommandEvent(wePlayer, cmd); CommandManager.getInstance().handleCommandOnCurrentThread(event); } }
Example #6
Source File: Spline.java From FastAsyncWorldedit with GNU General Public License v3.0 | 6 votes |
/** * Paste structure at the provided position on the curve. The position will not be position-corrected * but will be passed directly to the interpolation algorithm. * @param position The position on the curve. Must be between 0.0 and 1.0 (both inclusive) * @return The amount of blocks that have been changed * @throws MaxChangedBlocksException Thrown by WorldEdit if the limit of block changes for the {@link EditSession} has been reached */ public int pastePositionDirect(double position) throws MaxChangedBlocksException { Preconditions.checkArgument(position >= 0); Preconditions.checkArgument(position <= 1); // Calculate position from spline Vector target = interpolation.getPosition(position); Vector offset = target.subtract(target.round()); target = target.subtract(offset); // Calculate rotation from spline Vector deriv = interpolation.get1stDerivative(position); Vector2D deriv2D = new Vector2D(deriv.getX(), deriv.getZ()).normalize(); double angle = Math.toDegrees( Math.atan2(direction.getZ(), direction.getX()) - Math.atan2(deriv2D.getZ(), deriv2D.getX()) ); return pasteBlocks(target, offset, angle); }
Example #7
Source File: CommandBrush.java From FastAsyncWorldedit with GNU General Public License v3.0 | 6 votes |
@Override public void build(EditSession editSession, Vector position, Pattern pattern, double size) throws MaxChangedBlocksException { int radius = (int) size; CuboidRegionSelector selector = new CuboidRegionSelector(editSession.getWorld(), position.subtract(radius, radius, radius), position.add(radius, radius, radius)); String replaced = command.replace("{x}", position.getBlockX() + "") .replace("{y}", Integer.toString(position.getBlockY())) .replace("{z}", Integer.toString(position.getBlockZ())) .replace("{world}", editSession.getQueue().getWorldName()) .replace("{size}", Integer.toString(radius)); FawePlayer fp = editSession.getPlayer(); Player player = fp.getPlayer(); WorldVectorFace face = player.getBlockTraceFace(256, true); if (face == null) { position = position.add(0, 1, 1); } else { position = face.getFaceVector(); } fp.setSelection(selector); PlayerWrapper wePlayer = new SilentPlayerWrapper(new LocationMaskedPlayerWrapper(player, new Location(player.getExtent(), position))); List<String> cmds = StringMan.split(replaced, ';'); for (String cmd : cmds) { CommandEvent event = new CommandEvent(wePlayer, cmd); CommandManager.getInstance().handleCommandOnCurrentThread(event); } }
Example #8
Source File: FaweChunkManager.java From FastAsyncWorldedit with GNU General Public License v3.0 | 6 votes |
@Override public void swap(final Location pos1, final Location pos2, final Location pos3, final Location pos4, final Runnable whenDone) { TaskManager.IMP.async(new Runnable() { @Override public void run() { synchronized (FaweChunkManager.class) { EditSession sessionA = new EditSessionBuilder(pos1.getWorld()).checkMemory(false).fastmode(true).limitUnlimited().changeSetNull().autoQueue(false).build(); EditSession sessionB = new EditSessionBuilder(pos3.getWorld()).checkMemory(false).fastmode(true).limitUnlimited().changeSetNull().autoQueue(false).build(); CuboidRegion regionA = new CuboidRegion(new Vector(pos1.getX(), pos1.getY(), pos1.getZ()), new Vector(pos2.getX(), pos2.getY(), pos2.getZ())); CuboidRegion regionB = new CuboidRegion(new Vector(pos3.getX(), pos3.getY(), pos3.getZ()), new Vector(pos4.getX(), pos4.getY(), pos4.getZ())); ForwardExtentCopy copyA = new ForwardExtentCopy(sessionA, regionA, sessionB, regionB.getMinimumPoint()); ForwardExtentCopy copyB = new ForwardExtentCopy(sessionB, regionB, sessionA, regionA.getMinimumPoint()); try { Operations.completeLegacy(copyA); Operations.completeLegacy(copyB); sessionA.flushQueue(); sessionB.flushQueue(); } catch (MaxChangedBlocksException e) { e.printStackTrace(); } TaskManager.IMP.task(whenDone); } } }); }
Example #9
Source File: WorldWrapper.java From FastAsyncWorldedit with GNU General Public License v3.0 | 5 votes |
@Override public boolean generateTree(final EditSession editSession, final Vector pt) throws MaxChangedBlocksException { return TaskManager.IMP.sync(new RunnableVal<Boolean>() { @Override public void run(Boolean ignore) { try { this.value = parent.generateTree(editSession, pt); } catch (MaxChangedBlocksException e) { MainUtil.handleError(e); } } }); }
Example #10
Source File: GravityBrush.java From FastAsyncWorldedit with GNU General Public License v3.0 | 5 votes |
@Override public void build(EditSession editSession, Vector position, Pattern pattern, double sizeDouble) throws MaxChangedBlocksException { Mask mask = editSession.getMask(); if (mask == Masks.alwaysTrue() || mask == Masks.alwaysTrue2D()) { mask = null; } int size = (int) sizeDouble; int endY = position.getBlockY() + size; int startPerformY = Math.max(0, position.getBlockY() - size); int startCheckY = fullHeight ? 0 : startPerformY; Vector mutablePos = new Vector(0, 0, 0); for (int x = position.getBlockX() + size; x > position.getBlockX() - size; --x) { for (int z = position.getBlockZ() + size; z > position.getBlockZ() - size; --z) { int freeSpot = startCheckY; for (int y = startCheckY; y <= endY; y++) { BaseBlock block = editSession.getLazyBlock(x, y, z); if (block.getId() != 0) { if (y != freeSpot) { editSession.setBlock(x, y, z, EditSession.nullBlock); editSession.setBlock(x, freeSpot, z, block); } freeSpot = y + 1; } } } } }
Example #11
Source File: WorldWrapper.java From FastAsyncWorldedit with GNU General Public License v3.0 | 5 votes |
@Override public boolean generateTree(final TreeGenerator.TreeType type, final EditSession editSession, final Vector position) throws MaxChangedBlocksException { return TaskManager.IMP.sync(new RunnableVal<Boolean>() { @Override public void run(Boolean ignore) { try { this.value = parent.generateTree(type, editSession, position); } catch (MaxChangedBlocksException e) { MainUtil.handleError(e); } } }); }
Example #12
Source File: WorldWrapper.java From FastAsyncWorldedit with GNU General Public License v3.0 | 5 votes |
@Override public boolean generateTallRedwoodTree(final EditSession editSession, final Vector pt) throws MaxChangedBlocksException { return TaskManager.IMP.sync(new RunnableVal<Boolean>() { @Override public void run(Boolean ignore) { try { this.value = parent.generateTallRedwoodTree(editSession, pt); } catch (MaxChangedBlocksException e) { MainUtil.handleError(e); } } }); }
Example #13
Source File: WorldWrapper.java From FastAsyncWorldedit with GNU General Public License v3.0 | 5 votes |
@Override public boolean generateRedwoodTree(final EditSession editSession, final Vector pt) throws MaxChangedBlocksException { return TaskManager.IMP.sync(new RunnableVal<Boolean>() { @Override public void run(Boolean ignore) { try { this.value = parent.generateRedwoodTree(editSession, pt); } catch (MaxChangedBlocksException e) { MainUtil.handleError(e); } } }); }
Example #14
Source File: WorldWrapper.java From FastAsyncWorldedit with GNU General Public License v3.0 | 5 votes |
@Override public boolean generateBirchTree(final EditSession editSession, final Vector pt) throws MaxChangedBlocksException { return TaskManager.IMP.sync(new RunnableVal<Boolean>() { @Override public void run(Boolean ignore) { try { this.value = parent.generateBirchTree(editSession, pt); } catch (MaxChangedBlocksException e) { MainUtil.handleError(e); } } }); }
Example #15
Source File: WorldWrapper.java From FastAsyncWorldedit with GNU General Public License v3.0 | 5 votes |
@Override public boolean generateBigTree(final EditSession editSession, final Vector pt) throws MaxChangedBlocksException { return TaskManager.IMP.sync(new RunnableVal<Boolean>() { @Override public void run(Boolean ignore) { try { this.value = parent.generateBigTree(editSession, pt); } catch (MaxChangedBlocksException e) { MainUtil.handleError(e); } } }); }
Example #16
Source File: CatenaryBrush.java From FastAsyncWorldedit with GNU General Public License v3.0 | 5 votes |
@Override public void build(EditSession editSession, Vector pos2, final Pattern pattern, double size) throws MaxChangedBlocksException { boolean visual = (editSession.getExtent() instanceof VisualExtent); if (pos1 == null || pos2.equals(pos1)) { if (!visual) { pos1 = pos2; BBC.BRUSH_LINE_PRIMARY.send(editSession.getPlayer(), pos2); } return; } if (this.vertex == null) { vertex = getVertex(pos1, pos2, slack); if (this.direction) { BBC.BRUSH_CATENARY_DIRECTION.send(editSession.getPlayer(), 2); return; } } else if (this.direction) { Location loc = editSession.getPlayer().getPlayer().getLocation(); Vector facing = loc.getDirection().normalize(); Vector midpoint = pos1.add(pos2).divide(2); Vector offset = midpoint.subtract(vertex); vertex = midpoint.add(facing.multiply(offset.length())); } List<Vector> nodes = Arrays.asList(pos1, vertex, pos2); vertex = null; editSession.drawSpline(pattern, nodes, 0, 0, 0, 10, size, !shell); if (!visual) { BBC.BRUSH_LINE_SECONDARY.send(editSession.getPlayer()); if (!select) { pos1 = null; return; } else { pos1 = pos2; } } }
Example #17
Source File: FlattenBrush.java From FastAsyncWorldedit with GNU General Public License v3.0 | 5 votes |
@Override public void build(EditSession editSession, Vector position, Pattern pattern, double sizeDouble) throws MaxChangedBlocksException { int size = (int) sizeDouble; Mask mask = editSession.getMask(); if (mask == Masks.alwaysTrue() || mask == Masks.alwaysTrue2D()) { mask = null; } HeightMap map = getHeightMap(); map.setSize(size); map.perform(editSession, mask, position, size, rotation, yscale, smooth, true, layers); }
Example #18
Source File: ClipboardSpline.java From FastAsyncWorldedit with GNU General Public License v3.0 | 5 votes |
@Override protected int pasteBlocks(Vector target, Vector offset, double angle) throws MaxChangedBlocksException { RoundedTransform transform = new RoundedTransform(new AffineTransform() .translate(offset) .rotateY(angle)); if (!this.transform.isIdentity()) { transform = transform.combine(this.transform); } if (!originalTransform.isIdentity()) { transform = transform.combine(originalTransform); } // Pasting Clipboard clipboard = clipboardHolder.getClipboard(); clipboard.setOrigin(center.subtract(centerOffset).round()); clipboardHolder.setTransform(transform); Vector functionOffset = target.subtract(clipboard.getOrigin()); final int offX = functionOffset.getBlockX(); final int offY = functionOffset.getBlockY(); final int offZ = functionOffset.getBlockZ(); Operation operation = clipboardHolder .createPaste(editSession, editSession.getWorldData()) .to(target) .ignoreAirBlocks(true) .filter(v -> buffer.add(v.getBlockX() + offX, v.getBlockY() + offY, v.getBlockZ() + offZ)) .build(); Operations.completeLegacy(operation); // Cleanup clipboardHolder.setTransform(originalTransform); clipboard.setOrigin(originalOrigin); return operation instanceof ForwardExtentCopy ? ((ForwardExtentCopy) operation).getAffected() : 0; }
Example #19
Source File: ScatterOverlayBrush.java From FastAsyncWorldedit with GNU General Public License v3.0 | 5 votes |
@Override public void apply(EditSession editSession, LocalBlockVectorSet placed, Vector pt, Pattern p, double size) throws MaxChangedBlocksException { int x = pt.getBlockX(); int y = pt.getBlockY(); int z = pt.getBlockZ(); Vector dir = getDirection(pt); dir.setComponents(x + dir.getBlockX(), y + dir.getBlockY(), z + dir.getBlockZ()); editSession.setBlock(dir, p); }
Example #20
Source File: SurfaceSphereBrush.java From FastAsyncWorldedit with GNU General Public License v3.0 | 5 votes |
@Override public void build(EditSession editSession, Vector position, Pattern pattern, double size) throws MaxChangedBlocksException { SurfaceMask surface = new SurfaceMask(editSession); final SolidBlockMask solid = new SolidBlockMask(editSession); final RadiusMask radius = new RadiusMask(0, (int) size); RecursiveVisitor visitor = new RecursiveVisitor(vector -> surface.test(vector) && radius.test(vector), vector -> editSession.setBlock(vector, pattern)); visitor.visit(position); visitor.setDirections(Arrays.asList(BreadthFirstSearch.DIAGONAL_DIRECTIONS)); Operations.completeBlindly(visitor); }
Example #21
Source File: PopulateSchem.java From FastAsyncWorldedit with GNU General Public License v3.0 | 5 votes |
@Override public void build(EditSession editSession, Vector position, Pattern pattern, double size) throws MaxChangedBlocksException { new MaskTraverser(mask).reset(editSession); SchemGen gen = new SchemGen(mask, editSession, editSession.getWorldData(), clipboards, randomRotate); CuboidRegion cuboid = new CuboidRegion(editSession.getWorld(), position.subtract(size, size, size), position.add(size, size, size)); try { editSession.addSchems(cuboid, mask, editSession.getWorldData(), clipboards, rarity, randomRotate); } catch (WorldEditException e) { throw new RuntimeException(e); } }
Example #22
Source File: RockBrush.java From FastAsyncWorldedit with GNU General Public License v3.0 | 5 votes |
@Override public void build(EditSession editSession, Vector position, Pattern pattern, double size) throws MaxChangedBlocksException { double seedX = ThreadLocalRandom.current().nextDouble(); double seedY = ThreadLocalRandom.current().nextDouble(); double seedZ = ThreadLocalRandom.current().nextDouble(); int px = position.getBlockX(); int py = position.getBlockY(); int pz = position.getBlockZ(); double distort = this.frequency / size; double modX = 1d/radius.getX(); double modY = 1d/radius.getY(); double modZ = 1d/radius.getZ(); int radiusSqr = (int) (size * size); int sizeInt = (int) size * 2; for (int x = -sizeInt; x <= sizeInt; x++) { double nx = seedX + x * distort; double d1 = x * x * modX; for (int y = -sizeInt; y <= sizeInt; y++) { double d2 = d1 + y * y * modY; double ny = seedY + y * distort; for (int z = -sizeInt; z <= sizeInt; z++) { double nz = seedZ + z * distort; double distance = d2 + z * z * modZ; double noise = this.amplitude * SimplexNoise.noise(nx, ny, nz); if (distance + distance * noise < radiusSqr) { editSession.setBlock(px + x, py + y, pz + z, pattern); } } } } }
Example #23
Source File: Spline.java From FastAsyncWorldedit with GNU General Public License v3.0 | 5 votes |
/** * Paste the structure at the provided position on the curve. The position will be position-corrected if the * nodeCount provided to the constructor is bigger than 2. * @param position The position on the curve. Must be between 0.0 and 1.0 (both inclusive) * @return The amount of blocks that have been changed * @throws MaxChangedBlocksException Thrown by WorldEdit if the limit of block changes for the {@link EditSession} has been reached */ public int pastePosition(double position) throws MaxChangedBlocksException { Preconditions.checkArgument(position >= 0); Preconditions.checkArgument(position <= 1); if (nodeCount > 2) { return pastePositionDirect(translatePosition(position)); } else { return pastePositionDirect(position); } }
Example #24
Source File: SimpleWorld.java From FastAsyncWorldedit with GNU General Public License v3.0 | 4 votes |
@Override default boolean generateBigTree(EditSession editSession, Vector pt) throws MaxChangedBlocksException { return generateTree(TreeGenerator.TreeType.BIG_TREE, editSession, pt); }
Example #25
Source File: ErodeBrush.java From FastAsyncWorldedit with GNU General Public License v3.0 | 4 votes |
@Override public void build(EditSession editSession, Vector position, Pattern pattern, double size) throws MaxChangedBlocksException { this.erosion(editSession, 2, 1, 5, 1, position, size); }
Example #26
Source File: SimpleWorld.java From FastAsyncWorldedit with GNU General Public License v3.0 | 4 votes |
@Override default boolean generateBirchTree(EditSession editSession, Vector pt) throws MaxChangedBlocksException { return generateTree(TreeGenerator.TreeType.BIRCH, editSession, pt); }
Example #27
Source File: SimpleWorld.java From FastAsyncWorldedit with GNU General Public License v3.0 | 4 votes |
@Override default boolean generateRedwoodTree(EditSession editSession, Vector pt) throws MaxChangedBlocksException { return generateTree(TreeGenerator.TreeType.REDWOOD, editSession, pt); }
Example #28
Source File: SimpleWorld.java From FastAsyncWorldedit with GNU General Public License v3.0 | 4 votes |
@Override default boolean generateTallRedwoodTree(EditSession editSession, Vector pt) throws MaxChangedBlocksException { return generateTree(TreeGenerator.TreeType.TALL_REDWOOD, editSession, pt); }
Example #29
Source File: LocalWorldAdapter.java From FastAsyncWorldedit with GNU General Public License v3.0 | 4 votes |
@Override public boolean generateTree(TreeType type, EditSession editSession, Vector position) throws MaxChangedBlocksException { return world.generateTree(type, editSession, position); }
Example #30
Source File: LocalWorldAdapter.java From FastAsyncWorldedit with GNU General Public License v3.0 | 4 votes |
@Override @Deprecated public boolean generateTree(EditSession editSession, Vector position) throws MaxChangedBlocksException { return world.generateTree(editSession, position); }