https://github.com/PocketMine/PocketMine-MP/blob/master/src/pocketmine/entity/Entity.php#L415 Level::createEntity("FallingSand",$chunk,$nbt);
You talk about a block like in Hide'n'Seek, right? There are plenty of toppics in this forum, search for hide and seek
I would suggest looking in the code for Slapper; spawn a FallingSand entity with a custom block ID, and the tag NoAI (to make it float)
this works but now it sets the block instead of following the player. PHP: public function onMove(PlayerMoveEvent $e){ $p = $e->getPlayer(); $fall = Entity::createEntity("FallingSand", $p->getLevel()->getChunk($p->x >> 4, $p->z >> 4), new Compound("", [ "Pos" => new Enum("Pos", [ new Double("", $p->x + 0.5), new Double("", $p->y+1), new Double("", $p->z + 0.5) ]), "Motion" => new Enum("Motion", [ new Double("", 0), new Double("", 0), new Double("", 0) ]), "Rotation" => new Enum("Rotation", [ new Float("", 0), new Float("", 0) ]), "TileID" => new Int("TileID", 57), "Data" => new Byte("Data", 0), ])); $fall->spawnToAll(); }
Sorry. I mean: You have to kill the entity after some seconds (the packet) or update its coordinates instead of spawning a new one
You should spawn the FallingSand first for once (in events like PlayerJoinEvent), then store the FallingSand entityId in an array(for me i use player name as key). Then when player moves, get the FallingSand entity from the stored entityId and setPosition of the FallingSand to the player's position Like so PHP: $this->blocks[$player->getName()] = $fallingsand->getId();//just after spawning public function onPlayerMove(PlayerMoveEvent $e){ $p = $e->getPlayer(); $n = $p->getName(); if (!isset($this->blocks[$n])) return; $block = $p->getLevel()->getEntity($this->blocks[$n]); if ($block) $block->setPosition($p->getPosition()->add(0,0.2,0)); }