Pasting Pre-built Structure from One Location to Another

Discussion in 'Plugin Development' started by Munnzeh, Aug 4, 2020.

  1. Offline

    Munnzeh

    Hi All,

    I am looking to be able to take a pre-built structure for a Minigame from one location and paste it into an Arena on requirement so that It can be destroyed / blown up etc. and then when required again simply replaced by a fresh pre-built.

    I am not looking for any specific code but just some ideas / suggestions.

    Again, the idea is to have the structure pre-built somewhere off in the map and the plugin would simply copy all the blocks in that location and re paste them to the specified location. Surely this is possible as it is a core feature of WorldEdit.

    Thanks
     
  2. Offline

    KarimAKL

    @Munnzeh You can save the locations along with their blocks.
     
  3. Offline

    Munnzeh

    So I'm assuming I'm going to have to loop every block between two locations, save each block to a map with it's location <Block, Location> then when I want it pasted I'm going to have to loop through the map then set the blocks to their original Location modified by some value?

    Thanks for the suggestion, surely won't be any more intensive than World Edit.
     
  4. Offline

    timtower Moderator Moderator

    @Munnzeh Didn't Minecraft have a copy paste commands?
     
  5. Offline

    Munnzeh

    I'm not aware of this, are you referring to the 'Clone' command? Anyway I am looking for the plugin to do this automatically and not issued via a command.
     
  6. Offline

    X21_Eagle_X21

    You could try using the WorldEdit API as well. I should note I've never used it before but I do know it exists.
     
  7. Offline

    timtower Moderator Moderator

    I am.
    Then you list the area that you want to copy using a min / max block.
    Apply an offset and set the blockdata to the original one.
     
  8. Offline

    shasse

    I've had good luck using the following as a library within my project to load and save structures in the native format using Minecraft internals:

    https://github.com/Shynixn/StructureBlockLib

    Unfortunately that saves the .nbt files in a subdirectory of the world, so I copied those to a resource folder in my plugin and used some slower custom code to read in the .nbt files and paste them into the world. This post gives an example for doing that: https://www.spigotmc.org/threads/need-help-error-stream-nbt.436407/

    Although I use

    NBTInputStream input = new NBTInputStream(plugin.getResource("structures/" + name));

    rather than FileInputStream. That allows me to package the arenas in the plugin itself.

    Hope that helps,

    Scott

    I should add that using the Structure.java solution above you can use a regular minecraft Structure block to save your structure as well and avoid the Shynixn code altogether. In my case I wanted to save the whole arena, which was significantly larger than the structure size limit of 32x32x32, so it was handy to use the Shynixn API to save multiple smaller structure files in a 3-dimension loop.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Aug 6, 2020

Share This Page