feat: adapt gmlib 1.0.0

This commit is contained in:
zimuya4153
2025-04-16 17:47:08 +08:00
Unverified
parent 1693ac7290
commit ce7da22e96
10 changed files with 203 additions and 146 deletions
+40 -3
View File
@@ -2,13 +2,50 @@
* @returns {string} * @returns {string}
*/ */
const getPluginName = () => { const getPluginName = () => {
// quickjs
try { try {
throw new Error("getPluginName"); throw new Error("getPluginName");
} catch (error) { } catch (error) {
return error.stack.trim().match(/plugins\\(.*)\\.*\.js:[0-9]+\)$/i)?.[1] const /** @type {string} */ line = error.stack.trim().split("\n").pop().trim();
|| error.stack.trim().match(/at <anonymous> \(([^\\|/]+)(.*?):\d+:\d+\)$/i)?.[1] if (line.includes("<anonymous>")) {
|| "Unknown"; return line.slice(
line.indexOf("(") + 1,
line.indexOf("\\")
);
}
if (line.includes("<eval>")) {
return line.slice(
line.indexOf("/", line.indexOf("/") + 1) + 1,
line.indexOf("\\")
);
}
} }
// nodejs
try {
const path = require('path');
const selfFileName = path.basename(__filename);
const pluginDirectory = Object.entries(
require('module')._pathCache
).find(
([key, _]) =>
key.includes(selfFileName)
)[0].split("\u0000")[1];
const directories = pluginDirectory.split("\\");
const pluginName = directories[directories.findIndex(value => value === "plugins") + 1].trim();
if (pluginName) return pluginName;
} catch { }
try {
throw new Error("getPluginName");
} catch (error) {
const /** @type {string} */ line = error.stack.trim().split("\n").pop().trim();
if (line.includes(".js") && /:\d+:\d+$/.test(line)) {
const directories = line.split("\\");
const pluginName = directories[directories.findIndex(value => value === "plugins") + 1].trim();
if (pluginName) return pluginName;
}
}
return "Unknown";
}; };
module.exports = { module.exports = {
+2 -3
View File
@@ -256,7 +256,7 @@ const GMLIB_API = {
blockPlayerWillDestroy: ll.import("GMLIB_API", "blockPlayerWillDestroy"), blockPlayerWillDestroy: ll.import("GMLIB_API", "blockPlayerWillDestroy"),
/** 使玩家攻击实体 @type {function(Entity,Player):boolean} */ /** 使玩家攻击实体 @type {function(Entity,Player):boolean} */
playerAttack: ll.import("GMLIB_API", "playerAttack"), playerAttack: ll.import("GMLIB_API", "playerAttack"),
/** @type {function(Player,Entity):boolean} */ /** @type {function(Player,Entity):void} */
playerPullInEntity: ll.import("GMLIB_API", "playerPullInEntity"), playerPullInEntity: ll.import("GMLIB_API", "playerPullInEntity"),
/** 根据命令空间获取翻译键名 @type {function(string):string} */ /** 根据命令空间获取翻译键名 @type {function(string):string} */
getBlockTranslateKeyFromName: ll.import("GMLIB_API", "getBlockTranslateKeyFromName"), getBlockTranslateKeyFromName: ll.import("GMLIB_API", "getBlockTranslateKeyFromName"),
@@ -2739,10 +2739,9 @@ LLSE_Player.prototype.pullInEntity =
/** /**
* *
* @param {Entity} entity 实体对象 * @param {Entity} entity 实体对象
* @returns {boolean}
*/ */
function (entity) { function (entity) {
return GMLIB_API.playerPullInEntity(this, entity); GMLIB_API.playerPullInEntity(this, entity);
}; };
LLSE_Item.prototype.applyEnchant = LLSE_Item.prototype.applyEnchant =
+40 -3
View File
@@ -1,13 +1,50 @@
/// <reference path='d:/dts/dts/helperlib/src/index.d.ts'/> /// <reference path='d:/dts/dts/helperlib/src/index.d.ts'/>
const getPluginName = () => { const getPluginName = () => {
// quickjs
try { try {
throw new Error("getPluginName"); throw new Error("getPluginName");
} catch (error) { } catch (error) {
return error.stack.trim().match(/plugins\\(.*)\\.*\.js:[0-9]+\)$/i)?.[1] const /** @type {string} */ line = error.stack.trim().split("\n").pop().trim();
|| error.stack.trim().match(/at <anonymous> \(([^\\|/]+)(.*?):\d+:\d+\)$/i)?.[1] if (line.includes("<anonymous>")) {
|| "Unknown"; return line.slice(
line.indexOf("(") + 1,
line.indexOf("\\")
);
}
if (line.includes("<eval>")) {
return line.slice(
line.indexOf("/", line.indexOf("/") + 1) + 1,
line.indexOf("\\")
);
}
} }
// nodejs
try {
const path = require('path');
const selfFileName = path.basename(__filename);
const pluginDirectory = Object.entries(
require('module')._pathCache
).find(
([key, _]) =>
key.includes(selfFileName)
)[0].split("\u0000")[1];
const directories = pluginDirectory.split("\\");
const pluginName = directories[directories.findIndex(value => value === "plugins") + 1].trim();
if (pluginName) return pluginName;
} catch { }
try {
throw new Error("getPluginName");
} catch (error) {
const /** @type {string} */ line = error.stack.trim().split("\n").pop().trim();
if (line.includes(".js") && /:\d+:\d+$/.test(line)) {
const directories = line.split("\\");
const pluginName = directories[directories.findIndex(value => value === "plugins") + 1].trim();
if (pluginName) return pluginName;
}
}
return "Unknown";
}; };
Function.prototype.getName = Function.prototype.getName =
+41 -46
View File
@@ -1,17 +1,17 @@
#include "Global.h" #include "Global.h"
#include <regex> #include <regex>
#include <unordered_map>
ActorUniqueID parseScriptUniqueID(std::string const& uniqueId) { ActorUniqueID parseScriptUniqueID(std::string const& uniqueId) {
return StringUtils::isInteger(uniqueId) ? ActorUniqueID(std::stoll(uniqueId)) : ActorUniqueID::INVALID_ID(); return string_utils::isInteger(uniqueId) ? ActorUniqueID(std::stoll(uniqueId)) : ActorUniqueID::INVALID_ID();
} }
void Export_Compatibility_API() { void Export_Compatibility_API() {
RemoteCall::exportAs("GMLIB_API", "unregisterRecipe", [](std::string const& id) -> bool { RemoteCall::exportAs("GMLIB_API", "unregisterRecipe", [](std::string const& id) -> bool {
// return GMLevel::getInstance().has_value() ? GMLIB::Mod::CustomRecipe::unregisterRecipe(id) : false; return CustomRecipeRegistry::getInstance().unregisterRecipe(id, true);
throw std::runtime_error("GMLIB_API::unregisterRecipe is not implemented");
}); });
RemoteCall::exportAs("GMLIB_API", "setCustomPackPath", [](std::string const& path) -> void { RemoteCall::exportAs("GMLIB_API", "setCustomPackPath", [](std::string const& path) -> void {
AddonsLoaderUtils::addCustomPackPath(path); AddonsLoader::addCustomPackPath(path);
}); });
RemoteCall::exportAs("GMLIB_API", "getServerMspt", []() -> double { RemoteCall::exportAs("GMLIB_API", "getServerMspt", []() -> double {
return GMLevel::getInstance().transform( return GMLevel::getInstance().transform(
@@ -66,20 +66,21 @@ void Export_Compatibility_API() {
return OfflinePlayer::deletePlayerNbt(mce::UUID::fromString(uuid)); return OfflinePlayer::deletePlayerNbt(mce::UUID::fromString(uuid));
}); });
RemoteCall::exportAs("GMLIB_API", "getAllExperiments", []() -> std::vector<int> { RemoteCall::exportAs("GMLIB_API", "getAllExperiments", []() -> std::vector<int> {
// std::vector<int> result; return {36, 45, 38, 48, 47, 53, 56, 45, 40};
// for (auto& key : GMLevel::getAllExperiments()) {
// result.push_back((int)key);
// }
// return result;
throw std::runtime_error("GMLIB_API::getAllExperiments is not implemented");
}); });
RemoteCall::exportAs("GMLIB_API", "getExperimentTranslateKey", [](int id) -> std::string { RemoteCall::exportAs("GMLIB_API", "getExperimentTranslateKey", [](int id) -> std::string {
// std::string result; static std::unordered_map<int, std::string> mMap = {
// try { {36, "createWorldScreen.experimentalbiomes" },
// result = Experiments::getExperimentTextID(AllExperiments(id)); {45, "createWorldScreen.experimentalCreatorFeatures" },
// } catch (...) {} {38, "createWorldScreen.experimentalGameTest" },
// return result; {48, "createWorldScreen.experimentalThirdPersonCameras" },
throw std::runtime_error("GMLIB_API::getExperimentTranslateKey is not implemented"); {47, "createWorldScreen.experimentalFocusTargetCamera" },
{53, "createWorldScreen.experimentalVillagerTradesRebalance" },
{56, "createWorldScreen.experimentalDataDrivenJigsawStructures"},
{45, "createWorldScreen.experimentalCameraAimAssist" },
{40, "createWorldScreen.experimentalY2025Drop1" }
};
return mMap.contains(id) ? mMap[id] : "";
}); });
RemoteCall::exportAs( RemoteCall::exportAs(
"GMLIB_API", "GMLIB_API",
@@ -213,8 +214,10 @@ void Export_Compatibility_API() {
"GMLIB_API", "GMLIB_API",
"setPlayerPosition", "setPlayerPosition",
[](std::string const& uuid, std::pair<BlockPos, int> pos) -> bool { [](std::string const& uuid, std::pair<BlockPos, int> pos) -> bool {
// return GMPlayer::setPlayerPosition(mce::UUID::fromString(uuid), pos.first, pos.second); if (auto player = OfflinePlayer::getOfflinePlayer(mce::UUID::fromString(uuid))) {
throw std::runtime_error("GMLIB_API::setPlayerPosition is not implemented"); return player->setPosition(pos.first, pos.second);
}
return false;
} }
); );
RemoteCall::exportAs("GMLIB_API", "playerHasScore", [](std::string const& uuid, std::string const& obj) -> bool { RemoteCall::exportAs("GMLIB_API", "playerHasScore", [](std::string const& uuid, std::string const& obj) -> bool {
@@ -452,17 +455,14 @@ void Export_Compatibility_API() {
return true; return true;
}); });
RemoteCall::exportAs("GMLIB_API", "getPlayerSpawnPoint", [](Player* pl) -> std::pair<BlockPos, int> { RemoteCall::exportAs("GMLIB_API", "getPlayerSpawnPoint", [](Player* pl) -> std::pair<BlockPos, int> {
// auto res = ((GMPlayer*)pl)->getSpawnPoint(); return {pl->mPlayerRespawnPoint->mSpawnBlockPos, pl->mPlayerRespawnPoint->mDimension.get()};
// return {res.first, res.second};
throw std::runtime_error("GMLIB_API::getPlayerSpawnPoint is not implemented");
}); });
RemoteCall::exportAs("GMLIB_API", "setPlayerSpawnPoint", [](Player* pl, std::pair<BlockPos, int> pos) -> void { RemoteCall::exportAs("GMLIB_API", "setPlayerSpawnPoint", [](Player* pl, std::pair<BlockPos, int> pos) -> void {
// ((GMPlayer*)pl)->setSpawnPoint(pos.first, pos.second); pl->setRespawnPosition(pos.first, pos.second);
throw std::runtime_error("GMLIB_API::setPlayerSpawnPoint is not implemented");
}); });
RemoteCall::exportAs("GMLIB_API", "clearPlayerSpawnPoint", [](Player* pl) -> void { RemoteCall::exportAs("GMLIB_API", "clearPlayerSpawnPoint", [](Player* pl) -> void {
// ((GMPlayer*)pl)->clearSpawnPoint(); pl->mPlayerRespawnPoint->mSpawnBlockPos = BlockPos::MIN();
throw std::runtime_error("GMLIB_API::clearPlayerSpawnPoint is not implemented"); pl->mPlayerRespawnPoint->mDimension = VanillaDimensions::Undefined();
}); });
RemoteCall::exportAs( RemoteCall::exportAs(
"GMLIB_API", "GMLIB_API",
@@ -546,8 +546,7 @@ void Export_Compatibility_API() {
return block->mDirectData->mUnkc08fbd.as<float>(); return block->mDirectData->mUnkc08fbd.as<float>();
}); });
RemoteCall::exportAs("GMLIB_API", "getDestroyBlockSpeed", [](ItemStack const* item, Block const* block) -> float { RemoteCall::exportAs("GMLIB_API", "getDestroyBlockSpeed", [](ItemStack const* item, Block const* block) -> float {
// return item->getDestroySpeed(*block); return item->getItem()->getDestroySpeed(*item, *block);
throw std::runtime_error("GMLIB_API::getDestroyBlockSpeed is not implemented");
}); });
RemoteCall::exportAs( RemoteCall::exportAs(
"GMLIB_API", "GMLIB_API",
@@ -568,8 +567,7 @@ void Export_Compatibility_API() {
return false; return false;
}); });
RemoteCall::exportAs("GMLIB_API", "itemCanDestroySpecial", [](ItemStack const* item, Block const* block) -> bool { RemoteCall::exportAs("GMLIB_API", "itemCanDestroySpecial", [](ItemStack const* item, Block const* block) -> bool {
// return item->canDestroySpecial(*block); return item->getItem()->canDestroySpecial(*block);
throw std::runtime_error("GMLIB_API::itemCanDestroySpecial is not implemented");
}); });
RemoteCall::exportAs("GMLIB_API", "blockCanDropWithAnyTool", [](Block const* block) -> bool { RemoteCall::exportAs("GMLIB_API", "blockCanDropWithAnyTool", [](Block const* block) -> bool {
return !block->getLegacyBlock().mRequiresCorrectToolForDrops; return !block->getLegacyBlock().mRequiresCorrectToolForDrops;
@@ -584,9 +582,10 @@ void Export_Compatibility_API() {
RemoteCall::exportAs("GMLIB_API", "playerAttack", [](Player* player, Actor* entity) -> bool { RemoteCall::exportAs("GMLIB_API", "playerAttack", [](Player* player, Actor* entity) -> bool {
return player->attack(*entity, SharedTypes::Legacy::ActorDamageCause::EntityAttack); return player->attack(*entity, SharedTypes::Legacy::ActorDamageCause::EntityAttack);
}); });
RemoteCall::exportAs("GMLIB_API", "playerPullInEntity", [](Player* player, Actor* entity) -> bool { RemoteCall::exportAs("GMLIB_API", "playerPullInEntity", [](Player* player, Actor* entity) -> void {
// return player->pullInEntity(*entity); if (auto component = player->getEntityContext().tryGetComponent<RideableComponent>()){
throw std::runtime_error("GMLIB_API::playerPullInEntity is not implemented"); component->pullInEntity(*player, *entity);
}
}); });
RemoteCall::exportAs("GMLIB_API", "getBlockTranslateKeyFromName", [](std::string const& blockName) -> std::string { RemoteCall::exportAs("GMLIB_API", "getBlockTranslateKeyFromName", [](std::string const& blockName) -> std::string {
return Block::tryGetFromRegistry(blockName) return Block::tryGetFromRegistry(blockName)
@@ -896,20 +895,16 @@ void Export_Compatibility_API() {
"GMLIB_API", "GMLIB_API",
"registerCustomShapelessRecipe", "registerCustomShapelessRecipe",
[](std::string const& recipe_id, std::vector<std::string> ingredients, ItemStack* result) -> void { [](std::string const& recipe_id, std::vector<std::string> ingredients, ItemStack* result) -> void {
// if (!GMLevel::getInstance().has_value()) return; if (!GMLevel::getInstance().has_value()) return;
// std::vector<Recipes::Type> types; std::vector<ICustomRecipe::Ingredient> types;
// char rt = 'A'; for (auto& ing : ingredients) {
// for (auto& ing : ingredients) { types.push_back(ICustomRecipe::Ingredient{ing});
// auto ingredient = RecipeIngredient{ing, 0,1}; }
// types.push_back(Recipes::Type{ CustomRecipeRegistry::getInstance().registerShapelessRecipe(
// (Item*)ingredient.getItem(), recipe_id,
// ingredient.getBlock(), types,
// ingredient, ItemInstance(*result->getItem(), result->mCount, result->mAuxValue, result->mUserData.get())
// rt++ );
// });
// }
// GMLIB::Mod::CustomRecipe::registerShapelessCraftingTableRecipe(recipe_id, types, *result);
throw std::runtime_error("GMLIB_API::registerCustomShapelessRecipe is not implemented");
} }
); );
RemoteCall::exportAs( RemoteCall::exportAs(
+4 -1
View File
@@ -9,6 +9,7 @@ LegacyRemoteCallApi& LegacyRemoteCallApi::getInstance() {
} }
bool LegacyRemoteCallApi::load() { bool LegacyRemoteCallApi::load() {
(void)CustomRecipeRegistry::getInstance();
Export_Legacy_GMLib_ModAPI(); Export_Legacy_GMLib_ModAPI();
Export_Legacy_GMLib_ServerAPI(); Export_Legacy_GMLib_ServerAPI();
Export_Compatibility_API(); Export_Compatibility_API();
@@ -39,4 +40,6 @@ LL_REGISTER_MOD(gmlib::LegacyRemoteCallApi, gmlib::LegacyRemoteCallApi::getInsta
ll::thread::ThreadPoolExecutor const& getThreadPoolExecutor() { ll::thread::ThreadPoolExecutor const& getThreadPoolExecutor() {
return gmlib::LegacyRemoteCallApi::getInstance().getThreadPoolExecutor(); return gmlib::LegacyRemoteCallApi::getInstance().getThreadPoolExecutor();
} }
ll::io::Logger& getLogger() { return gmlib::LegacyRemoteCallApi::getInstance().getSelf().getLogger(); }
+1 -1
View File
@@ -141,7 +141,7 @@ void Export_Event_API() {
REGISTER_EVENT_LISTEN( REGISTER_EVENT_LISTEN(
ila::mc::SpawnItemActorAfterEvent, ila::mc::SpawnItemActorAfterEvent,
(Actor * item, std::pair<Vec3, int> position, int64 spawnerUniqueId), (Actor * item, std::pair<Vec3, int> position, int64 spawnerUniqueId),
(event.itemActor(), (&event.itemActor(),
{event.pos(), event.blockSource().getDimensionId().id}, {event.pos(), event.blockSource().getDimensionId().id},
event.spawner() ? event.spawner()->getOrCreateUniqueID().rawID : -1), event.spawner() ? event.spawner()->getOrCreateUniqueID().rawID : -1),
, ,
+3 -1
View File
@@ -1,10 +1,11 @@
#pragma once #pragma once
// clang-format off // clang-format off
#define GMLIB_Gloabl_Using #define GMLIB_GLOBAL_USING
#include <gmlib/GlobalUsing.h> #include <gmlib/GlobalUsing.h>
#include <gmlib/include_all.h> #include <gmlib/include_all.h>
#include <ila/include_all.h> #include <ila/include_all.h>
#include <RemoteCallAPI.h> #include <RemoteCallAPI.h>
using namespace gmlib::mod;
// clang-format on // clang-format on
#define PLUGIN_NAME fmt::format(fg(fmt::color::light_green), "GMLIB-LRCA") #define PLUGIN_NAME fmt::format(fg(fmt::color::light_green), "GMLIB-LRCA")
@@ -27,4 +28,5 @@ extern void ExportPAPI();
extern void Export_Event_API(); extern void Export_Event_API();
extern void Export_BinaryStream_API(); extern void Export_BinaryStream_API();
extern ll::thread::ThreadPoolExecutor const& getThreadPoolExecutor(); extern ll::thread::ThreadPoolExecutor const& getThreadPoolExecutor();
extern ll::io::Logger& getLogger();
// extern void Export_Form_API(); // extern void Export_Form_API();
+63 -73
View File
@@ -1,12 +1,13 @@
#include "Global.h" #include "Global.h"
#include "gmlib/mod/recipe/CustomRecipeRegistry.h"
#include <gmlib/mc/world/Level.h> #include <gmlib/mc/world/Level.h>
#include <mc/world/item/crafting/RecipeIngredient.h> #include <mc/world/item/crafting/RecipeIngredient.h>
std::unordered_set<std::string> HardCodedKeys = {"AlwaysUnlocked", "PlayerHasManyItems", "PlayerInWater", "None"}; std::unordered_set<std::string> HardCodedKeys = {"AlwaysUnlocked", "PlayerHasManyItems", "PlayerInWater", "None"};
std::variant<std::string, std::vector<RecipeIngredient>> makeRecipeUnlockingKey(std::string const& key) { ICustomRecipe::UnlockingRequirement makeRecipeUnlockingKey(std::string const& key) {
if (HardCodedKeys.count(key)) return key; if (HardCodedKeys.count(key)) return {{ICustomRecipe::Ingredient{key}}};
return std::vector<RecipeIngredient>({RecipeIngredient(key, 0, 1)}); return ICustomRecipe::UnlockingRequirement({ICustomRecipe::Ingredient(key, 1, 0)});
} }
void Export_Legacy_GMLib_ModAPI() { void Export_Legacy_GMLib_ModAPI() {
@@ -19,18 +20,13 @@ void Export_Legacy_GMLib_ModAPI() {
std::string const& result, std::string const& result,
int count, int count,
std::string const& unlock) -> void { std::string const& unlock) -> void {
// if (!GMLIB_Level::getInstance().has_value()) return; if (!GMLevel::getInstance().has_value()) return;
// std::vector<RecipeIngredient> types; std::vector<ICustomRecipe::Ingredient> types;
// for (auto ing : ingredients) { for (auto& ing : ingredients) {
// types.emplace_back(ing, 0, 1); types.emplace_back(ICustomRecipe::Ingredient{ing, 1});
// } }
// GMLIB::Mod::JsonRecipe::registerShapelessCraftingTableRecipe( CustomRecipeRegistry::getInstance()
// recipe_id, .registerShapelessRecipe(recipe_id, types, ItemInstance(result, count), makeRecipeUnlockingKey(unlock));
// types,
// RecipeIngredient(result, 0, count),
// makeRecipeUnlockingKey(unlock)
// );
throw std::runtime_error("GMLib_ModAPI::registerShapelessRecipe is not implemented");
} }
); );
RemoteCall::exportAs( RemoteCall::exportAs(
@@ -42,19 +38,20 @@ void Export_Legacy_GMLib_ModAPI() {
std::string const& result, std::string const& result,
int count, int count,
std::string const& unlock) -> void { std::string const& unlock) -> void {
// if (!GMLIB_Level::getInstance().has_value()) return; if (!GMLevel::getInstance().has_value()) return;
// std::vector<RecipeIngredient> types; ICustomShapedRecipe::ShapedIngredients types;
// for (auto ing : ingredients) { char index = 'a';
// types.push_back(RecipeIngredient(ing, 0, 1)); for (auto& ing : ingredients) {
// } types.add(std::string{index++}, ICustomRecipe::Ingredient{ing, 1});
// GMLIB::Mod::JsonRecipe::registerShapedCraftingTableRecipe( }
// recipe_id, CustomRecipeRegistry::getInstance().registerShapedRecipe(
// shape, recipe_id,
// types, shape,
// RecipeIngredient(result, 0, count), types,
// makeRecipeUnlockingKey(unlock) ItemInstance(result, count),
// ); makeRecipeUnlockingKey(unlock)
throw std::runtime_error("GMLib_ModAPI::registerShapedRecipe is not implemented"); );
} }
); );
RemoteCall::exportAs( RemoteCall::exportAs(
@@ -64,14 +61,9 @@ void Export_Legacy_GMLib_ModAPI() {
std::string const& input, std::string const& input,
std::string const& output, std::string const& output,
std::vector<std::string> tags) -> void { std::vector<std::string> tags) -> void {
// if (!GMLIB_Level::getInstance().has_value()) return; if (!GMLevel::getInstance().has_value()) return;
// GMLIB::Mod::JsonRecipe::registerFurnaceRecipe( CustomRecipeRegistry::getInstance()
// recipe_id, .registerFurnaceRecipe(ICustomRecipe::Ingredient{input}, ItemInstance{output}, tags);
// RecipeIngredient(input, 0, 1),
// RecipeIngredient(output, 0, 1),
// tags
// );
throw std::runtime_error("GMLib_ModAPI::registerFurnaceRecipe is not implemented");
} }
); );
RemoteCall::exportAs( RemoteCall::exportAs(
@@ -79,10 +71,12 @@ void Export_Legacy_GMLib_ModAPI() {
"registerBrewingMixRecipe", "registerBrewingMixRecipe",
[](std::string const& recipe_id, std::string const& input, std::string const& output, std::string const& reagent [](std::string const& recipe_id, std::string const& input, std::string const& output, std::string const& reagent
) -> void { ) -> void {
// if (!GMLIB_Level::getInstance().has_value()) return; if (!GMLevel::getInstance().has_value()) return;
// GMLIB::Mod::JsonRecipe::registerBrewingMixRecipe(recipe_id, input, output, RecipeIngredient(reagent, 0, CustomRecipeRegistry::getInstance().registerBrewingRecipe(
// 1)); ICustomRecipe::Ingredient{input},
throw std::runtime_error("GMLib_ModAPI::registerBrewingMixRecipe is not implemented"); ICustomRecipe::Ingredient{reagent},
ICustomRecipe::Ingredient{output}
);
} }
); );
RemoteCall::exportAs( RemoteCall::exportAs(
@@ -90,14 +84,12 @@ void Export_Legacy_GMLib_ModAPI() {
"registerBrewingContainerRecipe", "registerBrewingContainerRecipe",
[](std::string const& recipe_id, std::string const& input, std::string const& output, std::string const& reagent [](std::string const& recipe_id, std::string const& input, std::string const& output, std::string const& reagent
) -> void { ) -> void {
// if (!GMLIB_Level::getInstance().has_value()) return; if (!GMLevel::getInstance().has_value()) return;
// GMLIB::Mod::JsonRecipe::registerBrewingContainerRecipe( CustomRecipeRegistry::getInstance().registerBrewingRecipe(
// recipe_id, ICustomRecipe::Ingredient{input},
// RecipeIngredient(input, 0, 1), ICustomRecipe::Ingredient{reagent},
// RecipeIngredient(output, 0, 1), ICustomRecipe::Ingredient{output}
// RecipeIngredient(reagent, 0, 1) );
// );
throw std::runtime_error("GMLib_ModAPI::registerBrewingContainerRecipe is not implemented");
} }
); );
RemoteCall::exportAs( RemoteCall::exportAs(
@@ -108,15 +100,14 @@ void Export_Legacy_GMLib_ModAPI() {
std::string const& base, std::string const& base,
std::string const& addition, std::string const& addition,
std::string const& result) -> void { std::string const& result) -> void {
// if (!GMLIB_Level::getInstance().has_value()) return; if (!GMLevel::getInstance().has_value()) return;
// GMLIB::Mod::JsonRecipe::registerSmithingTransformRecipe( CustomRecipeRegistry::getInstance().registerSmithingTransformRecipe(
// recipe_id, recipe_id,
// smithing_template, ICustomRecipe::Ingredient{smithing_template},
// base, ICustomRecipe::Ingredient{base},
// addition, ICustomRecipe::Ingredient{addition},
// result ItemInstance{result}
// ); );
throw std::runtime_error("GMLib_ModAPI::registerSmithingTransformRecipe is not implemented");
} }
); );
RemoteCall::exportAs( RemoteCall::exportAs(
@@ -126,9 +117,13 @@ void Export_Legacy_GMLib_ModAPI() {
std::string const& smithing_template, std::string const& smithing_template,
std::string const& base, std::string const& base,
std::string const& addition) -> void { std::string const& addition) -> void {
// if (!GMLIB_Level::getInstance().has_value()) return; if (!GMLevel::getInstance().has_value()) return;
// GMLIB::Mod::JsonRecipe::registerSmithingTrimRecipe(recipe_id, smithing_template, base, addition); CustomRecipeRegistry::getInstance().registerSmithingTrimRecipe(
throw std::runtime_error("GMLib_ModAPI::registerSmithingTrimRecipe is not implemented"); recipe_id,
ICustomRecipe::Ingredient{smithing_template},
ICustomRecipe::Ingredient{base},
ICustomRecipe::Ingredient{addition}
);
} }
); );
RemoteCall::exportAs( RemoteCall::exportAs(
@@ -140,19 +135,17 @@ void Export_Legacy_GMLib_ModAPI() {
std::string const& output, std::string const& output,
int output_data, int output_data,
int output_count) -> void { int output_count) -> void {
// if (!GMLIB_Level::getInstance().has_value()) return; if (!GMLevel::getInstance().has_value()) return;
// GMLIB::Mod::JsonRecipe::registerStoneCutterRecipe( CustomRecipeRegistry::getInstance().registerStoneCutterRecipe(
// recipe_id, recipe_id,
// RecipeIngredient(input, 0, 1), ICustomRecipe::Ingredient{input, 1, input_data},
// RecipeIngredient(output, 0, 1) {output, output_count, output_data}
// ); );
throw std::runtime_error("GMLib_ModAPI::registerStoneCutterRecipe is not implemented");
} }
); );
// 错误方块清理 // 错误方块清理
RemoteCall::exportAs("GMLib_ModAPI", "setUnknownBlockCleaner", []() -> void { RemoteCall::exportAs("GMLib_ModAPI", "setUnknownBlockCleaner", []() -> void {
// GMLIB::Mod::VanillaFix::setAutoCleanUnknownBlockEnabled(); getLogger().error("setUnknownBlockCleaner is not implemented");
throw std::runtime_error("GMLib_ModAPI::setUnknownBlockCleaner is not implemented");
}); });
// 实验性 // 实验性
RemoteCall::exportAs("GMLib_ModAPI", "registerExperimentsRequire", [](int experiment_id) -> void { RemoteCall::exportAs("GMLib_ModAPI", "registerExperimentsRequire", [](int experiment_id) -> void {
@@ -172,8 +165,5 @@ void Export_Legacy_GMLib_ModAPI() {
.transform([&](GMLevel& level) { return level.getExperimentEnabled((AllExperiments)experiment_id); }) .transform([&](GMLevel& level) { return level.getExperimentEnabled((AllExperiments)experiment_id); })
.value_or(false); .value_or(false);
}); });
RemoteCall::exportAs("GMLib_ModAPI", "setFixI18nEnabled", []() -> void { RemoteCall::exportAs("GMLib_ModAPI", "setFixI18nEnabled", []() -> void {});
// GMLIB::Mod::VanillaFix::setFixI18nEnabled();
throw std::runtime_error("GMLib_ModAPI::setFixI18nEnabled is not implemented");
});
} }
+6 -12
View File
@@ -2,24 +2,19 @@
void Export_Legacy_GMLib_ServerAPI() { void Export_Legacy_GMLib_ServerAPI() {
RemoteCall::exportAs("GMLib_ServerAPI", "setEducationFeatureEnabled", []() -> void { RemoteCall::exportAs("GMLib_ServerAPI", "setEducationFeatureEnabled", []() -> void {
// GMLIB_Level::tryEnableEducationEdition(); getLogger().error("GMLib_ServerAPI::setEducationFeatureEnabled is not implemented");
throw std::runtime_error("GMLib_ServerAPI::setEducationFeatureEnabled is not implemented");
}); });
RemoteCall::exportAs("GMLib_ServerAPI", "registerAbilityCommand", []() -> void { RemoteCall::exportAs("GMLib_ServerAPI", "registerAbilityCommand", []() -> void {
// GMLIB_Level::tryRegisterAbilityCommand(); getLogger().error("GMLib_ServerAPI::registerAbilityCommand is not implemented");
throw std::runtime_error("GMLib_ServerAPI::registerAbilityCommand is not implemented");
}); });
RemoteCall::exportAs("GMLib_ServerAPI", "setEnableAchievement", []() -> void { RemoteCall::exportAs("GMLib_ServerAPI", "setEnableAchievement", []() -> void {
// GMLIB_Level::setForceAchievementsEnabled(); getLogger().error("GMLib_ServerAPI::setEnableAchievement is not implemented");
throw std::runtime_error("GMLib_ServerAPI::setEnableAchievement is not implemented");
}); });
RemoteCall::exportAs("GMLib_ServerAPI", "setForceTrustSkins", []() -> void { RemoteCall::exportAs("GMLib_ServerAPI", "setForceTrustSkins", []() -> void {
// GMLIB_Level::trustAllSkins(); getLogger().error("GMLib_ServerAPI::setForceTrustSkins is not implemented");
throw std::runtime_error("GMLib_ServerAPI::setForceTrustSkins is not implemented");
}); });
RemoteCall::exportAs("GMLib_ServerAPI", "enableCoResourcePack", []() -> void { RemoteCall::exportAs("GMLib_ServerAPI", "enableCoResourcePack", []() -> void {
// GMLIB_Level::requireServerResourcePackAndAllowClientResourcePack(); getLogger().error("GMLib_ServerAPI::enableCoResourcePack is not implemented");
throw std::runtime_error("GMLib_ServerAPI::enableCoResourcePack is not implemented");
}); });
RemoteCall::exportAs("GMLib_ServerAPI", "getLevelName", []() -> std::string { RemoteCall::exportAs("GMLib_ServerAPI", "getLevelName", []() -> std::string {
return GMLevel::getInstance().transform( return GMLevel::getInstance().transform(
@@ -37,8 +32,7 @@ void Export_Legacy_GMLib_ServerAPI() {
.value_or(""); .value_or("");
}); });
RemoteCall::exportAs("GMLib_ServerAPI", "setFakeSeed", [](int64_t seed) -> void { RemoteCall::exportAs("GMLib_ServerAPI", "setFakeSeed", [](int64_t seed) -> void {
// return GMLIB_Level::setFakeSeed(seed); getLogger().error("GMLib_ServerAPI::setFakeSeed is not implemented");
throw std::runtime_error("GMLib_ServerAPI::setFakeSeed is not implemented");
}); });
RemoteCall::exportAs( RemoteCall::exportAs(
"GMLib_ServerAPI", "GMLib_ServerAPI",
+3 -3
View File
@@ -10,7 +10,6 @@ end
add_requires("levilamina", {configs = {target_type = "server"}}) add_requires("levilamina", {configs = {target_type = "server"}})
add_requires("legacyremotecall") add_requires("legacyremotecall")
add_requires("gmlib")
add_requires("levibuildscript") add_requires("levibuildscript")
add_requires("ilistenattentively") add_requires("ilistenattentively")
@@ -28,12 +27,13 @@ target("GMLIB-LegacyRemoteCallApi")
"src/**.cpp" "src/**.cpp"
) )
add_includedirs( add_includedirs(
"src" "src",
"../GMLIB/bin/SDK/include"
) )
add_links("../GMLIB/bin/SDK/lib/GMLIB.lib")
add_packages( add_packages(
"levilamina", "levilamina",
"legacyremotecall", "legacyremotecall",
"gmlib",
"ilistenattentively" "ilistenattentively"
) )
add_rules("@levibuildscript/linkrule") add_rules("@levibuildscript/linkrule")