本文整理汇总了Java中com.sk89q.worldedit.EditSession.setBlocks方法的典型用法代码示例。如果您正苦于以下问题:Java EditSession.setBlocks方法的具体用法?Java EditSession.setBlocks怎么用?Java EditSession.setBlocks使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.sk89q.worldedit.EditSession
的用法示例。
在下文中一共展示了EditSession.setBlocks方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: execute
import com.sk89q.worldedit.EditSession; //导入方法依赖的package包/类
protected void execute(Event event) {
String name = (String) this.name.getSingle(event);
World world = (World) this.world.getSingle(event);
ItemStack block = (ItemStack) this.block.getSingle(event);
RegionManager regionManager = WGBukkit.getRegionManager((org.bukkit.World) world);
if (!regionManager.hasRegion(name)) {
Skript.error("Region \"" + name + "\" in world \"" + world.getName() + "\" does not exists.");
return;
}
Vector v1 = regionManager.getRegion(name).getMaximumPoint();
Vector v2 = regionManager.getRegion(name).getMinimumPoint();
Region region = new CuboidRegion(v1, v2);
BaseBlock b = new BaseBlock(block.getTypeId(), block.getData().getData());
EditSession es = WorldEdit.getInstance().getEditSessionFactory().getEditSession(world, -1);
try {
es.setBlocks(region, b);
} catch (Exception e) {
e.printStackTrace();
}
}
示例2: set
import com.sk89q.worldedit.EditSession; //导入方法依赖的package包/类
@Command(
aliases = {"/set", "/s"},
usage = "[pattern]",
desc = "Set all blocks within selection",
min = 1,
max = 1
)
@CommandPermissions("worldedit.region.set")
@Logging(REGION)
public void set(FawePlayer player, LocalSession session, EditSession editSession, @Selection Region selection, Pattern to, CommandContext context) throws WorldEditException {
player.checkConfirmationRegion(getArguments(context), selection);
int affected;
affected = editSession.setBlocks(selection, to);
if (affected != 0) {
BBC.OPERATION.send(player, affected);
if (!player.hasPermission("fawe.tips"))
BBC.TIP_FAST.or(BBC.TIP_CANCEL, BBC.TIP_MASK, BBC.TIP_MASK_ANGLE, BBC.TIP_SET_LINEAR, BBC.TIP_SURFACE_SPREAD, BBC.TIP_SET_HAND).send(player);
}
}
示例3: build
import com.sk89q.worldedit.EditSession; //导入方法依赖的package包/类
@Override
public void build(EditSession editSession, Vector pos, Pattern pattern, double radius) throws MaxChangedBlocksException {
int maxY = editSession.getMaxY();
boolean vis = editSession.getExtent() instanceof VisualExtent;
if (path.isEmpty() || !pos.equals(path.get(path.size() - 1))) {
int max = editSession.getNearestSurfaceTerrainBlock(pos.getBlockX(), pos.getBlockZ(), pos.getBlockY(), 0, editSession.getMaxY());
if (max == -1) return;
pos.mutY(max);
path.add(pos);
editSession.getPlayer().sendMessage(BBC.getPrefix() + BBC.BRUSH_SPLINE_PRIMARY_2.s());
if (!vis) return;
}
LocalBlockVectorSet vset = new LocalBlockVectorSet();
final List<Node> nodes = new ArrayList<>(path.size());
final KochanekBartelsInterpolation interpol = new KochanekBartelsInterpolation();
for (final Vector nodevector : path) {
final Node n = new Node(nodevector);
n.setTension(tension);
n.setBias(bias);
n.setContinuity(continuity);
nodes.add(n);
}
interpol.setNodes(nodes);
final double splinelength = interpol.arcLength(0, 1);
for (double loop = 0; loop <= 1; loop += 1D / splinelength / quality) {
final Vector tipv = interpol.getPosition(loop);
final int tipx = MathMan.roundInt(tipv.getX());
final int tipz = (int) tipv.getZ();
int tipy = MathMan.roundInt(tipv.getY());
tipy = editSession.getNearestSurfaceTerrainBlock(tipx, tipz, tipy, 0, maxY);
if (tipy == -1) continue;
if (radius == 0) {
editSession.setBlock(tipx, tipy, tipz, pattern.next(tipx, tipy, tipz));
} else {
vset.add(tipx, tipy, tipz);
}
}
if (radius != 0) {
double radius2 = (radius * radius);
LocalBlockVectorSet newSet = new LocalBlockVectorSet();
final int ceilrad = (int) Math.ceil(radius);
for (final Vector v : vset) {
final int tipx = v.getBlockX(), tipy = v.getBlockY(), tipz = v.getBlockZ();
for (int loopx = tipx - ceilrad; loopx <= (tipx + ceilrad); loopx++) {
for (int loopz = tipz - ceilrad; loopz <= (tipz + ceilrad); loopz++) {
if (MathMan.hypot2(loopx - tipx, 0, loopz - tipz) <= radius2) {
int y = editSession.getNearestSurfaceTerrainBlock(loopx, loopz, v.getBlockY(), 0, maxY);
if (y == -1) continue;
newSet.add(loopx, y, loopz);
}
}
}
}
editSession.setBlocks(newSet, pattern);
if (!vis) path.clear();
}
editSession.getPlayer().sendMessage(BBC.getPrefix() + BBC.BRUSH_SPLINE_SECONDARY.s());
}