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

canBlockStay - Define multiple blocks

Comments in 'Plugin Development' started by Muqsit, Feb 12, 2016.

  1. Muqsit
    Offline

    Muqsit Active Member

    Joined:
    Sep 9, 2015
    Posts:
    175
    Minecraft User:
    Muqsit
    How do you define multiple blocks? I want cactus to spawn on SAND and CACTUS. For now, it only spawns on sand.

    Code:
        private function canCactusStay($x, $y, $z){
            $b = $this->level->getBlockIdAt($x, $y, $z);
            return ($b === Block::AIR or $b === Block::SNOW_LAYER) and $this->level->getBlockIdAt($x, $y - 1, $z) === Block::SAND;
        }
    
  2. Svile
    Offline

    Svile Active Member

    Joined:
    Mar 30, 2015
    Posts:
    239
    Minecraft User:
    svile
    PHP:
    private function canCactusStay($x$y$z){
            
    $array = [Block::SANDBlock::ANOTHER_BLOCK];
            
    $b $this->level->getBlockIdAt($x$y$z);
            return (
    $b === Block::AIR or $b === Block::SNOW_LAYER) and in_array($this->level->getBlockIdAt($x$y 1$z), $array);
        }
    PocketKiller and Muqsit like this.
  3. Muqsit
    Offline

    Muqsit Active Member

    Joined:
    Sep 9, 2015
    Posts:
    175
    Minecraft User:
    Muqsit
    Dang, that was simple! Thanks

Share This Page

Advertisement