I'm creating a MurderMystery plugin, but there's a little trouble I do not know how to fix. When I use this code, Human is seen only in the spectator mode. PHP: $nbt = new CompoundTag("", [ "Pos" => new ListTag("Pos", [ new DoubleTag("", $entity->getX()), new DoubleTag("", $entity->getY()+1), new DoubleTag("", $entity->getZ()) ]), "Motion" => new ListTag("Motion", [ new DoubleTag("", 0), new DoubleTag("", 0), new DoubleTag("", 0) ]), "Rotation" => new ListTag("Rotation", [ new FloatTag("", $entity->getPitch()), new FloatTag("", $entity->getYaw()) ]), "Skin" => new CompoundTag("Skin", [ "Data" => new StringTag("Data", $entity->getSkinData()), "Name" => new StringTag("Name", $entity->getSkinId()) ]) ]);$npc = new Human($entity->getLevel(), $nbt);$npc->setDataFlag(Human::DATA_PLAYER_FLAGS, Human::DATA_PLAYER_FLAG_SLEEP, true, Human::DATA_TYPE_BYTE);$npc->setNameTag("§c".$entity->getName());$npc->spawnTo($entity);
You need to set this https://github.com/pmmp/PocketMine-MP/blob/master/src/pocketmine/Player.php#L1130 Before the sleep flag
$entity is your damaged entity in entitydamageevent and you moving then to spectate mode after damaging that why this happens