Compare commits
10 Commits
+40
-3
@@ -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 = {
|
||||||
|
|||||||
+6
-7
@@ -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"),
|
||||||
@@ -2291,14 +2291,14 @@ class GMLIB_BinaryStream {
|
|||||||
this.writeUnsignedVarInt(data.id);
|
this.writeUnsignedVarInt(data.id);
|
||||||
this.writeUnsignedVarInt(data.type);
|
this.writeUnsignedVarInt(data.type);
|
||||||
switch (data.type) {
|
switch (data.type) {
|
||||||
case 0: this.writeByte(data.value); break;
|
case 0: this.writeUnsignedChar(data.value); break;
|
||||||
case 1: this.writeSignedShort(data.value); break;
|
case 1: this.writeUnsignedShort(data.value); break;
|
||||||
case 2: this.writeSignedInt(data.value); break;
|
case 2: this.writeVarInt(data.value); break;
|
||||||
case 3: this.writeFloat(data.value); break;
|
case 3: this.writeFloat(data.value); break;
|
||||||
case 4: this.writeString(data.value); break;
|
case 4: this.writeString(data.value); break;
|
||||||
case 5: this.writeCompoundTag(data.value); break;
|
case 5: this.writeCompoundTag(data.value); break;
|
||||||
case 6: this.writeBlockPos(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;
|
case 8: this.writeVec3(data.value); break;
|
||||||
default: throw new Error("Unknown data type");
|
default: throw new Error("Unknown data type");
|
||||||
}
|
}
|
||||||
@@ -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
@@ -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 =
|
||||||
|
|||||||
+4
-1
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "${pluginName}",
|
"name": "${pluginName}",
|
||||||
"entry": "${pluginFile}",
|
"entry": "${pluginFile}",
|
||||||
"version": "1.0.0-rc.1",
|
"version": "1.0.0",
|
||||||
"author": "GroupMountain",
|
"author": "GroupMountain",
|
||||||
"type": "native",
|
"type": "native",
|
||||||
"passive": true,
|
"passive": true,
|
||||||
@@ -11,6 +11,9 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "LegacyRemoteCall"
|
"name": "LegacyRemoteCall"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "iListenAttentively"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -1,10 +1,8 @@
|
|||||||
#include "Global.h"
|
#include "Global.h"
|
||||||
#include <gmlib/mc/network/BinaryStream.h>
|
|
||||||
#include <mc/world/item/NetworkItemStackDescriptor.h>
|
|
||||||
|
|
||||||
class LegacyScriptBinaryStreamManager {
|
class LegacyScriptBinaryStreamManager {
|
||||||
private:
|
private:
|
||||||
int64 mNextBinaryStreamId = 0;
|
int64 mNextBinaryStreamId = 0;
|
||||||
std::unordered_map<uint64, std::shared_ptr<GMBinaryStream>> mBinaryStream;
|
std::unordered_map<uint64, std::shared_ptr<GMBinaryStream>> mBinaryStream;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@@ -15,7 +13,7 @@ public:
|
|||||||
uint64 copyBinaryStream(uint id) {
|
uint64 copyBinaryStream(uint id) {
|
||||||
auto nextId = getNextId();
|
auto nextId = getNextId();
|
||||||
cretateBinaryStream(nextId);
|
cretateBinaryStream(nextId);
|
||||||
if(auto bs = getBinaryStream(nextId); bs !=nullptr){
|
if (auto bs = getBinaryStream(nextId); bs != nullptr) {
|
||||||
getBinaryStream(nextId)->mBuffer = getBinaryStream(id)->mBuffer;
|
getBinaryStream(nextId)->mBuffer = getBinaryStream(id)->mBuffer;
|
||||||
}
|
}
|
||||||
return nextId;
|
return nextId;
|
||||||
|
|||||||
+82
-84
@@ -2,31 +2,30 @@
|
|||||||
#include <regex>
|
#include <regex>
|
||||||
|
|
||||||
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(
|
||||||
[](GMLevel& level) -> double { return level.getServerMspt(); }
|
[](GMLevel& level) -> double { return level.getServerMspt(); }
|
||||||
).value_or(0.0);
|
).value_or(0.0);
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "getServerCurrentTps", []() -> float {
|
RemoteCall::exportAs("GMLIB_API", "getServerCurrentTps", []() -> float {
|
||||||
return GMLevel::getInstance()
|
return GMLevel::getInstance().transform(
|
||||||
.transform([](GMLevel& level) -> float { return level.getServerCurrentTps(); })
|
[](GMLevel& level) -> float { return level.getServerCurrentTps(); }
|
||||||
.value_or(0.0);
|
).value_or(0.0);
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "getServerAverageTps", []() -> double {
|
RemoteCall::exportAs("GMLIB_API", "getServerAverageTps", []() -> double {
|
||||||
return GMLevel::getInstance()
|
return GMLevel::getInstance().transform(
|
||||||
.transform([](GMLevel& level) -> double { return level.getServerAverageTps(); })
|
[](GMLevel& level) -> double { return level.getServerAverageTps(); }
|
||||||
.value_or(0.0);
|
).value_or(0.0);
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "getAllPlayerUuids", []() -> std::vector<std::string> {
|
RemoteCall::exportAs("GMLIB_API", "getAllPlayerUuids", []() -> std::vector<std::string> {
|
||||||
std::vector<std::string> result;
|
std::vector<std::string> result;
|
||||||
@@ -66,20 +65,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",
|
||||||
@@ -116,7 +116,7 @@ void Export_Compatibility_API() {
|
|||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "removeFloatingTextFromPlayer", [](uint64 id, Player* pl) -> bool {
|
RemoteCall::exportAs("GMLIB_API", "removeFloatingTextFromPlayer", [](uint64 id, Player* pl) -> bool {
|
||||||
if (auto ft = FloatingTextManager::getInstance().get(id); !ft.expired()){
|
if (auto ft = FloatingTextManager::getInstance().get(id); !ft.expired()) {
|
||||||
ft.lock()->removeFrom((GMPlayer&)*pl);
|
ft.lock()->removeFrom((GMPlayer&)*pl);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -143,9 +143,13 @@ void Export_Compatibility_API() {
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "isVersionMatched", [](std::uint16_t a, std::uint16_t b, std::uint16_t c) -> bool {
|
RemoteCall::exportAs(
|
||||||
return LIB_VERSION >= ll::data::Version(a, b, c, "", "");
|
"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_LRCA", []() -> std::string { return LIB_VERSION.to_string(); });
|
||||||
RemoteCall::exportAs("GMLIB_API", "getVersion_GMLIB", []() -> std::string {
|
RemoteCall::exportAs("GMLIB_API", "getVersion_GMLIB", []() -> std::string {
|
||||||
return GMLIB_VERSION_TO_STRING(GMLIB_VERSION_MAJOR) "." GMLIB_VERSION_TO_STRING(GMLIB_VERSION_MINOR
|
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",
|
"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 {
|
||||||
@@ -406,7 +412,7 @@ void Export_Compatibility_API() {
|
|||||||
std::vector<std::unordered_map<std::string, std::string>> result;
|
std::vector<std::unordered_map<std::string, std::string>> result;
|
||||||
for (auto& player : GMScoreboard::getInstance()->getAllPlayers()) {
|
for (auto& player : GMScoreboard::getInstance()->getAllPlayers()) {
|
||||||
result.push_back({
|
result.push_back({
|
||||||
{"Type", "Player" },
|
{"Type", "Player" },
|
||||||
{"Uuid", player.getUUID().asString()}
|
{"Uuid", player.getUUID().asString()}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -418,7 +424,7 @@ void Export_Compatibility_API() {
|
|||||||
}
|
}
|
||||||
for (auto& uniqueId : GMScoreboard::getInstance()->getAllEntities()) {
|
for (auto& uniqueId : GMScoreboard::getInstance()->getAllEntities()) {
|
||||||
result.push_back({
|
result.push_back({
|
||||||
{"Type", "Entity" },
|
{"Type", "Entity" },
|
||||||
{"UniqueId", std::to_string(uniqueId.rawID)}
|
{"UniqueId", std::to_string(uniqueId.rawID)}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -440,25 +446,22 @@ void Export_Compatibility_API() {
|
|||||||
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;
|
||||||
GMLevel::getInstance()->getLevelData().setSpawnPos(pos.first);
|
GMLevel::getInstance()->getLevelData().setSpawnPos(pos.first);
|
||||||
auto pkt = SetSpawnPositionPacket();
|
auto pkt = SetSpawnPositionPacket();
|
||||||
pkt.mSpawnBlockPos = NetworkBlockPosition(pos.first);
|
pkt.mSpawnBlockPos = NetworkBlockPosition(pos.first);
|
||||||
pkt.mDimensionType = 0;
|
pkt.mDimensionType = 0;
|
||||||
pkt.mSpawnPosType = SpawnPositionType::WorldSpawn;
|
pkt.mSpawnPosType = SpawnPositionType::WorldSpawn;
|
||||||
pkt.sendToClients();
|
pkt.sendToClients();
|
||||||
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",
|
||||||
@@ -483,21 +486,21 @@ void Export_Compatibility_API() {
|
|||||||
return UserCache::getNameByXuid(xuid).value_or("");
|
return UserCache::getNameByXuid(xuid).value_or("");
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "getUuidByXuid", [](std::string const& xuid) -> std::string {
|
RemoteCall::exportAs("GMLIB_API", "getUuidByXuid", [](std::string const& xuid) -> std::string {
|
||||||
return UserCache::getUuidByXuid(xuid)
|
return UserCache::getUuidByXuid(xuid).transform(
|
||||||
.transform([](mce::UUID&& uuid) -> std::string { return uuid.asString(); })
|
[](mce::UUID&& uuid) -> std::string { return uuid.asString(); }
|
||||||
.value_or("");
|
).value_or("");
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "getUuidByName", [](std::string const& name) -> std::string {
|
RemoteCall::exportAs("GMLIB_API", "getUuidByName", [](std::string const& name) -> std::string {
|
||||||
return UserCache::getUuidByName(name)
|
return UserCache::getUuidByName(name).transform(
|
||||||
.transform([](mce::UUID&& uuid) -> std::string { return uuid.asString(); })
|
[](mce::UUID&& uuid) -> std::string { return uuid.asString(); }
|
||||||
.value_or("");
|
).value_or("");
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs(
|
RemoteCall::exportAs(
|
||||||
"GMLIB_API",
|
"GMLIB_API",
|
||||||
"getAllPlayerInfo",
|
"getAllPlayerInfo",
|
||||||
[]() -> std::vector<std::unordered_map<std::string, std::string>> {
|
[]() -> std::vector<std::unordered_map<std::string, std::string>> {
|
||||||
std::vector<std::unordered_map<std::string, std::string>> result;
|
std::vector<std::unordered_map<std::string, std::string>> result;
|
||||||
for (auto entry : UserCache::entries()){
|
for (auto entry : UserCache::entries()) {
|
||||||
result.push_back({
|
result.push_back({
|
||||||
{"Name", entry.mName },
|
{"Name", entry.mName },
|
||||||
{"Xuid", entry.mXuid },
|
{"Xuid", entry.mXuid },
|
||||||
@@ -513,7 +516,7 @@ void Export_Compatibility_API() {
|
|||||||
.value_or(0);
|
.value_or(0);
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "getBlockTranslateKey", [](Block const* block) -> std::string {
|
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 {
|
RemoteCall::exportAs("GMLIB_API", "getItemTranslateKey", [](ItemStack* item) -> std::string {
|
||||||
return item->getDescriptionId();
|
return item->getDescriptionId();
|
||||||
@@ -542,8 +545,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",
|
||||||
@@ -564,8 +566,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;
|
||||||
@@ -580,9 +581,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)
|
||||||
@@ -607,22 +609,22 @@ 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->mUnk29fff1.as<bool>())}
|
{"Value", std::to_string(gameRule.mValue->mUnk29fff1.as<bool>())}
|
||||||
});
|
});
|
||||||
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->mUnk768db5.as<float>())}
|
{"Value", std::to_string(gameRule.mValue->mUnk768db5.as<float>())}
|
||||||
});
|
});
|
||||||
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->mUnk2ab4f3.as<int>())}
|
{"Value", std::to_string(gameRule.mValue->mUnk2ab4f3.as<int>())}
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
@@ -634,7 +636,7 @@ void Export_Compatibility_API() {
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
RemoteCall::exportAs("GMLIB_API", "getEnchantTypeNameFromId", [](size_t id) -> std::string {
|
RemoteCall::exportAs("GMLIB_API", "getEnchantTypeNameFromId", [](size_t id) -> std::string {
|
||||||
if (id < Enchant::mEnchants().size()){
|
if (id < Enchant::mEnchants().size()) {
|
||||||
return Enchant::mEnchants()[id]->mStringId->getString();
|
return Enchant::mEnchants()[id]->mStringId->getString();
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
@@ -651,9 +653,7 @@ void Export_Compatibility_API() {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
RemoteCall::exportAs("GMLIB_API", "removeEnchants", [](ItemStack* item) -> void {
|
RemoteCall::exportAs("GMLIB_API", "removeEnchants", [](ItemStack* item) -> void { item->removeEnchants(); });
|
||||||
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);
|
||||||
});
|
});
|
||||||
@@ -694,8 +694,8 @@ void Export_Compatibility_API() {
|
|||||||
auto nbt = ((GMItemStack*)item)->getNbt();
|
auto nbt = ((GMItemStack*)item)->getNbt();
|
||||||
if (value) {
|
if (value) {
|
||||||
(*nbt)["tags"]["minecraft:keep_on_death"] = true;
|
(*nbt)["tags"]["minecraft:keep_on_death"] = true;
|
||||||
}else{
|
} else {
|
||||||
if (nbt->contains("tags") && (*nbt)["tags"].contains("minecraft:keep_on_death")){
|
if (nbt->contains("tags") && (*nbt)["tags"].contains("minecraft:keep_on_death")) {
|
||||||
(*nbt)["tags"].get<CompoundTag>().erase("minecraft:keep_on_death");
|
(*nbt)["tags"].get<CompoundTag>().erase("minecraft:keep_on_death");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -766,7 +766,7 @@ void Export_Compatibility_API() {
|
|||||||
return entity->getOwnerId().rawID;
|
return entity->getOwnerId().rawID;
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "getItemCategoryName", [](ItemStack const* item) -> std::string {
|
RemoteCall::exportAs("GMLIB_API", "getItemCategoryName", [](ItemStack const* item) -> std::string {
|
||||||
if (auto item2 = item->mItem){
|
if (auto item2 = item->mItem) {
|
||||||
return item2->buildCategoryDescriptionName();
|
return item2->buildCategoryDescriptionName();
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
@@ -775,7 +775,7 @@ void Export_Compatibility_API() {
|
|||||||
return item->getCustomName();
|
return item->getCustomName();
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "getItemEffecName", [](ItemStack const* item) -> std::string {
|
RemoteCall::exportAs("GMLIB_API", "getItemEffecName", [](ItemStack const* item) -> std::string {
|
||||||
if (auto item2 = item->mItem){
|
if (auto item2 = item->mItem) {
|
||||||
return item2->buildEffectDescriptionName(*item);
|
return item2->buildEffectDescriptionName(*item);
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
@@ -803,7 +803,9 @@ void Export_Compatibility_API() {
|
|||||||
return magic_enum::enum_name(container->mContainerType).data();
|
return magic_enum::enum_name(container->mContainerType).data();
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "hasPlayerNbt", [](std::string const& uuid) -> bool {
|
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 {
|
RemoteCall::exportAs("GMLIB_API", "getItemMaxCount", [](ItemStack const* item) -> int {
|
||||||
return item->getMaxStackSize();
|
return item->getMaxStackSize();
|
||||||
@@ -892,20 +894,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
@@ -9,11 +9,12 @@ 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();
|
||||||
ExportPAPI();
|
ExportPAPI();
|
||||||
// Export_Event_API();
|
Export_Event_API();
|
||||||
Export_BinaryStream_API();
|
Export_BinaryStream_API();
|
||||||
// Export_Form_API();
|
// Export_Form_API();
|
||||||
auto logger = ll::io::LoggerRegistry::getInstance().getOrCreate(PLUGIN_NAME);
|
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() {
|
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(); }
|
||||||
+145
-171
@@ -88,10 +88,7 @@ void Export_Event_API() {
|
|||||||
std::string const& uuid,
|
std::string const& uuid,
|
||||||
std::string const& serverXuid,
|
std::string const& serverXuid,
|
||||||
std::string const& clientXuid),
|
std::string const& clientXuid),
|
||||||
(event.realName(),
|
(event.realName(), event.uuid().asString(), event.serverAuthXuid(), event.clientAuthXuid()),
|
||||||
event.uuid().asString(),
|
|
||||||
event.serverAuthXuid(),
|
|
||||||
event.clientAuthXuid()),
|
|
||||||
if (result) event.disConnectClient();
|
if (result) event.disConnectClient();
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -116,12 +113,10 @@ void Export_Event_API() {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
case doHash("gmlib::MobPickupItemBeforeEvent"): {
|
case doHash("gmlib::MobPickupItemBeforeEvent"): {
|
||||||
REGISTER_EVENT_LISTEN(
|
REGISTER_EVENT_LISTEN(ila::mc::ActorPickupItemBeforeEvent,
|
||||||
ila::mc::ActorPickupItemBeforeEvent,
|
(Actor * mob, Actor * item, bool isCancelled),
|
||||||
(Actor * mob, Actor * item, bool isCancelled),
|
(&event.self(), (Actor*)&event.itemActor(), event.isCancelled()),
|
||||||
(&event.self(), (Actor*)&event.itemActor(), event.isCancelled()),
|
event.setCancelled(result););
|
||||||
event.setCancelled(result);
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
case doHash("gmlib::MobPickupItemAfterEvent"): {
|
case doHash("gmlib::MobPickupItemAfterEvent"): {
|
||||||
REGISTER_EVENT_LISTEN(
|
REGISTER_EVENT_LISTEN(
|
||||||
@@ -146,19 +141,17 @@ 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),
|
||||||
,
|
,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
case doHash("gmlib::ActorChangeDimensionBeforeEvent"): {
|
case doHash("gmlib::ActorChangeDimensionBeforeEvent"): {
|
||||||
REGISTER_EVENT_LISTEN(
|
REGISTER_EVENT_LISTEN(ila::mc::ActorChangeDimensionBeforeEvent,
|
||||||
ila::mc::ActorChangeDimensionBeforeEvent,
|
(Actor * entity, int toDimId, bool isCancelled),
|
||||||
(Actor * entity, int toDimId, bool isCancelled),
|
(&event.self(), event.toDimensionId(), event.isCancelled()),
|
||||||
(&event.self(), event.toDimensionId(), event.isCancelled()),
|
event.setCancelled(result););
|
||||||
event.setCancelled(result);
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
case doHash("gmlib::ActorChangeDimensionAfterEvent"): {
|
case doHash("gmlib::ActorChangeDimensionAfterEvent"): {
|
||||||
REGISTER_EVENT_LISTEN(
|
REGISTER_EVENT_LISTEN(
|
||||||
@@ -168,38 +161,38 @@ void Export_Event_API() {
|
|||||||
,
|
,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
// case doHash("gmlib::PlayerStartSleepBeforeEvent"): {
|
case doHash("gmlib::PlayerStartSleepBeforeEvent"): {
|
||||||
// REGISTER_EVENT_LISTEN(
|
REGISTER_EVENT_LISTEN(
|
||||||
// GMLIB::Event::PlayerEvent::PlayerStartSleepBeforeEvent,
|
ila::mc::PlayerStartSleepBeforeEvent,
|
||||||
// (Player * entity, BlockPos pos, bool isCancelled),
|
(Player * entity, BlockPos pos, bool isCancelled),
|
||||||
// (&event.self(), event.getPosition(), event.isCancelled()),
|
(&event.self(), event.pos(), event.isCancelled()),
|
||||||
// event.setCancelled(result);
|
event.setCancelled(result);
|
||||||
// );
|
);
|
||||||
// }
|
}
|
||||||
// case doHash("gmlib::PlayerStartSleepAfterEvent"): {
|
case doHash("gmlib::PlayerStartSleepAfterEvent"): {
|
||||||
// REGISTER_EVENT_LISTEN(
|
REGISTER_EVENT_LISTEN(
|
||||||
// GMLIB::Event::PlayerEvent::PlayerStartSleepAfterEvent,
|
ila::mc::PlayerStartSleepAfterEvent,
|
||||||
// (Player * entity, BlockPos pos, int result),
|
(Player * entity, BlockPos pos, int result),
|
||||||
// (&event.self(), event.getPosition(), (int)event.getResult()),
|
(&event.self(), event.pos(), (int)event.result()),
|
||||||
// ,
|
,
|
||||||
// );
|
);
|
||||||
// }
|
}
|
||||||
// case doHash("gmlib::PlayerStopSleepBeforeEvent"): {
|
case doHash("gmlib::PlayerStopSleepBeforeEvent"): {
|
||||||
// REGISTER_EVENT_LISTEN(
|
REGISTER_EVENT_LISTEN(
|
||||||
// GMLIB::Event::PlayerEvent::PlayerStopSleepBeforeEvent,
|
ila::mc::PlayerStopSleepBeforeEvent,
|
||||||
// (Player * entity, bool forcefulWakeUp, bool updateLevelList, bool isCancelled),
|
(Player * entity, bool forcefulWakeUp, bool updateLevelList, bool isCancelled),
|
||||||
// (&event.self(), event.isForcefulWakeUp(), event.isUpdateLevelList(), event.isCancelled()),
|
(&event.self(), event.forcefulWakeUp(), event.updateLevelList(), false),
|
||||||
// event.setCancelled(result);
|
|
||||||
// );
|
);
|
||||||
// }
|
}
|
||||||
// case doHash("gmlib::PlayerStopSleepAfterEvent"): {
|
case doHash("gmlib::PlayerStopSleepAfterEvent"): {
|
||||||
// REGISTER_EVENT_LISTEN(
|
REGISTER_EVENT_LISTEN(
|
||||||
// GMLIB::Event::PlayerEvent::PlayerStopSleepAfterEvent,
|
ila::mc::PlayerStopSleepAfterEvent,
|
||||||
// (Player * entity, bool forcefulWakeUp, bool updateLevelList, bool),
|
(Player * entity, bool forcefulWakeUp, bool updateLevelList, bool),
|
||||||
// (&event.self(), event.isForcefulWakeUp(), event.isUpdateLevelList(), false),
|
(&event.self(), event.forcefulWakeUp(), event.updateLevelList(), false),
|
||||||
// ,
|
,
|
||||||
// );
|
);
|
||||||
// }
|
}
|
||||||
case doHash("gmlib::DeathMessageAfterEvent"): {
|
case doHash("gmlib::DeathMessageAfterEvent"): {
|
||||||
REGISTER_EVENT_LISTEN(
|
REGISTER_EVENT_LISTEN(
|
||||||
ila::mc::DeathMessageAfterEvent,
|
ila::mc::DeathMessageAfterEvent,
|
||||||
@@ -208,68 +201,55 @@ void Export_Event_API() {
|
|||||||
,
|
,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
// case doHash("gmlib::MobHurtAfterEvent"): {
|
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"): {
|
|
||||||
REGISTER_EVENT_LISTEN(
|
REGISTER_EVENT_LISTEN(
|
||||||
ila::mc::EndermanTakeBlockBeforeEvent,
|
ila::mc::MobHealthChangeAfterEvent,
|
||||||
(Actor * mob, bool isCancelled),
|
(Actor * mob, Actor * source, float damage, int cause),
|
||||||
(&event.self(), event.isCancelled()),
|
(&event.self(), source, event.oldValue() - event.newValue(), (int)damageSource->mCause),
|
||||||
event.setCancelled(result);
|
,
|
||||||
|
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););
|
||||||
|
}
|
||||||
case doHash("gmlib::DragonRespawnBeforeEvent"): {
|
case doHash("gmlib::DragonRespawnBeforeEvent"): {
|
||||||
REGISTER_EVENT_LISTEN(
|
REGISTER_EVENT_LISTEN(ila::mc::DragonRespawnBeforeEvent,
|
||||||
ila::mc::DragonRespawnBeforeEvent,
|
(bool isCancelled),
|
||||||
(bool isCancelled),
|
(event.isCancelled()),
|
||||||
(event.isCancelled()),
|
event.setCancelled(result););
|
||||||
event.setCancelled(result);
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
case doHash("gmlib::DragonRespawnAfterEvent"): {
|
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(
|
REGISTER_EVENT_LISTEN(
|
||||||
ila::mc::DragonRespawnAfterEvent,
|
ila::mc::ProjectileCreateAfterEvent,
|
||||||
(Actor * mob),
|
(Actor * mob, int64 uniqueId),
|
||||||
(&event.self()),
|
(&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"): {
|
case doHash("gmlib::SpawnWanderingTraderBeforeEvent"): {
|
||||||
REGISTER_EVENT_LISTEN(
|
REGISTER_EVENT_LISTEN(ila::mc::SpawnWanderingTraderBeforeEvent,
|
||||||
ila::mc::SpawnWanderingTraderBeforeEvent,
|
(std::pair<BlockPos, int> pos, bool isCancelled),
|
||||||
(std::pair<BlockPos, int> pos, bool isCancelled),
|
({event.pos(), event.blockSource().getDimensionId()}, event.isCancelled()),
|
||||||
({event.pos(), event.blockSource().getDimensionId()}, event.isCancelled()),
|
event.setCancelled(result););
|
||||||
event.setCancelled(result);
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
case doHash("gmlib::SpawnWanderingTraderAfterEvent"): {
|
case doHash("gmlib::SpawnWanderingTraderAfterEvent"): {
|
||||||
REGISTER_EVENT_LISTEN(
|
REGISTER_EVENT_LISTEN(
|
||||||
@@ -278,76 +258,70 @@ void Export_Event_API() {
|
|||||||
({event.pos(), event.blockSource().getDimensionId()}),
|
({event.pos(), event.blockSource().getDimensionId()}),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
// case doHash("gmlib::HandleRequestActionBeforeEvent"): {
|
case doHash("gmlib::HandleRequestActionBeforeEvent"): {
|
||||||
// // clang-format off
|
// clang-format off
|
||||||
// REGISTER_EVENT_LISTEN(
|
REGISTER_EVENT_LISTEN(
|
||||||
// GMLIB::Event::PlayerEvent::HandleRequestActionBeforeEvent,
|
ila::mc::PlayerRequestItemActionBeforeEvent,
|
||||||
// (
|
(
|
||||||
// Player * player,
|
Player * player,
|
||||||
// std::string const& actionType,
|
std::string const& actionType,
|
||||||
// int count,
|
int count,
|
||||||
// std::string const& sourceContainerNetId,
|
std::string const& sourceContainerNetId,
|
||||||
// int sourceSlot,
|
int sourceSlot,
|
||||||
// std::string const& destinationContainerNetId,
|
std::string const& destinationContainerNetId,
|
||||||
// int destinationSlot,
|
int destinationSlot,
|
||||||
// bool isCancelled
|
bool isCancelled
|
||||||
// ),
|
),
|
||||||
// (
|
(
|
||||||
// (Player*)&event.self(),
|
(Player*)&event.self(),
|
||||||
// magic_enum::enum_name(requestAction.mActionType).data(),
|
magic_enum::enum_name(event.actionType()).data(),
|
||||||
// (int)requestAction.mAmount,
|
event.amount(),
|
||||||
// magic_enum::enum_name(requestAction.mSrc->mFullContainerName.mName).data(),
|
magic_enum::enum_name(event.src().mFullContainerName.mName).data(),
|
||||||
// (int)requestAction.mSrc->mSlot,
|
(int)event.src().mSlot,
|
||||||
// magic_enum::enum_name(requestAction.mDst->mFullContainerName.mName).data(),
|
magic_enum::enum_name(event.dst().mFullContainerName.mName).data(),
|
||||||
// (int)requestAction.mDst->mSlot,
|
(int)event.dst().mSlot,
|
||||||
// event.isCancelled()
|
event.isCancelled()
|
||||||
// ),
|
),
|
||||||
// event.setCancelled(result);,
|
event.setCancelled(result);,
|
||||||
// auto& requestAction = (ItemStackRequestActionTransferBase&)event.getRequestAction();
|
);
|
||||||
// );
|
// clang-format on
|
||||||
// // clang-format on
|
}
|
||||||
// }
|
case doHash("gmlib::HandleRequestActionAfterEvent"): {
|
||||||
// case doHash("gmlib::HandleRequestActionAfterEvent"): {
|
// clang-format off
|
||||||
// // clang-format off
|
REGISTER_EVENT_LISTEN(
|
||||||
// REGISTER_EVENT_LISTEN(
|
ila::mc::PlayerRequestItemActionAfterEvent,
|
||||||
// GMLIB::Event::PlayerEvent::HandleRequestActionAfterEvent,
|
(
|
||||||
// (
|
Player * player,
|
||||||
// Player * player,
|
std::string const& actionType,
|
||||||
// std::string const& actionType,
|
int count,
|
||||||
// int count,
|
std::string const& sourceContainerNetId,
|
||||||
// std::string const& sourceContainerNetId,
|
int sourceSlot,
|
||||||
// int sourceSlot,
|
std::string const& destinationContainerNetId,
|
||||||
// std::string const& destinationContainerNetId,
|
int destinationSlot
|
||||||
// int destinationSlot
|
),
|
||||||
// ),
|
(
|
||||||
// (
|
(Player*)&event.self(),
|
||||||
// (Player*)&event.self(),
|
magic_enum::enum_name(event.actionType()).data(),
|
||||||
// magic_enum::enum_name(requestAction.mActionType).data(),
|
event.amount(),
|
||||||
// (int)requestAction.mAmount,
|
magic_enum::enum_name(event.src().mFullContainerName.mName).data(),
|
||||||
// magic_enum::enum_name(requestAction.mSrc->mFullContainerName.mName).data(),
|
(int)event.src().mSlot,
|
||||||
// (int)requestAction.mSrc->mSlot,
|
magic_enum::enum_name(event.dst().mFullContainerName.mName).data(),
|
||||||
// magic_enum::enum_name(requestAction.mDst->mFullContainerName.mName).data(),
|
(int)event.dst().mSlot
|
||||||
// (int)requestAction.mDst->mSlot
|
),
|
||||||
// ),
|
,
|
||||||
// ,
|
);
|
||||||
// auto& requestAction = (ItemStackRequestActionTransferBase&)event.getRequestAction();
|
// clang-format on
|
||||||
// );
|
}
|
||||||
// // clang-format on
|
case doHash("gmlib::ContainerClosePacketSendAfterEvent"): {
|
||||||
// }
|
REGISTER_EVENT_LISTEN(
|
||||||
// case doHash("gmlib::ContainerClosePacketSendAfterEvent"): {
|
ila::mc::PlayerCloseContainerAfterEvent,
|
||||||
// REGISTER_EVENT_LISTEN(
|
(Player * player, int containerId, bool serverInitiatedClose, bool),
|
||||||
// GMLIB::Event::PacketEvent::ContainerClosePacketSendAfterEvent,
|
(&event.self(), (int)event.containerId(), event.serverInitiatedClose(), false),
|
||||||
// (Player * player, int containerId, bool serverInitiatedClose, bool),
|
,
|
||||||
// (event.getServerNetworkHandler()
|
);
|
||||||
// ._getServerPlayer(event.getNetworkIdentifier(), event.getPacket().mClientSubId),
|
}
|
||||||
// (int)event.getPacket().mContainerId,
|
}
|
||||||
// event.getPacket().mServerInitiatedClose,
|
return -1;
|
||||||
// false),
|
|
||||||
// ,
|
|
||||||
// );
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
+4
-2
@@ -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")
|
||||||
@@ -12,7 +13,7 @@
|
|||||||
#define LIB_VERSION_MAJOR 1
|
#define LIB_VERSION_MAJOR 1
|
||||||
#define LIB_VERSION_MINOR 0
|
#define LIB_VERSION_MINOR 0
|
||||||
#define LIB_VERSION_PATCH 0
|
#define LIB_VERSION_PATCH 0
|
||||||
#define LIB_VERSION_PRERELEASE "rc.1"
|
#define LIB_VERSION_PRERELEASE std::nullopt
|
||||||
|
|
||||||
#ifdef LIB_VERSION_PRERELEASE
|
#ifdef LIB_VERSION_PRERELEASE
|
||||||
#define LIB_VERSION ll::data::Version(LIB_VERSION_MAJOR, LIB_VERSION_MINOR, LIB_VERSION_PATCH, 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_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();
|
||||||
+62
-75
@@ -1,12 +1,10 @@
|
|||||||
#include "Global.h"
|
#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::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 +17,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 +35,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 +58,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 +68,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 +81,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 +97,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 +114,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 +132,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 +162,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
@@ -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
-2
@@ -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.0.0-rc.1",
|
"version": "1.0.0",
|
||||||
"info": {
|
"info": {
|
||||||
"name": "GMLIB-LegacyRemoteCallApi",
|
"name": "GMLIB-LegacyRemoteCallApi",
|
||||||
"description": "Legacy RemoteCall API for GMLIB",
|
"description": "Legacy RemoteCall API for GMLIB",
|
||||||
@@ -20,7 +20,8 @@
|
|||||||
"platform": "win-x64",
|
"platform": "win-x64",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"github.com/LiteLDev/LeviLamina": ">=1.1.1",
|
"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": [
|
"assets": [
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -10,14 +10,15 @@ 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")
|
||||||
|
add_requires("gmlib")
|
||||||
|
|
||||||
target("GMLIB-LegacyRemoteCallApi")
|
target("GMLIB-LegacyRemoteCallApi")
|
||||||
add_cxflags(
|
add_cxflags(
|
||||||
"/EHa",
|
"/EHa",
|
||||||
"/utf-8"
|
"/utf-8",
|
||||||
|
"/bigobj"
|
||||||
)
|
)
|
||||||
add_defines(
|
add_defines(
|
||||||
"NOMINMAX",
|
"NOMINMAX",
|
||||||
@@ -33,8 +34,8 @@ target("GMLIB-LegacyRemoteCallApi")
|
|||||||
add_packages(
|
add_packages(
|
||||||
"levilamina",
|
"levilamina",
|
||||||
"legacyremotecall",
|
"legacyremotecall",
|
||||||
"gmlib",
|
"ilistenattentively",
|
||||||
"ilistenattentively"
|
"gmlib"
|
||||||
)
|
)
|
||||||
add_rules("@levibuildscript/linkrule")
|
add_rules("@levibuildscript/linkrule")
|
||||||
set_exceptions("none")
|
set_exceptions("none")
|
||||||
|
|||||||
Reference in New Issue
Block a user