Compare commits

...

2 Commits

4 changed files with 48 additions and 22 deletions
+32 -6
View File
@@ -441,7 +441,30 @@ void Export_Compatibility_API() {
return ll::service::getLevel()->fetchEntity(parseScriptUniqueID(uniqueId), false);
});
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 {
if (pos.second != 0) return false;
@@ -628,21 +651,21 @@ void Export_Compatibility_API() {
result.push_back({
{"Name", gameRule.mName },
{"Type", "Bool" },
{"Value", std::to_string(gameRule.mValue->boolVal)}
{"Value", std::to_string(std::get<bool>(*gameRule.mValue))}
});
break;
case GameRule::Type::Float:
result.push_back({
{"Name", gameRule.mName },
{"Type", "Float" },
{"Value", std::to_string(gameRule.mValue->floatVal)}
{"Value", std::to_string(std::get<float>(*gameRule.mValue))}
});
break;
case GameRule::Type::Int:
result.push_back({
{"Name", gameRule.mName },
{"Type", "Int" },
{"Value", std::to_string(gameRule.mValue->intVal)}
{"Value", std::to_string(std::get<int>(*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<ActorTypeComponent>(); component) {
return (type & std::to_underlying(component->mType)) == type;
}
return false;
});
RemoteCall::exportAs("GMLIB_API", "getEntityTypeId", [](Actor* entity) -> int {
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 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
+5 -5
View File
@@ -2,7 +2,7 @@
"format_version": 3,
"format_uuid": "289f771f-2c9a-4d73-9f3f-8492495a924d",
"tooth": "github.com/GroupMountain/GMLIB-LegacyRemoteCallApi",
"version": "1.5.0",
"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.3.0",
"github.com/GroupMountain/GMLIB-Release": ">=1.3.0-rc.1",
"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": [
{
+4 -4
View File
@@ -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.1")
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(