com.sk89q.worldedit.extent.clipboard.Clipboard Java Examples

The following examples show how to use com.sk89q.worldedit.extent.clipboard.Clipboard. 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 vote down vote up
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: SchematicStreamer.java    From FastAsyncWorldedit with GNU General Public License v3.0 6 votes vote down vote up
public Clipboard getClipboard() throws IOException {
    try {
        addDimensionReaders();
        addBlockReaders();
        readFully();
        Vector min = new Vector(originX, originY, originZ);
        Vector offset = new Vector(offsetX, offsetY, offsetZ);
        Vector origin = min.subtract(offset);
        Vector dimensions = new Vector(width, height, length);
        fc.setDimensions(dimensions);
        CuboidRegion region = new CuboidRegion(min, min.add(width, height, length).subtract(Vector.ONE));
        clipboard.init(region, fc);
        clipboard.setOrigin(origin);
        return clipboard;
    } catch (Throwable e) {
        if (fc != null) {
            fc.close();
        }
        throw e;
    }
}
 
Example #3
Source File: BrushCommands.java    From FastAsyncWorldedit with GNU General Public License v3.0 6 votes vote down vote up
@Command(
        aliases = {"clipboard"},
        usage = "",
        desc = "Choose the clipboard brush (Recommended: `/br copypaste`)",
        help =
                "Chooses the clipboard brush.\n" +
                        "The -a flag makes it not paste air.\n" +
                        "Without the -p flag, the paste will appear centered at the target location. " +
                        "With the flag, then the paste will appear relative to where you had " +
                        "stood relative to the copied area when you copied it."
)
@CommandPermissions("worldedit.brush.clipboard")
public BrushSettings clipboardBrush(Player player, LocalSession session, @Switch('a') boolean ignoreAir, @Switch('p') boolean usingOrigin, CommandContext context) throws WorldEditException {
    ClipboardHolder holder = session.getClipboard();
    Clipboard clipboard = holder.getClipboard();

    Vector size = clipboard.getDimensions();

    WorldEdit.getInstance().checkMaxBrushRadius(size.getBlockX());
    WorldEdit.getInstance().checkMaxBrushRadius(size.getBlockY());
    WorldEdit.getInstance().checkMaxBrushRadius(size.getBlockZ());
    return set(session, context, new ClipboardBrush(holder, ignoreAir, usingOrigin));
}
 
Example #4
Source File: SchematicCommands.java    From FastAsyncWorldedit with GNU General Public License v3.0 6 votes vote down vote up
@Command(
        aliases = {"remap"},
        help = "Remap a clipboard between MCPE/PC values\n",
        desc = "Remap a clipboard between MCPE/PC values\n"
)
@Deprecated
@CommandPermissions({"worldedit.schematic.remap"})
public void remap(final Player player, final LocalSession session) throws WorldEditException {
    ClipboardRemapper remapper;
    if (Fawe.imp().getPlatform().equalsIgnoreCase("nukkit")) {
        remapper = new ClipboardRemapper(ClipboardRemapper.RemapPlatform.PC, ClipboardRemapper.RemapPlatform.PE);
    } else {
        remapper = new ClipboardRemapper(ClipboardRemapper.RemapPlatform.PE, ClipboardRemapper.RemapPlatform.PC);
    }

    for (Clipboard clip : session.getClipboard().getClipboards()) {
        remapper.apply(clip);
    }
    player.print(BBC.getPrefix() + "Remapped schematic");
}
 
Example #5
Source File: HeightBrush.java    From FastAsyncWorldedit with GNU General Public License v3.0 6 votes vote down vote up
public HeightBrush(InputStream stream, int rotation, double yscale, boolean layers, boolean smooth, Clipboard clipboard, ScalableHeightMap.Shape shape) {
    this.rotation = (rotation / 90) % 4;
    this.yscale = yscale;
    this.layers = layers;
    this.smooth = smooth;
    if (stream != null) {
        try {
            heightMap = ScalableHeightMap.fromPNG(stream);
        } catch (IOException e) {
            throw new FaweException(BBC.BRUSH_HEIGHT_INVALID);
        }
    } else if (clipboard != null) {
        heightMap = ScalableHeightMap.fromClipboard(clipboard);
    } else {
        heightMap = ScalableHeightMap.fromShape(shape);
    }
}
 
Example #6
Source File: ClipboardCommands.java    From FastAsyncWorldedit with GNU General Public License v3.0 6 votes vote down vote up
@Command(
        aliases = {"/flip"},
        usage = "[<direction>]",
        desc = "Flip the contents of the clipboard",
        help =
                "Flips the contents of the clipboard across the point from which the copy was made.\n",
        min = 0,
        max = 1
)
@CommandPermissions("worldedit.clipboard.flip")
public void flip(Player player, LocalSession session,
                 @Optional(Direction.AIM) @Direction Vector direction) throws WorldEditException {
    ClipboardHolder holder = session.getClipboard();
    Clipboard clipboard = holder.getClipboard();
    AffineTransform transform = new AffineTransform();
    transform = transform.scale(direction.positive().multiply(-2).add(1, 1, 1));
    holder.setTransform(transform.combine(holder.getTransform()));
    BBC.COMMAND_FLIPPED.send(player);
}
 
Example #7
Source File: RandomFullClipboardPattern.java    From FastAsyncWorldedit with GNU General Public License v3.0 6 votes vote down vote up
@Override
public boolean apply(Extent extent, Vector setPosition, Vector getPosition) throws WorldEditException {
    ClipboardHolder holder = clipboards.get(PseudoRandom.random.random(clipboards.size()));
    AffineTransform transform = new AffineTransform();
    if (randomRotate) {
        transform = transform.rotateY(PseudoRandom.random.random(4) * 90);
        holder.setTransform(new AffineTransform().rotateY(PseudoRandom.random.random(4) * 90));
    }
    if (randomFlip) {
        transform = transform.scale(new Vector(1, 0, 0).multiply(-2).add(1, 1, 1));
    }
    if (!transform.isIdentity()) {
        holder.setTransform(transform);
    }
    Clipboard clipboard = holder.getClipboard();
    Schematic schematic = new Schematic(clipboard);
    Transform newTransform = holder.getTransform();
    if (newTransform.isIdentity()) {
        schematic.paste(extent, setPosition, false);
    } else {
        schematic.paste(extent, worldData, setPosition, false, newTransform);
    }
    return true;
}
 
Example #8
Source File: FaweSchematicHandler.java    From FastAsyncWorldedit with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void getCompoundTag(final String world, final Set<RegionWrapper> regions, final RunnableVal<CompoundTag> whenDone) {
    TaskManager.IMP.async(new Runnable() {
        @Override
        public void run() {
            Location[] corners = MainUtil.getCorners(world, regions);
            Location pos1 = corners[0];
            Location pos2 = corners[1];
            final CuboidRegion region = new CuboidRegion(new Vector(pos1.getX(), pos1.getY(), pos1.getZ()), new Vector(pos2.getX(), pos2.getY(), pos2.getZ()));
            final EditSession editSession = new EditSessionBuilder(world).checkMemory(false).fastmode(true).limitUnlimited().changeSetNull().autoQueue(false).build();

            final int mx = pos1.getX();
            final int my = pos1.getY();
            final int mz = pos1.getZ();

            ReadOnlyClipboard clipboard = ReadOnlyClipboard.of(editSession, region);

            Clipboard holder = new BlockArrayClipboard(region, clipboard);
            com.sk89q.jnbt.CompoundTag weTag = SchematicWriter.writeTag(holder);
            CompoundTag tag = new CompoundTag((Map<String, Tag>) (Map<?, ?>) weTag.getValue());
            whenDone.run(tag);
        }
    });
}
 
Example #9
Source File: DefaultFloorRegenerator.java    From HeavySpleef with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void regenerate(Floor floor, EditSession session, RegenerationCause cause) {
	Clipboard clipboard = floor.getClipboard();
	
	Region region = clipboard.getRegion();
	World world = region.getWorld();
	WorldData data = world.getWorldData();
	
	ClipboardHolder holder = new ClipboardHolder(clipboard, data);
	
	Operation pasteOperation = holder.createPaste(session, data)
			.to(region.getMinimumPoint())
			.ignoreAirBlocks(true)
			.build();
	
	try {
		Operations.complete(pasteOperation);
	} catch (WorldEditException e) {
		throw new RuntimeException(e);
	}
}
 
Example #10
Source File: SchemGen.java    From FastAsyncWorldedit with GNU General Public License v3.0 6 votes vote down vote up
@Override
public boolean spawn(PseudoRandom random, int x, int z) throws WorldEditException {
    mutable.mutX(x);
    mutable.mutZ(z);
    int y = extent.getNearestSurfaceTerrainBlock(x, z, mutable.getBlockY(), 0, 255);
    if (y == -1) return false;
    mutable.mutY(y);
    if (!mask.test(mutable)) {
        return false;
    }
    mutable.mutY(y + 1);
    ClipboardHolder holder = clipboards.get(PseudoRandom.random.random(clipboards.size()));
    if (randomRotate) {
        holder.setTransform(new AffineTransform().rotateY(PseudoRandom.random.random(4) * 90));
    }
    Clipboard clipboard = holder.getClipboard();
    Schematic schematic = new Schematic(clipboard);
    Transform transform = holder.getTransform();
    if (transform.isIdentity()) {
        schematic.paste(extent, mutable, false);
    } else {
        schematic.paste(extent, worldData, mutable, false, transform);
    }
    mutable.mutY(y);
    return true;
}
 
Example #11
Source File: FAWEFloorRegenerator.java    From HeavySpleef with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void regenerate(Floor floor, EditSession session, RegenerationCause cause) {
    Clipboard clipboard = floor.getClipboard();
    Schematic faweSchematic = new Schematic(clipboard);

    Region region = clipboard.getRegion();
    World world = region.getWorld();
    if (world == null) {
        throw new IllegalStateException("World of floor " + floor.getName() + " is null!");
    }

    faweSchematic.paste(world, region.getMinimumPoint(), false, false, (Transform) null);
}
 
Example #12
Source File: WorldEdit7.java    From IridiumSkyblock with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void paste(File file, Location location, Island island) {
    try {
        ClipboardFormat format = ClipboardFormats.findByFile(file);
        ClipboardReader reader = format.getReader(new FileInputStream(file));
        Clipboard clipboard = reader.read();
        try (EditSession editSession = com.sk89q.worldedit.WorldEdit.getInstance().getEditSessionFactory().getEditSession(new BukkitWorld(location.getWorld()), -1)) {
            Operation operation = new ClipboardHolder(clipboard)
                    .createPaste(editSession)
                    .to(BlockVector3.at(location.getX(), location.getY(), location.getZ()))
                    .copyEntities(true)
                    .ignoreAirBlocks(true)
                    .build();
            Operations.complete(operation);
        }
    } catch (Exception e) {
        IridiumSkyblock.getInstance().getLogger().warning("Failed to paste schematic using worldedit");
        IridiumSkyblock.schematic.paste(file, location, island);
    }
}
 
Example #13
Source File: SchematicHandler13.java    From UhcCore with GNU General Public License v3.0 5 votes vote down vote up
public static ArrayList<Integer> pasteSchematic(Location loc, String path) throws Exception{
	Bukkit.getLogger().info("[UhcCore] Pasting "+path);
	File schematic = new File(path);
       World world = BukkitAdapter.adapt(loc.getWorld());

       ClipboardFormat format = ClipboardFormats.findByFile(schematic);
       ClipboardReader reader = format.getReader(new FileInputStream(schematic));
       Clipboard clipboard = reader.read();

       EditSession editSession = WorldEdit.getInstance().getEditSessionFactory().getEditSession(world, -1);

       enableWatchdog(editSession);

       Operation operation = new ClipboardHolder(clipboard)
               .createPaste(editSession)
               .to(BlockVector3.at(loc.getX(), loc.getY(), loc.getZ()))
               .ignoreAirBlocks(false)
               .build();

       Operations.complete(operation);
       editSession.flushSession();

	ArrayList<Integer> dimensions = new ArrayList<>();
	dimensions.add(clipboard.getDimensions().getY());
	dimensions.add(clipboard.getDimensions().getX());
	dimensions.add(clipboard.getDimensions().getZ());
	
	Bukkit.getLogger().info("[UhcCore] Successfully pasted '"+path+"' at "+loc.getBlockX()+" "+loc.getBlockY()+" "+loc.getBlockZ());
	return dimensions;
}
 
Example #14
Source File: PasteSchematicEvent.java    From BetonQuest with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected Void execute(String playerID) throws QuestRuntimeException {
    try {
        Location location = loc.getLocation(playerID);
        ClipboardFormat format = ClipboardFormats.findByFile(file);
        if (format == null) {
            throw new IOException("Unknown Schematic Format");
        }

        Clipboard clipboard;
        try (ClipboardReader reader = format.getReader(new FileInputStream(file))) {
            clipboard = reader.read();
        }


        try (EditSession editSession = WorldEdit.getInstance().getEditSessionFactory().getEditSession(BukkitAdapter.adapt(location.getWorld()), -1)) {
            Operation operation = new ClipboardHolder(clipboard)
                    .createPaste(editSession)
                    .to(BukkitAdapter.asBlockVector(location))
                    .ignoreAirBlocks(noAir)
                    .build();

            Operations.complete(operation);
        }
    } catch (IOException | WorldEditException e) {
        LogUtils.getLogger().log(Level.WARNING, "Error while pasting a schematic: " + e.getMessage());
        LogUtils.logThrowable(e);
    }
    return null;
}
 
Example #15
Source File: WorldEditHandler.java    From uSkyBlock with GNU General Public License v3.0 5 votes vote down vote up
public static void loadIslandSchematic(final File file, final Location origin, PlayerPerk playerPerk) {
    log.finer("Trying to load schematic " + file);
    if (file == null || !file.exists() || !file.canRead()) {
        LogUtil.log(Level.WARNING, "Unable to load schematic " + file);
    }
    boolean noAir = false;
    BlockVector3 to = BlockVector3.at(origin.getBlockX(), origin.getBlockY(), origin.getBlockZ());
    EditSession editSession = WorldEdit.getInstance().getEditSessionFactory().getEditSession(new BukkitWorld(origin.getWorld()), -1);
    editSession.setFastMode(true);
    ProtectedRegion region = WorldGuardHandler.getIslandRegionAt(origin);
    if (region != null) {
        editSession.setMask(new RegionMask(getRegion(origin.getWorld(), region)));
    }
    try {
        ClipboardFormat clipboardFormat = ClipboardFormats.findByFile(file);
        try (InputStream in = new FileInputStream(file)) {
            Clipboard clipboard = clipboardFormat.getReader(in).read();
            Operation operation = new ClipboardHolder(clipboard)
                    .createPaste(editSession)
                    .to(to)
                    .ignoreAirBlocks(noAir)
                    .build();
            Operations.completeBlindly(operation);
        }
        editSession.flushSession();
    } catch (IOException e) {
        log.log(Level.INFO, "Unable to paste schematic " + file, e);
    }
}
 
Example #16
Source File: FawePlayer.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Loads any history items from disk:
 * - Should already be called if history on disk is enabled
 */
public void loadClipboardFromDisk() {
    File file = MainUtil.getFile(Fawe.imp().getDirectory(), Settings.IMP.PATHS.CLIPBOARD + File.separator + getUUID() + ".bd");
    try {
        if (file.exists() && file.length() > 5) {
            DiskOptimizedClipboard doc = new DiskOptimizedClipboard(file);
            Player player = toWorldEditPlayer();
            LocalSession session = getSession();
            try {
                if (session.getClipboard() != null) {
                    return;
                }
            } catch (EmptyClipboardException e) {
            }
            if (player != null && session != null) {
                WorldData worldData = player.getWorld().getWorldData();
                Clipboard clip = doc.toClipboard();
                ClipboardHolder holder = new ClipboardHolder(clip, worldData);
                getSession().setClipboard(holder);
            }
        }
    } catch (Exception ignore) {
        Fawe.debug("====== INVALID CLIPBOARD ======");
        MainUtil.handleError(ignore, false);
        Fawe.debug("===============---=============");
        Fawe.debug("This shouldn't result in any failure");
        Fawe.debug("File: " + file.getName() + " (len:" + file.length() + ")");
        Fawe.debug("===============---=============");
    }
}
 
Example #17
Source File: MultiClipboardHolder.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
@Override
public URI getURI(Clipboard clipboard) {
    for (ClipboardHolder holder : getHolders()) {
        if (holder instanceof URIClipboardHolder) {
            URIClipboardHolder uriHolder = (URIClipboardHolder) holder;
            URI uri = uriHolder.getURI(clipboard);
            if (uri != null) return uri;
        }
    }
    return null;
}
 
Example #18
Source File: MultiClipboardHolder.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
public MultiClipboardHolder(Clipboard clipboard, WorldData worldData) {
    super(URI.create(""), EmptyClipboard.INSTANCE, worldData);
    holders = new ArrayList<>();
    URI uri = URI.create("");
    if (clipboard instanceof BlockArrayClipboard) {
        FaweClipboard fc = ((BlockArrayClipboard) clipboard).IMP;
        if (fc instanceof DiskOptimizedClipboard) {
            uri = ((DiskOptimizedClipboard) fc).getFile().toURI();
        }
    }
    add(uri, clipboard);
}
 
Example #19
Source File: MultiClipboardHolder.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean contains(Clipboard clipboard) {
    for (ClipboardHolder holder : holders) {
        if (holder.contains(clipboard)) return true;
    }
    return false;
}
 
Example #20
Source File: ScalableHeightMap.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
public static ScalableHeightMap fromClipboard(Clipboard clipboard) {
    Vector dim = clipboard.getDimensions();
    byte[][] heightArray = new byte[dim.getBlockX()][dim.getBlockZ()];
    int minX = clipboard.getMinimumPoint().getBlockX();
    int minZ = clipboard.getMinimumPoint().getBlockZ();
    int minY = clipboard.getMinimumPoint().getBlockY();
    int maxY = clipboard.getMaximumPoint().getBlockY();
    int clipHeight = maxY - minY + 1;
    HashSet<IntegerPair> visited = new HashSet<>();
    for (Vector pos : clipboard.getRegion()) {
        IntegerPair pair = new IntegerPair(pos.getBlockX(), pos.getBlockZ());
        if (visited.contains(pair)) {
            continue;
        }
        visited.add(pair);
        int xx = pos.getBlockX();
        int zz = pos.getBlockZ();
        int highestY = minY;
        for (int y = minY; y <= maxY; y++) {
            pos.mutY(y);
            BaseBlock block = clipboard.getBlock(pos);
            if (block.getId() != 0) {
                highestY = y + 1;
            }
        }
        int pointHeight = Math.min(255, (256 * (highestY - minY)) / clipHeight);
        int x = xx - minX;
        int z = zz - minZ;
        heightArray[x][z] = (byte) pointHeight;
    }
    return new ArrayHeightMap(heightArray);
}
 
Example #21
Source File: MultiClipboardHolder.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
@Override
public List<Clipboard> getClipboards() {
    ArrayList<Clipboard> all = new ArrayList<>();
    for (ClipboardHolder holder : holders) {
        all.addAll(holder.getClipboards());
    }
    return all;
}
 
Example #22
Source File: MultiClipboardHolder.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
@Override
public Clipboard getClipboard() {
    Clipboard[] available = cached;
    if (available == null) {
        cached = available = getClipboards().toArray(new Clipboard[0]);
    }
    switch (available.length) {
        case 0: return EmptyClipboard.INSTANCE;
        case 1: return available[0];
    }

    int index = PseudoRandom.random.nextInt(available.length);
    return available[index];
}
 
Example #23
Source File: PasteEvent.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
public PasteEvent(Player player, Clipboard clipboard, URI uri, Extent extent, Vector to) {
    this.player = player;
    this.clipboard = clipboard;
    this.uri = uri;
    this.extent = extent;
    this.to = to;
}
 
Example #24
Source File: ClipboardRemapper.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
public void apply(Clipboard clipboard) throws WorldEditException {
    if (clipboard instanceof BlockArrayClipboard) {
        BlockArrayClipboard bac = (BlockArrayClipboard) clipboard;
        bac.IMP = new RemappedClipboard(bac.IMP, this);
    } else {
        Region region = clipboard.getRegion();
        for (BlockVector pos : region) {
            BaseBlock block = clipboard.getBlock(pos);
            BaseBlock newBlock = remap(block);
            if (block != newBlock) {
                clipboard.setBlock(pos, newBlock);
            }
        }
    }
}
 
Example #25
Source File: SchematicWriter.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void write(final Clipboard clipboard, WorldData data) throws IOException {
    if (clipboard instanceof BlockArrayClipboard) {
        stream((BlockArrayClipboard) clipboard);
    } else {
        outputStream.writeNamedTag("Schematic", writeTag(clipboard));
        outputStream.flush();
    }
}
 
Example #26
Source File: SchematicReader.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
public Clipboard read(WorldData data, final UUID clipboardId) throws IOException {
    try {
        return new SchematicStreamer(inputStream, clipboardId).getClipboard();
    } catch (Exception e) {
        Fawe.debug("Input is corrupt!");
        e.printStackTrace();
        return new CorruptSchematicStreamer(rootStream, clipboardId).recover();
    }
}
 
Example #27
Source File: WavefrontReader.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
@Override
public Clipboard read(WorldData data) throws IOException {
    try (InputStream finalStream = inputStream) {
        load(finalStream);
    }
    return null;
}
 
Example #28
Source File: ClipboardHolder.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Create a new instance with the given clipboard.
 *
 * @param clipboard the clipboard
 * @param worldData the mapping of blocks, entities, and so on
 */
public ClipboardHolder(Clipboard clipboard, WorldData worldData) {
    checkNotNull(clipboard);
    checkNotNull(worldData);
    this.clipboard = clipboard;
    this.worldData = worldData;
}
 
Example #29
Source File: TextureUtil.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
public static TextureUtil fromClipboard(Clipboard clipboard) throws FileNotFoundException {
    boolean[] ids = new boolean[Character.MAX_VALUE + 1];
    for (Vector pt : clipboard.getRegion()) {
        ids[clipboard.getBlock(pt).getCombined()] = true;
    }
    HashSet<BaseBlock> blocks = new HashSet<>();
    for (int combined = 0; combined < ids.length; combined++) {
        if (ids[combined]) blocks.add(FaweCache.CACHE_BLOCK[combined]);
    }
    return fromBlocks(blocks);
}
 
Example #30
Source File: ClipboardPattern.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Create a new clipboard pattern.
 *
 * @param clipboard the clipboard
 */
public ClipboardPattern(Clipboard clipboard) {
    checkNotNull(clipboard);
    this.clipboard = clipboard;
    Vector size = clipboard.getMaximumPoint().subtract(clipboard.getMinimumPoint()).add(1, 1, 1);
    this.sx = size.getBlockX();
    this.sy = size.getBlockY();
    this.sz = size.getBlockZ();
    this.min = clipboard.getMinimumPoint();
}