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


Java Operations类代码示例

本文整理汇总了Java中com.sk89q.worldedit.function.operation.Operations的典型用法代码示例。如果您正苦于以下问题:Java Operations类的具体用法?Java Operations怎么用?Java Operations使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Operations类属于com.sk89q.worldedit.function.operation包,在下文中一共展示了Operations类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: swap

import com.sk89q.worldedit.function.operation.Operations; //导入依赖的package包/类
@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() {
            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);
        }
    });
}
 
开发者ID:boy0001,项目名称:FastAsyncWorldedit,代码行数:24,代码来源:FaweChunkManager.java

示例2: copyRegion

import com.sk89q.worldedit.function.operation.Operations; //导入依赖的package包/类
@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() {
            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;
}
 
开发者ID:boy0001,项目名称:FastAsyncWorldedit,代码行数:21,代码来源:FaweChunkManager.java

示例3: paste

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

示例4: fillDirection

import com.sk89q.worldedit.function.operation.Operations; //导入依赖的package包/类
/**
 * Fills an area recursively in the X/Z directions.
 *
 * @param origin    the location to start from
 * @param pattern     the block to fill with
 * @param radius    the radius of the spherical area to fill
 * @param depth     the maximum depth, starting from the origin
 * @param direction the direction to fill
 * @return number of blocks affected
 * @throws MaxChangedBlocksException thrown if too many blocks are changed
 */
public int fillDirection(final Vector origin, final Pattern pattern, final double radius, final int depth, Vector direction) {
    checkNotNull(origin);
    checkNotNull(pattern);
    checkArgument(radius >= 0, "radius >= 0");
    checkArgument(depth >= 1, "depth >= 1");
    if (direction.equals(new Vector(0, -1, 0))) {
        return fillXZ(origin, pattern, radius, depth, false);
    }
    final MaskIntersection mask = new MaskIntersection(new RegionMask(new EllipsoidRegion(null, origin, new Vector(radius, radius, radius))), Masks.negate(new ExistingBlockMask(EditSession.this)));

    // Want to replace blocks
    final BlockReplace replace = new BlockReplace(EditSession.this, pattern);

    // Pick how we're going to visit blocks
    RecursiveVisitor visitor = new DirectionalVisitor(mask, replace, origin, direction, (int) (radius * 2 + 1), this);

    // Start at the origin
    visitor.visit(origin);

    // Execute
    Operations.completeBlindly(visitor);
    return this.changes = visitor.getAffected();
}
 
开发者ID:boy0001,项目名称:FastAsyncWorldedit,代码行数:35,代码来源:EditSession.java

示例5: setBlocks

import com.sk89q.worldedit.function.operation.Operations; //导入依赖的package包/类
/**
 * Sets all the blocks inside a region to a given block type.
 *
 * @param region the region
 * @param block  the block
 * @return number of blocks affected
 * @throws MaxChangedBlocksException thrown if too many blocks are changed
 */
@SuppressWarnings("deprecation")
public int setBlocks(final Region region, final BaseBlock block) {
    checkNotNull(region);
    checkNotNull(block);
    if (canBypassAll(region, false, true) && !block.hasNbtData()) {
        return changes = queue.setBlocks((CuboidRegion) region, block.getId(), block.getData());
    }
    try {
        if (hasExtraExtents()) {
            RegionVisitor visitor = new RegionVisitor(region, new BlockReplace(extent, (block)), this);
            Operations.completeBlindly(visitor);
            this.changes += visitor.getAffected();
        } else {
            Iterator<BlockVector> iter = region.iterator();
            while (iter.hasNext()) {
                if (this.extent.setBlock(iter.next(), block)) {
                    changes++;
                }
            }
        }
    } catch (final WorldEditException e) {
        throw new RuntimeException("Unexpected exception", e);
    }
    return changes;
}
 
开发者ID:boy0001,项目名称:FastAsyncWorldedit,代码行数:34,代码来源:EditSession.java

示例6: stackCuboidRegion

import com.sk89q.worldedit.function.operation.Operations; //导入依赖的package包/类
/**
 * 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();
}
 
开发者ID:boy0001,项目名称:FastAsyncWorldedit,代码行数:34,代码来源:EditSession.java

示例7: makePumpkinPatches

import com.sk89q.worldedit.function.operation.Operations; //导入依赖的package包/类
/**
 * Makes pumpkin patches randomly in an area around the given position.
 *
 * @param position the base position
 * @param apothem  the apothem of the (square) area
 * @return number of patches created
 * @throws MaxChangedBlocksException thrown if too many blocks are changed
 */
public int makePumpkinPatches(final Vector position, final int apothem) {
    // We want to generate pumpkins
    final GardenPatchGenerator generator = new GardenPatchGenerator(EditSession.this);
    generator.setPlant(GardenPatchGenerator.getPumpkinPattern());

    // In a region of the given radius
    final FlatRegion region = new CuboidRegion(EditSession.this.getWorld(), // Causes clamping of Y range
            position.add(-apothem, -5, -apothem), position.add(apothem, 10, apothem));
    final double density = 0.02;

    final GroundFunction ground = new GroundFunction(new ExistingBlockMask(EditSession.this), generator);
    final LayerVisitor visitor = new LayerVisitor(region, minimumBlockY(region), maximumBlockY(region), ground);
    visitor.setMask(new NoiseFilter2D(new RandomNoise(), density));
    Operations.completeBlindly(visitor);
    return this.changes = ground.getAffected();
}
 
开发者ID:boy0001,项目名称:FastAsyncWorldedit,代码行数:25,代码来源:EditSession.java

示例8: forest

import com.sk89q.worldedit.function.operation.Operations; //导入依赖的package包/类
@Command(
        aliases = {"/forest"},
        usage = "[type] [density]",
        desc = "Make a forest within the region",
        min = 0,
        max = 2
)
@CommandPermissions("worldedit.region.forest")
@Logging(REGION)
public void forest(FawePlayer player, EditSession editSession, @Selection Region region, @Optional("tree") TreeType type,
                   @Optional("5") @Range(min = 0, max = 100) double density,
                   CommandContext context) throws WorldEditException {
    player.checkConfirmationRegion(getArguments(context), region);

    density = density / 100;
    ForestGenerator generator = new ForestGenerator(editSession, new TreeGenerator(type));
    GroundFunction ground = new GroundFunction(new ExistingBlockMask(editSession), generator);
    LayerVisitor visitor = new LayerVisitor(asFlatRegion(region), minimumBlockY(region), maximumBlockY(region), ground);
    visitor.setMask(new NoiseFilter2D(new RandomNoise(), density));
    Operations.completeLegacy(visitor);

    BBC.COMMAND_TREE.send(player, ground.getAffected());
}
 
开发者ID:boy0001,项目名称:FastAsyncWorldedit,代码行数:24,代码来源:RegionCommands.java

示例9: flora

import com.sk89q.worldedit.function.operation.Operations; //导入依赖的package包/类
@Command(
        aliases = {"/flora"},
        usage = "[density]",
        desc = "Make flora within the region",
        min = 0,
        max = 1
)
@CommandPermissions("worldedit.region.flora")
@Logging(REGION)
public void flora(FawePlayer player, EditSession editSession, @Selection Region region, @Optional("10") @Range(min = 0, max = 100) double density, CommandContext context) throws WorldEditException {
    player.checkConfirmationRegion(getArguments(context), region);
    density = density / 100;
    FloraGenerator generator = new FloraGenerator(editSession);
    GroundFunction ground = new GroundFunction(new ExistingBlockMask(editSession), generator);
    LayerVisitor visitor = new LayerVisitor(asFlatRegion(region), minimumBlockY(region), maximumBlockY(region), ground);
    visitor.setMask(new NoiseFilter2D(new RandomNoise(), density));
    Operations.completeLegacy(visitor);

    BBC.COMMAND_FLORA.send(player, ground.getAffected());
}
 
开发者ID:boy0001,项目名称:FastAsyncWorldedit,代码行数:21,代码来源:RegionCommands.java

示例10: pasteWithWE

import com.sk89q.worldedit.function.operation.Operations; //导入依赖的package包/类
public static void pasteWithWE(Player p, File f) throws DataException {
	SpongePlayer sp = SpongeWorldEdit.inst().wrapPlayer(p);
	SpongeWorld ws = SpongeWorldEdit.inst().getWorld(p.getWorld());
	
	LocalSession session = SpongeWorldEdit.inst().getSession(p);
	
	Closer closer = Closer.create();
	try {
		ClipboardFormat format = ClipboardFormat.findByAlias("schematic");
		FileInputStream fis = closer.register(new FileInputStream(f));
	    BufferedInputStream bis = closer.register(new BufferedInputStream(fis));
	    ClipboardReader reader = format.getReader(bis);
	    		    
	    WorldData worldData = ws.getWorldData();
	    Clipboard clipboard = reader.read(ws.getWorldData());
	    session.setClipboard(new ClipboardHolder(clipboard, worldData));
	    
	    ClipboardHolder holder = session.getClipboard();
	    
	    Operation op = holder.createPaste(session.createEditSession(sp), ws.getWorldData()).to(session.getPlacementPosition(sp)).build();
	    Operations.completeLegacy(op);
	} catch (IOException | MaxChangedBlocksException | EmptyClipboardException | IncompleteRegionException e) {
		e.printStackTrace();
	}		
}
 
开发者ID:FabioZumbi12,项目名称:RedProtect,代码行数:26,代码来源:WEListener.java

示例11: execute

import com.sk89q.worldedit.function.operation.Operations; //导入依赖的package包/类
public Integer execute(ICancelabeEditSession editSession) throws MaxChangedBlocksException {
    try {
        ClipboardReader reader = ClipboardFormat.SCHEMATIC.getReader(new FileInputStream(file));
        WorldData worldData = bukkitWorld.getWorldData();
        Clipboard clipboard = reader.read(worldData);
        ClipboardHolder holder = new ClipboardHolder(clipboard, worldData);
        editSession.enableQueue();
        editSession.setFastMode(true);
        Vector to = new Vector(origin.getBlockX(), origin.getBlockY(), origin.getBlockZ());
        final Operation operation = holder
                .createPaste(editSession, worldData)
                .to(to)
                .ignoreAirBlocks(true)
                .build();
        Operations.completeBlindly(operation);
        editSession.flushQueue();
    } catch (IOException e) {
        log.log(Level.WARNING, "Error trying to paste " + file, e);
    }
    return 32768;
}
 
开发者ID:rlf,项目名称:uSkyBlock,代码行数:22,代码来源:AWE330Adaptor.java

示例12: execute

import com.sk89q.worldedit.function.operation.Operations; //导入依赖的package包/类
public Integer execute(CancelabeEditSession editSession) throws MaxChangedBlocksException {
    try {
        ClipboardReader reader = ClipboardFormat.SCHEMATIC.getReader(new FileInputStream(file));
        WorldData worldData = bukkitWorld.getWorldData();
        Clipboard clipboard = reader.read(worldData);
        ClipboardHolder holder = new ClipboardHolder(clipboard, worldData);
        editSession.enableQueue();
        editSession.setFastMode(true);
        Vector to = new Vector(origin.getBlockX(), origin.getBlockY(), origin.getBlockZ());
        final Operation operation = holder
                .createPaste(editSession, worldData)
                .to(to)
                .ignoreAirBlocks(true)
                .build();
        Operations.completeBlindly(operation);
        editSession.flushQueue();
    } catch (IOException e) {
        log.log(Level.WARNING, "Error trying to paste " + file, e);
    }
    return 0;
}
 
开发者ID:rlf,项目名称:uSkyBlock,代码行数:22,代码来源:AWE211Adaptor.java

示例13: execute

import com.sk89q.worldedit.function.operation.Operations; //导入依赖的package包/类
public Integer execute(CancelabeEditSession editSession) throws MaxChangedBlocksException {
    try {
        ClipboardReader reader = ClipboardFormat.SCHEMATIC.getReader(new FileInputStream(file));
        WorldData worldData = bukkitWorld.getWorldData();
        Clipboard clipboard = reader.read(worldData);
        ClipboardHolder holder = new ClipboardHolder(clipboard, worldData);
        editSession.enableQueue();
        editSession.setFastMode(true);
        Vector to = new Vector(origin.getBlockX(), origin.getBlockY(), origin.getBlockZ());
        final Operation operation = holder
                .createPaste(editSession, worldData)
                .to(to)
                .ignoreAirBlocks(true)
                .build();
        Operations.completeBlindly(operation);
        editSession.flushQueue();
    } catch (IOException e) {
        log.log(Level.WARNING, "Error trying to paste " + file, e);
    }
    return 32768;
}
 
开发者ID:rlf,项目名称:uSkyBlock,代码行数:22,代码来源:AWE311Adaptor.java

示例14: regenerate

import com.sk89q.worldedit.function.operation.Operations; //导入依赖的package包/类
@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);
	}
}
 
开发者ID:xaniox,项目名称:HeavySpleef,代码行数:22,代码来源:DefaultFloorRegenerator.java

示例15: generate

import com.sk89q.worldedit.function.operation.Operations; //导入依赖的package包/类
@Override
@Deprecated
public void generate(EditSession session) {
	Region region = floorClipboard.getRegion();
	World world = region.getWorld();
	WorldData data = world.getWorldData();
	
	ClipboardHolder holder = new ClipboardHolder(floorClipboard, data);
	
	Operation pasteOperation = holder.createPaste(session, data)
			.to(region.getMinimumPoint())
			.ignoreAirBlocks(true)
			.build();
	
	try {
		Operations.complete(pasteOperation);
	} catch (WorldEditException e) {
		throw new RuntimeException(e);
	}
}
 
开发者ID:xaniox,项目名称:HeavySpleef,代码行数:21,代码来源:SimpleClipboardFloor.java


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