Is there a list of blocks I can get from a .schematic (WorldEdit API)

Discussion in 'Plugin Development' started by Dudemister1999, Feb 14, 2015.

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

    Dudemister1999

    The title is quite self explanatory, but I'll reiterate here:

    I need to get either a list of blocks, or a way to collect a list of blocks from a WorldEdit CuboidClipboard. Now, I've look around, and seen a tri-forloop, but that just seems... messy. Is there any other way?
     
  2. Offline

    Dudemister1999

    Just a bump. I hate bumping, but I do need assistance.
     
  3. Offline

    mythbusterma

    @Dudemister1999

    Considering a Block is an abstract representation of what actually exists on the server, no you can't create Blocks from a schematic.

    A schematic file stores an array of materials and associated data values, and you could either iterate over it in a nested for-loop, or you can iterate over it in one really long for loop that covers all three directions. Either way, you're pretty much stuck iterating over all the entries.
     
  4. Offline

    Dudemister1999

    @mythbusterma Well that's no fun. I didn't quite mean 'create' a Block object as much as get (perhaps) a relative coordinate to get a block? I've combed through the CuboidClipboard class, and I cannot for the life of me turn the finished (pasted) product into a set of Locations/Blocks.
     
  5. Offline

    mythbusterma

    @Dudemister1999

    Well, you could create a "dummy block" of sorts that just stores the information you need temporarily, or if you only need a couple blocks you can just access those. What is it exactly that you're trying to do?
     
  6. Offline

    Dudemister1999

    @mythbusterma Upon pasting a Schematic, I need to get a list ( map, set, whatever) of the blocks it affected (Locations would be preferred, but anything works at this point).
     
  7. Offline

    mythbusterma

    @Dudemister1999

    To serve what end? It would be faster just to put them in place as you go, if you don't absolutely need the information about how many will be changed (you can perform the change and then say how many were done with the same speed, however).
     
  8. Offline

    Dudemister1999

    @mythbusterma I'm designing a fancy system for spawning buildings and using the blocks for hitpoints. Sort of like building a house, then using that house as a destructable entity. Depending on the amount of blocks left in the structure, it'll set its health accordingly. All but the block counting is done.
     
  9. Offline

    mythbusterma

    @Dudemister1999

    I think you'd be better off listening for BlockBreakEvents, as doing this sort of comparison would be O(n*x*y) or O(n^3), which could likely be too expensive for real time.
     
Thread Status:
Not open for further replies.

Share This Page