Add Level::getPlayer(mce::UUID)

This commit is contained in:
Qiuzhizhe 2022-11-17 14:37:18 +08:00
parent 71bb904d81
commit 7332bc36c7
No known key found for this signature in database
GPG Key ID: 4EF4BF5521540263
2 changed files with 13 additions and 1 deletions

View File

@ -41,6 +41,7 @@ public:
LIAPI static std::vector<Player*> getAllPlayers();
LIAPI Player* getPlayer(const string& info); // name or xuid
LIAPI Player* getPlayer(ActorUniqueID id); // UniqueID
LIAPI Player* getPlayer(const mce::UUID& uuid)const; //原生函数Level::getPlayer(mce::UUID)
LIAPI static Actor* getEntity(ActorUniqueID id);
LIAPI static std::vector<Actor*> getAllEntities(int dimId);
LIAPI static std::vector<Actor*> getAllEntities();

View File

@ -294,7 +294,7 @@ Player* Level::getPlayer(const string& info) {
Player* Level::getPlayer(ActorUniqueID id) {
// 裂开,这个符号也没有
//根据伪代码重新写实现
// 根据伪代码重新写实现
Actor* actor = Level::fetchEntity(id,0);
if(actor && actor->hasCategory((ActorCategory)1))
return (Player*)actor;
@ -303,6 +303,17 @@ Player* Level::getPlayer(ActorUniqueID id) {
//return SymCall("?getPlayer@Level@@UEBAPEAVPlayer@@UActorUniqueID@@@Z", Player*, Level*, ActorUniqueID)(Global<Level>, id);
}
Player* Level::getPlayer(const mce::UUID& uuid) const{
// 根据函数
// std::_Func_impl_no_alloc__lambda_71cde901375eb38deb56f48a96514d77__bool_Player_const___::_Do_call
Player* findPlayer = this->findPlayer([&](const Player& pl)->bool {
if (pl.getClientUUID() == uuid)
return true;
return false;
});
return findPlayer;
}
Actor* Level::spawnMob(Vec3 pos, int dimId, std::string name) {
Spawner* sp = &Global<Level>->getSpawner();