I spawned human by this code PHP: public function spawnd($p){ $name = $p->getName(); $text = "ZTT"; $pk = new AddPlayerPacket(); $pk->eid = 2234; $pk->uuid = UUID::fromRandom(); $pk->x = $p->x; $pk->y = $p->y + 3; $pk->z = $p->z; $pk->speedX = 0; $pk->speedY = 0; $pk->speedZ = 0; $pk->yaw = 20; $pk->pitch = -30; $pk->item = Item::get(0); $flags = 0; // $flags |= 1 << Entity::DATA_FLAG_CAN_SHOW_NAMETAG; // $flags |= 1 << Entity::DATA_FLAG_ALWAYS_SHOW_NAMETAG; $flags |= 1 << Entity::DATA_FLAG_IMMOBILE; $pk->metadata = [ Entity::DATA_FLAGS => [Entity::DATA_TYPE_LONG, $flags], // Entity::DATA_NAMETAG => [Entity::DATA_TYPE_STRING, $text], Entity::DATA_LEAD_HOLDER_EID => [Entity::DATA_TYPE_LONG, 12],]; $p->dataPacket($pk); $p->dataPacket($pk);} Why when i use this Spoiler public function onDamage(EntityDamageEvent $e) { $en = $e->getEntity(); $this->getServer()->broadcastMessage("WORKING!!"); } and damage human it doesnt say Working
Oh yeah of course, you didn't create the entity how PocketMine would like it. The entity just doesn't exist for the Server since you only sent a packet to the client. Try using createEntity().
Used Spoiler public function addNPC(Player $p){ $block = $p; $npc = new Human($p->chunk, new CompoundTag("", [ "Pos" => new ListTag("Pos", [ new DoubleTag("", $block->getX()), new DoubleTag("", $block->getY()), new DoubleTag("", $block->getZ()) ]), "Motion" => new ListTag("Motion", [ new DoubleTag("", 0), new DoubleTag("", 0), new DoubleTag("", 0) ]), "Rotation" => new ListTag("Rotation", [ new FloatTag("", 0), new FloatTag("", 90) ]), "Skin" => new CompoundTag("Skin", [ "Data" => new StringTag("Data", $p->getSkinData()) ]) ] )); $npc->spawnToAll(); $npc->setNameTagVisible(true); $npc->setNameTagAlwaysVisible(true); $npc->setNameTag("TEST"); $npc->setMaxHealth(99999999); $npc->setHealth(99999999); } But nametag is not always visible when i restart server!
I guess you have to set the nametagvisible again. That shouldn't be the case though, will check on that.
Thanks can u help finish it? PHP: public function onInteract(PlayerInteractEvent $e){ $p = $e->getPlayer(); $pk = new PlayerInteractPacket(); $pk->eid = 2233; $pk->action = $p->sendMessage("It work"); $pk->target}
PHP: public function onPacketReceived(DataPacketReceiveEvent $e){ $pk = $e->getPacket(); if ($pk instanceof InteractPacket and InteractPacket::ACTION_LEFT_CLICK) { $pk->eid = 2233; $e->getPlayer()->sendMessage("It is working"); }} What is bad :'(