I have this: PHP: public function checkVoid(PlayerMoveEvent $event){ $player = $event->getPlayer(); $x = $this->getServer()->getDefaultLevel()->getSafeSpawn()->getFloorX(); $y = $this->getServer()->getDefaultLevel()->getSafeSpawn()->getFloorZ(); $z = $this->getServer()->getDefaultLevel()->getSafeSpawn()->getFloorZ(); $level = $this->getServer()->getDefaultLevel(); if($event->getTo()->getFloorY() < 122){; so when a player moves above Y 122 I want to get all the blocks in $level above Y 122 and foreach block get id and position, how can this be done?
getting all the blocks in the world above Y 122. this wouldn't have any lag because I know that in the world there are only 2 blocks above Y 122. or is air a block?
PHP: public function checkVoid(PlayerMoveEvent $event){ $player = $event->getPlayer(); $x = $this->getServer()->getDefaultLevel()->getSafeSpawn()->getFloorX(); $y = $this->getServer()->getDefaultLevel()->getSafeSpawn()->getFloorZ(); $z = $this->getServer()->getDefaultLevel()->getSafeSpawn()->getFloorZ(); $level = $this->getServer()->getDefaultLevel(); if($event->getTo()->getFloorY() < 122){; foreach($level->getBlock->getId() < 122 as $b){ $X = $b->getX(); $Y = $b->getY(); $Z = $b->getZ(); $pos = new Vector3($X-1, $Y, $Z); $level->setBlock($pos, $b, false, false); this didn't work
You will need to load each generated chunk and iterate all blocks in its y>122. It is not feasible to "get all blocks in an area in an array". Arrays are for storing data, and here, you just want a logical algorithm for looping, not a data storage for scanning. You should just use an ordinary for loop rather than a foreach loop.