本文整理汇总了Java中com.sk89q.worldedit.CuboidClipboard.getBlock方法的典型用法代码示例。如果您正苦于以下问题:Java CuboidClipboard.getBlock方法的具体用法?Java CuboidClipboard.getBlock怎么用?Java CuboidClipboard.getBlock使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.sk89q.worldedit.CuboidClipboard
的用法示例。
在下文中一共展示了CuboidClipboard.getBlock方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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) {
}
}
示例2: RestoreChunkFromDisk
import com.sk89q.worldedit.CuboidClipboard; //导入方法依赖的package包/类
public void RestoreChunkFromDisk()
{
valubleBlockIds.add(41);
valubleBlockIds.add(42);
valubleBlockIds.add(57);
valubleBlockIds.add(113);
valubleBlockIds.add(138);
valubleBlockMaterials.add(Material.IRON_BLOCK);
valubleBlockMaterials.add(Material.DIAMOND_BLOCK);
valubleBlockMaterials.add(Material.GOLD_BLOCK);
valubleBlockMaterials.add(Material.BEACON);
valubleBlockMaterials.add(Material.EMERALD_BLOCK);
ArrayList<BlockState> valubleBlocsToRmove = new ArrayList<BlockState>();
if(schematicFile.exists() == false) return;
try
{
EditSession editSession = new EditSession(new BukkitWorld(chunk.getWorld()), 131073);
CuboidClipboard clipboard = SchematicFormat.MCEDIT.load(schematicFile);
Vector newvec = locationToVector(chunk.getBlock(0, 0, 0).getLocation());
for(int y = 0; y < 256; y ++)
{
for(int z = 0; z < 16; z++)
{
for(int x = 0; x < 16 ; x++)
{
BaseBlock block = clipboard.getBlock(new Vector(x,y,z));
Block existingBlock = chunk.getBlock(x, y, z);
// if the schematic contains a valuable block at this position save what is currently there
// that way we dont restore any valuable block and instead leave whatever was there before this command
if(valubleBlockIds.contains(block.getId()))
{
System.out.print("Valuable Block Detected" + block.getId());
// we will revert the valuable block back to its post was state after the restore
valubleBlocsToRmove.add(existingBlock.getState());
}
// of if the location has a valuable block save it
else if(valubleBlockMaterials.contains(existingBlock.getType()))
{
System.out.print("Valuable Block Detected in current world");
valubleBlocsToRmove.add(existingBlock.getState());
}
}
}
}
HashMap<Integer,NationsContainer> PostWarContents = saveExistingChests(chunk);
// paste twice it helps fix any rail issues
clipboard.paste(editSession, newvec, false, true);
clipboard.paste(editSession, newvec, false, true);
// revert any valuable blocks back to whatever they were before this command was executed
for(BlockState bs : valubleBlocsToRmove)
{
System.out.print("Valuable Block Updated" + bs);
bs.update(true);
}
restoreChests(chunk, PostWarContents, brokenChests );
}
catch (Exception e)
{
e.printStackTrace();
}
}