Solved Replacing a region with AIR blocks via java API

Discussion in 'Plugin Development' started by mikygit, Mar 22, 2018.

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

    mikygit

    Hi,
    Is it possible to do just like the /fill command using the API?

    I can get blocks of the targeted region and replace them by AIR blocks one by one but it takes ages.

    I am looking for a way to replace all the blocks of a X Y Z region by AIR blocks just like this fill command would do:
    /fill 124 81 -40 -125 81 39 command_block 0 replace {Command:"/fill ~ 0 ~ ~ 250 ~ air 0",auto:1b}

    If not possible, is there a CLI API so that I could execute the above command directly from my java plugin?

    Thanx.
     
  2. Offline

    timtower Administrator Administrator Moderator

    @mikygit Get the position of the player (assuming you want the position to be relative.)
    Make a triple loop, x, y, z
    Get the blocks at those locations.
    Set them to whatever you want.
     
  3. Offline

    mikygit

    @timtower
    As stated in my msg, this is already what I am doing BUT it takes ages.

    I was looking for a quicker way.

    For instance, the command
    Code:
    /fill 124 81 -40 -125 81 39 command_block 0 replace {Command:"/fill ~ 0 ~ ~ 250 ~ air 0",auto:1b}
    goes much faster.

    Is there a possibility to do the same? Or to forward that command to the server from the plugin?
     
  4. Offline

    timtower Administrator Administrator Moderator

    @mikygit Define takes ages. How many blocks are we talking about? What code are you using?
     
  5. Offline

    mikygit

    @timtower
    3, 4 millions. Most of them are AIR already

    I'm using SPIGOT/BUKKIT 1.12.2

    I understand loading a new map would me more efficient but I looks like I failed to do it.
    Tried a lot with loading, unloading maps. copying original data ... but in vain. It simply has no effect.
     
  6. Offline

    timtower Administrator Administrator Moderator

    @mikygit Do you check if the block is air already?
     
  7. Offline

    mikygit

    Ok. My mistake.
    It was taking time because I sticked to the stick frequency which didn't have to be since most the blocks are AIR.
    Doing layer by layer (and maybe more ...) is much faster.
    Thanx for your help.
    nb: yes, i do check if its AIR before replacing
     
  8. Offline

    timtower Administrator Administrator Moderator

  9. Offline

    mikygit

    tick sorry
     
Thread Status:
Not open for further replies.

Share This Page