本文整理汇总了Java中com.sk89q.worldedit.function.operation.Operations类的典型用法代码示例。如果您正苦于以下问题:Java Operations类的具体用法?Java Operations怎么用?Java Operations使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Operations类属于com.sk89q.worldedit.function.operation包,在下文中一共展示了Operations类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: execute
import com.sk89q.worldedit.function.operation.Operations; //导入依赖的package包/类
@Override
protected void execute(Event e) {
WorldEditPlugin wep = (WorldEditPlugin) Bukkit.getServer().getPluginManager().getPlugin("WorldEdit");
LocalSession session = wep.getSession(pl.getSingle(e));
Location point1loc = point1.getSingle(e);
Location point2loc = point2.getSingle(e);
Vector min = new Vector(point1loc.getBlockX(), point1loc.getBlockY(), point1loc.getZ());
Vector max = new Vector(point2loc.getBlockX(), point2loc.getBlockY(), point2loc.getZ());
CuboidRegion cr = new CuboidRegion(min, max);
BlockArrayClipboard bc = new BlockArrayClipboard(cr);
EditSession es = wep.createEditSession(pl.getSingle(e));
try {
if (origin == null) {
bc.setOrigin(session.getPlacementPosition(wep.wrapPlayer(pl.getSingle(e))));
} else {
Location originloc = origin.getSingle(e);
Vector originvec = new Vector(originloc.getBlockX(), originloc.getBlockY(), originloc.getBlockZ());
bc.setOrigin(originvec);
}
session.setClipboard(new ClipboardHolder(bc, es.getWorld().getWorldData()));
ForwardExtentCopy copy = new ForwardExtentCopy(es, cr, bc, cr.getMinimumPoint());
Operations.complete(copy);
} catch (WorldEditException e1) {
main core = (main) Bukkit.getPluginManager().getPlugin("SharpSK");
core.getLogger().warning("Failed to save selection. Something went wrong");
return;
}
}
开发者ID:Sharpjaws,项目名称:SharpSK,代码行数:33,代码来源:EffSaveSelectionToClipboard.java
示例17: apply
import com.sk89q.worldedit.function.operation.Operations; //导入依赖的package包/类
@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;
}
开发者ID:boy0001,项目名称:FastAsyncWorldedit,代码行数:9,代码来源:FullClipboardPattern.java
示例18: select
import com.sk89q.worldedit.function.operation.Operations; //导入依赖的package包/类
public void select(int x, int y, int z) {
RecursiveVisitor search = new RecursiveVisitor(mask, new RegionFunction() {
@Override
public boolean apply(Vector p) throws WorldEditException {
setMinMax(p.getBlockX(), p.getBlockY(), p.getBlockZ());
return true;
}
}, 256, extent instanceof HasFaweQueue ? (HasFaweQueue) extent : null);
search.setVisited(set);
search.visit(new Vector(x, y, z));
Operations.completeBlindly(search);
}
开发者ID:boy0001,项目名称:FastAsyncWorldedit,代码行数:13,代码来源:FuzzyRegion.java
示例19: build
import com.sk89q.worldedit.function.operation.Operations; //导入依赖的package包/类
@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);
}
开发者ID:boy0001,项目名称:FastAsyncWorldedit,代码行数:11,代码来源:SurfaceSphereBrush.java
示例20: pasteBlocks
import com.sk89q.worldedit.function.operation.Operations; //导入依赖的package包/类
@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;
}
开发者ID:boy0001,项目名称:FastAsyncWorldedit,代码行数:37,代码来源:ClipboardSpline.java
注:本文中的com.sk89q.worldedit.function.operation.Operations类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论