Paste schematics into world

Discussion in 'Plugin Development' started by MrCreeper, Sep 1, 2011.

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

    MrCreeper

    Hey :)
    How can I paste a .schematics file at a given location? Is there actually a way?
     
  2. Offline

    Seta

    WorldEdit ^^
     
  3. Regios will be able to do this.
     
  4. Offline

    MrCreeper

    How do I do this exactly with Regios API or wE API? =)
    Btw, I want to do it with code, not ingame. ^^
     
  5. I'll be exposing api methods for this when I release
     
  6. Offline

    MrCreeper

    When can I expect to can get use of it? :)
     
  7. 3-5 Days. I'm finishing up the GUI, then I have to do some final bug and api testing and then you could hook in to save regions.
     
  8. WorldEdit can do so via API as well
    will edit if i can find the code snippet i used.

    For WorldEdit, it's as follows
    Code:
    private void saveArea(World world,Vector origin,Vector size,File file) throws IOException, DataException{
            EditSession es = new EditSession(new BukkitWorld(world), 20000);
    
            CuboidClipboard cc = new CuboidClipboard(size,origin);
            cc.copy(es);
            cc.saveSchematic(file);
    
        }
    
        private void loadArea(World world, File file,Vector origin) throws DataException, IOException, MaxChangedBlocksException{
            EditSession es = new EditSession(new BukkitWorld(world), 20000);
            CuboidClipboard cc = CuboidClipboard.loadSchematic(file);
            cc.paste(es,origin, true);
      
        }
     
    dkramer likes this.
  9. Offline

    MrCreeper

    Ah, great. :)
    Is there a way to get the selection points of a player with wE API?
     
  10. If you really want to do this in code and won't have another plugin as dependencie try to figure out how schemtic files are looking (in code), calculate the informations you get from the schematic to coordinates, materials, blockData, ... then recalculate the coordinates with the coordinates of the triggering event (so you have world coordinates now) and change the blocks at the coordinates with the data you collected.
    I don't know how easy it would be to translate a schematic to the needed data but as it's designed for MC (correct me if I'm wrong) it shouldn't be that hard. ;)
     
  11. It is pretty hard, I had to figure out how notch did it and then recode it to suit my own needs :p. He uses NBT, named binary tag which is very efficient at storing data but it has to be in byte form. You can look at my regios source on github if you'd like. Just look in Regios > couk > Adamki11s > Regios > RBF > RBF_Save & RBF_Load
     
  12. Offline

    Timberjaw

    @Adamki11s If you haven't already, check out the JNBT library. It abstracts the byte-level nature of NBT and lets you manipulate type-specific tags in a more friendly way. I've been using it on my Dungeonator plugin to create my own import/export format for schematics and it's saved a ton of work.
     
    V10lator likes this.
  13. Sorry, that was what I meant :p

    I use it to backup and restore Region files and instead of a backup file being 7mb+ it's under 100KB for most large regions :D
     
Thread Status:
Not open for further replies.

Share This Page