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

Help set block to air

Comments in 'Plugin Development' started by BSHRMG, Aug 4, 2016.

  1. BSHRMG
    Offline

    BSHRMG New Member

    Joined:
    Mar 15, 2016
    Posts:
    21
    Hello, I would like someone tell me if there is an easy way to set this wood wall to air?

    Attached Files:

  2. TheDiamondMan
    Offline

    TheDiamondMan New Member

    Joined:
    Dec 14, 2015
    Posts:
    4
    Minecraft User:
    XxDiamondLoverxX
    First you need to set a loop which gets all the blocks is the arena, then just check if the block youre checking is wood then set it to air, example:
    PHP:
    for($x $startingx$x $endingx$x++){//make sure that $startingx is  lower than $endingx
    for($y $startingy$y $endingy$y++){//make sure that $startingy is  lower than $endingy
      
    for($z $startingz$z $endingz$z++){//make sure that $startingz is  lower than $endingz
       
    if(Level::getBlock($x$y$z)->getId() === Block::WOOD){
        
    Level::setBlock(new Vector3($x$y$z), Block::get(Block::AIR));
       }
      }
    }
    }
    lets say my starting x is 10 and ending x is 50 so it qill get all blocks between x 10 to 50x do than to the y and z and youre pretty much done!
    BTW: make sure that youve setted up level instance like $this->getServer()->getLevelByName("yourworld");
    BSHRMG and Primus like this.
  3. TheDiamondMan
    Offline

    TheDiamondMan New Member

    Joined:
    Dec 14, 2015
    Posts:
    4
    Minecraft User:
    XxDiamondLoverxX
    oh getBlock() requires Vector3 so you might change that as well
    BSHRMG and Primus like this.
  4. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    Hint: max and min
    BSHRMG likes this.
  5. BSHRMG
    Offline

    BSHRMG New Member

    Joined:
    Mar 15, 2016
    Posts:
    21
    Thanks everyone :D
  6. SOFe
    Offline

    SOFe Banned

    Joined:
    May 28, 2016
    Posts:
    386
    Minecraft User:
    Herobrine
    Avoid using static call syntax in example code incorrectly. Instead, use the -> operator, along with predefined variables as recommended from https://github.com/sof3/forums-common-sense/wiki/Code-Environment
    HotFireyDeath likes this.

Share This Page

Advertisement