Saving and loading blocks from file

Discussion in 'Plugin Development' started by Pik0, Jun 14, 2014.

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

    Pik0

    I was kinda messing with blocks regeneration, and I tried to figure out a simple way to do this. However i couldnt think of anything: I wanted a way to save a list of blocks to a file, and if the block is a chest, I wanted a way to save its contents to a file, and then load everything...
     
  2. Offline

    jthort

    To save the block to a file you can take a look at this thread, it should explain everything you need
    https://forums.bukkit.org/threads/block-serialization.145018/

    While your saving it, if the block is a chest, get the contents and save that to a file then load it. You can do this a variety of ways, you can try a string list in the config if you want, whatever works best for your config.

    You also might want to take a look at this library https://forums.bukkit.org/threads/cardboard-serializable-itemstack-with-enchantments.75768/

    Helpful resources:
    https://forums.bukkit.org/threads/s...s-of-a-chest-using-basic-configuration.72848/
    https://forums.bukkit.org/threads/chest-storing-restoring.95574/
    https://forums.bukkit.org/threads/tutorial-block-restoration.228896/
    https://forums.bukkit.org/threads/restore-an-area.82857/

    Just a side Note:
    If you are planning on regenerating an area, your going to have to account for more than just chests and blocks. You are going to have to restore grass, mushrooms, picture frames, stuff like that.

    If you want to see how this is done, world edit has their source code which uses this. Another thought is to import world edit and use that to save the area, but of course then your plugin would then require world edit.
     
  3. Offline

    Pik0

    jthort thanks, really complete answer ! =)
     
Thread Status:
Not open for further replies.

Share This Page