Storing the blocks of a WorldEdit Cuboid Region

Discussion in 'Plugin Development' started by wreed12345, Nov 12, 2013.

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

    wreed12345

    Hey, I have a cuboid region set up and I would like to store the type of Material of each block in the region to set it back to that. Would I have to manually loop through the region and store each block and its material type? Or is there some world edit way to do this?
     
  2. Offline

    Milkywayz

    'b' is an integer array which contains six values, the x,y,z of the two bounds.
    'w' is the world instance.
    Math.min and Math.max are statically imported.
    Code:
    for (int x = min(b[0], b[3]); x <= max(b[0], b[3]); x++) {
                for (int y = min(b[1], b[4]); y <= max(b[1], b[4]); y++) {
                    for (int z = min(b[2], b[5]); z <= max(b[2], b[5]); z++) {
                        Block b0 = w.getBlockAt(x, y, z);
                    }
                }
            }
    That's how you manually loop, I'm fairly certain it's the easiest and most efficient way to do this yourself, i'd recommend not relying on other plugins to handle specific functions such as this as it would not work as well in most cases.
     
  3. Offline

    wreed12345

    My cuboid region was created with world edit that's why it seems like a good idea to use a world edit method for this
    Milkywayz
     
  4. Offline

    Milkywayz

    If the WorldEdit api has the methods you need, then feel free to use it.

    http://wiki.sk89q.com/wiki/WorldEdit/API
     
  5. Offline

    Minecrell

    wreed12345
    Why don't you use schematics to store the blocks? WorldEdit has some inbuild methods to save / load them to a region.
    Or you can just iterate through the blocks using WorldEdit like already mentioned yesterday.
     
  6. Offline

    wreed12345

    I am trying to use the schematic approach, but CuboidClipboard.saveSchematic(); appears to be deprecated... Has anyone found substitutes for this? Minecrell Milkywayz
     
  7. Offline

    Minecrell

    You can use this instead (you need to specify the schematic format now):
    Code:java
    1. SchematicFormat.MCEDIT.save(CuboidClipboard, File);
     
    wreed12345 likes this.
Thread Status:
Not open for further replies.

Share This Page