getBlockIdAt() public method

Gets the raw block id.
public getBlockIdAt ( integer $x, integer $y, integer $z ) : integer
$x integer
$y integer
$z integer
return integer 0-255
Ejemplo n.º 1
0
 private function getHighestWorkableBlock($x, $z)
 {
     for ($y = 0; $y <= 127; ++$y) {
         $b = $this->level->getBlockIdAt($x, $y, $z);
         if ($b == Block::AIR) {
             break;
         }
     }
     return $y === 0 ? -1 : $y;
 }
Ejemplo n.º 2
0
 private function getHighestWorkableBlock($x, $z)
 {
     for ($y = 127; $y >= 0; --$y) {
         $b = $this->level->getBlockIdAt($x, $y, $z);
         if ($b !== Block::AIR and $b !== Block::LEAVES and $b !== Block::LEAVES2 and $b !== Block::SNOW_LAYER) {
             break;
         }
     }
     return $y === 0 ? -1 : ++$y;
 }
Ejemplo n.º 3
0
 private function getHighestWorkableBlock($x, $z)
 {
     for ($y = 127; $y >= 0; --$y) {
         $b = $this->level->getBlockIdAt($x, $y, $z);
         if ($b == 0) {
             break;
         }
     }
     return $y === 0 ? -1 : ++$y;
 }
Ejemplo n.º 4
0
 private function getHighestWorkableBlock($x, $z)
 {
     for ($y = 127; $y > 0; --$y) {
         $b = $this->level->getBlockIdAt($x, $y, $z);
         if ($b === Block::DIRT or $b === Block::GRASS) {
             break;
         } elseif ($b !== 0 and $b !== Block::SNOW_LAYER) {
             return -1;
         }
     }
     return ++$y;
 }
Ejemplo n.º 5
0
 public static function growGrass(ChunkManager $level, Vector3 $pos, Random $random, $count = 15, $radius = 10)
 {
     $arr = [[Block::DANDELION, 0], [Block::POPPY, 0], [Block::TALL_GRASS, 1], [Block::TALL_GRASS, 1], [Block::TALL_GRASS, 1], [Block::TALL_GRASS, 1]];
     $arrC = \count($arr) - 1;
     for ($c = 0; $c < $count; ++$c) {
         $x = $random->nextRange($pos->x - $radius, $pos->x + $radius);
         $z = $random->nextRange($pos->z - $radius, $pos->z + $radius);
         if ($level->getBlockIdAt($x, $pos->y + 1, $z) === Block::AIR and $level->getBlockIdAt($x, $pos->y, $z) === Block::GRASS) {
             $t = $arr[$random->nextRange(0, $arrC)];
             $level->setBlockIdAt($x, $pos->y + 1, $z, $t[0]);
             $level->setBlockDataAt($x, $pos->y + 1, $z, $t[1]);
         }
     }
 }
Ejemplo n.º 6
0
 private function getHighestWorkableBlock($x, $z)
 {
     for ($y = 128; $y > 0; --$y) {
         $b = $this->level->getBlockIdAt($x, $y, $z);
         if ($b === Block::AIR or $b === Block::LEAVES) {
             if (--$y <= 0) {
                 return -1;
             }
         } else {
             break;
         }
     }
     return ++$y;
 }
Ejemplo n.º 7
0
 public function placeObject(ChunkManager $level, $x, $y, $z)
 {
     $clusterSize = (int) $this->type->clusterSize;
     $angle = $this->random->nextFloat() * M_PI;
     $offset = VectorMath::getDirection2D($angle)->multiply($clusterSize)->divide(8);
     $x1 = $x + 8 + $offset->x;
     $x2 = $x + 8 - $offset->x;
     $z1 = $z + 8 + $offset->y;
     $z2 = $z + 8 - $offset->y;
     $y1 = $y + $this->random->nextBoundedInt(3) + 2;
     $y2 = $y + $this->random->nextBoundedInt(3) + 2;
     for ($count = 0; $count <= $clusterSize; ++$count) {
         $seedX = $x1 + ($x2 - $x1) * $count / $clusterSize;
         $seedY = $y1 + ($y2 - $y1) * $count / $clusterSize;
         $seedZ = $z1 + ($z2 - $z1) * $count / $clusterSize;
         $size = ((\sin($count * (M_PI / $clusterSize)) + 1) * $this->random->nextFloat() * $clusterSize / 16 + 1) / 2;
         $startX = (int) ($seedX - $size);
         $startY = (int) ($seedY - $size);
         $startZ = (int) ($seedZ - $size);
         $endX = (int) ($seedX + $size);
         $endY = (int) ($seedY + $size);
         $endZ = (int) ($seedZ + $size);
         for ($x = $startX; $x <= $endX; ++$x) {
             $sizeX = ($x + 0.5 - $seedX) / $size;
             $sizeX *= $sizeX;
             if ($sizeX < 1) {
                 for ($y = $startY; $y <= $endY; ++$y) {
                     $sizeY = ($y + 0.5 - $seedY) / $size;
                     $sizeY *= $sizeY;
                     if ($y > 0 and $sizeX + $sizeY < 1) {
                         for ($z = $startZ; $z <= $endZ; ++$z) {
                             $sizeZ = ($z + 0.5 - $seedZ) / $size;
                             $sizeZ *= $sizeZ;
                             if ($sizeX + $sizeY + $sizeZ < 1 and (in_array($level->getBlockIdAt($x, $y, $z), $this->normal_replaced) and $this->type->material->getId() === 0 or $level->getBlockIdAt($x, $y, $z) === 1 and $this->type->material->getId() !== 0)) {
                                 $level->setBlockIdAt($x, $y, $z, $this->type->material->getId());
                                 if ($this->type->material->getDamage() !== 0) {
                                     $level->setBlockDataAt($x, $y, $z, $this->type->material->getDamage());
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
 }
Ejemplo n.º 8
0
 public function canPlaceObject(ChunkManager $level, $x, $y, $z, Random $random)
 {
     $radiusToCheck = 0;
     for ($yy = 0; $yy < $this->trunkHeight + 3; ++$yy) {
         if ($yy == 1 or $yy === $this->trunkHeight) {
             ++$radiusToCheck;
         }
         for ($xx = -$radiusToCheck; $xx < $radiusToCheck + 1; ++$xx) {
             for ($zz = -$radiusToCheck; $zz < $radiusToCheck + 1; ++$zz) {
                 if (!isset($this->overridable[$level->getBlockIdAt($x + $xx, $y + $yy, $z + $zz)])) {
                     return false;
                 }
             }
         }
     }
     return true;
 }
Ejemplo n.º 9
0
 public function canPlaceObject(ChunkManager $level, $x, $y, $z, Random $random)
 {
     $this->findRandomLeavesSize($random);
     $checkRadius = 0;
     for ($yy = 0; $yy < $this->totalHeight + 2; ++$yy) {
         if ($yy === $this->leavesBottomY) {
             $checkRadius = $this->leavesMaxRadius;
         }
         for ($xx = -$checkRadius; $xx < $checkRadius + 1; ++$xx) {
             for ($zz = -$checkRadius; $zz < $checkRadius + 1; ++$zz) {
                 if (!isset($this->overridable[$level->getBlockIdAt($x + $xx, $y + $yy, $z + $zz)])) {
                     return false;
                 }
             }
         }
     }
     return true;
 }
Ejemplo n.º 10
0
 protected function placeTrunk(ChunkManager $level, $x, $y, $z, Random $random, $trunkHeight)
 {
     // The base dirt block
     $level->setBlockIdAt($x, $y - 1, $z, Block::DIRT);
     for ($yy = 0; $yy < $trunkHeight; ++$yy) {
         $blockId = $level->getBlockIdAt($x, $y + $yy, $z);
         if (isset($this->overridable[$blockId])) {
             $level->setBlockIdAt($x, $y + $yy, $z, $this->trunkBlock);
             $level->setBlockDataAt($x, $y + $yy, $z, $this->type);
         }
     }
 }
Ejemplo n.º 11
0
 public function place()
 {
     for ($x = $this->start->getFloorX(); $x < $this->end->getFloorX(); $x++) {
         $xOffset = ($this->chunk->getX() + $x + 0.5 - $this->target->getX()) / $this->horizontalSize;
         for ($z = $this->start->getFloorZ(); $z < $this->end->getFloorZ(); $z++) {
             $zOffset = ($this->chunk->getZ() + $z + 0.5 - $this->target->getZ()) / $this->horizontalSize;
             if ($xOffset * $xOffset + $zOffset * $zOffset >= 1) {
                 continue;
             }
             for ($y = $this->end->getFloorY() - 1; $y >= $this->start->getFloorY(); $y--) {
                 $yOffset = ($y + 0.5 - $this->target->getY()) / $this->verticalSize;
                 if ($yOffset > -0.7 and $xOffset * $xOffset + $yOffset * $yOffset + $zOffset * $zOffset < 1) {
                     $xx = $this->chunk->getX() + $x;
                     $zz = $this->chunk->getZ() + $z;
                     $blockId = $this->level->getBlockIdAt($xx, $y, $zz);
                     if ($blockId == Block::STONE or $blockId == Block::DIRT or $blockId == Block::GRASS) {
                         if ($y < 10) {
                             $this->level->setBlockIdAt($xx, $y, $zz, Block::STILL_LAVA);
                         } else {
                             if ($blockId == Block::GRASS and $this->level->getBlockIdAt($xx, $y - 1, $zz) == Block::DIRT) {
                                 $this->level->setBlockIdAt($xx, $y - 1, $zz, Block::GRASS);
                             }
                             $this->level->setBlockIdAt($xx, $y, $zz, Block::AIR);
                         }
                     }
                 }
             }
         }
     }
 }
Ejemplo n.º 12
0
 private function getAvailableBlockSpace(ChunkManager $level, Vector3 $from, Vector3 $to)
 {
     $count = 0;
     $iter = new VectorIterator($level, $from, $to);
     while ($iter->valid()) {
         $iter->next();
         $pos = $iter->current();
         if (!isset($this->overridable[$level->getBlockIdAt($pos->x, $pos->y, $pos->z)])) {
             return $count;
         }
         $count++;
     }
     return -1;
 }