API Saving structures

Discussion in 'Resources' started by nielsbwashere, Jul 11, 2015.


Was this useful to you?

  1. No, not at all

    1 vote(s)
  2. Sure, A little bit

    1 vote(s)
  3. Yes!

    1 vote(s)
Thread Status:
Not open for further replies.
  1. Offline


    Hey guys, nielsbwashere here, and I made a plugin that is somewhat of an API.
    This plugin allows you to save structures as Java code or you can get it as a file that this API can read.

    To get started, get a structure in the world, that you want to generate the code of.
    For example, I want the crappy structure (in the picture below) to spawn from a block.
    Step 1 is selecting the structure. In this picture you can see red wool and green wool, the coordinates of those blocks are important.
    For me the coordinates were:
    RED: 100,5,100
    GREEN: 106,7,94

    The blue box, most certainly the middle, is supposed to be the block the structure generates from, so the structure must be centered to that.
    The coordinates of the blue wool are:
    BLUE: 103,6,97

    Now, you want to take the last step; turn it into code.
    For this you have to have the plugin installed, and you should use this command:
    If we fill in the coordinates we will get
    /savestructure 100 5 100 106 7 94 103 6 97 <name> <type>

    Now for the argument <name> we need to fill in the name of the file that it will write.
    The last argument is <type>, this argument can be plugin, mod or structure.
    If you use plugin, it will put out code that can be read by a plugin, and if you put mod, it can be read by a modded client.
    Structure is a custom type, this will just put out the locations of certain blocks with certain metadata. The file can be read by the API itself.

    So we executed the command
    /savestructure 100 5 100 106 7 94 103 6 97 DumbStructure plugin
    What to do now?

    If you go into the plugins folder, you can see that there is a structure2code folder, with a saves folder in there.
    The save folder contains the files it made from the structure.
    For us, there will be a file called "DumbStructure.txt" with all of the Java code in there.

    My structure is too big! It's over 9000 blocks!
    Size doesn't matter, it does if you export it as plugin/mod code, but if you export it as a structure type, you can use the special method we got:
    net.nielsbwashere.src.Structure2Code.Core.set(JavaPlugin, Name, World, X, Y, Z)
    You just copy the file it exported, for us "DumbStructure.txt"
    And place it into: plugins/<YourPluginName>/saves/
    Now when we use
    net.nielsbwashere.src.Structure2Code.Core.set(this, "DumbStructure", block.getLocation().getWorld(), block.getLocation().getBlockX(), block.getLocation().getBlockY(), block.getLocation().getBlockZ())
    It will read the file in our saves folder, called DumbStructure, and put it into our world, relative to the coordinates we put in.

    This has spawner support, so if you want to generate a dungeon, be free!

    link: https://www.dropbox.com/s/htur5hq2ypf5kr8/Structure2Code.jar?dl=0

    PS. This is alpha, it saves direction, metadata, block id, location and spawner type, but it doesn't support chests, furnaces, etc. I will NOT add chests, since you probably want to randomize them. If you want support for item frames, etc. you need to ask me. I thought it wasn't necessary so I left it out.

    Hope that this helped someone with spawning structures :)
Thread Status:
Not open for further replies.

Share This Page