Compare commits
10 Commits
v1.0.0-rc.1
...
v1.0.0
+40
-3
@@ -2,13 +2,50 @@
|
||||
* @returns {string}
|
||||
*/
|
||||
const getPluginName = () => {
|
||||
// quickjs
|
||||
try {
|
||||
throw new Error("getPluginName");
|
||||
} catch (error) {
|
||||
return error.stack.trim().match(/plugins\\(.*)\\.*\.js:[0-9]+\)$/i)?.[1]
|
||||
|| error.stack.trim().match(/at <anonymous> \(([^\\|/]+)(.*?):\d+:\d+\)$/i)?.[1]
|
||||
|| "Unknown";
|
||||
const /** @type {string} */ line = error.stack.trim().split("\n").pop().trim();
|
||||
if (line.includes("<anonymous>")) {
|
||||
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 = {
|
||||
|
||||
+6
-7
@@ -256,7 +256,7 @@ const GMLIB_API = {
|
||||
blockPlayerWillDestroy: ll.import("GMLIB_API", "blockPlayerWillDestroy"),
|
||||
/** 使玩家攻击实体 @type {function(Entity,Player):boolean} */
|
||||
playerAttack: ll.import("GMLIB_API", "playerAttack"),
|
||||
/** @type {function(Player,Entity):boolean} */
|
||||
/** @type {function(Player,Entity):void} */
|
||||
playerPullInEntity: ll.import("GMLIB_API", "playerPullInEntity"),
|
||||
/** 根据命令空间获取翻译键名 @type {function(string):string} */
|
||||
getBlockTranslateKeyFromName: ll.import("GMLIB_API", "getBlockTranslateKeyFromName"),
|
||||
@@ -2291,14 +2291,14 @@ class GMLIB_BinaryStream {
|
||||
this.writeUnsignedVarInt(data.id);
|
||||
this.writeUnsignedVarInt(data.type);
|
||||
switch (data.type) {
|
||||
case 0: this.writeByte(data.value); break;
|
||||
case 1: this.writeSignedShort(data.value); break;
|
||||
case 2: this.writeSignedInt(data.value); break;
|
||||
case 0: this.writeUnsignedChar(data.value); break;
|
||||
case 1: this.writeUnsignedShort(data.value); break;
|
||||
case 2: this.writeVarInt(data.value); break;
|
||||
case 3: this.writeFloat(data.value); break;
|
||||
case 4: this.writeString(data.value); break;
|
||||
case 5: this.writeCompoundTag(data.value); break;
|
||||
case 6: this.writeBlockPos(data.value); break;
|
||||
case 7: this.writeSignedInt64(data.value); break;
|
||||
case 7: this.writeVarInt64(data.value); break;
|
||||
case 8: this.writeVec3(data.value); break;
|
||||
default: throw new Error("Unknown data type");
|
||||
}
|
||||
@@ -2739,10 +2739,9 @@ LLSE_Player.prototype.pullInEntity =
|
||||
/**
|
||||
*
|
||||
* @param {Entity} entity 实体对象
|
||||
* @returns {boolean}
|
||||
*/
|
||||
function (entity) {
|
||||
return GMLIB_API.playerPullInEntity(this, entity);
|
||||
GMLIB_API.playerPullInEntity(this, entity);
|
||||
};
|
||||
|
||||
LLSE_Item.prototype.applyEnchant =
|
||||
|
||||
+40
-3
@@ -1,13 +1,50 @@
|
||||
/// <reference path='d:/dts/dts/helperlib/src/index.d.ts'/>
|
||||
|
||||
const getPluginName = () => {
|
||||
// quickjs
|
||||
try {
|
||||
throw new Error("getPluginName");
|
||||
} catch (error) {
|
||||
return error.stack.trim().match(/plugins\\(.*)\\.*\.js:[0-9]+\)$/i)?.[1]
|
||||
|| error.stack.trim().match(/at <anonymous> \(([^\\|/]+)(.*?):\d+:\d+\)$/i)?.[1]
|
||||
|| "Unknown";
|
||||
const /** @type {string} */ line = error.stack.trim().split("\n").pop().trim();
|
||||
if (line.includes("<anonymous>")) {
|
||||
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 =
|
||||
|
||||
+4
-1
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "${pluginName}",
|
||||
"entry": "${pluginFile}",
|
||||
"version": "1.0.0-rc.1",
|
||||
"version": "1.0.0",
|
||||
"author": "GroupMountain",
|
||||
"type": "native",
|
||||
"passive": true,
|
||||
@@ -11,6 +11,9 @@
|
||||
},
|
||||
{
|
||||
"name": "LegacyRemoteCall"
|
||||
},
|
||||
{
|
||||
"name": "iListenAttentively"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,6 +1,4 @@
|
||||
#include "Global.h"
|
||||
#include <gmlib/mc/network/BinaryStream.h>
|
||||
#include <mc/world/item/NetworkItemStackDescriptor.h>
|
||||
|
||||
class LegacyScriptBinaryStreamManager {
|
||||
private:
|
||||
|
||||
+63
-65
@@ -2,16 +2,15 @@
|
||||
#include <regex>
|
||||
|
||||
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() {
|
||||
RemoteCall::exportAs("GMLIB_API", "unregisterRecipe", [](std::string const& id) -> bool {
|
||||
// return GMLevel::getInstance().has_value() ? GMLIB::Mod::CustomRecipe::unregisterRecipe(id) : false;
|
||||
throw std::runtime_error("GMLIB_API::unregisterRecipe is not implemented");
|
||||
return CustomRecipeRegistry::getInstance().unregisterRecipe(id, true);
|
||||
});
|
||||
RemoteCall::exportAs("GMLIB_API", "setCustomPackPath", [](std::string const& path) -> void {
|
||||
AddonsLoaderUtils::addCustomPackPath(path);
|
||||
AddonsLoader::addCustomPackPath(path);
|
||||
});
|
||||
RemoteCall::exportAs("GMLIB_API", "getServerMspt", []() -> double {
|
||||
return GMLevel::getInstance().transform(
|
||||
@@ -19,14 +18,14 @@ void Export_Compatibility_API() {
|
||||
).value_or(0.0);
|
||||
});
|
||||
RemoteCall::exportAs("GMLIB_API", "getServerCurrentTps", []() -> float {
|
||||
return GMLevel::getInstance()
|
||||
.transform([](GMLevel& level) -> float { return level.getServerCurrentTps(); })
|
||||
.value_or(0.0);
|
||||
return GMLevel::getInstance().transform(
|
||||
[](GMLevel& level) -> float { return level.getServerCurrentTps(); }
|
||||
).value_or(0.0);
|
||||
});
|
||||
RemoteCall::exportAs("GMLIB_API", "getServerAverageTps", []() -> double {
|
||||
return GMLevel::getInstance()
|
||||
.transform([](GMLevel& level) -> double { return level.getServerAverageTps(); })
|
||||
.value_or(0.0);
|
||||
return GMLevel::getInstance().transform(
|
||||
[](GMLevel& level) -> double { return level.getServerAverageTps(); }
|
||||
).value_or(0.0);
|
||||
});
|
||||
RemoteCall::exportAs("GMLIB_API", "getAllPlayerUuids", []() -> std::vector<std::string> {
|
||||
std::vector<std::string> result;
|
||||
@@ -66,20 +65,21 @@ void Export_Compatibility_API() {
|
||||
return OfflinePlayer::deletePlayerNbt(mce::UUID::fromString(uuid));
|
||||
});
|
||||
RemoteCall::exportAs("GMLIB_API", "getAllExperiments", []() -> std::vector<int> {
|
||||
// std::vector<int> result;
|
||||
// for (auto& key : GMLevel::getAllExperiments()) {
|
||||
// result.push_back((int)key);
|
||||
// }
|
||||
// return result;
|
||||
throw std::runtime_error("GMLIB_API::getAllExperiments is not implemented");
|
||||
return {36, 45, 38, 48, 47, 53, 56, 45, 40};
|
||||
});
|
||||
RemoteCall::exportAs("GMLIB_API", "getExperimentTranslateKey", [](int id) -> std::string {
|
||||
// std::string result;
|
||||
// try {
|
||||
// result = Experiments::getExperimentTextID(AllExperiments(id));
|
||||
// } catch (...) {}
|
||||
// return result;
|
||||
throw std::runtime_error("GMLIB_API::getExperimentTranslateKey is not implemented");
|
||||
static std::unordered_map<int, std::string> mMap = {
|
||||
{36, "createWorldScreen.experimentalbiomes" },
|
||||
{45, "createWorldScreen.experimentalCreatorFeatures" },
|
||||
{38, "createWorldScreen.experimentalGameTest" },
|
||||
{48, "createWorldScreen.experimentalThirdPersonCameras" },
|
||||
{47, "createWorldScreen.experimentalFocusTargetCamera" },
|
||||
{53, "createWorldScreen.experimentalVillagerTradesRebalance" },
|
||||
{56, "createWorldScreen.experimentalDataDrivenJigsawStructures"},
|
||||
{45, "createWorldScreen.experimentalCameraAimAssist" },
|
||||
{40, "createWorldScreen.experimentalY2025Drop1" }
|
||||
};
|
||||
return mMap.contains(id) ? mMap[id] : "";
|
||||
});
|
||||
RemoteCall::exportAs(
|
||||
"GMLIB_API",
|
||||
@@ -143,9 +143,13 @@ void Export_Compatibility_API() {
|
||||
}
|
||||
return false;
|
||||
});
|
||||
RemoteCall::exportAs("GMLIB_API", "isVersionMatched", [](std::uint16_t a, std::uint16_t b, std::uint16_t c) -> bool {
|
||||
RemoteCall::exportAs(
|
||||
"GMLIB_API",
|
||||
"isVersionMatched",
|
||||
[](std::uint16_t a, std::uint16_t b, std::uint16_t c) -> bool {
|
||||
return LIB_VERSION >= ll::data::Version(a, b, c, "", "");
|
||||
});
|
||||
}
|
||||
);
|
||||
RemoteCall::exportAs("GMLIB_API", "getVersion_LRCA", []() -> std::string { return LIB_VERSION.to_string(); });
|
||||
RemoteCall::exportAs("GMLIB_API", "getVersion_GMLIB", []() -> std::string {
|
||||
return GMLIB_VERSION_TO_STRING(GMLIB_VERSION_MAJOR) "." GMLIB_VERSION_TO_STRING(GMLIB_VERSION_MINOR
|
||||
@@ -209,8 +213,10 @@ void Export_Compatibility_API() {
|
||||
"GMLIB_API",
|
||||
"setPlayerPosition",
|
||||
[](std::string const& uuid, std::pair<BlockPos, int> pos) -> bool {
|
||||
// return GMPlayer::setPlayerPosition(mce::UUID::fromString(uuid), pos.first, pos.second);
|
||||
throw std::runtime_error("GMLIB_API::setPlayerPosition is not implemented");
|
||||
if (auto player = OfflinePlayer::getOfflinePlayer(mce::UUID::fromString(uuid))) {
|
||||
return player->setPosition(pos.first, pos.second);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
);
|
||||
RemoteCall::exportAs("GMLIB_API", "playerHasScore", [](std::string const& uuid, std::string const& obj) -> bool {
|
||||
@@ -448,17 +454,14 @@ void Export_Compatibility_API() {
|
||||
return true;
|
||||
});
|
||||
RemoteCall::exportAs("GMLIB_API", "getPlayerSpawnPoint", [](Player* pl) -> std::pair<BlockPos, int> {
|
||||
// auto res = ((GMPlayer*)pl)->getSpawnPoint();
|
||||
// return {res.first, res.second};
|
||||
throw std::runtime_error("GMLIB_API::getPlayerSpawnPoint is not implemented");
|
||||
return {pl->mPlayerRespawnPoint->mSpawnBlockPos, pl->mPlayerRespawnPoint->mDimension.get()};
|
||||
});
|
||||
RemoteCall::exportAs("GMLIB_API", "setPlayerSpawnPoint", [](Player* pl, std::pair<BlockPos, int> pos) -> void {
|
||||
// ((GMPlayer*)pl)->setSpawnPoint(pos.first, pos.second);
|
||||
throw std::runtime_error("GMLIB_API::setPlayerSpawnPoint is not implemented");
|
||||
pl->setRespawnPosition(pos.first, pos.second);
|
||||
});
|
||||
RemoteCall::exportAs("GMLIB_API", "clearPlayerSpawnPoint", [](Player* pl) -> void {
|
||||
// ((GMPlayer*)pl)->clearSpawnPoint();
|
||||
throw std::runtime_error("GMLIB_API::clearPlayerSpawnPoint is not implemented");
|
||||
pl->mPlayerRespawnPoint->mSpawnBlockPos = BlockPos::MIN();
|
||||
pl->mPlayerRespawnPoint->mDimension = VanillaDimensions::Undefined();
|
||||
});
|
||||
RemoteCall::exportAs(
|
||||
"GMLIB_API",
|
||||
@@ -483,14 +486,14 @@ void Export_Compatibility_API() {
|
||||
return UserCache::getNameByXuid(xuid).value_or("");
|
||||
});
|
||||
RemoteCall::exportAs("GMLIB_API", "getUuidByXuid", [](std::string const& xuid) -> std::string {
|
||||
return UserCache::getUuidByXuid(xuid)
|
||||
.transform([](mce::UUID&& uuid) -> std::string { return uuid.asString(); })
|
||||
.value_or("");
|
||||
return UserCache::getUuidByXuid(xuid).transform(
|
||||
[](mce::UUID&& uuid) -> std::string { return uuid.asString(); }
|
||||
).value_or("");
|
||||
});
|
||||
RemoteCall::exportAs("GMLIB_API", "getUuidByName", [](std::string const& name) -> std::string {
|
||||
return UserCache::getUuidByName(name)
|
||||
.transform([](mce::UUID&& uuid) -> std::string { return uuid.asString(); })
|
||||
.value_or("");
|
||||
return UserCache::getUuidByName(name).transform(
|
||||
[](mce::UUID&& uuid) -> std::string { return uuid.asString(); }
|
||||
).value_or("");
|
||||
});
|
||||
RemoteCall::exportAs(
|
||||
"GMLIB_API",
|
||||
@@ -513,7 +516,7 @@ void Export_Compatibility_API() {
|
||||
.value_or(0);
|
||||
});
|
||||
RemoteCall::exportAs("GMLIB_API", "getBlockTranslateKey", [](Block const* block) -> std::string {
|
||||
return block->getLegacyBlock().mDescriptionId;
|
||||
return block->getLegacyBlock().mDescriptionId.get() + ".name";
|
||||
});
|
||||
RemoteCall::exportAs("GMLIB_API", "getItemTranslateKey", [](ItemStack* item) -> std::string {
|
||||
return item->getDescriptionId();
|
||||
@@ -542,8 +545,7 @@ void Export_Compatibility_API() {
|
||||
return block->mDirectData->mUnkc08fbd.as<float>();
|
||||
});
|
||||
RemoteCall::exportAs("GMLIB_API", "getDestroyBlockSpeed", [](ItemStack const* item, Block const* block) -> float {
|
||||
// return item->getDestroySpeed(*block);
|
||||
throw std::runtime_error("GMLIB_API::getDestroyBlockSpeed is not implemented");
|
||||
return item->getItem()->getDestroySpeed(*item, *block);
|
||||
});
|
||||
RemoteCall::exportAs(
|
||||
"GMLIB_API",
|
||||
@@ -564,8 +566,7 @@ void Export_Compatibility_API() {
|
||||
return false;
|
||||
});
|
||||
RemoteCall::exportAs("GMLIB_API", "itemCanDestroySpecial", [](ItemStack const* item, Block const* block) -> bool {
|
||||
// return item->canDestroySpecial(*block);
|
||||
throw std::runtime_error("GMLIB_API::itemCanDestroySpecial is not implemented");
|
||||
return item->getItem()->canDestroySpecial(*block);
|
||||
});
|
||||
RemoteCall::exportAs("GMLIB_API", "blockCanDropWithAnyTool", [](Block const* block) -> bool {
|
||||
return !block->getLegacyBlock().mRequiresCorrectToolForDrops;
|
||||
@@ -580,9 +581,10 @@ void Export_Compatibility_API() {
|
||||
RemoteCall::exportAs("GMLIB_API", "playerAttack", [](Player* player, Actor* entity) -> bool {
|
||||
return player->attack(*entity, SharedTypes::Legacy::ActorDamageCause::EntityAttack);
|
||||
});
|
||||
RemoteCall::exportAs("GMLIB_API", "playerPullInEntity", [](Player* player, Actor* entity) -> bool {
|
||||
// return player->pullInEntity(*entity);
|
||||
throw std::runtime_error("GMLIB_API::playerPullInEntity is not implemented");
|
||||
RemoteCall::exportAs("GMLIB_API", "playerPullInEntity", [](Player* player, Actor* entity) -> void {
|
||||
if (auto component = player->getEntityContext().tryGetComponent<RideableComponent>()){
|
||||
component->pullInEntity(*player, *entity);
|
||||
}
|
||||
});
|
||||
RemoteCall::exportAs("GMLIB_API", "getBlockTranslateKeyFromName", [](std::string const& blockName) -> std::string {
|
||||
return Block::tryGetFromRegistry(blockName)
|
||||
@@ -651,9 +653,7 @@ void Export_Compatibility_API() {
|
||||
);
|
||||
}
|
||||
);
|
||||
RemoteCall::exportAs("GMLIB_API", "removeEnchants", [](ItemStack* item) -> void {
|
||||
item->removeEnchants();
|
||||
});
|
||||
RemoteCall::exportAs("GMLIB_API", "removeEnchants", [](ItemStack* item) -> void { item->removeEnchants(); });
|
||||
RemoteCall::exportAs("GMLIB_API", "hasEnchant", [](ItemStack* item, std::string const& typeName) -> bool {
|
||||
return EnchantUtils::hasEnchant(Enchant::mEnchantNameToType()[HashedString(typeName)], *item);
|
||||
});
|
||||
@@ -803,7 +803,9 @@ void Export_Compatibility_API() {
|
||||
return magic_enum::enum_name(container->mContainerType).data();
|
||||
});
|
||||
RemoteCall::exportAs("GMLIB_API", "hasPlayerNbt", [](std::string const& uuid) -> bool {
|
||||
return OfflinePlayer::getOfflinePlayer(mce::UUID::fromString(uuid)).transform([&](auto&& player) -> bool { return player.hasNbt(); }).value_or(false);
|
||||
return OfflinePlayer::getOfflinePlayer(mce::UUID::fromString(uuid))
|
||||
.transform([&](auto&& player) -> bool { return player.hasNbt(); })
|
||||
.value_or(false);
|
||||
});
|
||||
RemoteCall::exportAs("GMLIB_API", "getItemMaxCount", [](ItemStack const* item) -> int {
|
||||
return item->getMaxStackSize();
|
||||
@@ -892,20 +894,16 @@ void Export_Compatibility_API() {
|
||||
"GMLIB_API",
|
||||
"registerCustomShapelessRecipe",
|
||||
[](std::string const& recipe_id, std::vector<std::string> ingredients, ItemStack* result) -> void {
|
||||
// if (!GMLevel::getInstance().has_value()) return;
|
||||
// std::vector<Recipes::Type> types;
|
||||
// char rt = 'A';
|
||||
// for (auto& ing : ingredients) {
|
||||
// auto ingredient = RecipeIngredient{ing, 0,1};
|
||||
// types.push_back(Recipes::Type{
|
||||
// (Item*)ingredient.getItem(),
|
||||
// ingredient.getBlock(),
|
||||
// ingredient,
|
||||
// rt++
|
||||
// });
|
||||
// }
|
||||
// GMLIB::Mod::CustomRecipe::registerShapelessCraftingTableRecipe(recipe_id, types, *result);
|
||||
throw std::runtime_error("GMLIB_API::registerCustomShapelessRecipe is not implemented");
|
||||
if (!GMLevel::getInstance().has_value()) return;
|
||||
std::vector<ICustomRecipe::Ingredient> types;
|
||||
for (auto& ing : ingredients) {
|
||||
types.push_back(ICustomRecipe::Ingredient{ing});
|
||||
}
|
||||
CustomRecipeRegistry::getInstance().registerShapelessRecipe(
|
||||
recipe_id,
|
||||
types,
|
||||
ItemInstance(*result->getItem(), result->mCount, result->mAuxValue, result->mUserData.get())
|
||||
);
|
||||
}
|
||||
);
|
||||
RemoteCall::exportAs(
|
||||
|
||||
+4
-1
@@ -9,11 +9,12 @@ LegacyRemoteCallApi& LegacyRemoteCallApi::getInstance() {
|
||||
}
|
||||
|
||||
bool LegacyRemoteCallApi::load() {
|
||||
(void)CustomRecipeRegistry::getInstance();
|
||||
Export_Legacy_GMLib_ModAPI();
|
||||
Export_Legacy_GMLib_ServerAPI();
|
||||
Export_Compatibility_API();
|
||||
ExportPAPI();
|
||||
// Export_Event_API();
|
||||
Export_Event_API();
|
||||
Export_BinaryStream_API();
|
||||
// Export_Form_API();
|
||||
auto logger = ll::io::LoggerRegistry::getInstance().getOrCreate(PLUGIN_NAME);
|
||||
@@ -40,3 +41,5 @@ LL_REGISTER_MOD(gmlib::LegacyRemoteCallApi, gmlib::LegacyRemoteCallApi::getInsta
|
||||
ll::thread::ThreadPoolExecutor const& getThreadPoolExecutor() {
|
||||
return gmlib::LegacyRemoteCallApi::getInstance().getThreadPoolExecutor();
|
||||
}
|
||||
|
||||
ll::io::Logger& getLogger() { return gmlib::LegacyRemoteCallApi::getInstance().getSelf().getLogger(); }
|
||||
+134
-160
@@ -88,10 +88,7 @@ void Export_Event_API() {
|
||||
std::string const& uuid,
|
||||
std::string const& serverXuid,
|
||||
std::string const& clientXuid),
|
||||
(event.realName(),
|
||||
event.uuid().asString(),
|
||||
event.serverAuthXuid(),
|
||||
event.clientAuthXuid()),
|
||||
(event.realName(), event.uuid().asString(), event.serverAuthXuid(), event.clientAuthXuid()),
|
||||
if (result) event.disConnectClient();
|
||||
);
|
||||
}
|
||||
@@ -116,12 +113,10 @@ void Export_Event_API() {
|
||||
);
|
||||
}
|
||||
case doHash("gmlib::MobPickupItemBeforeEvent"): {
|
||||
REGISTER_EVENT_LISTEN(
|
||||
ila::mc::ActorPickupItemBeforeEvent,
|
||||
REGISTER_EVENT_LISTEN(ila::mc::ActorPickupItemBeforeEvent,
|
||||
(Actor * mob, Actor * item, bool isCancelled),
|
||||
(&event.self(), (Actor*)&event.itemActor(), event.isCancelled()),
|
||||
event.setCancelled(result);
|
||||
);
|
||||
event.setCancelled(result););
|
||||
}
|
||||
case doHash("gmlib::MobPickupItemAfterEvent"): {
|
||||
REGISTER_EVENT_LISTEN(
|
||||
@@ -146,19 +141,17 @@ void Export_Event_API() {
|
||||
REGISTER_EVENT_LISTEN(
|
||||
ila::mc::SpawnItemActorAfterEvent,
|
||||
(Actor * item, std::pair<Vec3, int> position, int64 spawnerUniqueId),
|
||||
(event.itemActor(),
|
||||
(&event.itemActor(),
|
||||
{event.pos(), event.blockSource().getDimensionId().id},
|
||||
event.spawner() ? event.spawner()->getOrCreateUniqueID().rawID : -1),
|
||||
,
|
||||
);
|
||||
}
|
||||
case doHash("gmlib::ActorChangeDimensionBeforeEvent"): {
|
||||
REGISTER_EVENT_LISTEN(
|
||||
ila::mc::ActorChangeDimensionBeforeEvent,
|
||||
REGISTER_EVENT_LISTEN(ila::mc::ActorChangeDimensionBeforeEvent,
|
||||
(Actor * entity, int toDimId, bool isCancelled),
|
||||
(&event.self(), event.toDimensionId(), event.isCancelled()),
|
||||
event.setCancelled(result);
|
||||
);
|
||||
event.setCancelled(result););
|
||||
}
|
||||
case doHash("gmlib::ActorChangeDimensionAfterEvent"): {
|
||||
REGISTER_EVENT_LISTEN(
|
||||
@@ -168,38 +161,38 @@ void Export_Event_API() {
|
||||
,
|
||||
);
|
||||
}
|
||||
// case doHash("gmlib::PlayerStartSleepBeforeEvent"): {
|
||||
// REGISTER_EVENT_LISTEN(
|
||||
// GMLIB::Event::PlayerEvent::PlayerStartSleepBeforeEvent,
|
||||
// (Player * entity, BlockPos pos, bool isCancelled),
|
||||
// (&event.self(), event.getPosition(), event.isCancelled()),
|
||||
// event.setCancelled(result);
|
||||
// );
|
||||
// }
|
||||
// case doHash("gmlib::PlayerStartSleepAfterEvent"): {
|
||||
// REGISTER_EVENT_LISTEN(
|
||||
// GMLIB::Event::PlayerEvent::PlayerStartSleepAfterEvent,
|
||||
// (Player * entity, BlockPos pos, int result),
|
||||
// (&event.self(), event.getPosition(), (int)event.getResult()),
|
||||
// ,
|
||||
// );
|
||||
// }
|
||||
// case doHash("gmlib::PlayerStopSleepBeforeEvent"): {
|
||||
// REGISTER_EVENT_LISTEN(
|
||||
// GMLIB::Event::PlayerEvent::PlayerStopSleepBeforeEvent,
|
||||
// (Player * entity, bool forcefulWakeUp, bool updateLevelList, bool isCancelled),
|
||||
// (&event.self(), event.isForcefulWakeUp(), event.isUpdateLevelList(), event.isCancelled()),
|
||||
// event.setCancelled(result);
|
||||
// );
|
||||
// }
|
||||
// case doHash("gmlib::PlayerStopSleepAfterEvent"): {
|
||||
// REGISTER_EVENT_LISTEN(
|
||||
// GMLIB::Event::PlayerEvent::PlayerStopSleepAfterEvent,
|
||||
// (Player * entity, bool forcefulWakeUp, bool updateLevelList, bool),
|
||||
// (&event.self(), event.isForcefulWakeUp(), event.isUpdateLevelList(), false),
|
||||
// ,
|
||||
// );
|
||||
// }
|
||||
case doHash("gmlib::PlayerStartSleepBeforeEvent"): {
|
||||
REGISTER_EVENT_LISTEN(
|
||||
ila::mc::PlayerStartSleepBeforeEvent,
|
||||
(Player * entity, BlockPos pos, bool isCancelled),
|
||||
(&event.self(), event.pos(), event.isCancelled()),
|
||||
event.setCancelled(result);
|
||||
);
|
||||
}
|
||||
case doHash("gmlib::PlayerStartSleepAfterEvent"): {
|
||||
REGISTER_EVENT_LISTEN(
|
||||
ila::mc::PlayerStartSleepAfterEvent,
|
||||
(Player * entity, BlockPos pos, int result),
|
||||
(&event.self(), event.pos(), (int)event.result()),
|
||||
,
|
||||
);
|
||||
}
|
||||
case doHash("gmlib::PlayerStopSleepBeforeEvent"): {
|
||||
REGISTER_EVENT_LISTEN(
|
||||
ila::mc::PlayerStopSleepBeforeEvent,
|
||||
(Player * entity, bool forcefulWakeUp, bool updateLevelList, bool isCancelled),
|
||||
(&event.self(), event.forcefulWakeUp(), event.updateLevelList(), false),
|
||||
|
||||
);
|
||||
}
|
||||
case doHash("gmlib::PlayerStopSleepAfterEvent"): {
|
||||
REGISTER_EVENT_LISTEN(
|
||||
ila::mc::PlayerStopSleepAfterEvent,
|
||||
(Player * entity, bool forcefulWakeUp, bool updateLevelList, bool),
|
||||
(&event.self(), event.forcefulWakeUp(), event.updateLevelList(), false),
|
||||
,
|
||||
);
|
||||
}
|
||||
case doHash("gmlib::DeathMessageAfterEvent"): {
|
||||
REGISTER_EVENT_LISTEN(
|
||||
ila::mc::DeathMessageAfterEvent,
|
||||
@@ -208,68 +201,55 @@ void Export_Event_API() {
|
||||
,
|
||||
);
|
||||
}
|
||||
// case doHash("gmlib::MobHurtAfterEvent"): {
|
||||
// REGISTER_EVENT_LISTEN(
|
||||
// GMLIB::Event::EntityEvent::MobHurtAfterEvent,
|
||||
// (Actor * mob, Actor * source, float damage, int cause),
|
||||
// (&event.self(), source, -event.getDamage(), (int)damageSource.getCause()),
|
||||
// ,
|
||||
// auto& damageSource = event.getSource();
|
||||
// Actor* source = nullptr;
|
||||
// if (damageSource.isEntitySource()) {
|
||||
// auto uniqueId = damageSource.getDamagingEntityUniqueID();
|
||||
// source = ll::service::getLevel()->fetchEntity(uniqueId, false);
|
||||
// if (source->getOwner()) source = source->getOwner();
|
||||
// }
|
||||
// );
|
||||
// }
|
||||
case doHash("gmlib::EndermanTakeBlockBeforeEvent"): {
|
||||
case doHash("gmlib::MobHurtAfterEvent"): {
|
||||
REGISTER_EVENT_LISTEN(
|
||||
ila::mc::EndermanTakeBlockBeforeEvent,
|
||||
ila::mc::MobHealthChangeAfterEvent,
|
||||
(Actor * mob, Actor * source, float damage, int cause),
|
||||
(&event.self(), source, event.oldValue() - event.newValue(), (int)damageSource->mCause),
|
||||
,
|
||||
if (event.newValue() > event.oldValue()) return;
|
||||
auto& damageSource = event.buff().mSource;
|
||||
Actor* source = nullptr;
|
||||
if (damageSource->isEntitySource()) {
|
||||
auto uniqueId = damageSource->getDamagingEntityUniqueID();
|
||||
source = ll::service::getLevel()->fetchEntity(uniqueId, false);
|
||||
if (source->getOwner()) source = source->getOwner();
|
||||
}
|
||||
);
|
||||
}
|
||||
case doHash("gmlib::EndermanTakeBlockBeforeEvent"): {
|
||||
REGISTER_EVENT_LISTEN(ila::mc::EndermanTakeBlockBeforeEvent,
|
||||
(Actor * mob, bool isCancelled),
|
||||
(&event.self(), event.isCancelled()),
|
||||
event.setCancelled(result);
|
||||
);
|
||||
event.setCancelled(result););
|
||||
}
|
||||
case doHash("gmlib::DragonRespawnBeforeEvent"): {
|
||||
REGISTER_EVENT_LISTEN(
|
||||
ila::mc::DragonRespawnBeforeEvent,
|
||||
REGISTER_EVENT_LISTEN(ila::mc::DragonRespawnBeforeEvent,
|
||||
(bool isCancelled),
|
||||
(event.isCancelled()),
|
||||
event.setCancelled(result);
|
||||
);
|
||||
event.setCancelled(result););
|
||||
}
|
||||
case doHash("gmlib::DragonRespawnAfterEvent"): {
|
||||
REGISTER_EVENT_LISTEN(ila::mc::DragonRespawnAfterEvent, (Actor * mob), (&event.self()), );
|
||||
}
|
||||
case doHash("gmlib::ProjectileCreateBeforeEvent"): {
|
||||
REGISTER_EVENT_LISTEN(ila::mc::ProjectileCreateBeforeEvent,
|
||||
(Actor * mob, int64 uniqueId, bool isCancelled),
|
||||
(&event.self(), event.self().getOwnerId().rawID, event.isCancelled()),
|
||||
event.setCancelled(result););
|
||||
}
|
||||
case doHash("gmlib::ProjectileCreateAfterEvent"): {
|
||||
REGISTER_EVENT_LISTEN(
|
||||
ila::mc::DragonRespawnAfterEvent,
|
||||
(Actor * mob),
|
||||
(&event.self()),
|
||||
ila::mc::ProjectileCreateAfterEvent,
|
||||
(Actor * mob, int64 uniqueId),
|
||||
(&event.self(), event.self().getOwnerId().rawID),
|
||||
);
|
||||
}
|
||||
// case doHash("gmlib::ProjectileCreateBeforeEvent"): {
|
||||
// REGISTER_EVENT_LISTEN(
|
||||
// ila::mc::ProjectileCreateBeforeEvent,
|
||||
// (Actor * mob, int64 uniqueId, bool isCancelled),
|
||||
// (&event.self(),
|
||||
// event.getShooter() ? event.getShooter()->getOrCreateUniqueID().rawID : -1,
|
||||
// event.isCancelled()),
|
||||
// event.setCancelled(result);
|
||||
// );
|
||||
// }
|
||||
// case doHash("gmlib::ProjectileCreateAfterEvent"): {
|
||||
// REGISTER_EVENT_LISTEN(
|
||||
// GMLIB::Event::EntityEvent::ProjectileCreateAfterEvent,
|
||||
// (Actor * mob, int64 uniqueId),
|
||||
// (&event.self(), event.getShooter() ? event.getShooter()->getOrCreateUniqueID().rawID : -1),
|
||||
// );
|
||||
// }
|
||||
case doHash("gmlib::SpawnWanderingTraderBeforeEvent"): {
|
||||
REGISTER_EVENT_LISTEN(
|
||||
ila::mc::SpawnWanderingTraderBeforeEvent,
|
||||
REGISTER_EVENT_LISTEN(ila::mc::SpawnWanderingTraderBeforeEvent,
|
||||
(std::pair<BlockPos, int> pos, bool isCancelled),
|
||||
({event.pos(), event.blockSource().getDimensionId()}, event.isCancelled()),
|
||||
event.setCancelled(result);
|
||||
);
|
||||
event.setCancelled(result););
|
||||
}
|
||||
case doHash("gmlib::SpawnWanderingTraderAfterEvent"): {
|
||||
REGISTER_EVENT_LISTEN(
|
||||
@@ -278,74 +258,68 @@ void Export_Event_API() {
|
||||
({event.pos(), event.blockSource().getDimensionId()}),
|
||||
);
|
||||
}
|
||||
// case doHash("gmlib::HandleRequestActionBeforeEvent"): {
|
||||
// // clang-format off
|
||||
// REGISTER_EVENT_LISTEN(
|
||||
// GMLIB::Event::PlayerEvent::HandleRequestActionBeforeEvent,
|
||||
// (
|
||||
// Player * player,
|
||||
// std::string const& actionType,
|
||||
// int count,
|
||||
// std::string const& sourceContainerNetId,
|
||||
// int sourceSlot,
|
||||
// std::string const& destinationContainerNetId,
|
||||
// int destinationSlot,
|
||||
// bool isCancelled
|
||||
// ),
|
||||
// (
|
||||
// (Player*)&event.self(),
|
||||
// magic_enum::enum_name(requestAction.mActionType).data(),
|
||||
// (int)requestAction.mAmount,
|
||||
// magic_enum::enum_name(requestAction.mSrc->mFullContainerName.mName).data(),
|
||||
// (int)requestAction.mSrc->mSlot,
|
||||
// magic_enum::enum_name(requestAction.mDst->mFullContainerName.mName).data(),
|
||||
// (int)requestAction.mDst->mSlot,
|
||||
// event.isCancelled()
|
||||
// ),
|
||||
// event.setCancelled(result);,
|
||||
// auto& requestAction = (ItemStackRequestActionTransferBase&)event.getRequestAction();
|
||||
// );
|
||||
// // clang-format on
|
||||
// }
|
||||
// case doHash("gmlib::HandleRequestActionAfterEvent"): {
|
||||
// // clang-format off
|
||||
// REGISTER_EVENT_LISTEN(
|
||||
// GMLIB::Event::PlayerEvent::HandleRequestActionAfterEvent,
|
||||
// (
|
||||
// Player * player,
|
||||
// std::string const& actionType,
|
||||
// int count,
|
||||
// std::string const& sourceContainerNetId,
|
||||
// int sourceSlot,
|
||||
// std::string const& destinationContainerNetId,
|
||||
// int destinationSlot
|
||||
// ),
|
||||
// (
|
||||
// (Player*)&event.self(),
|
||||
// magic_enum::enum_name(requestAction.mActionType).data(),
|
||||
// (int)requestAction.mAmount,
|
||||
// magic_enum::enum_name(requestAction.mSrc->mFullContainerName.mName).data(),
|
||||
// (int)requestAction.mSrc->mSlot,
|
||||
// magic_enum::enum_name(requestAction.mDst->mFullContainerName.mName).data(),
|
||||
// (int)requestAction.mDst->mSlot
|
||||
// ),
|
||||
// ,
|
||||
// auto& requestAction = (ItemStackRequestActionTransferBase&)event.getRequestAction();
|
||||
// );
|
||||
// // clang-format on
|
||||
// }
|
||||
// case doHash("gmlib::ContainerClosePacketSendAfterEvent"): {
|
||||
// REGISTER_EVENT_LISTEN(
|
||||
// GMLIB::Event::PacketEvent::ContainerClosePacketSendAfterEvent,
|
||||
// (Player * player, int containerId, bool serverInitiatedClose, bool),
|
||||
// (event.getServerNetworkHandler()
|
||||
// ._getServerPlayer(event.getNetworkIdentifier(), event.getPacket().mClientSubId),
|
||||
// (int)event.getPacket().mContainerId,
|
||||
// event.getPacket().mServerInitiatedClose,
|
||||
// false),
|
||||
// ,
|
||||
// );
|
||||
// }
|
||||
case doHash("gmlib::HandleRequestActionBeforeEvent"): {
|
||||
// clang-format off
|
||||
REGISTER_EVENT_LISTEN(
|
||||
ila::mc::PlayerRequestItemActionBeforeEvent,
|
||||
(
|
||||
Player * player,
|
||||
std::string const& actionType,
|
||||
int count,
|
||||
std::string const& sourceContainerNetId,
|
||||
int sourceSlot,
|
||||
std::string const& destinationContainerNetId,
|
||||
int destinationSlot,
|
||||
bool isCancelled
|
||||
),
|
||||
(
|
||||
(Player*)&event.self(),
|
||||
magic_enum::enum_name(event.actionType()).data(),
|
||||
event.amount(),
|
||||
magic_enum::enum_name(event.src().mFullContainerName.mName).data(),
|
||||
(int)event.src().mSlot,
|
||||
magic_enum::enum_name(event.dst().mFullContainerName.mName).data(),
|
||||
(int)event.dst().mSlot,
|
||||
event.isCancelled()
|
||||
),
|
||||
event.setCancelled(result);,
|
||||
);
|
||||
// clang-format on
|
||||
}
|
||||
case doHash("gmlib::HandleRequestActionAfterEvent"): {
|
||||
// clang-format off
|
||||
REGISTER_EVENT_LISTEN(
|
||||
ila::mc::PlayerRequestItemActionAfterEvent,
|
||||
(
|
||||
Player * player,
|
||||
std::string const& actionType,
|
||||
int count,
|
||||
std::string const& sourceContainerNetId,
|
||||
int sourceSlot,
|
||||
std::string const& destinationContainerNetId,
|
||||
int destinationSlot
|
||||
),
|
||||
(
|
||||
(Player*)&event.self(),
|
||||
magic_enum::enum_name(event.actionType()).data(),
|
||||
event.amount(),
|
||||
magic_enum::enum_name(event.src().mFullContainerName.mName).data(),
|
||||
(int)event.src().mSlot,
|
||||
magic_enum::enum_name(event.dst().mFullContainerName.mName).data(),
|
||||
(int)event.dst().mSlot
|
||||
),
|
||||
,
|
||||
);
|
||||
// clang-format on
|
||||
}
|
||||
case doHash("gmlib::ContainerClosePacketSendAfterEvent"): {
|
||||
REGISTER_EVENT_LISTEN(
|
||||
ila::mc::PlayerCloseContainerAfterEvent,
|
||||
(Player * player, int containerId, bool serverInitiatedClose, bool),
|
||||
(&event.self(), (int)event.containerId(), event.serverInitiatedClose(), false),
|
||||
,
|
||||
);
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
+4
-2
@@ -1,10 +1,11 @@
|
||||
#pragma once
|
||||
// clang-format off
|
||||
#define GMLIB_Gloabl_Using
|
||||
#define GMLIB_GLOBAL_USING
|
||||
#include <gmlib/GlobalUsing.h>
|
||||
#include <gmlib/include_all.h>
|
||||
#include <ila/include_all.h>
|
||||
#include <RemoteCallAPI.h>
|
||||
using namespace gmlib::mod;
|
||||
// clang-format on
|
||||
|
||||
#define PLUGIN_NAME fmt::format(fg(fmt::color::light_green), "GMLIB-LRCA")
|
||||
@@ -12,7 +13,7 @@
|
||||
#define LIB_VERSION_MAJOR 1
|
||||
#define LIB_VERSION_MINOR 0
|
||||
#define LIB_VERSION_PATCH 0
|
||||
#define LIB_VERSION_PRERELEASE "rc.1"
|
||||
#define LIB_VERSION_PRERELEASE std::nullopt
|
||||
|
||||
#ifdef LIB_VERSION_PRERELEASE
|
||||
#define LIB_VERSION ll::data::Version(LIB_VERSION_MAJOR, LIB_VERSION_MINOR, LIB_VERSION_PATCH, LIB_VERSION_PRERELEASE)
|
||||
@@ -27,4 +28,5 @@ extern void ExportPAPI();
|
||||
extern void Export_Event_API();
|
||||
extern void Export_BinaryStream_API();
|
||||
extern ll::thread::ThreadPoolExecutor const& getThreadPoolExecutor();
|
||||
extern ll::io::Logger& getLogger();
|
||||
// extern void Export_Form_API();
|
||||
+62
-75
@@ -1,12 +1,10 @@
|
||||
#include "Global.h"
|
||||
#include <gmlib/mc/world/Level.h>
|
||||
#include <mc/world/item/crafting/RecipeIngredient.h>
|
||||
|
||||
std::unordered_set<std::string> HardCodedKeys = {"AlwaysUnlocked", "PlayerHasManyItems", "PlayerInWater", "None"};
|
||||
|
||||
std::variant<std::string, std::vector<RecipeIngredient>> makeRecipeUnlockingKey(std::string const& key) {
|
||||
if (HardCodedKeys.count(key)) return key;
|
||||
return std::vector<RecipeIngredient>({RecipeIngredient(key, 0, 1)});
|
||||
ICustomRecipe::UnlockingRequirement makeRecipeUnlockingKey(std::string const& key) {
|
||||
if (HardCodedKeys.count(key)) return {{ICustomRecipe::Ingredient{key}}};
|
||||
return ICustomRecipe::UnlockingRequirement({ICustomRecipe::Ingredient(key, 1, 0)});
|
||||
}
|
||||
|
||||
void Export_Legacy_GMLib_ModAPI() {
|
||||
@@ -19,18 +17,13 @@ void Export_Legacy_GMLib_ModAPI() {
|
||||
std::string const& result,
|
||||
int count,
|
||||
std::string const& unlock) -> void {
|
||||
// if (!GMLIB_Level::getInstance().has_value()) return;
|
||||
// std::vector<RecipeIngredient> types;
|
||||
// for (auto ing : ingredients) {
|
||||
// types.emplace_back(ing, 0, 1);
|
||||
// }
|
||||
// GMLIB::Mod::JsonRecipe::registerShapelessCraftingTableRecipe(
|
||||
// recipe_id,
|
||||
// types,
|
||||
// RecipeIngredient(result, 0, count),
|
||||
// makeRecipeUnlockingKey(unlock)
|
||||
// );
|
||||
throw std::runtime_error("GMLib_ModAPI::registerShapelessRecipe is not implemented");
|
||||
if (!GMLevel::getInstance().has_value()) return;
|
||||
std::vector<ICustomRecipe::Ingredient> types;
|
||||
for (auto& ing : ingredients) {
|
||||
types.emplace_back(ICustomRecipe::Ingredient{ing, 1});
|
||||
}
|
||||
CustomRecipeRegistry::getInstance()
|
||||
.registerShapelessRecipe(recipe_id, types, ItemInstance(result, count), makeRecipeUnlockingKey(unlock));
|
||||
}
|
||||
);
|
||||
RemoteCall::exportAs(
|
||||
@@ -42,19 +35,20 @@ void Export_Legacy_GMLib_ModAPI() {
|
||||
std::string const& result,
|
||||
int count,
|
||||
std::string const& unlock) -> void {
|
||||
// if (!GMLIB_Level::getInstance().has_value()) return;
|
||||
// std::vector<RecipeIngredient> types;
|
||||
// for (auto ing : ingredients) {
|
||||
// types.push_back(RecipeIngredient(ing, 0, 1));
|
||||
// }
|
||||
// GMLIB::Mod::JsonRecipe::registerShapedCraftingTableRecipe(
|
||||
// recipe_id,
|
||||
// shape,
|
||||
// types,
|
||||
// RecipeIngredient(result, 0, count),
|
||||
// makeRecipeUnlockingKey(unlock)
|
||||
// );
|
||||
throw std::runtime_error("GMLib_ModAPI::registerShapedRecipe is not implemented");
|
||||
if (!GMLevel::getInstance().has_value()) return;
|
||||
ICustomShapedRecipe::ShapedIngredients types;
|
||||
char index = 'a';
|
||||
for (auto& ing : ingredients) {
|
||||
types.add(std::string{index++}, ICustomRecipe::Ingredient{ing, 1});
|
||||
}
|
||||
CustomRecipeRegistry::getInstance().registerShapedRecipe(
|
||||
recipe_id,
|
||||
shape,
|
||||
types,
|
||||
ItemInstance(result, count),
|
||||
makeRecipeUnlockingKey(unlock)
|
||||
);
|
||||
|
||||
}
|
||||
);
|
||||
RemoteCall::exportAs(
|
||||
@@ -64,14 +58,9 @@ void Export_Legacy_GMLib_ModAPI() {
|
||||
std::string const& input,
|
||||
std::string const& output,
|
||||
std::vector<std::string> tags) -> void {
|
||||
// if (!GMLIB_Level::getInstance().has_value()) return;
|
||||
// GMLIB::Mod::JsonRecipe::registerFurnaceRecipe(
|
||||
// recipe_id,
|
||||
// RecipeIngredient(input, 0, 1),
|
||||
// RecipeIngredient(output, 0, 1),
|
||||
// tags
|
||||
// );
|
||||
throw std::runtime_error("GMLib_ModAPI::registerFurnaceRecipe is not implemented");
|
||||
if (!GMLevel::getInstance().has_value()) return;
|
||||
CustomRecipeRegistry::getInstance()
|
||||
.registerFurnaceRecipe(ICustomRecipe::Ingredient{input}, ItemInstance{output}, tags);
|
||||
}
|
||||
);
|
||||
RemoteCall::exportAs(
|
||||
@@ -79,10 +68,12 @@ void Export_Legacy_GMLib_ModAPI() {
|
||||
"registerBrewingMixRecipe",
|
||||
[](std::string const& recipe_id, std::string const& input, std::string const& output, std::string const& reagent
|
||||
) -> void {
|
||||
// if (!GMLIB_Level::getInstance().has_value()) return;
|
||||
// GMLIB::Mod::JsonRecipe::registerBrewingMixRecipe(recipe_id, input, output, RecipeIngredient(reagent, 0,
|
||||
// 1));
|
||||
throw std::runtime_error("GMLib_ModAPI::registerBrewingMixRecipe is not implemented");
|
||||
if (!GMLevel::getInstance().has_value()) return;
|
||||
CustomRecipeRegistry::getInstance().registerBrewingRecipe(
|
||||
ICustomRecipe::Ingredient{input},
|
||||
ICustomRecipe::Ingredient{reagent},
|
||||
ICustomRecipe::Ingredient{output}
|
||||
);
|
||||
}
|
||||
);
|
||||
RemoteCall::exportAs(
|
||||
@@ -90,14 +81,12 @@ void Export_Legacy_GMLib_ModAPI() {
|
||||
"registerBrewingContainerRecipe",
|
||||
[](std::string const& recipe_id, std::string const& input, std::string const& output, std::string const& reagent
|
||||
) -> void {
|
||||
// if (!GMLIB_Level::getInstance().has_value()) return;
|
||||
// GMLIB::Mod::JsonRecipe::registerBrewingContainerRecipe(
|
||||
// recipe_id,
|
||||
// RecipeIngredient(input, 0, 1),
|
||||
// RecipeIngredient(output, 0, 1),
|
||||
// RecipeIngredient(reagent, 0, 1)
|
||||
// );
|
||||
throw std::runtime_error("GMLib_ModAPI::registerBrewingContainerRecipe is not implemented");
|
||||
if (!GMLevel::getInstance().has_value()) return;
|
||||
CustomRecipeRegistry::getInstance().registerBrewingRecipe(
|
||||
ICustomRecipe::Ingredient{input},
|
||||
ICustomRecipe::Ingredient{reagent},
|
||||
ICustomRecipe::Ingredient{output}
|
||||
);
|
||||
}
|
||||
);
|
||||
RemoteCall::exportAs(
|
||||
@@ -108,15 +97,14 @@ void Export_Legacy_GMLib_ModAPI() {
|
||||
std::string const& base,
|
||||
std::string const& addition,
|
||||
std::string const& result) -> void {
|
||||
// if (!GMLIB_Level::getInstance().has_value()) return;
|
||||
// GMLIB::Mod::JsonRecipe::registerSmithingTransformRecipe(
|
||||
// recipe_id,
|
||||
// smithing_template,
|
||||
// base,
|
||||
// addition,
|
||||
// result
|
||||
// );
|
||||
throw std::runtime_error("GMLib_ModAPI::registerSmithingTransformRecipe is not implemented");
|
||||
if (!GMLevel::getInstance().has_value()) return;
|
||||
CustomRecipeRegistry::getInstance().registerSmithingTransformRecipe(
|
||||
recipe_id,
|
||||
ICustomRecipe::Ingredient{smithing_template},
|
||||
ICustomRecipe::Ingredient{base},
|
||||
ICustomRecipe::Ingredient{addition},
|
||||
ItemInstance{result}
|
||||
);
|
||||
}
|
||||
);
|
||||
RemoteCall::exportAs(
|
||||
@@ -126,9 +114,13 @@ void Export_Legacy_GMLib_ModAPI() {
|
||||
std::string const& smithing_template,
|
||||
std::string const& base,
|
||||
std::string const& addition) -> void {
|
||||
// if (!GMLIB_Level::getInstance().has_value()) return;
|
||||
// GMLIB::Mod::JsonRecipe::registerSmithingTrimRecipe(recipe_id, smithing_template, base, addition);
|
||||
throw std::runtime_error("GMLib_ModAPI::registerSmithingTrimRecipe is not implemented");
|
||||
if (!GMLevel::getInstance().has_value()) return;
|
||||
CustomRecipeRegistry::getInstance().registerSmithingTrimRecipe(
|
||||
recipe_id,
|
||||
ICustomRecipe::Ingredient{smithing_template},
|
||||
ICustomRecipe::Ingredient{base},
|
||||
ICustomRecipe::Ingredient{addition}
|
||||
);
|
||||
}
|
||||
);
|
||||
RemoteCall::exportAs(
|
||||
@@ -140,19 +132,17 @@ void Export_Legacy_GMLib_ModAPI() {
|
||||
std::string const& output,
|
||||
int output_data,
|
||||
int output_count) -> void {
|
||||
// if (!GMLIB_Level::getInstance().has_value()) return;
|
||||
// GMLIB::Mod::JsonRecipe::registerStoneCutterRecipe(
|
||||
// recipe_id,
|
||||
// RecipeIngredient(input, 0, 1),
|
||||
// RecipeIngredient(output, 0, 1)
|
||||
// );
|
||||
throw std::runtime_error("GMLib_ModAPI::registerStoneCutterRecipe is not implemented");
|
||||
if (!GMLevel::getInstance().has_value()) return;
|
||||
CustomRecipeRegistry::getInstance().registerStoneCutterRecipe(
|
||||
recipe_id,
|
||||
ICustomRecipe::Ingredient{input, 1, input_data},
|
||||
{output, output_count, output_data}
|
||||
);
|
||||
}
|
||||
);
|
||||
// 错误方块清理
|
||||
RemoteCall::exportAs("GMLib_ModAPI", "setUnknownBlockCleaner", []() -> void {
|
||||
// GMLIB::Mod::VanillaFix::setAutoCleanUnknownBlockEnabled();
|
||||
throw std::runtime_error("GMLib_ModAPI::setUnknownBlockCleaner is not implemented");
|
||||
getLogger().error("setUnknownBlockCleaner is not implemented");
|
||||
});
|
||||
// 实验性
|
||||
RemoteCall::exportAs("GMLib_ModAPI", "registerExperimentsRequire", [](int experiment_id) -> void {
|
||||
@@ -172,8 +162,5 @@ void Export_Legacy_GMLib_ModAPI() {
|
||||
.transform([&](GMLevel& level) { return level.getExperimentEnabled((AllExperiments)experiment_id); })
|
||||
.value_or(false);
|
||||
});
|
||||
RemoteCall::exportAs("GMLib_ModAPI", "setFixI18nEnabled", []() -> void {
|
||||
// GMLIB::Mod::VanillaFix::setFixI18nEnabled();
|
||||
throw std::runtime_error("GMLib_ModAPI::setFixI18nEnabled is not implemented");
|
||||
});
|
||||
RemoteCall::exportAs("GMLib_ModAPI", "setFixI18nEnabled", []() -> void {});
|
||||
}
|
||||
+6
-12
@@ -2,24 +2,19 @@
|
||||
|
||||
void Export_Legacy_GMLib_ServerAPI() {
|
||||
RemoteCall::exportAs("GMLib_ServerAPI", "setEducationFeatureEnabled", []() -> void {
|
||||
// GMLIB_Level::tryEnableEducationEdition();
|
||||
throw std::runtime_error("GMLib_ServerAPI::setEducationFeatureEnabled is not implemented");
|
||||
getLogger().error("GMLib_ServerAPI::setEducationFeatureEnabled is not implemented");
|
||||
});
|
||||
RemoteCall::exportAs("GMLib_ServerAPI", "registerAbilityCommand", []() -> void {
|
||||
// GMLIB_Level::tryRegisterAbilityCommand();
|
||||
throw std::runtime_error("GMLib_ServerAPI::registerAbilityCommand is not implemented");
|
||||
getLogger().error("GMLib_ServerAPI::registerAbilityCommand is not implemented");
|
||||
});
|
||||
RemoteCall::exportAs("GMLib_ServerAPI", "setEnableAchievement", []() -> void {
|
||||
// GMLIB_Level::setForceAchievementsEnabled();
|
||||
throw std::runtime_error("GMLib_ServerAPI::setEnableAchievement is not implemented");
|
||||
getLogger().error("GMLib_ServerAPI::setEnableAchievement is not implemented");
|
||||
});
|
||||
RemoteCall::exportAs("GMLib_ServerAPI", "setForceTrustSkins", []() -> void {
|
||||
// GMLIB_Level::trustAllSkins();
|
||||
throw std::runtime_error("GMLib_ServerAPI::setForceTrustSkins is not implemented");
|
||||
getLogger().error("GMLib_ServerAPI::setForceTrustSkins is not implemented");
|
||||
});
|
||||
RemoteCall::exportAs("GMLib_ServerAPI", "enableCoResourcePack", []() -> void {
|
||||
// GMLIB_Level::requireServerResourcePackAndAllowClientResourcePack();
|
||||
throw std::runtime_error("GMLib_ServerAPI::enableCoResourcePack is not implemented");
|
||||
getLogger().error("GMLib_ServerAPI::enableCoResourcePack is not implemented");
|
||||
});
|
||||
RemoteCall::exportAs("GMLib_ServerAPI", "getLevelName", []() -> std::string {
|
||||
return GMLevel::getInstance().transform(
|
||||
@@ -37,8 +32,7 @@ void Export_Legacy_GMLib_ServerAPI() {
|
||||
.value_or("");
|
||||
});
|
||||
RemoteCall::exportAs("GMLib_ServerAPI", "setFakeSeed", [](int64_t seed) -> void {
|
||||
// return GMLIB_Level::setFakeSeed(seed);
|
||||
throw std::runtime_error("GMLib_ServerAPI::setFakeSeed is not implemented");
|
||||
getLogger().error("GMLib_ServerAPI::setFakeSeed is not implemented");
|
||||
});
|
||||
RemoteCall::exportAs(
|
||||
"GMLib_ServerAPI",
|
||||
|
||||
+3
-2
@@ -2,7 +2,7 @@
|
||||
"format_version": 3,
|
||||
"format_uuid": "289f771f-2c9a-4d73-9f3f-8492495a924d",
|
||||
"tooth": "github.com/GroupMountain/GMLIB-LegacyRemoteCallApi",
|
||||
"version": "1.0.0-rc.1",
|
||||
"version": "1.0.0",
|
||||
"info": {
|
||||
"name": "GMLIB-LegacyRemoteCallApi",
|
||||
"description": "Legacy RemoteCall API for GMLIB",
|
||||
@@ -20,7 +20,8 @@
|
||||
"platform": "win-x64",
|
||||
"dependencies": {
|
||||
"github.com/LiteLDev/LeviLamina": ">=1.1.1",
|
||||
"github.com/GroupMountain/GMLIB-Release": ">=1.0.0-rc.3"
|
||||
"github.com/GroupMountain/GMLIB-Release": ">=1.0.0",
|
||||
"github.com/MiracleForest/iListenAttentively-Release": ">=0.4.1"
|
||||
},
|
||||
"assets": [
|
||||
{
|
||||
|
||||
@@ -10,14 +10,15 @@ end
|
||||
|
||||
add_requires("levilamina", {configs = {target_type = "server"}})
|
||||
add_requires("legacyremotecall")
|
||||
add_requires("gmlib")
|
||||
add_requires("levibuildscript")
|
||||
add_requires("ilistenattentively")
|
||||
add_requires("gmlib")
|
||||
|
||||
target("GMLIB-LegacyRemoteCallApi")
|
||||
add_cxflags(
|
||||
"/EHa",
|
||||
"/utf-8"
|
||||
"/utf-8",
|
||||
"/bigobj"
|
||||
)
|
||||
add_defines(
|
||||
"NOMINMAX",
|
||||
@@ -33,8 +34,8 @@ target("GMLIB-LegacyRemoteCallApi")
|
||||
add_packages(
|
||||
"levilamina",
|
||||
"legacyremotecall",
|
||||
"gmlib",
|
||||
"ilistenattentively"
|
||||
"ilistenattentively",
|
||||
"gmlib"
|
||||
)
|
||||
add_rules("@levibuildscript/linkrule")
|
||||
set_exceptions("none")
|
||||
|
||||
Reference in New Issue
Block a user