com.sk89q.worldedit.function.operation.ForwardExtentCopy Java Examples
The following examples show how to use
com.sk89q.worldedit.function.operation.ForwardExtentCopy.
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: 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 #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: Schematic.java From FastAsyncWorldedit with GNU General Public License v3.0 | 6 votes |
public void paste(Extent extent, WorldData worldData, Vector to, boolean pasteAir, Transform transform) { checkNotNull(transform); Region region = clipboard.getRegion(); Extent source = clipboard; if (worldData != null && transform != null) { source = new BlockTransformExtent(clipboard, transform, worldData.getBlockRegistry()); } ForwardExtentCopy copy = new ForwardExtentCopy(source, clipboard.getRegion(), clipboard.getOrigin(), extent, to); if (transform != null) { copy.setTransform(transform); } copy.setCopyBiomes(!(clipboard instanceof BlockArrayClipboard) || ((BlockArrayClipboard) clipboard).IMP.hasBiomes()); if (extent instanceof EditSession) { EditSession editSession = (EditSession) extent; Mask sourceMask = editSession.getSourceMask(); if (sourceMask != null) { new MaskTraverser(sourceMask).reset(extent); copy.setSourceMask(sourceMask); editSession.setSourceMask(null); } } if (!pasteAir) { copy.setSourceMask(new ExistingBlockMask(clipboard)); } Operations.completeBlindly(copy); }
Example #4
Source File: PasteBuilder.java From FastAsyncWorldedit with GNU General Public License v3.0 | 6 votes |
/** * Build the operation. * * @return the operation */ public Operation build() { Extent extent = clipboard; if (!transform.isIdentity()) { extent = new BlockTransformExtent(extent, transform, targetWorldData.getBlockRegistry()); } ForwardExtentCopy copy = new ForwardExtentCopy(extent, clipboard.getRegion(), clipboard.getOrigin(), targetExtent, to); copy.setTransform(transform); copy.setCopyEntities(!ignoreEntities); copy.setCopyBiomes((!ignoreBiomes) && (!(clipboard instanceof BlockArrayClipboard) || ((BlockArrayClipboard) clipboard).IMP.hasBiomes())); if (this.canApply != null) { copy.setFilterFunction(this.canApply); } if (targetExtent instanceof EditSession) { Mask sourceMask = ((EditSession) targetExtent).getSourceMask(); if (sourceMask != null) { new MaskTraverser(sourceMask).reset(extent); copy.setSourceMask(sourceMask); ((EditSession) targetExtent).setSourceMask(null); } } if (ignoreAirBlocks) { copy.setSourceMask(new ExistingBlockMask(clipboard)); } return copy; }
Example #5
Source File: EditSession.java From FastAsyncWorldedit with GNU General Public License v3.0 | 6 votes |
/** * Stack a cuboid region. * * @param region the region to stack * @param dir the direction to stack * @param count the number of times to stack * @param copyAir true to also copy air blocks * @return number of blocks affected * @throws MaxChangedBlocksException thrown if too many blocks are changed */ public int stackCuboidRegion(final Region region, final Vector dir, final int count, final boolean copyAir, boolean copyEntities, boolean copyBiomes) { checkNotNull(region); checkNotNull(dir); checkArgument(count >= 1, "count >= 1 required"); final Vector size = region.getMaximumPoint().subtract(region.getMinimumPoint()).add(1, 1, 1); final Vector to = region.getMinimumPoint(); final ForwardExtentCopy copy = new ForwardExtentCopy(EditSession.this, region, EditSession.this, to); copy.setCopyEntities(copyEntities); copy.setCopyBiomes(copyBiomes); copy.setRepetitions(count); copy.setTransform(new AffineTransform().translate(dir.multiply(size))); Mask sourceMask = getSourceMask(); if (sourceMask != null) { new MaskTraverser(sourceMask).reset(EditSession.this); copy.setSourceMask(sourceMask); setSourceMask(null); } if (!copyAir) { copy.setSourceMask(new ExistingBlockMask(EditSession.this)); } Operations.completeBlindly(copy); return this.changes = copy.getAffected(); }
Example #6
Source File: FullClipboardPattern.java From FastAsyncWorldedit with GNU General Public License v3.0 | 5 votes |
@Override public boolean apply(Extent extent, Vector setPosition, Vector getPosition) throws WorldEditException { Region region = clipboard.getRegion(); ForwardExtentCopy copy = new ForwardExtentCopy(clipboard, clipboard.getRegion(), clipboard.getOrigin(), extent, setPosition); copy.setSourceMask(new ExistingBlockMask(clipboard)); Operations.completeBlindly(copy); return true; }
Example #7
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 #8
Source File: EditSession.java From FastAsyncWorldedit with GNU General Public License v3.0 | 5 votes |
public int moveRegion(final Region region, final Vector dir, final int distance, final boolean copyAir, final boolean copyEntities, final boolean copyBiomes, Pattern replacement) { checkNotNull(region); checkNotNull(dir); checkArgument(distance >= 1, "distance >= 1 required"); final Vector displace = dir.multiply(distance); final Vector size = region.getMaximumPoint().subtract(region.getMinimumPoint()).add(1, 1, 1); final Vector to = region.getMinimumPoint().add(dir.multiply(distance)); Vector disAbs = displace.positive(); if (disAbs.getBlockX() < size.getBlockX() && disAbs.getBlockY() < size.getBlockY() && disAbs.getBlockZ() < size.getBlockZ()) { // Buffer if overlapping queue.dequeue(); } final ForwardExtentCopy copy = new ForwardExtentCopy(EditSession.this, region, EditSession.this, to); if (replacement == null) replacement = nullBlock; final BlockReplace remove = replacement instanceof ExistingPattern ? null : new BlockReplace(EditSession.this, replacement); copy.setCopyBiomes(copyBiomes); copy.setCopyEntities(copyEntities); copy.setSourceFunction(remove); copy.setRepetitions(1); Mask sourceMask = getSourceMask(); if (sourceMask != null) { new MaskTraverser(sourceMask).reset(EditSession.this); copy.setSourceMask(sourceMask); setSourceMask(null); } if (!copyAir) { copy.setSourceMask(new ExistingBlockMask(EditSession.this)); } Operations.completeBlindly(copy); return this.changes = copy.getAffected(); }
Example #9
Source File: FlattenedClipboardTransform.java From FastAsyncWorldedit with GNU General Public License v3.0 | 5 votes |
/** * Create an operation to copy from the original clipboard to the given extent. * * @param target the target * @return the operation */ public Operation copyTo(Extent target) { BlockTransformExtent extent = new BlockTransformExtent(original, transform, worldData.getBlockRegistry()); ForwardExtentCopy copy = new ForwardExtentCopy(extent, original.getRegion(), original.getOrigin(), target, original.getOrigin()); copy.setTransform(transform); return copy; }