当前位置: 首页>>代码示例>>Java>>正文


Java ClipboardHolder.getClipboard方法代码示例

本文整理汇总了Java中com.sk89q.worldedit.session.ClipboardHolder.getClipboard方法的典型用法代码示例。如果您正苦于以下问题:Java ClipboardHolder.getClipboard方法的具体用法?Java ClipboardHolder.getClipboard怎么用?Java ClipboardHolder.getClipboard使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.sk89q.worldedit.session.ClipboardHolder的用法示例。


在下文中一共展示了ClipboardHolder.getClipboard方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: apply

import com.sk89q.worldedit.session.ClipboardHolder; //导入方法依赖的package包/类
@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;
}
 
开发者ID:boy0001,项目名称:FastAsyncWorldedit,代码行数:25,代码来源:RandomFullClipboardPattern.java

示例2: spawn

import com.sk89q.worldedit.session.ClipboardHolder; //导入方法依赖的package包/类
@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;
}
 
开发者ID:boy0001,项目名称:FastAsyncWorldedit,代码行数:27,代码来源:SchemGen.java

示例3: brush

import com.sk89q.worldedit.session.ClipboardHolder; //导入方法依赖的package包/类
@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.checkMaxBrushRadius(size.getBlockX());
    worldEdit.checkMaxBrushRadius(size.getBlockY());
    worldEdit.checkMaxBrushRadius(size.getBlockZ());
    return get(context).setBrush(new ClipboardBrush(holder, ignoreAir, usingOrigin));
}
 
开发者ID:boy0001,项目名称:FastAsyncWorldedit,代码行数:24,代码来源:BrushCommands.java

示例4: flip

import com.sk89q.worldedit.session.ClipboardHolder; //导入方法依赖的package包/类
@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);
}
 
开发者ID:boy0001,项目名称:FastAsyncWorldedit,代码行数:20,代码来源:ClipboardCommands.java

示例5: fullcopy

import com.sk89q.worldedit.session.ClipboardHolder; //导入方法依赖的package包/类
@Command(
        aliases = {"#fullcopy"},
        desc = "Places your full clipboard at each block",
        usage = "[schem|folder|url=#copy] [rotate=false] [flip=false]",
        min = 0,
        max = 2
)
public Pattern fullcopy(Player player, Extent extent, LocalSession session, @Optional("#copy") String location, @Optional("false") boolean rotate, @Optional("false") boolean flip) throws EmptyClipboardException, InputParseException, IOException {
    List<ClipboardHolder> clipboards;
    switch (location.toLowerCase()) {
        case "#copy":
        case "#clipboard":
            ClipboardHolder clipboard = session.getExistingClipboard();
            if (clipboard == null) {
                throw new InputParseException("To use #fullcopy, please first copy something to your clipboard");
            }
            if (!rotate && !flip) {
                return new FullClipboardPattern(extent, clipboard.getClipboard());
            }
            clipboards = Collections.singletonList(clipboard);
            break;
        default:
            MultiClipboardHolder multi = ClipboardFormat.SCHEMATIC.loadAllFromInput(player, player.getWorld().getWorldData(), location, true);
            clipboards = multi != null ? multi.getHolders() : null;
            break;
    }
    if (clipboards == null) {
        throw new InputParseException("#fullcopy:<source>");
    }
    return new RandomFullClipboardPattern(extent, player.getWorld().getWorldData(), clipboards, rotate, flip);
}
 
开发者ID:boy0001,项目名称:FastAsyncWorldedit,代码行数:32,代码来源:PatternCommands.java

示例6: ClipboardSpline

import com.sk89q.worldedit.session.ClipboardHolder; //导入方法依赖的package包/类
/**
 * Constructor with position-correction. Use this constructor for an interpolation implementation that needs position-correction.
 * <p>
 * Some interpolation implementations calculate the position on the curve (used by {@link #pastePosition(double)})
 * based on an equidistant distribution of the nodes on the curve. For example: on a spline with 5 nodes position 0.0 would refer
 * to the first node, 0.25 to the second, 0.5 to the third, ... .<br>
 * By providing this method with the amount of nodes used by the interpolation implementation the distribution of the
 * nodes is converted to a proportional distribution based on the length between two adjacent nodes calculated by {@link Interpolation#arcLength(double, double)}.<br>
 * This means that the distance between two positions used to paste the clipboard (e.g. 0.75 - 0.5 = 0.25) on the curve
 * will always amount to that part of the length (e.g. 40 units) of the curve. In this example it would amount to
 * 0.25 * 40 = 10 units of curve length between these two positions.
 * <p>
 * Be advised that currently subsequent changes to the interpolation parameters may not be supported.
 * @param editSession     The EditSession which will be used when pasting the clipboard content
 * @param clipboardHolder The clipboard that will be pasted along the spline
 * @param interpolation   An implementation of the interpolation algorithm used to calculate the curve
 * @param nodeCount       The number of nodes provided to the interpolation object
 */
public ClipboardSpline(EditSession editSession, ClipboardHolder clipboardHolder, Interpolation interpolation, Transform transform, int nodeCount) {
    super(editSession, interpolation, nodeCount);
    this.clipboardHolder = clipboardHolder;

    this.originalTransform = clipboardHolder.getTransform();
    Clipboard clipboard = clipboardHolder.getClipboard();
    this.originalOrigin = clipboard.getOrigin();

    Region region = clipboard.getRegion();
    center = region.getCenter().setY(region.getMinimumPoint().getY());
    this.centerOffset = center.subtract(center.round());
    this.center = center.subtract(centerOffset);
    this.transform = transform;
    this.buffer = new LocalBlockVectorSet();
}
 
开发者ID:boy0001,项目名称:FastAsyncWorldedit,代码行数:34,代码来源:ClipboardSpline.java

示例7: addSchems

import com.sk89q.worldedit.session.ClipboardHolder; //导入方法依赖的package包/类
public void addSchems(BufferedImage img, Mask mask, WorldData worldData, List<ClipboardHolder> clipboards, int rarity, int distance, boolean randomRotate) throws WorldEditException {
    if (img.getWidth() != getWidth() || img.getHeight() != getLength())
        throw new IllegalArgumentException("Input image dimensions do not match the current height map!");
    double doubleRarity = rarity / 100d;
    int index = 0;
    AffineTransform identity = new AffineTransform();
    LocalBlockVector2DSet placed = new LocalBlockVector2DSet();
    for (int z = 0; z < getLength(); z++) {
        mutable.mutZ(z);
        for (int x = 0; x < getWidth(); x++, index++) {
            int y = heights.getByte(index) & 0xFF;
            int height = img.getRGB(x, z) & 0xFF;
            if (height == 0 || PseudoRandom.random.nextInt(256) > height * doubleRarity) {
                continue;
            }
            mutable.mutX(x);
            mutable.mutY(y);
            if (!mask.test(mutable)) {
                continue;
            }
            if (placed.containsRadius(x, z, distance)) {
                continue;
            }
            placed.add(x, z);
            ClipboardHolder holder = clipboards.get(PseudoRandom.random.random(clipboards.size()));
            if (randomRotate) {
                int rotate = PseudoRandom.random.random(4) * 90;
                if (rotate != 0) {
                    holder.setTransform(new AffineTransform().rotateY(PseudoRandom.random.random(4) * 90));
                } else {
                    holder.setTransform(identity);
                }
            }
            Clipboard clipboard = holder.getClipboard();
            Schematic schematic = new Schematic(clipboard);
            Transform transform = holder.getTransform();
            if (transform.isIdentity()) {
                schematic.paste(this, mutable, false);
            } else {
                schematic.paste(this, worldData, mutable, false, transform);
            }
            if (x + distance < getWidth()) {
                x += distance;
                index += distance;
            } else {
                break;
            }
        }
    }
}
 
开发者ID:boy0001,项目名称:FastAsyncWorldedit,代码行数:51,代码来源:HeightMapMCAGenerator.java

示例8: paletteblocks

import com.sk89q.worldedit.session.ClipboardHolder; //导入方法依赖的package包/类
@Command(
        aliases = {"paletteblocks", "colorpaletterblocks", "setcolorpaletteblocks"},
        usage = "<blocks|#clipboard|*>",
        desc = "Set the blocks used for coloring",
        help = "Allow only specific blocks to be used for coloring\n" +
                "`blocks` is a list of blocks e.g. stone,bedrock,wool\n" +
                "`#clipboard` will only use the blocks present in your clipboard."
)
@CommandPermissions("worldedit.anvil.cfi")
public void paletteblocks(FawePlayer fp, @Optional String arg) throws ParameterException, EmptyClipboardException, InputParseException, FileNotFoundException {
    if (arg == null) {
        msg("What blocks do you want to color with?").newline()
        .text("&7[&aAll&7]").cmdTip(alias() + " PaletteBlocks *").text(" - All available blocks")
        .newline()
        .text("&7[&aClipboard&7]").cmdTip(alias() + " PaletteBlocks #clipboard").text(" - The blocks in your clipboard")
        .newline()
        .text("&7[&aList&7]").suggestTip(alias() + " PaletteBlocks stone,gravel").text(" - A comma separated list of blocks")
        .newline()
        .text("&7[&aComplexity&7]").cmdTip(alias() + " Complexity").text(" - Block textures within a complexity range")
        .newline()
        .text("&8< &7[&aBack&7]").cmdTip(alias() + " " + Commands.getAlias(CFICommands.class, "coloring"))
        .send(fp);
        return;
    }
    HeightMapMCAGenerator generator = assertSettings(fp).getGenerator();
    ParserContext context = new ParserContext();
    context.setActor(fp.getPlayer());
    context.setWorld(fp.getWorld());
    context.setSession(fp.getSession());
    context.setExtent(generator);
    Request.request().setExtent(generator);

    Set<BaseBlock> blocks;
    switch (arg.toLowerCase()) {
        case "*": {
            generator.setTextureUtil(Fawe.get().getTextureUtil());
            return;
        }
        case "#clipboard": {
            ClipboardHolder holder = fp.getSession().getClipboard();
            Clipboard clipboard = holder.getClipboard();
            boolean[] ids = new boolean[Character.MAX_VALUE + 1];
            for (Vector pt : clipboard.getRegion()) {
                ids[clipboard.getBlock(pt).getCombined()] = true;
            }
            blocks = new HashSet<>();
            for (int combined = 0; combined < ids.length; combined++) {
                if (ids[combined]) blocks.add(FaweCache.CACHE_BLOCK[combined]);
            }
            break;
        }
        default: {
            blocks = worldEdit.getBlockFactory().parseFromListInput(arg, context);
            break;
        }
    }
    generator.setTextureUtil(new FilteredTextureUtil(Fawe.get().getTextureUtil(), blocks));
    coloring(fp);
}
 
开发者ID:boy0001,项目名称:FastAsyncWorldedit,代码行数:60,代码来源:CFICommands.java

示例9: exec

import com.sk89q.worldedit.session.ClipboardHolder; //导入方法依赖的package包/类
@Override
public Construct exec(Target t, Environment env, Construct... args) throws CancelCommandException, ConfigRuntimeException {
	MCPlayer player = null;
	Static.checkPlugin("WorldEdit", t);
	
	if (args.length == 0) {
		player = env.getEnv(CommandHelperEnvironment.class).GetPlayer();
	} else {
		player = Static.GetPlayer(args[0].val(), t);
	}
	
	SKCommandSender user = getSKPlayer(player, t);
	
	RegionSelector sel = user.getLocalSession().getRegionSelector(user.getWorld());
	if (!( sel instanceof CuboidRegionSelector )) {
		throw new CREPluginInternalException("Only cuboid regions are supported with " + this.getName(), t);
	}
	
	LocalSession localSession = user.getLocalSession();
	ClipboardHolder clipHolder = null;
	try {
		clipHolder = localSession.getClipboard();
	} catch (EmptyClipboardException e) {
		return CNull.NULL; // Return null as the given player has an empty clipboard.
	}
	Clipboard clip = clipHolder.getClipboard();
	Transform transform = clipHolder.getTransform();
	
	// Create return array.
	CArray ret = new CArray(t);
	CArray origin            = ObjectGenerator.GetGenerator().vector(vtov(clip.getOrigin())      , t);
	CArray dimensions        = ObjectGenerator.GetGenerator().vector(vtov(clip.getDimensions())  , t);
	CArray minPointOriginal  = ObjectGenerator.GetGenerator().vector(vtov(clip.getMinimumPoint()), t);
	CArray maxPointOriginal  = ObjectGenerator.GetGenerator().vector(vtov(clip.getMaximumPoint()), t);
	CArray minPointRelative  = ObjectGenerator.GetGenerator().vector(vtov(clip.getMinimumPoint().subtract(clip.getOrigin())), t);
	CArray maxPointRelative  = ObjectGenerator.GetGenerator().vector(vtov(clip.getMaximumPoint().subtract(clip.getOrigin())), t);
	CArray minPoint = new CArray(t);
	CArray maxPoint = new CArray(t);
	minPoint.set("original", minPointOriginal, t); // Original copy region world coords (//paste -o).
	maxPoint.set("original", maxPointOriginal, t); // Original copy region world coords (//paste -o).
	minPoint.set("relative", minPointRelative, t); // Initialize to non-rotated/flipped region.
	maxPoint.set("relative", maxPointRelative, t); // Initialize to non-rotated/flipped region.
	
	ret.set("origin"    , origin    , t);
	ret.set("dimensions", dimensions, t);
	ret.set("minPoint"  , minPoint  , t);
	ret.set("maxPoint"  , maxPoint  , t);
	
	if (!(transform instanceof AffineTransform)) {
		return ret; // Return here, as we can't add any rotation and paste data.
	}
	AffineTransform affineTransform = (AffineTransform) transform;
	
	Vector minPointOriginalVec = affineTransform.apply(clip.getMinimumPoint().subtract(clip.getOrigin())).add(clip.getOrigin());
	Vector maxPointOriginalVec = affineTransform.apply(clip.getMaximumPoint().subtract(clip.getOrigin())).add(clip.getOrigin());
	Vector minPointRelativeVec = affineTransform.apply(clip.getMinimumPoint().subtract(clip.getOrigin()));
	Vector maxPointRelativeVec = affineTransform.apply(clip.getMaximumPoint().subtract(clip.getOrigin()));
	
	CArray minPointOriginalCVec = ObjectGenerator.GetGenerator().vector(vtov(minPointOriginalVec), t);
	CArray maxPointOriginalCVec = ObjectGenerator.GetGenerator().vector(vtov(maxPointOriginalVec), t);
	CArray minPointRelativeCVec = ObjectGenerator.GetGenerator().vector(vtov(minPointRelativeVec), t);
	CArray maxPointRelativeCVec = ObjectGenerator.GetGenerator().vector(vtov(maxPointRelativeVec), t);
	
	minPoint.set("original", minPointOriginalCVec, t); // 'Original' copy region world coords (//paste -o) inc rotation & flip.
	maxPoint.set("original", maxPointOriginalCVec, t); // 'Original' copy region world coords (//paste -o) inc rotation & flip.
	minPoint.set("relative", minPointRelativeCVec, t); // Relative copy selection world coords inc rotation & flip (//paste).
	maxPoint.set("relative", maxPointRelativeCVec, t); // Relative copy selection world coords inc rotation & flip (//paste).
	
	return ret;
}
 
开发者ID:jb-aero,项目名称:SKCompat,代码行数:71,代码来源:CHWorldEdit.java


注:本文中的com.sk89q.worldedit.session.ClipboardHolder.getClipboard方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。