I started developing after a long time now and some Code is not working for me. I am sending clientside blocks to players but now I cant convert blockRuntimeIds to normal blockIds, so the server crashes. Crash Log: My IDE tells me: And that is my code: Code: public function placeBlock(Player $target, $x, $y, $z, $blockRuntimeid) { $pk = new UpdateBlockPacket(); $pk->x = $x; $pk->y = $y; $pk->z = $z; $pk->dataLayerId = 0; $pk->blockRuntimeId = types\RuntimeBlockMapping::toStaticRuntimeId($blockRuntimeid, 0); $pk->flags = 0b0000; $target->dataPacket($pk); } I searched the whole internet for the issue but nobody had the problem yet!? Thank you for your help <3
You can use PHP: /** * @var \pocketmine\Player $target * @var \pocketmine\block\Block $block */Level->sendBlocks([$target], [$block]); api function instead
So final code: Code: public function placeBlock(Player $target, $x, $y, $z, $blockRuntimeid) { $block = Block::get($blockRuntimeid); $block->position(Position::fromObject(new Vector3($x, $y, $z))); $block->level = $target->level; $target->level->sendBlocks([$target],[$block]); }