diff --git a/src/CompatibilityApi.cpp b/src/CompatibilityApi.cpp index 1f5aff6..69fad2a 100644 --- a/src/CompatibilityApi.cpp +++ b/src/CompatibilityApi.cpp @@ -441,7 +441,30 @@ void Export_Compatibility_API() { return ll::service::getLevel()->fetchEntity(parseScriptUniqueID(uniqueId), false); }); RemoteCall::exportAs("GMLIB_API", "getWorldSpawn", []() -> std::pair { - return {GMLevel::getInstance()->getLevelData().getSpawnPos(), 0}; + constexpr static HashedString SPAWN_POS{"spawnPos"}; + using mUnkfc867e = std::variant< + int, + bool, + float, + std::string, + GeneratorType, + GameType, + BlockPos, + LevelSeed64, + LevelDataValue::Tag, + DaylightCycle>; + auto& levelData = GMLevel::getInstance()->getLevelData(); + if (auto it = levelData.mValues->find(SPAWN_POS); it != levelData.mValues->end()) { + if (auto value = std::get_if(&it->second.mUnkfc867e.as()); value) { + return {*value, 0}; + } + } + if (auto it = levelData.mOverrides->find(SPAWN_POS); it != levelData.mOverrides->end()) { + if (auto value = std::get_if(&it->second.mUnkfc867e.as()); value) { + return {*value, 0}; + } + } + return {BlockPos::ZERO(), 1}; }); RemoteCall::exportAs("GMLIB_API", "setWorldSpawn", [](std::pair pos) -> bool { if (pos.second != 0) return false; @@ -626,23 +649,23 @@ void Export_Compatibility_API() { switch (gameRule.mType) { case GameRule::Type::Bool: result.push_back({ - {"Name", gameRule.mName }, - {"Type", "Bool" }, - {"Value", std::to_string(gameRule.mValue->boolVal)} + {"Name", gameRule.mName }, + {"Type", "Bool" }, + {"Value", std::to_string(std::get(*gameRule.mValue))} }); break; case GameRule::Type::Float: result.push_back({ - {"Name", gameRule.mName }, - {"Type", "Float" }, - {"Value", std::to_string(gameRule.mValue->floatVal)} + {"Name", gameRule.mName }, + {"Type", "Float" }, + {"Value", std::to_string(std::get(*gameRule.mValue))} }); break; case GameRule::Type::Int: result.push_back({ - {"Name", gameRule.mName }, - {"Type", "Int" }, - {"Value", std::to_string(gameRule.mValue->intVal)} + {"Name", gameRule.mName }, + {"Type", "Int" }, + {"Value", std::to_string(std::get(*gameRule.mValue))} }); break; case GameRule::Type::Invalid: @@ -670,7 +693,7 @@ void Export_Compatibility_API() { ); } ); - RemoteCall::exportAs("GMLIB_API", "removeEnchants", [](ItemStack* item) -> void { item->removeEnchants(); }); + RemoteCall::exportAs("GMLIB_API", "removeEnchants", [](ItemStack* item) -> void { (void)item->removeEnchants(); }); RemoteCall::exportAs("GMLIB_API", "hasEnchant", [](ItemStack* item, std::string const& typeName) -> bool { return EnchantUtils::hasEnchant(Enchant::mEnchantNameToType()[HashedString(typeName)], *item); }); @@ -968,7 +991,10 @@ void Export_Compatibility_API() { return entity->isType((ActorType)type); }); RemoteCall::exportAs("GMLIB_API", "entityHasType", [](Actor* entity, int type) -> bool { - return entity->hasType((ActorType)type); + if (auto component = entity->mEntityContext->tryGetComponent(); component) { + return (type & std::to_underlying(component->mType)) == type; + } + return false; }); RemoteCall::exportAs("GMLIB_API", "getEntityTypeId", [](Actor* entity) -> int { return (int)entity->getEntityTypeId(); diff --git a/src/Global.h b/src/Global.h index 850acd1..91c5f56 100644 --- a/src/Global.h +++ b/src/Global.h @@ -22,7 +22,7 @@ using namespace modapi; #define PLUGIN_NAME fmt::format(fg(fmt::color::light_green), "GMLIB-LRCA") #define LIB_VERSION_MAJOR 1 -#define LIB_VERSION_MINOR 0 +#define LIB_VERSION_MINOR 6 #define LIB_VERSION_PATCH 0 #define LIB_VERSION_PRERELEASE std::nullopt diff --git a/tooth.json b/tooth.json index 6bce560..ce55f2d 100644 --- a/tooth.json +++ b/tooth.json @@ -2,7 +2,7 @@ "format_version": 3, "format_uuid": "289f771f-2c9a-4d73-9f3f-8492495a924d", "tooth": "github.com/GroupMountain/GMLIB-LegacyRemoteCallApi", - "version": "1.5.1", + "version": "1.6.0", "info": { "name": "GMLIB-LegacyRemoteCallApi", "description": "Legacy RemoteCall API for GMLIB", @@ -19,10 +19,10 @@ { "platform": "win-x64", "dependencies": { - "github.com/LiteLDev/LeviLamina": ">=1.5.0", - "github.com/GroupMountain/GMLIB-Release": ">=1.5.2", - "github.com/GroupMountain/ModAPI-Release": ">=0.1.0", - "github.com/MiracleForest/iListenAttentively-Release": ">=0.6.0" + "github.com/LiteLDev/LeviLamina": ">=1.6.0", + "github.com/GroupMountain/GMLIB-Release": ">=1.6.0", + "github.com/GroupMountain/ModAPI-Release": ">=0.2.0", + "github.com/MiracleForest/iListenAttentively-Release": ">=0.9.0" }, "assets": [ { diff --git a/xmake.lua b/xmake.lua index 243f4bb..de719ce 100644 --- a/xmake.lua +++ b/xmake.lua @@ -8,12 +8,12 @@ if not has_config("vs_runtime") then set_runtimes("MD") end -add_requires("levilamina 1.5.2", {configs = {target_type = "server"}}) +add_requires("levilamina 1.6.0", {configs = {target_type = "server"}}) add_requires("legacyremotecall") add_requires("levibuildscript 0.5.2") -add_requires("ilistenattentively 0.8.0") -add_requires("gmlib 1.5.2") -add_requires("modapi 0.1.1") +add_requires("ilistenattentively 0.9.0") +add_requires("gmlib 1.6.0") +add_requires("modapi 0.2.0") target("GMLIB-LegacyRemoteCallApi") add_cxflags(