pocketmine\level\Level::setBlockIdAt PHP Method

setBlockIdAt() public method

Sets the raw block id.
public setBlockIdAt ( integer $x, integer $y, integer $z, integer $id )
$x integer
$y integer
$z integer
$id integer 0-255
    public function setBlockIdAt(int $x, int $y, int $z, int $id)
    {
        unset($this->blockCache[Level::blockHash($x, $y, $z)]);
        $this->getChunk($x >> 4, $z >> 4, true)->setBlockId($x & 0xf, $y & 0x7f, $z & 0xf, $id & 0xff);
        if (!isset($this->changedBlocks[$index = Level::chunkHash($x >> 4, $z >> 4)])) {
            $this->changedBlocks[$index] = [];
        }
        $this->changedBlocks[$index][Level::blockHash($x, $y, $z)] = $v = new Vector3($x, $y, $z);
        foreach ($this->getChunkLoaders($x >> 4, $z >> 4) as $loader) {
            $loader->onBlockChanged($v);
        }
    }

Usage Example

コード例 #1
0
 public function updateBlock2(Block $block, Level $level, $blockType)
 {
     $players = $level->getPlayers();
     foreach ($players as $p) {
         $pk = new UpdateBlockPacket();
         $pk->x = $block->getX();
         $pk->y = $block->getY();
         $pk->z = $block->getZ();
         $pk->block = $blockType;
         $pk->meta = 0;
         $p->dataPacket($pk);
         $level->setBlockIdAt($block->getX(), $block->getY(), $block->getZ(), $blockType);
         $pos = new Position($block->x, $block->y, $block->z);
         $block = $level->getBlock($pos, true);
         $direct = true;
         $update = true;
         $level->setBlock($pos, $block, $direct, $update);
     }
 }
All Usage Examples Of pocketmine\level\Level::setBlockIdAt
Level