Compare commits

..

2 Commits

4 changed files with 48 additions and 22 deletions
+38 -12
View File
@@ -441,7 +441,30 @@ void Export_Compatibility_API() {
return ll::service::getLevel()->fetchEntity(parseScriptUniqueID(uniqueId), false); return ll::service::getLevel()->fetchEntity(parseScriptUniqueID(uniqueId), false);
}); });
RemoteCall::exportAs("GMLIB_API", "getWorldSpawn", []() -> std::pair<BlockPos, int> { RemoteCall::exportAs("GMLIB_API", "getWorldSpawn", []() -> std::pair<BlockPos, int> {
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<BlockPos>(&it->second.mUnkfc867e.as<mUnkfc867e>()); value) {
return {*value, 0};
}
}
if (auto it = levelData.mOverrides->find(SPAWN_POS); it != levelData.mOverrides->end()) {
if (auto value = std::get_if<BlockPos>(&it->second.mUnkfc867e.as<mUnkfc867e>()); value) {
return {*value, 0};
}
}
return {BlockPos::ZERO(), 1};
}); });
RemoteCall::exportAs("GMLIB_API", "setWorldSpawn", [](std::pair<BlockPos, int> pos) -> bool { RemoteCall::exportAs("GMLIB_API", "setWorldSpawn", [](std::pair<BlockPos, int> pos) -> bool {
if (pos.second != 0) return false; if (pos.second != 0) return false;
@@ -626,23 +649,23 @@ void Export_Compatibility_API() {
switch (gameRule.mType) { switch (gameRule.mType) {
case GameRule::Type::Bool: case GameRule::Type::Bool:
result.push_back({ result.push_back({
{"Name", gameRule.mName }, {"Name", gameRule.mName },
{"Type", "Bool" }, {"Type", "Bool" },
{"Value", std::to_string(gameRule.mValue->boolVal)} {"Value", std::to_string(std::get<bool>(*gameRule.mValue))}
}); });
break; break;
case GameRule::Type::Float: case GameRule::Type::Float:
result.push_back({ result.push_back({
{"Name", gameRule.mName }, {"Name", gameRule.mName },
{"Type", "Float" }, {"Type", "Float" },
{"Value", std::to_string(gameRule.mValue->floatVal)} {"Value", std::to_string(std::get<float>(*gameRule.mValue))}
}); });
break; break;
case GameRule::Type::Int: case GameRule::Type::Int:
result.push_back({ result.push_back({
{"Name", gameRule.mName }, {"Name", gameRule.mName },
{"Type", "Int" }, {"Type", "Int" },
{"Value", std::to_string(gameRule.mValue->intVal)} {"Value", std::to_string(std::get<int>(*gameRule.mValue))}
}); });
break; break;
case GameRule::Type::Invalid: 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 { RemoteCall::exportAs("GMLIB_API", "hasEnchant", [](ItemStack* item, std::string const& typeName) -> bool {
return EnchantUtils::hasEnchant(Enchant::mEnchantNameToType()[HashedString(typeName)], *item); return EnchantUtils::hasEnchant(Enchant::mEnchantNameToType()[HashedString(typeName)], *item);
}); });
@@ -968,7 +991,10 @@ void Export_Compatibility_API() {
return entity->isType((ActorType)type); return entity->isType((ActorType)type);
}); });
RemoteCall::exportAs("GMLIB_API", "entityHasType", [](Actor* entity, int type) -> bool { RemoteCall::exportAs("GMLIB_API", "entityHasType", [](Actor* entity, int type) -> bool {
return entity->hasType((ActorType)type); if (auto component = entity->mEntityContext->tryGetComponent<ActorTypeComponent>(); component) {
return (type & std::to_underlying(component->mType)) == type;
}
return false;
}); });
RemoteCall::exportAs("GMLIB_API", "getEntityTypeId", [](Actor* entity) -> int { RemoteCall::exportAs("GMLIB_API", "getEntityTypeId", [](Actor* entity) -> int {
return (int)entity->getEntityTypeId(); return (int)entity->getEntityTypeId();
+1 -1
View File
@@ -22,7 +22,7 @@ using namespace modapi;
#define PLUGIN_NAME fmt::format(fg(fmt::color::light_green), "GMLIB-LRCA") #define PLUGIN_NAME fmt::format(fg(fmt::color::light_green), "GMLIB-LRCA")
#define LIB_VERSION_MAJOR 1 #define LIB_VERSION_MAJOR 1
#define LIB_VERSION_MINOR 0 #define LIB_VERSION_MINOR 6
#define LIB_VERSION_PATCH 0 #define LIB_VERSION_PATCH 0
#define LIB_VERSION_PRERELEASE std::nullopt #define LIB_VERSION_PRERELEASE std::nullopt
+5 -5
View File
@@ -2,7 +2,7 @@
"format_version": 3, "format_version": 3,
"format_uuid": "289f771f-2c9a-4d73-9f3f-8492495a924d", "format_uuid": "289f771f-2c9a-4d73-9f3f-8492495a924d",
"tooth": "github.com/GroupMountain/GMLIB-LegacyRemoteCallApi", "tooth": "github.com/GroupMountain/GMLIB-LegacyRemoteCallApi",
"version": "1.5.0", "version": "1.6.0",
"info": { "info": {
"name": "GMLIB-LegacyRemoteCallApi", "name": "GMLIB-LegacyRemoteCallApi",
"description": "Legacy RemoteCall API for GMLIB", "description": "Legacy RemoteCall API for GMLIB",
@@ -19,10 +19,10 @@
{ {
"platform": "win-x64", "platform": "win-x64",
"dependencies": { "dependencies": {
"github.com/LiteLDev/LeviLamina": ">=1.3.0", "github.com/LiteLDev/LeviLamina": ">=1.6.0",
"github.com/GroupMountain/GMLIB-Release": ">=1.3.0-rc.1", "github.com/GroupMountain/GMLIB-Release": ">=1.6.0",
"github.com/GroupMountain/ModAPI-Release": ">=0.1.0", "github.com/GroupMountain/ModAPI-Release": ">=0.2.0",
"github.com/MiracleForest/iListenAttentively-Release": ">=0.6.0" "github.com/MiracleForest/iListenAttentively-Release": ">=0.9.0"
}, },
"assets": [ "assets": [
{ {
+4 -4
View File
@@ -8,12 +8,12 @@ if not has_config("vs_runtime") then
set_runtimes("MD") set_runtimes("MD")
end 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("legacyremotecall")
add_requires("levibuildscript 0.5.2") add_requires("levibuildscript 0.5.2")
add_requires("ilistenattentively 0.8.0") add_requires("ilistenattentively 0.9.0")
add_requires("gmlib 1.5.1") add_requires("gmlib 1.6.0")
add_requires("modapi 0.1.1") add_requires("modapi 0.2.0")
target("GMLIB-LegacyRemoteCallApi") target("GMLIB-LegacyRemoteCallApi")
add_cxflags( add_cxflags(