How do I make a player sit.? Packets have been changed in PocketMine and old chair plugins don't work. I found this edit of a plugin by Jasonwynn on the forums which is probably my best hope of fixing it: PHP: <?phpnamespace maru;use pocketmine\entity\Entity;use pocketmine\Server;use pocketmine\plugin\PluginBase;use pocketmine\event\Listener;use pocketmine\event\server\DataPacketReceiveEvent;use pocketmine\network\mcpe\protocol\AddEntityPacket;use pocketmine\event\player\PlayerInteractEvent;use pocketmine\network\mcpe\protocol\ProtocolInfo;use pocketmine\block\Stair;use pocketmine\network\mcpe\protocol\RemoveEntityPacket;use pocketmine\network\mcpe\protocol\SetEntityLinkPacket;use pocketmine\math\Vector3;use pocketmine\network\mcpe\protocol\types\EntityLink;class PmChair extends PluginBase implements Listener{ public $counter = []; public $count = 0; public function onEnable(){ $this->getServer()->getPluginManager()->registerEvents($this, $this); $this->count = 10000; } public function onPacketReceived(DataPacketReceiveEvent $event){ $pk = $event->getPacket(); switch($pk::NETWORK_ID){ case ProtocolInfo::PLAYER_ACTION_PACKET; $player = $event->getPlayer(); if(isset($this->counter[$player->getName()])){ if($pk->action === 8){$ppk = new SetEntityLinkPacket(); $ppk->from = $this->counter[$player->getName()]; $ppk->to = 0; $ppk->type = 0; $player->dataPacket($ppk); $pkc = new SetEntityLinkPacket(); $pkc->from = $this->counter[$player->getName()]; $pkc->to = $player->getId(); $pkc->type = 0; $ps = Server::getInstance()->getOnlinePlayers(); Server::getInstance()->broadcastPacket($ps,$pkc); $pk0 = new RemoveEntityPacket(); $pk0->entityUniqueId = $this->counter[$player->getName()]; $ps = Server::getInstance()->getOnlinePlayers(); Server::getInstance()->broadcastPacket($ps,$pk0); unset($this->counter[$player->getName()]); } } } } public function onTouch(PlayerInteractEvent $event){ if($event->getBlock()->getID() === 53){ $player = $event->getPlayer(); $pk = new AddEntityPacket(); $this->count = $this->count + 1; $pk->entityRuntimeId=$this->count; $pk->type = 86; $pk->motion = new Vector3(); $block = $event->getBlock (); if ($block instanceof Stair) { $pk->position = $block->asVector3()->add(0.5, 1.5, 0.5); $pk->speedX = 0; $pk->speedY = 0; $pk->speedZ = 0; $pk->yaw = $player->yaw; $pk->pitch = $player->pitch; $pk->metadata = [Entity::DATA_FLAGS => [Entity::DATA_TYPE_BYTE, 1 << Entity::DATA_FLAG_INVISIBLE],[Entity::DATA_TYPE_STRING << Entity::DATA_NAMETAG] , [Entity::DATA_TYPE_BYTE,1 << Entity::DATA_FLAG_ALWAYS_SHOW_NAMETAG], [Entity::DATA_TYPE_BYTE,1 << Entity::DATA_FLAG_NO_AI]]; $ps=Server::getInstance()->getOnlinePlayers(); Server::getInstance()->broadcastPacket($ps,$pk); $ppk = new SetEntityLinkPacket(); $ppk->from = $this->count; $ppk->to = 0; $ppk->type = 2;$player->dataPacket($ppk); $pkc = new SetEntityLinkPacket(); $pkc->from = $this->count; $pkc->to = $player->getId();$pkc->type = 2; $ps=Server::getInstance()->getOnlinePlayers(); Server::getInstance()->broadcastPacket($ps,$pkc); $this->counter[$player->getName()] = $this->count; } } }} This had a couple of errors which I fixed but the big issue with this is something to do with putEntityLink ? Code: [22:34:20] [Server thread/CRITICAL]: Could not pass event 'pocketmine\event\player\PlayerInteractEvent' to 'PmChair v1.3': Argument 1 passed to pocketmine\network\mcpe\protocol\DataPacket::putEntityLink() must be an instance of pocketmine\network\mcpe\protocol\types\EntityLink, null given, called in phar://C:/Users/Admin/Creative Cloud Files/Desktop/Server/Server - DEV/PocketMine-MP.phar/src/pocketmine/network/mcpe/protocol/SetEntityLinkPacket.php on line 43 on maru\PmChair [22:34:20] [Server thread/CRITICAL]: TypeError: "Argument 1 passed to pocketmine\network\mcpe\protocol\DataPacket::putEntityLink() must be an instance of pocketmine\network\mcpe\protocol\types\EntityLink, null given, called in phar://C:/Users/Admin/Creative Cloud Files/Desktop/Server/Server - DEV/PocketMine-MP.phar/src/pocketmine/network/mcpe/protocol/SetEntityLinkPacket.php on line 43" (EXCEPTION) in "src/pocketmine/network/mcpe/protocol/DataPacket" at line 533 When the player taps block ID 53 it needs to sit them on it, please help me do this
PHP: public function onClick(PlayerInteractEvent $e){ if($e->getItem()->getId() !== 280 || $e->getAction() !== $e::RIGHT_CLICK_BLOCK){ return; } $block = $e->getBlock(); $player = $e->getPlayer(); $player->setMotion(new Vector3(0, 0.2, 0)); $add = new AddEntityPacket; $add->entityRuntimeId = 666; $add->type = 95; $add->position = new Vector3($block->x - 0.3, $block->y + 1.7, $block->z + 0.3); $player->dataPacket($add); $link = new SetEntityLinkPacket; $link->link = [666, $player->getId(), 1, 1]; $player->dataPacket($link);}
How do I make it allow only being able to tap the block 53 to sit on it this..? PHP: public function onTouch(PlayerInteractEvent $event){ if($event->getBlock()->getID() === 53){ $block = $event->getBlock(); $player = $event->getPlayer(); $player->setMotion(new Vector3(0, 0.2, 0)); $add = new AddEntityPacket; $add->entityRuntimeId = 666; $add->type = 95; $add->position = new Vector3($block->x - 0.5, $block->y + 1.5, $block->z + 0.5); $player->dataPacket($add); $link = new SetEntityLinkPacket; $link->link = [666, $player->getId(), 1, 1]; $player->dataPacket($link); } }
oh it works but is there a way to remove the popup that appears when the player sits on the chair? "action.hint.exit.area_effect_cloud"