WorldEdit api help..

Discussion in 'Plugin Development' started by Creeoer, Dec 20, 2014.

Thread Status:
Not open for further replies.
  1. Offline

    Creeoer

    I'm trying to get a list of blocks from my cuboidclipboard, but all it returns is this Countable list of baseblocks

    I can't seem to loop through it since it always returns a Countable with a baseblock casted to it (not too sure what a countable is either) , how would I get a list of blocks from my clipbard? I could try calcualting a bunch of locations with the width of schematic, but that would get other blocks as well that aren't part of the schematic.
     
  2. Offline

    Europia79

    @Creeoer

    What exactly are you trying to do ?
     
  3. Offline

    Creeoer

    @Europia79
    Get a list of blocks within a cuboidclipboard, loop through them and set them to air.
     
  4. Offline

    KingFaris11

    In the latest WorldEdit, CuboidClipboard is depreciated and you should just use Clipboard.

    Below is how to do it with the latest WorldEdit (I'm sorry if this isn't what you're asking):
    Code:
    Clipboard clipboard = null; // This will be the Clipboard instead of the Cuboid
    int startingX = clipboard.getMinimumPoint().getBlockX(); // Get the starting position (X) of the region.
    int startingY = clipboard.getMinimumPoint().getBlockY(); // Get the starting position (Y) of the region.
    int startingZ = clipboard.getMinimumPoint().getBlockZ(); // Get the starting position (Z) of the region.
    for (int x = startingX; x <= clipboard.getMaximumPoint().getBlockX(); x++) { // Loop through all the X values from the starting X position up till the end X position.
       for (int y = startingY; y <= clipboard.getMaximumPoint().getBlockY(); y++) { // Same thing as above, but Y.
          for (int z = startingZ; z <= clipboard.getMaximumPoint().getBlockZ(); z++) { // Same thing as above, but Z.
             player.getWorld().getBlockAt(x, y, z).setType(Material.AIR); // Get the block at that location and set it to AIR.
          }
       }
    }
    
     
    Last edited: Dec 20, 2014
  5. Offline

    Creeoer

    @KingFaris11

    This was exactly what I was looking for, thanks.

    @KingFaris11
    I'm looking for a method in the javadocs to return a clipboard, can't seem to find it. You have any idea how?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 29, 2016
  6. Offline

    KingFaris11

    Code:
    try {
        LocalSession session = WorldEdit.getInstance().getSession(player.getName());
        if (session != null) { // Not needed, but just in-case?
            Clipboard clipboard = session.getClipboard().getClipboard();
        }
    } catch (EmptyClipboardException ex) {
       // They don't have a clipboard, send them a message possibly?
    }
    
     
Thread Status:
Not open for further replies.

Share This Page