Advertisement
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

getBlocks

Comments in 'Plugin Development' started by CookieSteve, Apr 19, 2016.

  1. CookieSteve
    Offline

    CookieSteve Active Member

    Joined:
    Apr 22, 2014
    Posts:
    132
    Minecraft User:
    iStrqfeChris
    i wanna remove the big wall for walls could i get all the blocks in a certain area and set it to air if it has a certain ID?
  2. minebuilder0110
    Offline

    minebuilder0110 Notable Member

    Joined:
    Dec 8, 2014
    Posts:
    485
    Minecraft User:
    Apparitional
    For each blocks in certain area (check by coordinate), check their ID. If it matches, set the blocks to block ID 0.
  3. CookieSteve
    Offline

    CookieSteve Active Member

    Joined:
    Apr 22, 2014
    Posts:
    132
    Minecraft User:
    iStrqfeChris
    Example Code? how would i do $level->getBlock() foreach block in that area?
  4. minebuilder0110
    Offline

    minebuilder0110 Notable Member

    Joined:
    Dec 8, 2014
    Posts:
    485
    Minecraft User:
    Apparitional
    I am only a theoretical programmer. However, I recommend looking at the source code of MineReset or WorldEditor. On block objects, you may call getID() for ID, which returns integers. Blocks, if I rember correctly, extends to Position already, allowing you to call setBlock() on it directly.
    https://github.com/PocketMine/PocketMine-MP/blob/master/src/pocketmine/level/Level.php#L1374
  5. MyNameIsTriXz
    Offline

    MyNameIsTriXz Notable Member

    Joined:
    Aug 17, 2015
    Posts:
    538
    Minecraft User:
    MyNameIsTriXz
    Here:
    PHP:

    for($y $minY$y $maxY$y++){
    for(
    $x $minX$x $maxX$x++){
    for(
    $z $minZ$z $maxX$z++){

    $this->getServer()->getLevelByName($name)->setBlock(new Vector3($x$y$z), Block::get(000));

    }}}

    // wall 2
    // the wall has another direction, thats why we need to change x and z



    for($y $minY$y $maxY$y++){
    for(
    $x $minX$x $maxX$x++){
    for(
    $z $minZ$z $maxX$z++){

    $this->getServer()->getLevelByName($name)->setBlock(new Vector3($z$y$x), Block::get(000));

    }}}

    To imagine how you have to set the coordinates:

    [​IMG]

    I hope I was able to help you!
    Last edited: Apr 19, 2016
    CookieSteve and Primus like this.
  6. CraftYourBukkit
    Offline

    CraftYourBukkit Notable Member Plugin Developer

    Joined:
    Jan 20, 2015
    Posts:
    1,022
    Plugins:
    2
    Minecraft User:
    CraftYourBukkit
    Lag, lag, lag!
    Skullex likes this.
  7. MyNameIsTriXz
    Offline

    MyNameIsTriXz Notable Member

    Joined:
    Aug 17, 2015
    Posts:
    538
    Minecraft User:
    MyNameIsTriXz
    What do you recommend to do?
  8. CraftYourBukkit
    Offline

    CraftYourBukkit Notable Member Plugin Developer

    Joined:
    Jan 20, 2015
    Posts:
    1,022
    Plugins:
    2
    Minecraft User:
    CraftYourBukkit
    A task, so the server can respond to other stuff while placing the blocks
  9. MyNameIsTriXz
    Offline

    MyNameIsTriXz Notable Member

    Joined:
    Aug 17, 2015
    Posts:
    538
    Minecraft User:
    MyNameIsTriXz
    What kind of task? AsyncTask?
  10. CraftYourBukkit
    Offline

    CraftYourBukkit Notable Member Plugin Developer

    Joined:
    Jan 20, 2015
    Posts:
    1,022
    Plugins:
    2
    Minecraft User:
    CraftYourBukkit
    MyNameIsTriXz likes this.

Share This Page

Advertisement