本文整理汇总了Java中com.sk89q.worldedit.MaxChangedBlocksException类的典型用法代码示例。如果您正苦于以下问题:Java MaxChangedBlocksException类的具体用法?Java MaxChangedBlocksException怎么用?Java MaxChangedBlocksException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MaxChangedBlocksException类属于com.sk89q.worldedit包,在下文中一共展示了MaxChangedBlocksException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: swap
import com.sk89q.worldedit.MaxChangedBlocksException; //导入依赖的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);
}
});
}
示例2: copyRegion
import com.sk89q.worldedit.MaxChangedBlocksException; //导入依赖的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;
}
示例3: build
import com.sk89q.worldedit.MaxChangedBlocksException; //导入依赖的package包/类
@Override
public void build(EditSession editSession, Vector position, Pattern pattern, double size) throws MaxChangedBlocksException {
int radius = (int) size;
CuboidRegionSelector selector = new CuboidRegionSelector(editSession.getWorld(), position.subtract(radius, radius, radius), position.add(radius, radius, radius));
String replaced = command.replace("{x}", position.getBlockX() + "")
.replace("{y}", Integer.toString(position.getBlockY()))
.replace("{z}", Integer.toString(position.getBlockZ()))
.replace("{world}", editSession.getQueue().getWorldName())
.replace("{size}", Integer.toString(radius));
FawePlayer fp = editSession.getPlayer();
Player player = fp.getPlayer();
WorldVectorFace face = player.getBlockTraceFace(256, true);
if (face == null) {
position = position.add(0, 1, 1);
} else {
position = face.getFaceVector();
}
fp.setSelection(selector);
PlayerWrapper wePlayer = new SilentPlayerWrapper(new LocationMaskedPlayerWrapper(player, new Location(player.getExtent(), position)));
List<String> cmds = StringMan.split(replaced, ';');
for (String cmd : cmds) {
CommandEvent event = new CommandEvent(wePlayer, cmd);
CommandManager.getInstance().handleCommandOnCurrentThread(event);
}
}
示例4: pastePositionDirect
import com.sk89q.worldedit.MaxChangedBlocksException; //导入依赖的package包/类
/**
* Paste structure at the provided position on the curve. The position will not be position-corrected
* but will be passed directly to the interpolation algorithm.
* @param position The position on the curve. Must be between 0.0 and 1.0 (both inclusive)
* @return The amount of blocks that have been changed
* @throws MaxChangedBlocksException Thrown by WorldEdit if the limit of block changes for the {@link EditSession} has been reached
*/
public int pastePositionDirect(double position) throws MaxChangedBlocksException {
Preconditions.checkArgument(position >= 0);
Preconditions.checkArgument(position <= 1);
// Calculate position from spline
Vector target = interpolation.getPosition(position);
Vector offset = target.subtract(target.round());
target = target.subtract(offset);
// Calculate rotation from spline
Vector deriv = interpolation.get1stDerivative(position);
Vector2D deriv2D = new Vector2D(deriv.getX(), deriv.getZ()).normalize();
double angle = Math.toDegrees(
Math.atan2(direction.getZ(), direction.getX()) - Math.atan2(deriv2D.getZ(), deriv2D.getX())
);
return pasteBlocks(target, offset, angle);
}
示例5: build
import com.sk89q.worldedit.MaxChangedBlocksException; //导入依赖的package包/类
@Override
public void build(EditSession editSession, Vector pos2, final Pattern pattern, double size) throws MaxChangedBlocksException {
boolean visual = (editSession.getExtent() instanceof VisualExtent);
if (pos1 == null || pos2.equals(pos1)) {
if (!visual) {
pos1 = pos2;
BBC.BRUSH_LINE_PRIMARY.send(editSession.getPlayer(), pos2);
}
return;
}
Vector vertex = getVertex(pos1, pos2, slack);
List<Vector> nodes = Arrays.asList(pos1, vertex, pos2);
editSession.drawSpline(pattern, nodes, 0, 0, 0, 10, size, !shell);
if (!visual) {
BBC.BRUSH_LINE_SECONDARY.send(editSession.getPlayer());
if (!select) {
pos1 = null;
return;
} else {
pos1 = pos2;
}
}
}
示例6: apply
import com.sk89q.worldedit.MaxChangedBlocksException; //导入依赖的package包/类
@Override
public void apply(EditSession editSession, LocalBlockVectorSet placed, Vector position, Pattern p, double size) throws MaxChangedBlocksException {
int radius = getDistance();
CuboidRegionSelector selector = new CuboidRegionSelector(editSession.getWorld(), position.subtract(radius, radius, radius), position.add(radius, radius, radius));
String replaced = command.replace("{x}", position.getBlockX() + "")
.replace("{y}", Integer.toString(position.getBlockY()))
.replace("{z}", Integer.toString(position.getBlockZ()))
.replace("{world}", editSession.getQueue().getWorldName())
.replace("{size}", Integer.toString(radius));
FawePlayer fp = editSession.getPlayer();
Player player = fp.getPlayer();
fp.setSelection(selector);
PlayerWrapper wePlayer = new SilentPlayerWrapper(new LocationMaskedPlayerWrapper(player, new Location(player.getExtent(), position)));
List<String> cmds = StringMan.split(replaced, ';');
for (String cmd : cmds) {
CommandEvent event = new CommandEvent(wePlayer, cmd);
CommandManager.getInstance().handleCommandOnCurrentThread(event);
}
}
示例7: build
import com.sk89q.worldedit.MaxChangedBlocksException; //导入依赖的package包/类
@Override
public void build(EditSession editSession, Vector position, final Pattern pattern, double size) throws MaxChangedBlocksException {
boolean visual = (editSession.getExtent() instanceof VisualExtent);
if (pos1 == null) {
if (!visual) {
pos1 = position;
BBC.BRUSH_LINE_PRIMARY.send(editSession.getPlayer(), position);
}
return;
}
editSession.drawLine(pattern, pos1, position, size, !shell, flat);
if (!visual) {
BBC.BRUSH_LINE_SECONDARY.send(editSession.getPlayer());
if (!select) {
pos1 = null;
return;
} else {
pos1 = position;
}
}
}
示例8: pasteWithWE
import com.sk89q.worldedit.MaxChangedBlocksException; //导入依赖的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();
}
}
示例9: showStartingPlatform
import com.sk89q.worldedit.MaxChangedBlocksException; //导入依赖的package包/类
private void showStartingPlatform(boolean present) {
Location<World> platformLocation = startingLocation.add(0, -1, 0);
EditSession editor = WorldEdit.getInstance().getEditSessionFactory().getEditSession(
new WorldResolver(getRegion().getExtent()).getWorldEditWorld(),
-1
);
com.sk89q.worldedit.Vector origin = new com.sk89q.worldedit.Vector(
platformLocation.getX(), platformLocation.getY(), platformLocation.getZ()
);
BaseBlock targetBlock;
if (present) {
targetBlock = WorldEdit.getInstance().getBaseBlockFactory().getBaseBlock(BlockID.STAINED_GLASS, 15);
} else {
targetBlock = WorldEdit.getInstance().getBaseBlockFactory().getBaseBlock(BlockID.AIR);
}
try {
editor.makeCylinder(origin, new SingleBlockPattern(targetBlock), 12, 1, true);
} catch (MaxChangedBlocksException e) {
e.printStackTrace();
}
}
示例10: execute
import com.sk89q.worldedit.MaxChangedBlocksException; //导入依赖的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;
}
示例11: execute
import com.sk89q.worldedit.MaxChangedBlocksException; //导入依赖的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;
}
示例12: execute
import com.sk89q.worldedit.MaxChangedBlocksException; //导入依赖的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;
}
示例13: loadIslandSchematic
import com.sk89q.worldedit.MaxChangedBlocksException; //导入依赖的package包/类
@Override
public void loadIslandSchematic(final File file, final Location origin, final PlayerPerk playerPerk) {
plugin.async(new Runnable() {
@Override
public void run() {
boolean noAir = false;
boolean entities = true;
Vector to = new Vector(origin.getBlockX(), origin.getBlockY(), origin.getBlockZ());
EditSession editSession = getEditSession(playerPerk, origin);
try {
SchematicFormat.getFormat(file)
.load(file)
.paste(editSession, to, noAir, entities);
editSession.flushQueue();
} catch (MaxChangedBlocksException | IOException | DataException e) {
log.log(Level.INFO, "Unable to paste schematic " + file, e);
}
}
});
}
示例14: execute
import com.sk89q.worldedit.MaxChangedBlocksException; //导入依赖的package包/类
@Override
protected boolean execute() {
while (!regions.isEmpty()) {
final Region region = regions.remove(0);
LocalWorld localWorld = BukkitUtil.getLocalWorld(world);
final EditSession editSession = WorldEditHandler.createEditSession(localWorld, region.getArea() * 255);
editSession.enableQueue();
editSession.setFastMode(true);
try {
editSession.setBlocks(region, AIR);
} catch (MaxChangedBlocksException e) {
log.log(Level.INFO, "Warning: we got MaxChangedBlocks from WE, please increase it!");
}
editSession.flushQueue();
//editSession.commit();
if (!tick()) {
break;
}
}
return regions.isEmpty();
}
示例15: resetNext
import com.sk89q.worldedit.MaxChangedBlocksException; //导入依赖的package包/类
public void resetNext() {
build = true;
Util.debug("reset next!");
Bukkit.getScheduler().callSyncMethod(SurvivalGames.instance, new Callable<Void>() {
@Override
public Void call() {
for(Entry<Vector, BaseBlock> map : cReset.entrySet()) {
try {
es.setBlock(map.getKey(), map.getValue());
} catch (MaxChangedBlocksException e) {
e.printStackTrace();
}
}
cReset.clear();
build = false;
return null;
}
});
}