本文整理汇总了Java中com.sk89q.worldedit.CuboidClipboard类的典型用法代码示例。如果您正苦于以下问题:Java CuboidClipboard类的具体用法?Java CuboidClipboard怎么用?Java CuboidClipboard使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CuboidClipboard类属于com.sk89q.worldedit包,在下文中一共展示了CuboidClipboard类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: saveSchematic
import com.sk89q.worldedit.CuboidClipboard; //导入依赖的package包/类
public void saveSchematic(String file, final String world, final PlotId id) {
Location bot = MainUtil.getPlotBottomLoc(world, id).add(1, 0, 1);
Location top = MainUtil.getPlotTopLoc(world, id);
Vector size = new Vector(top.getX() - bot.getX() + 1, top.getY() - bot.getY() - 1, top.getZ() - bot.getZ() + 1);
Vector origin = new Vector(bot.getX(), bot.getY(), bot.getZ());
CuboidClipboard clipboard = new CuboidClipboard(size, origin);
Vector pos1 = new Vector(bot.getX(), bot.getY(), bot.getZ());
Vector pos2 = new Vector(top.getX(), top.getY(), top.getZ());
EditSession session = PlotSquared.worldEdit.getWorldEdit().getEditSessionFactory().getEditSession(new BukkitWorld(Bukkit.getWorld(world)), 999999999);
clipboard.copy(session);
try {
clipboard.saveSchematic(new File(file));
MainUtil.sendMessage(null, "&7 - &a success: " + id);
} catch (Exception e) {
e.printStackTrace();
MainUtil.sendMessage(null, "&7 - Failed to save &c" + id);
}
}
示例2: saveRegionBlocks
import com.sk89q.worldedit.CuboidClipboard; //导入依赖的package包/类
@Override
public boolean saveRegionBlocks(File file, GeneralRegionInterface regionInterface) {
boolean result = true;
ProtectedRegion region = regionInterface.getRegion();
// Get the origin and size of the region
Vector origin = new Vector(region.getMinimumPoint().getBlockX(), region.getMinimumPoint().getBlockY(), region.getMinimumPoint().getBlockZ());
Vector size = (new Vector(region.getMaximumPoint().getBlockX(), region.getMaximumPoint().getBlockY(), region.getMaximumPoint().getBlockZ()).subtract(origin)).add(new Vector(1, 1, 1));
EditSession editSession = new EditSession(new BukkitWorld(regionInterface.getWorld()), pluginInterface.getConfig().getInt("maximumBlocks"));
// Save the schematic
editSession.enableQueue();
CuboidClipboard clipboard = new CuboidClipboard(size, origin);
clipboard.copy(editSession);
Exception otherException = null;
try {
SchematicFormat.MCEDIT.save(clipboard, file);
} catch(DataException | IOException e) {
otherException = e;
}
if(otherException != null) {
pluginInterface.getLogger().warning("Failed to save schematic for region " + regionInterface.getName());
pluginInterface.debugI(ExceptionUtils.getStackTrace(otherException));
result = false;
}
editSession.flushQueue();
return result;
}
示例3: spawnTree
import com.sk89q.worldedit.CuboidClipboard; //导入依赖的package包/类
private void spawnTree(Location startBlock, String fileName, Vector offset){
BukkitWorld world = new BukkitWorld(startBlock.getWorld());
EditSession session = new EditSession(world, 1000);
WorldEditPlugin wep = ((WorldEditPlugin) Bukkit.getServer().getPluginManager().getPlugin("WorldEdit"));
WorldEdit we = wep.getWorldEdit();
LocalConfiguration config = we.getConfiguration();
BukkitPlayer p = wep.wrapPlayer(startBlock.getWorld().getPlayers().get(0));
File dir = we.getWorkingDirectoryFile(config.saveDir);
File f;
Vector v = new Vector(startBlock.getX(), startBlock.getY(), startBlock.getZ());
try {
f = we.getSafeOpenFile(p, dir, fileName, "schematic", "schematic");
CuboidClipboard cc = SchematicFormat.MCEDIT.load(f);
cc.setOffset(offset);
cc.paste(session, v, true);
} catch (Exception e) {
e.printStackTrace();
}
}
示例4: buildIsland
import com.sk89q.worldedit.CuboidClipboard; //导入依赖的package包/类
/**
* Clean up all blocks in a location and paste the island schematic instead.
*
* @param loc1 Minimum point of the island.
* @param loc2 Maximum point of the island.
* @param world World to create the island in.
* @param file Schematic file to load.
*/
protected Region buildIsland(Vector loc1, Vector loc2, World world, File file) {
try {
EditSession editSession = instance.getEngineManager().getWorldEditUtils().getEditSession(world);
editSession.enableQueue();
Region region = LocationsParser.getRegion(loc1, loc2);
// Replacing the blocks is MUCH faster than just setting them all to air.
editSession.replaceBlocks(region, null, AIR);
editSession.flushQueue();
// Loading schematics.
CuboidClipboard cuboidClipboard = instance.getEngineManager().getWorldEditUtils().getCuboidClipboard(file);
// Pasting the schematic.
cuboidClipboard.paste(editSession, region.getCenter(), false);
editSession.flushQueue();
// Cause pokemon is awesome.
return region;
} catch (Exception ex) {
throw new RuntimeException("Problem with generating island.", ex);
}
}
示例5: saveWEChunk
import com.sk89q.worldedit.CuboidClipboard; //导入依赖的package包/类
private void saveWEChunk(Chunk chunk, File saveFile)
{
WorldEditPlugin wep = (WorldEditPlugin)Bukkit.getPluginManager().getPlugin("WorldEdit");
if (wep == null)
{
Bukkit.broadcastMessage(ChatColor.RED+"Unable to find WorldEdit plugin - Unable to restore.");
return;
}
EditSession editSession = new EditSession(new BukkitWorld(chunk.getWorld()), 1000);
Vector startPos = locationToVector(chunk.getBlock(0, 0, 0).getLocation());
Vector size = new Vector(16,256,16);
CuboidClipboard clipboard = new CuboidClipboard(size, startPos);
clipboard.copy(editSession);
try
{
SchematicFormat.MCEDIT.save(clipboard, saveFile);
}
catch (Exception e)
{
e.printStackTrace();
}
}
示例6: loadBounds
import com.sk89q.worldedit.CuboidClipboard; //导入依赖的package包/类
public static CuboidRegion loadBounds(String frameName, MCMEAnimation animation) {
SchematicFormat sf = MCEditSchematicFormat.MCEDIT;
try {
CuboidClipboard clip = sf.load(new File(MCMEAnimations.MCMEAnimationsInstance.getDataFolder() + File.separator + "schematics" + File.separator + "animations" + File.separator + frameName + ".schematic"));
Vector v1 = new Vector(animation.origin.getX() + clip.getOffset().getX(), animation.origin.getY() + clip.getOffset().getY(), animation.origin.getZ() + clip.getOffset().getZ());
Vector v2 = new Vector(Math.floor(animation.origin.getX() + clip.getWidth() + clip.getOffset().getX() - 1),
Math.floor(animation.origin.getY() + clip.getHeight() + clip.getOffset().getY() - 1),
Math.floor(animation.origin.getZ() + clip.getLength() + clip.getOffset().getZ() - 1));
return new CuboidRegion(v1, v2);
} catch (IOException | DataException ex) {
Logger.getLogger(WELoader.class.getName()).log(Level.SEVERE, null, ex);
}
return null;
}
示例7: place
import com.sk89q.worldedit.CuboidClipboard; //导入依赖的package包/类
/**
* Place the waiting lobby in the world
*/
public void place()
{
this.logger.info("Generating lobby...");
if (this.file.exists())
{
try
{
Vector vector = new Vector(0, 190, 0);
World world = Bukkit.getWorld("world");
world.loadChunk(0, 0);
BukkitWorld bwf = new BukkitWorld(world);
this.editSession = new EditSession(bwf, -1);
this.editSession.setFastMode(true);
CuboidClipboard c1 = SchematicFormat.MCEDIT.load(this.file);
c1.paste(this.editSession, vector, true);
}
catch (MaxChangedBlocksException | IOException | DataException ex)
{
this.logger.log(Level.SEVERE, "Error in world", ex);
}
}
else
{
this.logger.severe("File does not exist. Abort...");
}
this.logger.info("Done.");
}
示例8: loadSchematic
import com.sk89q.worldedit.CuboidClipboard; //导入依赖的package包/类
@SuppressWarnings("deprecation")
public static void loadSchematic(World world, int size, Vector v) throws Exception {
if (getRandomCasa(size) == null) {
return;
}
EditSession es = new EditSession(new BukkitWorld(world), Integer.MAX_VALUE);
CuboidClipboard cc = CuboidClipboard.loadSchematic(getRandomCasa(size));
cc.paste(es, v, false);
cc.paste(es, v, false);
}
示例9: load
import com.sk89q.worldedit.CuboidClipboard; //导入依赖的package包/类
public static void load() {
try {
Chunk chunk = new Chunk(null, 0, 0);
CuboidClipboard clipboard = CuboidClipboard.loadSchematic(new File(ProtocolSupportAntiBot.getInstance().getDataFolder(), name));
for (int x = 0; x < clipboard.getLength(); x++) {
for (int z = 0; z < clipboard.getWidth(); z++) {
for (int y = 0; y < clipboard.getHeight(); y++) {
BaseBlock block = clipboard.getBlock(new Vector(x, y, z));
ChunkSection[] sections = chunk.getSections();
int ysect = y >> 4;
ChunkSection section = sections[ysect];
if (section == null) {
section = new ChunkSection(ysect, true);
sections[ysect] = section;
}
IBlockData iblockdata = Block.getById(block.getId()).fromLegacyData(block.getData());
section.setType(x, y & 0xF, z, iblockdata);
section.a(x, y & 0xF, z, 15);
section.b(x, y & 0xF, z, 15);
}
}
}
PacketPlayOutMapChunk mapchunk = new PacketPlayOutMapChunk();
chunkdata = PacketContainer.fromPacket(mapchunk);
chunkdata.getBooleans().write(0, true);
ByteBuf buffer = Unpooled.buffer();
chunkdata.getIntegers().write(2, mapchunk.a(new PacketDataSerializer(buffer), chunk, true, 65535));
byte[] bufferdata = new byte[buffer.readableBytes()];
buffer.readBytes(bufferdata);
chunkdata.getByteArrays().write(0, bufferdata);
chunkdata.getSpecificModifier(List.class).write(0, Collections.emptyList());
} catch (DataException | IOException e) {
}
}
示例10: pasteWithWE
import com.sk89q.worldedit.CuboidClipboard; //导入依赖的package包/类
public static void pasteWithWE(Player p, File file) {
World world = p.getWorld();
Location loc = p.getLocation();
EditSession es = new EditSession(new BukkitWorld(world), 999999999);
try {
CuboidClipboard cc = CuboidClipboard.loadSchematic(file);
cc.paste(es, new com.sk89q.worldedit.Vector(loc.getX(),loc.getY(),loc.getZ()), false);
} catch (DataException | IOException | MaxChangedBlocksException e) {
e.printStackTrace();
}
}
示例11: regenerate
import com.sk89q.worldedit.CuboidClipboard; //导入依赖的package包/类
/**
* Pastes a schematic into the room.
*/
private void regenerate() {
try {
Location location = sign.getLocation();
CuboidClipboard clipboard = schematic.load(schematicFile);
BukkitWorld world = new BukkitWorld(location.getWorld());
WorldEditPlugin we = (WorldEditPlugin) Bukkit.getPluginManager().getPlugin("WorldEdit");
EditSession editSession = we.getWorldEdit().getEditSessionFactory().getEditSession(world, 64*64*64);
Vector newOrigin = region.getMinimumPoint();
clipboard.paste(editSession, newOrigin, false);
} catch (DataException | MaxChangedBlocksException | IOException e) {
e.printStackTrace();
}
}
示例12: place
import com.sk89q.worldedit.CuboidClipboard; //导入依赖的package包/类
public void place(Vector size, CuboidClipboard cc, String arenaName) {
for (int x = 0; x < size.getBlockX(); x++) {
for (int z = 0; z < size.getBlockZ(); z++) {
World world = Bukkit.getWorld(((Config) BlockParty.getArena.get(arenaName)).getWorld().getName());
world.getBlockAt(((Config) BlockParty.getArena.get(arenaName)).getLocMin().getBlockX() + x,
((Config) BlockParty.getArena.get(arenaName)).getLocMin().getBlockY(),
((Config) BlockParty.getArena.get(arenaName)).getLocMin().getBlockZ() + z).setTypeId(cc.getBlock(new Vector(x, 0, z)).getId());
world.getBlockAt(((Config) BlockParty.getArena.get(arenaName)).getLocMin().getBlockX() + x,
((Config) BlockParty.getArena.get(arenaName)).getLocMin().getBlockY(),
((Config) BlockParty.getArena.get(arenaName)).getLocMin().getBlockZ() + z).setData((byte) cc.getBlock(new Vector(x, 0, z)).getData());
}
}
}
示例13: run
import com.sk89q.worldedit.CuboidClipboard; //导入依赖的package包/类
@Override
public void run(String playerID) throws QuestRuntimeException {
try {
Location location = loc.getLocation(playerID);
SchematicFormat schematic = SchematicFormat.getFormat(file);
CuboidClipboard clipboard = schematic.load(file);
BukkitWorld world = new BukkitWorld(location.getWorld());
EditSession editSession = we.getWorldEdit().getEditSessionFactory().getEditSession(world, 64*64*64);
Vector newOrigin = BukkitUtil.toVector(location);
clipboard.paste(editSession, newOrigin, noAir);
} catch (DataException | IOException | MaxChangedBlocksException e) {
Debug.error("Error while pasting a schematic: " + e.getMessage());
}
}
示例14: place
import com.sk89q.worldedit.CuboidClipboard; //导入依赖的package包/类
@SuppressWarnings("deprecation")
public void place(Vector size, CuboidClipboard cc, String arenaName) {
for (int x = 0; x < size.getBlockX(); x++) {
for (int z = 0; z < size.getBlockZ(); z++) {
World world = Bukkit.getWorld(((Config) BlockParty.getArena.get(arenaName)).getWorld().getName());
world.getBlockAt(((Config) BlockParty.getArena.get(arenaName)).getLocMin().getBlockX() + x,
((Config) BlockParty.getArena.get(arenaName)).getLocMin().getBlockY(),
((Config) BlockParty.getArena.get(arenaName)).getLocMin().getBlockZ() + z).setTypeId(cc.getBlock(new Vector(x, 0, z)).getId());
world.getBlockAt(((Config) BlockParty.getArena.get(arenaName)).getLocMin().getBlockX() + x,
((Config) BlockParty.getArena.get(arenaName)).getLocMin().getBlockY(),
((Config) BlockParty.getArena.get(arenaName)).getLocMin().getBlockZ() + z).setData((byte) cc.getBlock(new Vector(x, 0, z)).getData());
}
}
}
示例15: storeClip
import com.sk89q.worldedit.CuboidClipboard; //导入依赖的package包/类
public static boolean storeClip(Player p, String frameName) {
LocalSession s = MCMEAnimations.WEPlugin.getSession(p);
try {
// Selection sel = MCMEAnimations.WEPlugin.getSelection(p);
// if(null == sel){
// p.sendMessage(ChatColor.RED + "Select a placement block using WorldEdit!");
// return false;
// }
// if(sel.getArea()!=1){
// p.sendMessage(ChatColor.RED + "Select a single placement block using WorldEdit!");
// return false;
// }
CuboidClipboard clip = s.getClipboard();
boolean alreadyThere = false;
for (MCMEClipboardStore cs : clips) {
if (cs.getSchematicName().equals(frameName)) {
cs.setClip(clip);
p.sendMessage(ChatColor.BLUE + "Clipboard named \"" + frameName + "\" replaced.");
alreadyThere = true;
break;
}
}
if (!alreadyThere) {
MCMEClipboardStore store = new MCMEClipboardStore();
store.setClip(clip);
store.setSchematicName(frameName);
clips.add(store);
p.sendMessage(ChatColor.BLUE + "Clipboard named \"" + frameName + "\" stored.");
}
s.setClipboard(null);
return true;
} catch (EmptyClipboardException ex) {
p.sendMessage(ChatColor.RED + "WorldEdit clipboard is empty! Remember to /copy before storing the frame");
return false;
//Logger.getLogger(AnimationFacroty.class.getName()).log(Level.SEVERE, null, ex);
}
}