增加3个接口

- getPlayerRuntimeId
- getEntityRuntimeId
- getEntityNameTag
This commit is contained in:
子沐呀
2024-07-10 11:06:44 +08:00
Unverified
parent 27518fa2fc
commit 2d5e6736d7
2 changed files with 10 additions and 3 deletions
+10 -2
View File
@@ -1,5 +1,4 @@
#include "Global.h" #include "Global.h"
#include "mc/deps/core/string/HashedString.h"
#include <regex> #include <regex>
bool isInteger(const std::string& str) { bool isInteger(const std::string& str) {
@@ -732,7 +731,7 @@ void Export_Compatibility_API() {
}); });
RemoteCall::exportAs("GMLIB_API", "getEnchantTypeNameFromId", [](int id) -> std::string { RemoteCall::exportAs("GMLIB_API", "getEnchantTypeNameFromId", [](int id) -> std::string {
if (auto enchant = Enchant::getEnchant((Enchant::Type)id)) { if (auto enchant = Enchant::getEnchant((Enchant::Type)id)) {
return enchant->getStringId(); return std::string(enchant->getStringId());
} }
return ""; return "";
}); });
@@ -772,4 +771,13 @@ void Export_Compatibility_API() {
"dropPlayerItem", "dropPlayerItem",
[](Player* player, ItemStack const* item, bool randomly) -> bool { return player->drop(*item, randomly); } [](Player* player, ItemStack const* item, bool randomly) -> bool { return player->drop(*item, randomly); }
); );
RemoteCall::exportAs("GMLIB_API", "getPlayerRuntimeId", [](Player* player) -> uint64 {
return player->getRuntimeID().id;
});
RemoteCall::exportAs("GMLIB_API", "getEntityRuntimeId", [](Actor* entity) -> uint64 {
return entity->getRuntimeID().id;
});
RemoteCall::exportAs("GMLIB_API", "getEntityNameTag", [](Actor* entity) -> std::string {
return entity->getNameTag();
});
} }
-1
View File
@@ -1,5 +1,4 @@
#include "Global.h" #include "Global.h"
#include "mc/world/ActorUniqueID.h"
using namespace ll::hash_utils; using namespace ll::hash_utils;
void Export_Event_API() { void Export_Event_API() {