diff --git a/src/legacy/api/EntityAPI.cpp b/src/legacy/api/EntityAPI.cpp index 4e13f50..9c2a3b4 100644 --- a/src/legacy/api/EntityAPI.cpp +++ b/src/legacy/api/EntityAPI.cpp @@ -210,9 +210,11 @@ std::optional EntityClass::tryExtractActor(Local v) { // 成员函数 void EntityClass::set(Actor* actor) { - if (actor) { - runtimeId = actor->getRuntimeID(); - } + try { + if (actor && actor->hasRuntimeID()) { + runtimeId = actor->getRuntimeID(); + } + } catch (...) {} } Actor* EntityClass::get() { diff --git a/src/legacy/api/PlayerAPI.cpp b/src/legacy/api/PlayerAPI.cpp index 48cb14a..fad24b1 100644 --- a/src/legacy/api/PlayerAPI.cpp +++ b/src/legacy/api/PlayerAPI.cpp @@ -718,9 +718,11 @@ Local McClass::broadcast(const Arguments& args) { // 成员函数 void PlayerClass::set(Player* player) { - if (player) { - runtimeId = player->getRuntimeID(); - } + try { + if (player && player->hasRuntimeID()) { + runtimeId = player->getRuntimeID(); + } + } catch (...) {} } Player* PlayerClass::get() {