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

Create a "Box" With 2 set's of Coords

Comments in 'Plugin Development' started by CrazedMiner, May 24, 2015.

  1. CrazedMiner
    Offline

    CrazedMiner Notable Member Plugin Developer

    Joined:
    Jan 31, 2015
    Posts:
    348
    Plugins:
    2
    Minecraft User:
    CrazedMinerYT
    How would I create a "Box" using two sets of coords?

    Any help is appreciated thanks!
  2. Falk
    Offline

    Falk Staff Member Global Moderator

    Joined:
    Sep 2, 2013
    Posts:
    1,710
    Plugins:
    22
    Minecraft User:
    Falkirknh
    Not sure if this works, it's somewhere to start from :)
    PHP:
    public function makeBox(Block $blockVector3 $aVector3 $b$level null){
        if(
    $level === null){
            if(
    $a instanceof Position$level $a->getlevel();
            elseif(
    $b instanceof Position$level $b->getlevel();
            else{
                throw new 
    Exception("No level specified.");
                return;
            }
        }
        
    // I put these outside the loop so they aren't run every iteration
        
    $xMax max($a->getX(), $b->getX());
        
    $yMax max($a->getY(), $b->getY());
        
    $zMax max($a->getZ(), $b->getZ());
        for(
    $x min($a->getX(), $b->getX()); $x <= $xMax$x++){
            for(
    $y min($a->getY(), $b->getY()); $y <= $yMax$y++){
                for(
    $z min($a->getZ(), $b->getZ()); $z <= $zMax$z++){
                    
    $level->setBlock(new Vector3($x$y$z), $block);
                }
            }
        }
    }
  3. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,325
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Have a look at the pemapmodder\worldeditart\utils\spaces namespace.
    CrazedMiner likes this.

Share This Page

Advertisement