Compare commits

...

19 Commits

20 changed files with 760 additions and 802 deletions
+2
View File
@@ -11,6 +11,8 @@ jobs:
uses: actions/checkout@v2
- uses: xmake-io/github-action-setup-xmake@v1
with:
xmake-version: 2.9.9
- run: |
xmake repo -u
+2
View File
@@ -11,6 +11,8 @@ jobs:
uses: actions/checkout@v2
- uses: xmake-io/github-action-setup-xmake@v1
with:
xmake-version: 2.9.9
- run: |
xmake repo -u
+9 -9
View File
@@ -1,22 +1,22 @@
const PlaceholderAPI = {
/** 获取一个服务器变量的值 @type {function(string):string} */
getValueAPI: ll.import("BEPlaceholderAPI", "GetValue"),
getValueAPI: ll.imports("BEPlaceholderAPI", "GetValue"),
/** 获取一个玩家变量的值 @type {function(string,Player):string} */
getValueByPlayerAPI: ll.import("BEPlaceholderAPI", "GetValueWithPlayer"),
getValueByPlayerAPI: ll.imports("BEPlaceholderAPI", "GetValueWithPlayer"),
/** 注册一个玩家变量 @type {function(string,string,string):boolean} */
registerPlayerPlaceholderAPI: ll.import("BEPlaceholderAPI", "registerPlayerPlaceholder"),
registerPlayerPlaceholderAPI: ll.imports("BEPlaceholderAPI", "registerPlayerPlaceholder"),
/** 注册一个服务器变量 @type {function(string,string,string):boolean} */
registerServerPlaceholderAPI: ll.import("BEPlaceholderAPI", "registerServerPlaceholder"),
registerServerPlaceholderAPI: ll.imports("BEPlaceholderAPI", "registerServerPlaceholder"),
/** 注册一个静态变量 @type {function(string,string,string,number):boolean} */
registerStaticPlaceholderAPI: ll.import("BEPlaceholderAPI", "registerStaticPlaceholder"),
registerStaticPlaceholderAPI: ll.imports("BEPlaceholderAPI", "registerStaticPlaceholder"),
/** 翻译包含PAPI服务器变量的字符串 @type {function(string):string} */
translateStringAPI: ll.import("BEPlaceholderAPI", "translateString"),
translateStringAPI: ll.imports("BEPlaceholderAPI", "translateString"),
/** 翻译包含PAPI玩家变量的字符串 @type {function(string,Player):string} */
translateStringWithPlayerAPI: ll.import("BEPlaceholderAPI", "translateStringWithPlayer"),
translateStringWithPlayerAPI: ll.imports("BEPlaceholderAPI", "translateStringWithPlayer"),
/** 注销PAPI变量 @type {function(string):boolean} */
unRegisterPlaceholderAPI: ll.import("BEPlaceholderAPI", "unRegisterPlaceholder"),
unRegisterPlaceholderAPI: ll.imports("BEPlaceholderAPI", "unRegisterPlaceholder"),
/** 获取所有已注册的PAPI变量 @type {function():Array.<string>} */
getAllPAPI: ll.import("BEPlaceholderAPI", "getAllPAPI")
getAllPAPI: ll.imports("BEPlaceholderAPI", "getAllPAPI")
}
Function.prototype.getName =
+44 -7
View File
@@ -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 = {
@@ -79,7 +116,7 @@ module.exports = {
*/
emplaceListener: function (eventName, callback, priority = this.EventPriority.Normal, pluginName = getPluginName()) {
if (typeof callback !== "function") throw new Error("callback must be a function!");
const /** @type {number} */ eventId = ll.imports("GMLIB_Event_API", "emplaceListener")(pluginName, eventName, priority);
const /** @type {number} */ eventId = ll.importss("GMLIB_Event_API", "emplaceListener")(pluginName, eventName, priority);
if (eventId === -1) throw new Error(`Event ${eventName} creation failed!`);
ll.exports((...data) => {
let /** @type {boolean} */ result = typeof (data.slice(-1)[0]) === "boolean" ? data.pop() : false;
@@ -109,7 +146,7 @@ module.exports = {
* @param {boolean}
*/
removeListener: function (eventId) {
const result = ll.imports("GMLIB_Event_API", "removeListener")(eventId);
const result = ll.importss("GMLIB_Event_API", "removeListener")(eventId);
if (result) {
for (let [eventName, eventIds] of Object.entries(this.mEventData)) {
this.mEventData[eventName] = eventIds.filter(id => id !== eventId);
@@ -125,7 +162,7 @@ module.exports = {
* @returns {boolean}
*/
hasListener: function (eventId) {
return ll.imports("GMLIB_Event_API", "hasListener")(eventId);
return ll.importss("GMLIB_Event_API", "hasListener")(eventId);
},
/**
@@ -134,7 +171,7 @@ module.exports = {
* @returns {number?}
*/
getListenerPriority: function (eventId) {
const priority = ll.imports("GMLIB_Event_API", "getListenerPriority")(eventId);
const priority = ll.importss("GMLIB_Event_API", "getListenerPriority")(eventId);
return priority === -1 ? undefined : priority;
},
+24 -24
View File
@@ -1,4 +1,4 @@
// // const getNextCallbackId = ll.import("GMLIB_FormAPI", "getNextFormCallbackId");
// // const getNextCallbackId = ll.imports("GMLIB_FormAPI", "getNextFormCallbackId");
// class ServerSettingForm {
// constructor() {
@@ -6,35 +6,35 @@
// }
// static getDefaultPriority() {
// return ll.import("GMLIB_ServerSettingForm", "getDefaultPriority")();
// return ll.imports("GMLIB_ServerSettingForm", "getDefaultPriority")();
// }
// static hasTitle() {
// return ll.import("GMLIB_ServerSettingForm", "hasTitle")();
// return ll.imports("GMLIB_ServerSettingForm", "hasTitle")();
// }
// static getTitle() {
// return ll.import("GMLIB_ServerSettingForm", "getTitle")();
// return ll.imports("GMLIB_ServerSettingForm", "getTitle")();
// }
// static setTitle(title, forceModify = false) {
// return ll.import("GMLIB_ServerSettingForm", "setTitle")(title, forceModify);
// return ll.imports("GMLIB_ServerSettingForm", "setTitle")(title, forceModify);
// }
// static hasIcon() {
// return ll.import("GMLIB_ServerSettingForm", "hasIcon")();
// return ll.imports("GMLIB_ServerSettingForm", "hasIcon")();
// }
// static getIconData() {
// return hasIcon() ? ll.import("GMLIB_ServerSettingForm", "getIconData")() : null;
// return hasIcon() ? ll.imports("GMLIB_ServerSettingForm", "getIconData")() : null;
// }
// static getIconType() {
// return ll.import("GMLIB_ServerSettingForm", "getIconType")();
// return ll.imports("GMLIB_ServerSettingForm", "getIconType")();
// }
// static setIcon(data, type = 0, forceModify = false) {
// return ll.import("GMLIB_ServerSettingForm", "setIcon")(data, type, forceModify);
// return ll.imports("GMLIB_ServerSettingForm", "setIcon")(data, type, forceModify);
// }
// static addLabel(
@@ -44,7 +44,7 @@
// ) {
// let detectorId = getNextCallbackId();
// ll.export(playerDetector, "GMLIB_FORM_CALLBACK", detectorId);
// return ll.import("GMLIB_ServerSettingForm", "addLabel")(text, detectorId, priority);
// return ll.imports("GMLIB_ServerSettingForm", "addLabel")(text, detectorId, priority);
// }
@@ -60,7 +60,7 @@
// ll.export(callback, "GMLIB_FORM_CALLBACK", callbackId);
// let detectorId = getNextCallbackId();
// ll.export(playerDetector, "GMLIB_FORM_CALLBACK", detectorId);
// return ll.import("GMLIB_ServerSettingForm", "addInput")(text, placeholder, defaultVal, callbackId, detectorId, priority);
// return ll.imports("GMLIB_ServerSettingForm", "addInput")(text, placeholder, defaultVal, callbackId, detectorId, priority);
// }
// static addToggle(
@@ -74,7 +74,7 @@
// ll.export(callback, "GMLIB_FORM_CALLBACK", callbackId);
// let detectorId = getNextCallbackId();
// ll.export(playerDetector, "GMLIB_FORM_CALLBACK", detectorId);
// return ll.import("GMLIB_ServerSettingForm", "addToggle")(text, defaultVal, callbackId, detectorId, priority);
// return ll.imports("GMLIB_ServerSettingForm", "addToggle")(text, defaultVal, callbackId, detectorId, priority);
// }
// static addDropdown(
@@ -89,7 +89,7 @@
// ll.export(callback, "GMLIB_FORM_CALLBACK", callbackId);
// let detectorId = getNextCallbackId();
// ll.export(playerDetector, "GMLIB_FORM_CALLBACK", detectorId);
// return ll.import("GMLIB_ServerSettingForm", "addDropdown")(text, options, defaultVal, callbackId, detectorId, priority);
// return ll.imports("GMLIB_ServerSettingForm", "addDropdown")(text, options, defaultVal, callbackId, detectorId, priority);
// }
// static addSlider(
@@ -106,7 +106,7 @@
// ll.export(callback, "GMLIB_FORM_CALLBACK", callbackId);
// let detectorId = getNextCallbackId();
// ll.export(playerDetector, "GMLIB_FORM_CALLBACK", detectorId);
// return ll.import("GMLIB_ServerSettingForm", "addSlider")(text, min, max, step, defaultVal, callbackId, detectorId, priority);
// return ll.imports("GMLIB_ServerSettingForm", "addSlider")(text, min, max, step, defaultVal, callbackId, detectorId, priority);
// }
// static addStepSlider(
@@ -121,57 +121,57 @@
// ll.export(callback, "GMLIB_FORM_CALLBACK", callbackId);
// let detectorId = getNextCallbackId();
// ll.export(playerDetector, "GMLIB_FORM_CALLBACK", detectorId);
// return ll.import("GMLIB_ServerSettingForm", "addStepSlider")(text, steps, defaultVal, callbackId, detectorId, priority);
// return ll.imports("GMLIB_ServerSettingForm", "addStepSlider")(text, steps, defaultVal, callbackId, detectorId, priority);
// }
// static removeElement(id) {
// return ll.import("GMLIB_ServerSettingForm", "removeElement")(id);
// return ll.imports("GMLIB_ServerSettingForm", "removeElement")(id);
// }
// }
// class NpcDialogueForm {
// constructor(npcName, sceneName, dialogue) {
// this.mFormId = ll.import("GMLIB_NpcDialogueForm", "createForm")(npcName, sceneName, dialogue);
// this.mFormId = ll.imports("GMLIB_NpcDialogueForm", "createForm")(npcName, sceneName, dialogue);
// }
// addButton(button) {
// return ll.import("GMLIB_NpcDialogueForm", "addButton")(this.mFormId, button);
// return ll.imports("GMLIB_NpcDialogueForm", "addButton")(this.mFormId, button);
// }
// sendTo(pl, callback = (pl, index, type) => { }, free = true) {
// let callbackId = getNextCallbackId();
// ll.export(callback, "GMLIB_FORM_CALLBACK", callbackId);
// ll.import("GMLIB_NpcDialogueForm", "sendTo")(this.mFormId, pl, callbackId);
// ll.imports("GMLIB_NpcDialogueForm", "sendTo")(this.mFormId, pl, callbackId);
// if (free) {
// this.destroy();
// }
// }
// destroy() {
// ll.import("GMLIB_NpcDialogueForm", "destroyForm")(this.mFormId);
// ll.imports("GMLIB_NpcDialogueForm", "destroyForm")(this.mFormId);
// }
// }
// class ChestForm {
// constructor(npcName, sceneName, dialogue) {
// this.mFormId = ll.import("GMLIB_NpcDialogueForm", "createForm")(npcName, sceneName, dialogue);
// this.mFormId = ll.imports("GMLIB_NpcDialogueForm", "createForm")(npcName, sceneName, dialogue);
// }
// addButton(button) {
// return ll.import("GMLIB_NpcDialogueForm", "addButton")(this.mFormId, button);
// return ll.imports("GMLIB_NpcDialogueForm", "addButton")(this.mFormId, button);
// }
// sendTo(pl, free = true) {
// //let callbackId = getNextCallbackId();
// //ll.export(callback, "GMLIB_FORM_CALLBACK", callbackId);
// //ll.import("GMLIB_NpcDialogueForm", "sendTo")(this.mFormId, pl, callbackId);
// //ll.imports("GMLIB_NpcDialogueForm", "sendTo")(this.mFormId, pl, callbackId);
// //if (free) {
// // this.destroy();
// //}
// }
// destroy() {
// //ll.import("GMLIB_NpcDialogueForm", "destroyForm")(this.mFormId);
// //ll.imports("GMLIB_NpcDialogueForm", "destroyForm")(this.mFormId);
// }
// }
+3
View File
@@ -1556,6 +1556,9 @@ interface Player {
slot: number
): Item;
/** (GMLIB & Glacie)获取客户端版本协议*/
getNetworkProtocolVersion(): number
/** (GMLIB)发送更新更新物品数据包 */
sendInventorySlotPacket(
/** 容器ID */
+231 -221
View File
@@ -1,437 +1,439 @@
/** LRCA导出接口 */
const GMLIB_API = {
/** 创建悬浮字 @type {function(FloatPos,string,boolean):number} */
createFloatingText: ll.import("GMLIB_API", "createFloatingText"),
createFloatingText: ll.imports("GMLIB_API", "createFloatingText"),
/** 删除悬浮字 @type {function(number):boolean} */
deleteFloatingText: ll.import("GMLIB_API", "deleteFloatingText"),
deleteFloatingText: ll.imports("GMLIB_API", "deleteFloatingText"),
/** 设置悬浮字文本 @type {function(number,string):boolean} */
setFloatingTextData: ll.import("GMLIB_API", "setFloatingTextData"),
setFloatingTextData: ll.imports("GMLIB_API", "setFloatingTextData"),
/** 发送悬浮字给玩家 @type {function(number,Player):boolean} */
sendFloatingTextToPlayer: ll.import("GMLIB_API", "sendFloatingTextToPlayer"),
sendFloatingTextToPlayer: ll.imports("GMLIB_API", "sendFloatingTextToPlayer"),
/** 发送悬浮字给所有玩家 @type {function(number):boolean} */
sendFloatingText: ll.import("GMLIB_API", "sendFloatingText"),
sendFloatingText: ll.imports("GMLIB_API", "sendFloatingText"),
/** 删除玩家的悬浮字 @type {function(number,Player):boolean} */
removeFloatingTextFromPlayer: ll.import("GMLIB_API", "removeFloatingTextFromPlayer"),
removeFloatingTextFromPlayer: ll.imports("GMLIB_API", "removeFloatingTextFromPlayer"),
/** 删除所有玩家悬浮字 @type {function(number):boolean} */
removeFloatingText: ll.import("GMLIB_API", "removeFloatingText"),
removeFloatingText: ll.imports("GMLIB_API", "removeFloatingText"),
/** 更新玩家的悬浮字 @type {function(number,Player):boolean} */
updateClientFloatingTextData: ll.import("GMLIB_API", "updateClientFloatingTextData"),
updateClientFloatingTextData: ll.imports("GMLIB_API", "updateClientFloatingTextData"),
/** 更新所有玩家的悬浮字 @type {function(number):boolean} */
updateAllClientsFloatingTextData: ll.import("GMLIB_API", "updateAllClientsFloatingTextData"),
updateAllClientsFloatingTextData: ll.imports("GMLIB_API", "updateAllClientsFloatingTextData"),
/** 获取服务器Mspt @type {function():number} */
getServerMspt: ll.import("GMLIB_API", "getServerMspt"),
getServerMspt: ll.imports("GMLIB_API", "getServerMspt"),
/** 获取服务器当前tps @type {function():number} */
getServerCurrentTps: ll.import("GMLIB_API", "getServerCurrentTps"),
getServerCurrentTps: ll.imports("GMLIB_API", "getServerCurrentTps"),
/** 获取服务器平均tps @type {function():number} */
getServerAverageTps: ll.import("GMLIB_API", "getServerAverageTps"),
getServerAverageTps: ll.imports("GMLIB_API", "getServerAverageTps"),
/** 获取存档内所有玩家的uuid @type {function():Array<string>} */
getAllPlayerUuids: ll.import("GMLIB_API", "getAllPlayerUuids"),
getAllPlayerUuids: ll.imports("GMLIB_API", "getAllPlayerUuids"),
/** 获取玩家NBT @type {function(string):NbtCompound} */
getPlayerNbt: ll.import("GMLIB_API", "getPlayerNbt"),
getPlayerNbt: ll.imports("GMLIB_API", "getPlayerNbt"),
/** 设置玩家NBT @type {function(string,NbtCompound,boolean):boolean} */
setPlayerNbt: ll.import("GMLIB_API", "setPlayerNbt"),
setPlayerNbt: ll.imports("GMLIB_API", "setPlayerNbt"),
/** 覆盖玩家的特定nbtTags @type {function(string,NbtCompound,Array.<string>):boolean} */
setPlayerNbtTags: ll.import("GMLIB_API", "setPlayerNbtTags"),
setPlayerNbtTags: ll.imports("GMLIB_API", "setPlayerNbtTags"),
/** 删除玩家所有的NBT @type {function(string):boolean} */
deletePlayerNbt: ll.import("GMLIB_API", "deletePlayerNbt"),
deletePlayerNbt: ll.imports("GMLIB_API", "deletePlayerNbt"),
/** 使用特定语言翻译资源包文本 @type {function(string,Array.<string>,string):string} */
resourcePackTranslate: ll.import("GMLIB_API", "resourcePackTranslate"),
resourcePackTranslate: ll.imports("GMLIB_API", "resourcePackTranslate"),
/** 使用默认语言翻译资源包文本 @type {function(string,Array.<string>):string} */
resourcePackDefaultTranslate: ll.import("GMLIB_API", "resourcePackDefaultTranslate"),
resourcePackDefaultTranslate: ll.imports("GMLIB_API", "resourcePackDefaultTranslate"),
/** 获取资源包默认语言 @type {function():string} */
getResourcePackI18nLanguage: ll.import("GMLIB_API", "getResourcePackI18nLanguage"),
getResourcePackI18nLanguage: ll.imports("GMLIB_API", "getResourcePackI18nLanguage"),
/** 设置资源包默认语言 @type {function(string):void} */
chooseResourcePackI18nLanguage: ll.import("GMLIB_API", "chooseResourcePackI18nLanguage"),
chooseResourcePackI18nLanguage: ll.imports("GMLIB_API", "chooseResourcePackI18nLanguage"),
/** 启用教育版内容 @type {function():void} */
setEducationFeatureEnabled: ll.import("GMLib_ServerAPI", "setEducationFeatureEnabled"),
setEducationFeatureEnabled: ll.imports("GMLib_ServerAPI", "setEducationFeatureEnabled"),
/** 注册Ability命令 @type {function():void} */
registerAbilityCommand: ll.import("GMLib_ServerAPI", "registerAbilityCommand"),
registerAbilityCommand: ll.imports("GMLib_ServerAPI", "registerAbilityCommand"),
/** 启用Xbox成就 @type {function():void} */
setEnableAchievement: ll.import("GMLib_ServerAPI", "setEnableAchievement"),
setEnableAchievement: ll.imports("GMLib_ServerAPI", "setEnableAchievement"),
/** 信任所有玩家皮肤 @type {function():void} */
setForceTrustSkins: ll.import("GMLib_ServerAPI", "setForceTrustSkins"),
setForceTrustSkins: ll.imports("GMLib_ServerAPI", "setForceTrustSkins"),
/** 资源包双端共存 @type {function():void} */
enableCoResourcePack: ll.import("GMLib_ServerAPI", "enableCoResourcePack"),
enableCoResourcePack: ll.imports("GMLib_ServerAPI", "enableCoResourcePack"),
/** 获取存档名字 @type {function():string} */
getLevelName: ll.import("GMLib_ServerAPI", "getLevelName"),
getLevelName: ll.imports("GMLib_ServerAPI", "getLevelName"),
/** 设置存档名字 @type {function(string):boolean} */
setLevelName: ll.import("GMLib_ServerAPI", "setLevelName"),
setLevelName: ll.imports("GMLib_ServerAPI", "setLevelName"),
/** 设置假种子 @type {function(number):void} */
setFakeSeed: ll.import("GMLib_ServerAPI", "setFakeSeed"),
setFakeSeed: ll.imports("GMLib_ServerAPI", "setFakeSeed"),
/** 强制生成实体 @type {function(FloatPos,string):Entity} */
spawnEntity: ll.import("GMLib_ServerAPI", "spawnEntity"),
spawnEntity: ll.imports("GMLib_ServerAPI", "spawnEntity"),
/** 射弹投射物 @type {function(Entity,string,number,number):boolean} */
shootProjectile: ll.import("GMLib_ServerAPI", "shootProjectile"),
shootProjectile: ll.imports("GMLib_ServerAPI", "shootProjectile"),
/** 投掷实体 @type {function(Entity,Entity,number,number):boolean} */
throwEntity: ll.import("GMLib_ServerAPI", "throwEntity"),
throwEntity: ll.imports("GMLib_ServerAPI", "throwEntity"),
/** 根据玩家对象获取实体对象 @type {function(Player):Entity} */
PlayerToEntity: ll.import("GMLib_ServerAPI", "PlayerToEntity"),
PlayerToEntity: ll.imports("GMLib_ServerAPI", "PlayerToEntity"),
/** 启用错误方块清理 @type {function():void} */
setUnknownBlockCleaner: ll.import("GMLib_ModAPI", "setUnknownBlockCleaner"),
setUnknownBlockCleaner: ll.imports("GMLib_ModAPI", "setUnknownBlockCleaner"),
/** 获取实验性功能ID列表 @type {function():Array<number>} */
getAllExperiments: ll.import("GMLIB_API", "getAllExperiments"),
getAllExperiments: ll.imports("GMLIB_API", "getAllExperiments"),
/** 获取实验性功能文本的键名 @type {function(number):string} */
getExperimentTranslateKey: ll.import("GMLIB_API", "getExperimentTranslateKey"),
getExperimentTranslateKey: ll.imports("GMLIB_API", "getExperimentTranslateKey"),
/** 获取实验性功能启用状态 @type {function(number):boolean} */
getExperimentEnabled: ll.import("GMLib_ModAPI", "getExperimentEnabled"),
getExperimentEnabled: ll.imports("GMLib_ModAPI", "getExperimentEnabled"),
/** 设置实验性功能启用状态 @type {function(number,boolean):void} */
setExperimentEnabled: ll.import("GMLib_ModAPI", "setExperimentEnabled"),
setExperimentEnabled: ll.imports("GMLib_ModAPI", "setExperimentEnabled"),
/** 注销合成表 @type {function(string):boolean} */
unregisterRecipe: ll.import("GMLIB_API", "unregisterRecipe"),
unregisterRecipe: ll.imports("GMLIB_API", "unregisterRecipe"),
/** 设置实验性依赖 @type {function(number):void} */
registerExperimentsRequire: ll.import("GMLib_ModAPI", "registerExperimentsRequire"),
registerExperimentsRequire: ll.imports("GMLib_ModAPI", "registerExperimentsRequire"),
/** 注册切石机合成表 @type {function(string,string,number,string,number,number):boolean} */
registerStoneCutterRecipe: ll.import("GMLib_ModAPI", "registerStoneCutterRecipe"),
registerStoneCutterRecipe: ll.imports("GMLib_ModAPI", "registerStoneCutterRecipe"),
/** 注册锻造纹饰合成表 @type {function(string,string,string,string):boolean} */
registerSmithingTrimRecipe: ll.import("GMLib_ModAPI", "registerSmithingTrimRecipe"),
registerSmithingTrimRecipe: ll.imports("GMLib_ModAPI", "registerSmithingTrimRecipe"),
/** 注册锻造配方合成表 @type {function(string,string,string,string):boolean} */
registerSmithingTransformRecipe: ll.import("GMLib_ModAPI", "registerSmithingTransformRecipe"),
registerSmithingTransformRecipe: ll.imports("GMLib_ModAPI", "registerSmithingTransformRecipe"),
/** 注册酿造容器表 @type {function(string,string,string,string):boolean} */
registerBrewingContainerRecipe: ll.import("GMLib_ModAPI", "registerBrewingContainerRecipe"),
registerBrewingContainerRecipe: ll.imports("GMLib_ModAPI", "registerBrewingContainerRecipe"),
/** 注册酿造混合表 @type {function(string,string,string,string):boolean} */
registerBrewingMixRecipe: ll.import("GMLib_ModAPI", "registerBrewingMixRecipe"),
registerBrewingMixRecipe: ll.imports("GMLib_ModAPI", "registerBrewingMixRecipe"),
/** 注册熔炼合成表 @type {function(string,string,string,Array.<string>):boolean} */
registerFurnaceRecipe: ll.import("GMLib_ModAPI", "registerFurnaceRecipe"),
registerFurnaceRecipe: ll.imports("GMLib_ModAPI", "registerFurnaceRecipe"),
/** 注册有序合成表 @type {function(string,Array.<string>,Array.<string>,string,number,string)} */
registerShapedRecipe: ll.import("GMLib_ModAPI", "registerShapedRecipe"),
registerShapedRecipe: ll.imports("GMLib_ModAPI", "registerShapedRecipe"),
/** 注册无序合成表 @type {function(string,Array.<string>,Array.<string>,string,number,string)} */
registerShapelessRecipe: ll.import("GMLib_ModAPI", "registerShapelessRecipe"),
registerShapelessRecipe: ll.imports("GMLib_ModAPI", "registerShapelessRecipe"),
/** 注册有序合成表 @type {function(string,Array.<string>,Array.<string>,string,number,string)} */
registerCustomShapedRecipe: ll.import("GMLIB_API", "registerCustomShapedRecipe"),
registerCustomShapedRecipe: ll.imports("GMLIB_API", "registerCustomShapedRecipe"),
/** 注册无序合成表 @type {function(string,Array.<string>,Array.<string>,string,number,string)} */
registerCustomShapelessRecipe: ll.import("GMLIB_API", "registerCustomShapelessRecipe"),
registerCustomShapelessRecipe: ll.imports("GMLIB_API", "registerCustomShapelessRecipe"),
/** 检测LRCA版本是否大于或等于此版本 @type {function(number,number,number):boolean} */
isVersionMatched: ll.import("GMLIB_API", "isVersionMatched"),
isVersionMatched: ll.imports("GMLIB_API", "isVersionMatched"),
/** 获取LRCA版本 @type {function():string} */
getVersion_LRCA: ll.import("GMLIB_API", "getVersion_LRCA"),
getVersion_LRCA: ll.imports("GMLIB_API", "getVersion_LRCA"),
/** 获取GMLIB版本 @type {function():string} */
getVersion_GMLIB: ll.import("GMLIB_API", "getVersion_GMLIB"),
getVersion_GMLIB: ll.imports("GMLIB_API", "getVersion_GMLIB"),
/** 获取玩家坐标 @type {function(string):IntPos} */
getPlayerPosition: ll.import("GMLIB_API", "getPlayerPosition"),
getPlayerPosition: ll.imports("GMLIB_API", "getPlayerPosition"),
/** 设置玩家坐标 @type {function(string,IntPos):boolean} */
setPlayerPosition: ll.import("GMLIB_API", "setPlayerPosition"),
setPlayerPosition: ll.imports("GMLIB_API", "setPlayerPosition"),
/** 玩家是否存在于计分板 @type {function(string,string):boolean} */
playerHasScore: ll.import("GMLIB_API", "playerHasScore"),
playerHasScore: ll.imports("GMLIB_API", "playerHasScore"),
/** 获取玩家在计分板中的值 @type {function(string,string):number} */
getPlayerScore: ll.import("GMLIB_API", "getPlayerScore"),
getPlayerScore: ll.imports("GMLIB_API", "getPlayerScore"),
/** 增加玩家在计分板中的值 @type {function(string,string,number):boolean} */
addPlayerScore: ll.import("GMLIB_API", "addPlayerScore"),
addPlayerScore: ll.imports("GMLIB_API", "addPlayerScore"),
/** 减少玩家在计分板中的值 @type {function(string,string,number):boolean} */
reducePlayerScore: ll.import("GMLIB_API", "reducePlayerScore"),
reducePlayerScore: ll.imports("GMLIB_API", "reducePlayerScore"),
/** 设置玩家在计分板中的值 @type {function(string,string,number):boolean} */
setPlayerScore: ll.import("GMLIB_API", "setPlayerScore"),
setPlayerScore: ll.imports("GMLIB_API", "setPlayerScore"),
/** 重置玩家在计分板中的数据 @type {function(string,string):boolean} */
resetPlayerScore: ll.import("GMLIB_API", "resetPlayerScore"),
resetPlayerScore: ll.imports("GMLIB_API", "resetPlayerScore"),
/** 重置玩家所有的计分板数据 @type {function(string):boolean} */
resetPlayerScores: ll.import("GMLIB_API", "resetPlayerScores"),
resetPlayerScores: ll.imports("GMLIB_API", "resetPlayerScores"),
/** 实体是否存在于计分板中 @type {function(string,string):boolean} */
entityHasScore: ll.import("GMLIB_API", "entityHasScore"),
entityHasScore: ll.imports("GMLIB_API", "entityHasScore"),
/** 获取实体在计分板中的值 @type {function(string,string):number} */
getEntityScore: ll.import("GMLIB_API", "getEntityScore"),
getEntityScore: ll.imports("GMLIB_API", "getEntityScore"),
/** 增加实体在计分板中的值 @type {function(string,string,number):boolean} */
addEntityScore: ll.import("GMLIB_API", "addEntityScore"),
addEntityScore: ll.imports("GMLIB_API", "addEntityScore"),
/** 减少实体在计分板中的值 @type {function(string,string,number):boolean} */
reduceEntityScore: ll.import("GMLIB_API", "reduceEntityScore"),
reduceEntityScore: ll.imports("GMLIB_API", "reduceEntityScore"),
/** 设置实体在计分板中的值 @type {function(string,string,number):boolean} */
setEntityScore: ll.import("GMLIB_API", "setEntityScore"),
setEntityScore: ll.imports("GMLIB_API", "setEntityScore"),
/** 重置实体在计分板中的数据 @type {function(string,string):boolean} */
resetEntityScore: ll.import("GMLIB_API", "resetEntityScore"),
resetEntityScore: ll.imports("GMLIB_API", "resetEntityScore"),
/** 重置实体所有的计分板数据 @type {function(string):boolean} */
resetEntityScores: ll.import("GMLIB_API", "resetEntityScores"),
resetEntityScores: ll.imports("GMLIB_API", "resetEntityScores"),
/** 字符串是否存在于计分板 @type {function(string,string):boolean} */
fakePlayerHasScore: ll.import("GMLIB_API", "fakePlayerHasScore"),
fakePlayerHasScore: ll.imports("GMLIB_API", "fakePlayerHasScore"),
/** 获取字符串在计分板中的值 @type {function(string,string):number} */
getFakePlayerScore: ll.import("GMLIB_API", "getFakePlayerScore"),
getFakePlayerScore: ll.imports("GMLIB_API", "getFakePlayerScore"),
/** 增加字符串在计分板中的值 @type {function(string,string,number):boolean} */
addFakePlayerScore: ll.import("GMLIB_API", "addFakePlayerScore"),
addFakePlayerScore: ll.imports("GMLIB_API", "addFakePlayerScore"),
/** 减少字符串在计分板中的值 @type {function(string,string,number):boolean} */
reduceFakePlayerScore: ll.import("GMLIB_API", "reduceFakePlayerScore"),
reduceFakePlayerScore: ll.imports("GMLIB_API", "reduceFakePlayerScore"),
/** 设置字符串在计分板中的值 @type {function(string,string,number):boolean} */
setFakePlayerScore: ll.import("GMLIB_API", "setFakePlayerScore"),
setFakePlayerScore: ll.imports("GMLIB_API", "setFakePlayerScore"),
/** 重置字符串在计分板中的数据 @type {function(string,string):boolean} */
resetFakePlayerScore: ll.import("GMLIB_API", "resetFakePlayerScore"),
resetFakePlayerScore: ll.imports("GMLIB_API", "resetFakePlayerScore"),
/** 重置字符串所有的计分板数据 @type {function(string):boolean} */
resetFakePlayerScores: ll.import("GMLIB_API", "resetFakePlayerScores"),
resetFakePlayerScores: ll.imports("GMLIB_API", "resetFakePlayerScores"),
/** 创建计分板 @type {function(string):boolean} */
addObjective: ll.import("GMLIB_API", "addObjective"),
addObjective: ll.imports("GMLIB_API", "addObjective"),
/** 创建带有显示名称的计分板 @type {function(string,string):boolean} */
addObjectiveWithDisplayName: ll.import("GMLIB_API", "addObjectiveWithDisplayName"),
addObjectiveWithDisplayName: ll.imports("GMLIB_API", "addObjectiveWithDisplayName"),
/** 获取计分板显示名字 @type {function(string):string} */
getDisplayName: ll.import("GMLIB_API", "getDisplayName"),
getDisplayName: ll.imports("GMLIB_API", "getDisplayName"),
/** 设置计分板显示名字 @type {function(string,string):boolean} */
setDisplayName: ll.import("GMLIB_API", "setDisplayName"),
setDisplayName: ll.imports("GMLIB_API", "setDisplayName"),
/** 删除计分板 @type {function(string):boolean} */
removeObjective: ll.import("GMLIB_API", "removeObjective"),
removeObjective: ll.imports("GMLIB_API", "removeObjective"),
/** 设置计分板显示 @type {function(string,"list"|"sidebar"|"belowname",0|1):void} */
setDisplayObjective: ll.import("GMLIB_API", "setDisplayObjective"),
setDisplayObjective: ll.imports("GMLIB_API", "setDisplayObjective"),
/** 清除计分板显示 @type {function("list"|"sidebar"|"belowname"):void} */
clearDisplayObjective: ll.import("GMLIB_API", "clearDisplayObjective"),
clearDisplayObjective: ll.imports("GMLIB_API", "clearDisplayObjective"),
/** 获取所有计分板 @type {function():Array.<string>} */
getAllObjectives: ll.import("GMLIB_API", "getAllObjectives"),
getAllObjectives: ll.imports("GMLIB_API", "getAllObjectives"),
/** 获取所有跟踪目标 @type {function():Array.<{"Type":"Player","Uuid":string}|{"Type":"FakePlayer","Name":string}|{"Type":"Entity","UniqueId":string}>} */
getAllTrackedTargets: ll.import("GMLIB_API", "getAllTrackedTargets"),
getAllTrackedTargets: ll.imports("GMLIB_API", "getAllTrackedTargets"),
/** 获取所有跟踪玩家 @type {function():Array.<string>} */
getAllScoreboardPlayers: ll.import("GMLIB_API", "getAllScoreboardPlayers"),
getAllScoreboardPlayers: ll.imports("GMLIB_API", "getAllScoreboardPlayers"),
/** 获取所有跟踪字符串 @type {function():Array.<string>} */
getAllScoreboardFakePlayers: ll.import("GMLIB_API", "getAllScoreboardFakePlayers"),
getAllScoreboardFakePlayers: ll.imports("GMLIB_API", "getAllScoreboardFakePlayers"),
/** 获取所有跟踪实体 @type {function():Array.<string>} */
getAllScoreboardEntities: ll.import("GMLIB_API", "getAllScoreboardEntities"),
getAllScoreboardEntities: ll.imports("GMLIB_API", "getAllScoreboardEntities"),
/** 根据uuid获取玩家对象 @type {function(string):Player} */
getPlayerFromUuid: ll.import("GMLIB_API", "getPlayerFromUuid"),
getPlayerFromUuid: ll.imports("GMLIB_API", "getPlayerFromUuid"),
/** 根据UniqueId获取玩家对象 @type {function(string):Player} */
getPlayerFromUniqueId: ll.import("GMLIB_API", "getPlayerFromUniqueId"),
getPlayerFromUniqueId: ll.imports("GMLIB_API", "getPlayerFromUniqueId"),
/** 根据UniqueId获取实体对象 @type {function(string):Entity} */
getEntityFromUniqueId: ll.import("GMLIB_API", "getEntityFromUniqueId"),
getEntityFromUniqueId: ll.imports("GMLIB_API", "getEntityFromUniqueId"),
/** 获取世界出生点 @type {function():IntPos} */
getWorldSpawn: ll.import("GMLIB_API", "getWorldSpawn"),
getWorldSpawn: ll.imports("GMLIB_API", "getWorldSpawn"),
/** 设置世界出生点 @type {function(IntPos):void} */
setWorldSpawn: ll.import("GMLIB_API", "setWorldSpawn"),
setWorldSpawn: ll.imports("GMLIB_API", "setWorldSpawn"),
/** 获取玩家重生点 @type {function(Player):IntPos} */
getPlayerSpawnPoint: ll.import("GMLIB_API", "getPlayerSpawnPoint"),
getPlayerSpawnPoint: ll.imports("GMLIB_API", "getPlayerSpawnPoint"),
/** 设置玩家重生点 @type {function(Player,IntPos):void} */
setPlayerSpawnPoint: ll.import("GMLIB_API", "setPlayerSpawnPoint"),
setPlayerSpawnPoint: ll.imports("GMLIB_API", "setPlayerSpawnPoint"),
/** 清除玩家重生点 @type {function(Player):void} */
clearPlayerSpawnPoint: ll.import("GMLIB_API", "clearPlayerSpawnPoint"),
clearPlayerSpawnPoint: ll.imports("GMLIB_API", "clearPlayerSpawnPoint"),
/** 设置资源包路径 @type {function(string):void} */
setCustomPackPath: ll.import("GMLIB_API", "setCustomPackPath"),
setCustomPackPath: ll.imports("GMLIB_API", "setCustomPackPath"),
/** 获取支持的语言标识符 @type {function():Array.<string>} */
getSupportedLanguages: ll.import("GMLIB_API", "getSupportedLanguages"),
getSupportedLanguages: ll.imports("GMLIB_API", "getSupportedLanguages"),
/** 加载语言翻译 @type {function(string,string):void} */
loadLanguage: ll.import("GMLIB_API", "loadLanguage"),
loadLanguage: ll.imports("GMLIB_API", "loadLanguage"),
/** 更新或创建语言文件 @type {function(string,string,string):void} */
updateOrCreateLanguageFile: ll.import("GMLIB_API", "updateOrCreateLanguageFile"),
updateOrCreateLanguageFile: ll.imports("GMLIB_API", "updateOrCreateLanguageFile"),
/** 加载语言文件目录 @type {function(string):void} */
loadLanguagePath: ll.import("GMLIB_API", "loadLanguagePath"),
loadLanguagePath: ll.imports("GMLIB_API", "loadLanguagePath"),
/** 合并json @type {function(string,string):string} */
mergePatchJson: ll.import("GMLIB_API", "mergePatchJson"),
mergePatchJson: ll.imports("GMLIB_API", "mergePatchJson"),
/** 根据uuid获取xuid @type {function(string):string} */
getXuidByUuid: ll.import("GMLIB_API", "getXuidByUuid"),
getXuidByUuid: ll.imports("GMLIB_API", "getXuidByUuid"),
/** 根据uuid获取名字 @type {function(string):string} */
getNameByUuid: ll.import("GMLIB_API", "getNameByUuid"),
getNameByUuid: ll.imports("GMLIB_API", "getNameByUuid"),
/** 根据xuid获取uuid @type {function(string):string} */
getUuidByXuid: ll.import("GMLIB_API", "getUuidByXuid"),
getUuidByXuid: ll.imports("GMLIB_API", "getUuidByXuid"),
/** 根据xuid获取名字 @type {function(string):string} */
getNameByXuid: ll.import("GMLIB_API", "getNameByXuid"),
getNameByXuid: ll.imports("GMLIB_API", "getNameByXuid"),
/** 根据名字获取xuid @type {function(string):string} */
getXuidByName: ll.import("GMLIB_API", "getXuidByName"),
getXuidByName: ll.imports("GMLIB_API", "getXuidByName"),
/** 根据名字获取uuid @type {function(string):string} */
getUuidByName: ll.import("GMLIB_API", "getUuidByName"),
getUuidByName: ll.imports("GMLIB_API", "getUuidByName"),
/** 获取所有已记录的玩家信息 @type {function():Array.<{"Uuid":string,"Xuid":string,"Name":string}>} */
getAllPlayerInfo: ll.import("GMLIB_API", "getAllPlayerInfo"),
getAllPlayerInfo: ll.imports("GMLIB_API", "getAllPlayerInfo"),
/** 获取方块RuntimeId @type {function(string,number):number} */
getBlockRuntimeId: ll.import("GMLIB_API", "getBlockRuntimeId"),
getBlockRuntimeId: ll.imports("GMLIB_API", "getBlockRuntimeId"),
/** 添加虚假列表玩家 @type {function(string,string):boolean} */
addFakeList: ll.import("GMLIB_API", "addFakeList"),
addFakeList: ll.imports("GMLIB_API", "addFakeList"),
/** 删除虚假列表玩家 @type {function(string):boolean} */
removeFakeList: ll.import("GMLIB_API", "removeFakeList"),
removeFakeList: ll.imports("GMLIB_API", "removeFakeList"),
/** 删除所有虚假列表玩家 @type {function():void} */
removeAllFakeLists: ll.import("GMLIB_API", "removeAllFakeList"),
removeAllFakeLists: ll.imports("GMLIB_API", "removeAllFakeList"),
/** 启用I18n修复 @type {function():void} */
setFixI18nEnabled: ll.import("GMLib_ModAPI", "setFixI18nEnabled"),
setFixI18nEnabled: ll.imports("GMLib_ModAPI", "setFixI18nEnabled"),
/** 获取方块翻译键名 @type {function(Block):string} */
getBlockTranslateKey: ll.import("GMLIB_API", "getBlockTranslateKey"),
getBlockTranslateKey: ll.imports("GMLIB_API", "getBlockTranslateKey"),
/** 获取物品翻译键名 @type {function(Item):string} */
getItemTranslateKey: ll.import("GMLIB_API", "getItemTranslateKey"),
getItemTranslateKey: ll.imports("GMLIB_API", "getItemTranslateKey"),
/** 获取实体翻译键名 @type {function(Entity):string} */
getEntityTranslateKey: ll.import("GMLIB_API", "getEntityTranslateKey"),
getEntityTranslateKey: ll.imports("GMLIB_API", "getEntityTranslateKey"),
/** 从文件中读取NBT @type {function(string,boolean):NbtCompound} */
readNbtFromFile: ll.import("GMLIB_API", "readNbtFromFile"),
readNbtFromFile: ll.imports("GMLIB_API", "readNbtFromFile"),
/** 保存NBT至文件 @type {function(string,NbtCompound,boolean):void} */
saveNbtToFile: ll.import("GMLIB_API", "saveNbtToFile"),
saveNbtToFile: ll.imports("GMLIB_API", "saveNbtToFile"),
/** 获取方块硬度 @type {function(Block):number} */
getBlockDestroySpeed: ll.import("GMLIB_API", "getBlockDestroySpeed"),
getBlockDestroySpeed: ll.imports("GMLIB_API", "getBlockDestroySpeed"),
/** 获取物品挖掘方块速度 @type {function(Item,Block):number} */
getDestroyBlockSpeed: ll.import("GMLIB_API", "getDestroyBlockSpeed"),
getDestroyBlockSpeed: ll.imports("GMLIB_API", "getDestroyBlockSpeed"),
/** 使玩家挖掘方块 @type {function(Block,IntPos,Player):void} */
playerDestroyBlock: ll.import("GMLIB_API", "playerDestroyBlock"),
playerDestroyBlock: ll.imports("GMLIB_API", "playerDestroyBlock"),
/** 物品冒险模式下是否可以挖掘方块 @type {function(Item,Block):boolean} */
itemCanDestroyBlock: ll.import("GMLIB_API", "itemCanDestroyBlock"),
itemCanDestroyBlock: ll.imports("GMLIB_API", "itemCanDestroyBlock"),
/** 物品是否能破坏方块 @type {function(Item):boolean} */
itemCanDestroyInCreative: ll.import("GMLIB_API", "itemCanDestroyInCreative"),
itemCanDestroyInCreative: ll.imports("GMLIB_API", "itemCanDestroyInCreative"),
/** 物品是否可以采集方块 @type {function(Item,Block):boolean} */
itemCanDestroySpecial: ll.import("GMLIB_API", "itemCanDestroySpecial"),
itemCanDestroySpecial: ll.imports("GMLIB_API", "itemCanDestroySpecial"),
/** @type {function(Block):boolean} */
blockCanDropWithAnyTool: ll.import("GMLIB_API", "blockCanDropWithAnyTool"),
blockCanDropWithAnyTool: ll.imports("GMLIB_API", "blockCanDropWithAnyTool"),
/** @type {function(Block,Player,IntPos):boolean} */
blockPlayerWillDestroy: ll.import("GMLIB_API", "blockPlayerWillDestroy"),
blockPlayerWillDestroy: ll.imports("GMLIB_API", "blockPlayerWillDestroy"),
/** 使玩家攻击实体 @type {function(Entity,Player):boolean} */
playerAttack: ll.import("GMLIB_API", "playerAttack"),
/** @type {function(Player,Entity):boolean} */
playerPullInEntity: ll.import("GMLIB_API", "playerPullInEntity"),
playerAttack: ll.imports("GMLIB_API", "playerAttack"),
/** @type {function(Player,Entity):void} */
playerPullInEntity: ll.imports("GMLIB_API", "playerPullInEntity"),
/** 根据命令空间获取翻译键名 @type {function(string):string} */
getBlockTranslateKeyFromName: ll.import("GMLIB_API", "getBlockTranslateKeyFromName"),
getBlockTranslateKeyFromName: ll.imports("GMLIB_API", "getBlockTranslateKeyFromName"),
/** 获取存档种子 @type {function():string} */
getLevelSeed: ll.import("GMLib_ServerAPI", "getLevelSeed"),
getLevelSeed: ll.imports("GMLib_ServerAPI", "getLevelSeed"),
/** 获取方块亮度 @type {function(string,number):number} */
getBlockLightEmission: ll.import("GMLIB_API", "getBlockLightEmission"),
getBlockLightEmission: ll.imports("GMLIB_API", "getBlockLightEmission"),
/** 获取游戏规则列表 @type {function():Array.<{Name:string,Value:string,Type:"Bool"|"Float"|"Int"}>} */
getGameRules: ll.import("GMLIB_API", "getGameRules"),
getGameRules: ll.imports("GMLIB_API", "getGameRules"),
/** 给物品添加附魔 @type {function(Item,string,number,boolean):boolean} */
applyEnchant: ll.import("GMLIB_API", "applyEnchant"),
applyEnchant: ll.imports("GMLIB_API", "applyEnchant"),
/** 删除物品所有附魔 @type {function(Item):void} */
removeEnchants: ll.import("GMLIB_API", "removeEnchants"),
removeEnchants: ll.imports("GMLIB_API", "removeEnchants"),
/** 判断物品是否拥有附魔 @type {function(Item,string):boolean} */
hasEnchant: ll.import("GMLIB_API", "hasEnchant"),
hasEnchant: ll.imports("GMLIB_API", "hasEnchant"),
/** 获取附魔等级 @type {function(Item,string):number} */
getEnchantLevel: ll.import("GMLIB_API", "getEnchantLevel"),
getEnchantLevel: ll.imports("GMLIB_API", "getEnchantLevel"),
/** 获取附魔名字 @type {function(string,number):number} */
getEnchantNameAndLevel: ll.import("GMLIB_API", "getEnchantNameAndLevel"),
getEnchantNameAndLevel: ll.imports("GMLIB_API", "getEnchantNameAndLevel"),
/** 通过ID获取附魔命名空间ID @type {function(number):string} */
getEnchantTypeNameFromId: ll.import("GMLIB_API", "getEnchantTypeNameFromId"),
getEnchantTypeNameFromId: ll.imports("GMLIB_API", "getEnchantTypeNameFromId"),
/** 获取最大玩家数 @type {function():number} */
getMaxPlayers: ll.import("GMLib_ServerAPI", "getMaxPlayers"),
getMaxPlayers: ll.imports("GMLib_ServerAPI", "getMaxPlayers"),
/** 丢出玩家背包内物品 @type {function(Player,Item,boolean):boolean} */
dropPlayerItem: ll.import("GMLIB_API", "dropPlayerItem"),
dropPlayerItem: ll.imports("GMLIB_API", "dropPlayerItem"),
/** 获取玩家的RuntimeId @type {function(Player):number} */
getPlayerRuntimeId: ll.import("GMLIB_API", "getPlayerRuntimeId"),
getPlayerRuntimeId: ll.imports("GMLIB_API", "getPlayerRuntimeId"),
/** 获取实体的RuntimeId @type {function(Entity):number} */
getEntityRuntimeId: ll.import("GMLIB_API", "getEntityRuntimeId"),
getEntityRuntimeId: ll.imports("GMLIB_API", "getEntityRuntimeId"),
/** 获取实体命名 @type {function(Entity):string} */
getEntityNameTag: ll.import("GMLIB_API", "getEntityNameTag"),
getEntityNameTag: ll.imports("GMLIB_API", "getEntityNameTag"),
/** 物品是否有不可破坏标签 @type {function(Item):boolean} */
ItemisUnbreakable: ll.import("GMLIB_API", "ItemisUnbreakable"),
ItemisUnbreakable: ll.imports("GMLIB_API", "ItemisUnbreakable"),
/** 设置物品不可破坏标签 @type {function(Item,boolean):void} */
setItemUnbreakable: ll.import("GMLIB_API", "setItemUnbreakable"),
setItemUnbreakable: ll.imports("GMLIB_API", "setItemUnbreakable"),
/** 物品是否死亡不会掉落 @type {function(Item):boolean} */
getItemShouldKeepOnDeath: ll.import("GMLIB_API", "getItemShouldKeepOnDeath"),
getItemShouldKeepOnDeath: ll.imports("GMLIB_API", "getItemShouldKeepOnDeath"),
/** 设置物品死亡不掉落 @type {function(Item,boolean):void} */
setItemShouldKeepOnDeath: ll.import("GMLIB_API", "setItemShouldKeepOnDeath"),
setItemShouldKeepOnDeath: ll.imports("GMLIB_API", "setItemShouldKeepOnDeath"),
/** 获取物品锁定模式 @type {function(Item):number} */
getItemLockMode: ll.import("GMLIB_API", "getItemLockMode"),
getItemLockMode: ll.imports("GMLIB_API", "getItemLockMode"),
/** 设置物品锁定模式 @type {function(Item,number):void} */
setItemLockMode: ll.import("GMLIB_API", "setItemLockMode"),
setItemLockMode: ll.imports("GMLIB_API", "setItemLockMode"),
/** 获取物品惩罚等级 @type {function(Item):number} */
getItemRepairCost: ll.import("GMLIB_API", "getItemRepairCost"),
getItemRepairCost: ll.imports("GMLIB_API", "getItemRepairCost"),
/** 设置物品惩罚等级 @type {function(Item,number):void} */
setItemRepairCost: ll.import("GMLIB_API", "setItemRepairCost"),
setItemRepairCost: ll.imports("GMLIB_API", "setItemRepairCost"),
/** 获取物品冒险模式下可破坏的方块 @type {function(Item):Array.<string>} */
getItemCanDestroy: ll.import("GMLIB_API", "getItemCanDestroy"),
getItemCanDestroy: ll.imports("GMLIB_API", "getItemCanDestroy"),
/** 设置物品冒险模式下可破坏的方块 @type {function(Item,Array.<string>):void} */
setItemCanDestroy: ll.import("GMLIB_API", "setItemCanDestroy"),
setItemCanDestroy: ll.imports("GMLIB_API", "setItemCanDestroy"),
/** 获取物品冒险模式下能放置在什么方块上 @type {function(Item):Array.<string>} */
getItemCanPlaceOn: ll.import("GMLIB_API", "getItemCanPlaceOn"),
getItemCanPlaceOn: ll.imports("GMLIB_API", "getItemCanPlaceOn"),
/** 设置物品冒险模式下能放置在什么方块上 @type {function(Item,Array.<string>):void} */
setItemCanPlaceOn: ll.import("GMLIB_API", "setItemCanPlaceOn"),
setItemCanPlaceOn: ll.imports("GMLIB_API", "setItemCanPlaceOn"),
/** 获取玩家饥饿值 @type {function(Player):number} */
getPlayerHungry: ll.import("GMLIB_API", "getPlayerHungry"),
getPlayerHungry: ll.imports("GMLIB_API", "getPlayerHungry"),
/** 获取玩家盔甲覆盖百分比 @type {function(Player):number} */
getPlayerArmorCoverPercentage: ll.import("GMLIB_API", "getPlayerArmorCoverPercentage"),
getPlayerArmorCoverPercentage: ll.imports("GMLIB_API", "getPlayerArmorCoverPercentage"),
/** 获取玩家盔甲值 @type {function(Player):number} */
getPlayerArmorValue: ll.import("GMLIB_API", "getPlayerArmorValue"),
getPlayerArmorValue: ll.imports("GMLIB_API", "getPlayerArmorValue"),
/** 获取实体主人的UniqueID @type {function(Entity):Entity} */
getEntityOwnerUniqueId: ll.import("GMLIB_API", "getEntityOwnerUniqueId"),
getEntityOwnerUniqueId: ll.imports("GMLIB_API", "getEntityOwnerUniqueId"),
/** 获取物品分类名称 @type {function(Item):string} */
getItemCategoryName: ll.import("GMLIB_API", "getItemCategoryName"),
getItemCategoryName: ll.imports("GMLIB_API", "getItemCategoryName"),
/** 获取物品的命名 @type {function(Item):string} */
getItemCustomName: ll.import("GMLIB_API", "getItemCustomName"),
getItemCustomName: ll.imports("GMLIB_API", "getItemCustomName"),
/** 获取物品BUFF效果名称 @type {function(Item):string} */
getItemEffecName: ll.import("GMLIB_API", "getItemEffecName"),
getItemEffecName: ll.imports("GMLIB_API", "getItemEffecName"),
/** 物品是否为食物 @type {function(Item):boolean} */
itemIsFood: ll.import("GMLIB_API", "itemIsFood"),
itemIsFood: ll.imports("GMLIB_API", "itemIsFood"),
/** 设置玩家UI栏物品 @type {function(Player,number,Item):void} */
setPlayerUIItem: ll.import("GMLIB_API", "setPlayerUIItem"),
setPlayerUIItem: ll.imports("GMLIB_API", "setPlayerUIItem"),
/** 获取玩家UI栏物品 @type {function(Player,number):Item} */
getPlayerUIItem: ll.import("GMLIB_API", "getPlayerUIItem"),
getPlayerUIItem: ll.imports("GMLIB_API", "getPlayerUIItem"),
/** 更新玩家容器物品 @type {function(Player,number,number,Item):void} */
sendInventorySlotPacket: ll.import("GMLIB_API", "sendInventorySlotPacket"),
sendInventorySlotPacket: ll.imports("GMLIB_API", "sendInventorySlotPacket"),
/** 获取容器类型 @type {function(Container):string} */
getContainerType: ll.import("GMLIB_API", "getContainerType"),
getContainerType: ll.imports("GMLIB_API", "getContainerType"),
/** 玩家是否拥有NBT @type {function(string):boolean} */
hasPlayerNbt: ll.import("GMLIB_API", "hasPlayerNbt"),
hasPlayerNbt: ll.imports("GMLIB_API", "hasPlayerNbt"),
/** 获取物品最大堆叠数量 @type {function(Item):number} */
getItemMaxCount: ll.import("GMLIB_API", "getItemMaxCount"),
getItemMaxCount: ll.imports("GMLIB_API", "getItemMaxCount"),
/** 实体包含在某族里 @type {function(Entity,string):boolean} */
entityHasFamily: ll.import("GMLIB_API", "entityHasFamily"),
entityHasFamily: ll.imports("GMLIB_API", "entityHasFamily"),
/** 获取玩家破坏方块所需时间 @type {function(Player,Block):number} */
getPlayerDestroyBlockProgress: ll.import("GMLIB_API", "getPlayerDestroyBlockProgress"),
getPlayerDestroyBlockProgress: ll.imports("GMLIB_API", "getPlayerDestroyBlockProgress"),
/** 获取实体的buff是否显示 @type {function(Player,number):boolean} */
getEntityEffectVisible: ll.import("GMLIB_API", "getEntityEffectVisible"),
getEntityEffectVisible: ll.imports("GMLIB_API", "getEntityEffectVisible"),
/** 获取实体的buff持续时间 @type {function(Player,number):number} */
getEntityEffectDuration: ll.import("GMLIB_API", "getEntityEffectDuration"),
getEntityEffectDuration: ll.imports("GMLIB_API", "getEntityEffectDuration"),
/** 获取实体的buff简单模式下的持续时间 @type {function(Player,number):number} */
getEntityEffectDurationEasy: ll.import("GMLIB_API", "getEntityEffectDuration"),
getEntityEffectDurationEasy: ll.imports("GMLIB_API", "getEntityEffectDuration"),
/** 获取实体的buff困难模式下的持续时间 @type {function(Player,number):number} */
getEntityEffectDurationHard: ll.import("GMLIB_API", "getEntityEffectDurationHard"),
getEntityEffectDurationHard: ll.imports("GMLIB_API", "getEntityEffectDurationHard"),
/** 获取实体的buff普通模式下的持续时间 @type {function(Player,number):number} */
getEntityEffectDurationNormal: ll.import("GMLIB_API", "getEntityEffectDurationNormal"),
getEntityEffectDurationNormal: ll.imports("GMLIB_API", "getEntityEffectDurationNormal"),
/** 获取实体的buff效果等级 @type {function(Entity,number):number} */
getEntityEffectAmplifier: ll.import("GMLIB_API", "getEntityEffectAmplifier"),
getEntityEffectAmplifier: ll.imports("GMLIB_API", "getEntityEffectAmplifier"),
/** 获取实体的buff是否为信标给予 @type {function(Entity,number):boolean} */
getEntityEffectAmbient: ll.import("GMLIB_API", "getEntityEffectAmbient"),
getEntityEffectAmbient: ll.imports("GMLIB_API", "getEntityEffectAmbient"),
/** 实体是否拥有buff效果 @type {function(Entity,number):boolean} */
entityHasEffect: ll.import("GMLIB_API", "entityHasEffect"),
entityHasEffect: ll.imports("GMLIB_API", "entityHasEffect"),
/** 获取实体所有buff效果 @type {function(Entity):Array.<number>} */
getEntityAllEffects: ll.import("GMLIB_API", "getEntityAllEffects"),
getEntityAllEffects: ll.imports("GMLIB_API", "getEntityAllEffects"),
/** 获取游戏难度 @type {function():number} */
getGameDifficulty: ll.import("GMLIB_API", "getGameDifficulty"),
getGameDifficulty: ll.imports("GMLIB_API", "getGameDifficulty"),
/** 设置游戏难度 @type {function(difficulty):void} */
setGameDifficulty: ll.import("GMLIB_API", "setGameDifficulty"),
setGameDifficulty: ll.imports("GMLIB_API", "setGameDifficulty"),
/** 获取默认游戏模式 @type {function():number} */
getDefaultGameMode: ll.import("GMLIB_API", "getDefaultGameMode"),
getDefaultGameMode: ll.imports("GMLIB_API", "getDefaultGameMode"),
/** 设置默认游戏模式 @type {function(mode):void} */
setDefaultGameMode: ll.import("GMLIB_API", "setDefaultGameMode"),
setDefaultGameMode: ll.imports("GMLIB_API", "setDefaultGameMode"),
/** 实体是否为某类型 @type {function(Entity, number):boolean} */
entityIsType: ll.import("GMLIB_API", "entityIsType"),
entityIsType: ll.imports("GMLIB_API", "entityIsType"),
/** 实体是包含某类型 @type {function(Entity, number):boolean} */
entityHasType: ll.import("GMLIB_API", "entityHasType"),
entityHasType: ll.imports("GMLIB_API", "entityHasType"),
/** 获取实体类型ID @type {function(Entity):number} */
getEntityTypeId: ll.import("GMLIB_API", "getEntityTypeId"),
getEntityTypeId: ll.imports("GMLIB_API", "getEntityTypeId"),
/** 获取实体类型ID @type {function(Entity):number} */
getPlayerProtocolVersion: ll.imports("GMLIB_API", "getPlayerProtocolVersion"),
};
/** LRCA的二进制流数据包导出接口 */
const GMLIB_BinaryStream_API = {
/** 创建二进制流数据包 @type {function():number} */
create: ll.import("GMLIB_BinaryStream_API", "create"),
create: ll.imports("GMLIB_BinaryStream_API", "create"),
/** 拷贝二进制流数据包 @type {function(number):number} */
copy: ll.import("GMLIB_BinaryStream_API", "copy"),
copy: ll.imports("GMLIB_BinaryStream_API", "copy"),
/** 发送二进制流数据包 @type {function(number,player):void} */
sendTo: ll.import("GMLIB_BinaryStream_API", "sendTo"),
sendTo: ll.imports("GMLIB_BinaryStream_API", "sendTo"),
/** 销毁二进制流数据包 @type {function(number):void} */
destroy: ll.import("GMLIB_BinaryStream_API", "destroy"),
destroy: ll.imports("GMLIB_BinaryStream_API", "destroy"),
/** 重置二进制流数据包 @type {function(number):void} */
reset: ll.import("GMLIB_BinaryStream_API", "reset"),
reset: ll.imports("GMLIB_BinaryStream_API", "reset"),
/** 写入二进制流数据包头部 @type {function(number, number):void} */
writePacketHeader: ll.import("GMLIB_BinaryStream_API", "writePacketHeader"),
writePacketHeader: ll.imports("GMLIB_BinaryStream_API", "writePacketHeader"),
/** 写入UUID @type {function(number, string):void} */
writeUuid: ll.import("GMLIB_BinaryStream_API", "writeUuid"),
writeUuid: ll.imports("GMLIB_BinaryStream_API", "writeUuid"),
/** 写入物品 @type {function(number, Item):void} */
writeItem: ll.import("GMLIB_BinaryStream_API", "writeItem"),
writeItem: ll.imports("GMLIB_BinaryStream_API", "writeItem"),
/** 写入NBT @type {function(NbtCompound, Item):void} */
writeCompoundTag: ll.import("GMLIB_BinaryStream_API", "writeCompoundTag"),
writeCompoundTag: ll.imports("GMLIB_BinaryStream_API", "writeCompoundTag"),
/** 写入字符串 @type {function(number, string):void} */
writeString: ll.import("GMLIB_BinaryStream_API", "writeString"),
writeString: ll.imports("GMLIB_BinaryStream_API", "writeString"),
/** 写入布尔值 @type {function(number, boolean):void} */
writeBool: ll.import("GMLIB_BinaryStream_API", "writeBool"),
writeBool: ll.imports("GMLIB_BinaryStream_API", "writeBool"),
/** 写入字节 @type {function(number, number):void} */
writeByte: ll.import("GMLIB_BinaryStream_API", "writeByte"),
writeByte: ll.imports("GMLIB_BinaryStream_API", "writeByte"),
/** 写入双精度浮点数 @type {function(number, number):void} */
writeDouble: ll.import("GMLIB_BinaryStream_API", "writeDouble"),
writeDouble: ll.imports("GMLIB_BinaryStream_API", "writeDouble"),
/** 写入浮点数 @type {function(number, number):void} */
writeFloat: ll.import("GMLIB_BinaryStream_API", "writeFloat"),
writeFloat: ll.imports("GMLIB_BinaryStream_API", "writeFloat"),
/** @type {function(number, number):void} */
writeSignedBigEndianInt: ll.import("GMLIB_BinaryStream_API", "writeSignedBigEndianInt"),
writeSignedBigEndianInt: ll.imports("GMLIB_BinaryStream_API", "writeSignedBigEndianInt"),
/** @type {function(number, number):void} */
writeSignedInt: ll.import("GMLIB_BinaryStream_API", "writeSignedInt"),
writeSignedInt: ll.imports("GMLIB_BinaryStream_API", "writeSignedInt"),
/** @type {function(number, number):void} */
writeSignedInt64: ll.import("GMLIB_BinaryStream_API", "writeSignedInt64"),
writeSignedInt64: ll.imports("GMLIB_BinaryStream_API", "writeSignedInt64"),
/** @type {function(number, number):void} */
writeSignedShort: ll.import("GMLIB_BinaryStream_API", "writeSignedShort"),
writeSignedShort: ll.imports("GMLIB_BinaryStream_API", "writeSignedShort"),
/** @type {function(number, number):void} */
writeUnsignedChar: ll.import("GMLIB_BinaryStream_API", "writeUnsignedChar"),
writeUnsignedChar: ll.imports("GMLIB_BinaryStream_API", "writeUnsignedChar"),
/** @type {function(number, number):void} */
writeUnsignedInt: ll.import("GMLIB_BinaryStream_API", "writeUnsignedInt"),
writeUnsignedInt: ll.imports("GMLIB_BinaryStream_API", "writeUnsignedInt"),
/** @type {function(number, number):void} */
writeUnsignedInt64: ll.import("GMLIB_BinaryStream_API", "writeUnsignedInt64"),
writeUnsignedInt64: ll.imports("GMLIB_BinaryStream_API", "writeUnsignedInt64"),
/** @type {function(number, number):void} */
writeUnsignedShort: ll.import("GMLIB_BinaryStream_API", "writeUnsignedShort"),
writeUnsignedShort: ll.imports("GMLIB_BinaryStream_API", "writeUnsignedShort"),
/** @type {function(number, number):void} */
writeUnsignedVarInt: ll.import("GMLIB_BinaryStream_API", "writeUnsignedVarInt"),
writeUnsignedVarInt: ll.imports("GMLIB_BinaryStream_API", "writeUnsignedVarInt"),
/** @type {function(number, number):void} */
writeUnsignedVarInt64: ll.import("GMLIB_BinaryStream_API", "writeUnsignedVarInt64"),
writeUnsignedVarInt64: ll.imports("GMLIB_BinaryStream_API", "writeUnsignedVarInt64"),
/** @type {function(number, number):void} */
writeVarInt: ll.import("GMLIB_BinaryStream_API", "writeVarInt"),
writeVarInt: ll.imports("GMLIB_BinaryStream_API", "writeVarInt"),
/** @type {function(number, number):void} */
writeVarInt64: ll.import("GMLIB_BinaryStream_API", "writeVarInt64"),
writeVarInt64: ll.imports("GMLIB_BinaryStream_API", "writeVarInt64"),
};
/** 静态悬浮字类列表 @type {Map<number,StaticFloatingText>} */
@@ -2291,14 +2293,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 +2741,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 =
@@ -3035,6 +3036,15 @@ LLSE_Player.prototype.sendInventorySlotPacket =
GMLIB_API.sendInventorySlotPacket(this, containerId, slot, item);
};
LLSE_Player.prototype.getNetworkProtocolVersion =
/**
* 获取客户端版本协议
* @returns {number}
*/
function (containerId, slot, item) {
GMLIB_API.getPlayerProtocolVersion(this);
};
LLSE_Container.prototype.getContainerType =
/**
* 获取容器类型
+48 -11
View File
@@ -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 =
@@ -38,8 +75,8 @@ function getStringHashCode(str) {
module.exports = {
translate(value, actor = undefined, language = "") {
return actor instanceof LLSE_Entity
? ll.imports("PlaceholderAPI", "translateFromActor")(value, actor, language)
: ll.imports("PlaceholderAPI", "translate")(value, language);
? ll.importss("PlaceholderAPI", "translateFromActor")(value, actor, language)
: ll.importss("PlaceholderAPI", "translate")(value, language);
},
registerPlaceholder(placeholder, callback) {
const pluginName = getPluginName();
@@ -47,19 +84,19 @@ module.exports = {
if(!args[0].uniqueId) args[0] = undefined;
return callback(...args) ?? "<std::nullopt>";
}, pluginName, callback.getName());
ll.imports("PlaceholderAPI", "registerPlaceholder")(placeholder, callback.getName(), pluginName);
ll.importss("PlaceholderAPI", "registerPlaceholder")(placeholder, callback.getName(), pluginName);
},
unregisterPlaceholder(placeholder) {
return ll.imports("PlaceholderAPI", "unregisterPlaceholder")(placeholder);
return ll.importss("PlaceholderAPI", "unregisterPlaceholder")(placeholder);
},
unregisterPlaceholderFromModName(placeholder) {
return ll.imports("PlaceholderAPI", "unregisterPlaceholderFromModName")(placeholder);
return ll.importss("PlaceholderAPI", "unregisterPlaceholderFromModName")(placeholder);
},
getValue(placeholder, actor = undefined, params = {}, language = "") {
if (actor instanceof LLSE_Player) actor = ll.import("GMLib_ServerAPI", "PlayerToEntity")(actor);
if (actor instanceof LLSE_Player) actor = ll.imports("GMLib_ServerAPI", "PlayerToEntity")(actor);
const result = actor instanceof LLSE_Entity
? ll.imports("PlaceholderAPI", "getValueFromActor")(placeholder, actor, params, language)
: ll.imports("PlaceholderAPI", "getValue")(placeholder, params, language);
? ll.importss("PlaceholderAPI", "getValueFromActor")(placeholder, actor, params, language)
: ll.importss("PlaceholderAPI", "getValue")(placeholder, params, language);
return result !== "<std::nullopt>" ? result : undefined;
}
};
+6 -3
View File
@@ -1,7 +1,7 @@
{
"name": "${pluginName}",
"entry": "${pluginFile}",
"version": "1.0.0-rc.1",
"name": "${modName}",
"entry": "${modFile}",
"version": "${modVersion}",
"author": "GroupMountain",
"type": "native",
"passive": true,
@@ -11,6 +11,9 @@
},
{
"name": "LegacyRemoteCall"
},
{
"name": "iListenAttentively"
}
]
}
-121
View File
@@ -1,121 +0,0 @@
function beautify_json(value, indent)
import("core.base.json")
local json_text = ""
local stack = {}
local function escape_str(s)
return string.gsub(s, '[%c\\"]', function(c)
local replacements = {['\b'] = '\\b', ['\f'] = '\\f', ['\n'] = '\\n', ['\r'] = '\\r', ['\t'] = '\\t', ['"'] = '\\"', ['\\'] = '\\\\'}
return replacements[c] or string.format('\\u%04x', c:byte())
end)
end
local function is_null(v)
return v == json.null
end
local function is_empty_table(t)
if type(t) ~= 'table' then return false end
for _ in pairs(t) do
return false
end
return true
end
local function is_array(t)
return type(t) == 'table' and json.is_marked_as_array(t) or #t > 0
end
local function serialize(val, level)
local spaces = string.rep(" ", level * indent)
if type(val) == "table" and not stack[val] then
if is_empty_table(val) then
json_text = json_text .. (is_array(val) and "[]" or "{}")
return
end
stack[val] = true
local isArray = is_array(val)
json_text = json_text .. (isArray and "[\n" or "{\n")
local keys = isArray and {} or {}
for k in pairs(val) do
table.insert(keys, k)
end
if not isArray then
table.sort(keys)
end
for _, k in ipairs(keys) do
local v = val[k]
json_text = json_text .. spaces .. (isArray and "" or '"' .. escape_str(tostring(k)) .. '": ')
serialize(v, level + 1)
json_text = json_text .. ",\n"
end
json_text = string.sub(json_text, 1, -3) .. "\n" .. string.rep(" ", (level - 1) * indent) .. (isArray and "]" or "}")
stack[val] = nil
elseif type(val) == "string" then
json_text = json_text .. '"' .. escape_str(val) .. '"'
elseif type(val) == "number" then
if val % 1 == 0 then
json_text = json_text .. tostring(math.floor(val))
else
json_text = json_text .. tostring(val)
end
elseif type(val) == "boolean" then
json_text = json_text .. tostring(val)
elseif is_null(val) then
json_text = json_text .. "null"
else
error("Invalid value type: " .. type(val))
end
end
serialize(value, 1)
return json_text
end
function string_formatter(str, variables)
return str:gsub("%${(.-)}", function(var)
return variables[var] or "${" .. var .. "}"
end)
end
function pack_plugin(target,plugin_define)
import("lib.detect.find_file")
local manifest_path = find_file("manifest.json", os.projectdir())
if manifest_path then
local manifest = io.readfile(manifest_path)
local bindir = path.join(os.projectdir(), "bin/DLL")
local pdbdir = path.join(os.projectdir(), "bin/PDB")
local outputdir = path.join(bindir, plugin_define.pluginName)
local targetfile = path.join(outputdir, plugin_define.pluginFile)
local pdbfile = path.join(pdbdir, path.basename(plugin_define.pluginFile) .. ".pdb")
local libfile = path.join(os.projectdir(), "lib")
local manifestfile = path.join(outputdir, "manifest.json")
local oritargetfile = target:targetfile()
local oripdbfile = path.join(path.directory(oritargetfile), path.basename(oritargetfile) .. ".pdb")
os.mkdir(outputdir)
os.cp(oritargetfile, targetfile)
if os.isfile(oripdbfile) then
os.cp(oripdbfile, pdbfile)
end
os.cp(libfile, outputdir)
formattedmanifest = string_formatter(manifest, plugin_define)
io.writefile(manifestfile,formattedmanifest)
cprint("${bright green}[Plugin Packer]: ${reset}plugin already generated to " .. outputdir)
else
cprint("${bright yellow}warn: ${reset}not found manifest.json in root dir!")
end
end
return {
pack_plugin = pack_plugin,
beautify_json = beautify_json,
string_formatter = string_formatter
}
+3 -5
View File
@@ -1,10 +1,8 @@
#include "Global.h"
#include <gmlib/mc/network/BinaryStream.h>
#include <mc/world/item/NetworkItemStackDescriptor.h>
class LegacyScriptBinaryStreamManager {
private:
int64 mNextBinaryStreamId = 0;
int64 mNextBinaryStreamId = 0;
std::unordered_map<uint64, std::shared_ptr<GMBinaryStream>> mBinaryStream;
public:
@@ -15,7 +13,7 @@ public:
uint64 copyBinaryStream(uint id) {
auto nextId = getNextId();
cretateBinaryStream(nextId);
if(auto bs = getBinaryStream(nextId); bs !=nullptr){
if (auto bs = getBinaryStream(nextId); bs != nullptr) {
getBinaryStream(nextId)->mBuffer = getBinaryStream(id)->mBuffer;
}
return nextId;
@@ -80,6 +78,7 @@ void Export_BinaryStream_API() {
EXPORTAPI("writeItem", ItemStack*, bs->writeNetworkItemStackDescriptor(NetworkItemStackDescriptor(*value)));
EXPORTAPI("writeString", std::string const&, bs->writeString(value));
EXPORTAPI("writeCompoundTag", CompoundTag*, bs->writeCompoundTag(*value));
EXPORTAPI("writeUnsignedChar", uchar, bs->writeUnsignedChar(value));
EXPORTAPI2(writeBool);
EXPORTAPI2(writeByte);
EXPORTAPI2(writeDouble);
@@ -88,7 +87,6 @@ void Export_BinaryStream_API() {
EXPORTAPI2(writeSignedInt);
EXPORTAPI2(writeSignedInt64);
EXPORTAPI2(writeSignedShort);
EXPORTAPI2(writeUnsignedChar);
EXPORTAPI2(writeUnsignedInt);
EXPORTAPI2(writeUnsignedInt64);
EXPORTAPI2(writeUnsignedShort);
+116 -98
View File
@@ -1,32 +1,32 @@
#include "Global.h"
#include "mc/platform/UUID.h"
#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(
[](GMLevel& level) -> double { return level.getServerMspt(); }
[](GMLevel& level) -> double { return level.getServerMspt(); }
).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;
@@ -36,7 +36,7 @@ void Export_Compatibility_API() {
return result;
});
RemoteCall::exportAs("GMLIB_API", "getPlayerNbt", [](std::string const& uuid) -> std::unique_ptr<CompoundTag> {
if (auto player = OfflinePlayer::getOfflinePlayer(mce::UUID::fromString(uuid))) {
if (auto player = OfflinePlayer::fromUuid(mce::UUID::fromString(uuid))) {
return std::make_unique<CompoundTag>(*player->getNbt());
}
return nullptr;
@@ -45,7 +45,7 @@ void Export_Compatibility_API() {
"GMLIB_API",
"setPlayerNbt",
[](std::string const& uuid, CompoundTag* nbt, bool forceCreate) -> bool {
if (auto player = OfflinePlayer::getOfflinePlayer(mce::UUID::fromString(uuid))) return player->setNbt(*nbt);
if (auto player = OfflinePlayer::fromUuid(mce::UUID::fromString(uuid))) return player->setNbt(*nbt);
return forceCreate ? OfflinePlayer::createNewPlayerNbt(mce::UUID::fromString(uuid), *nbt).has_value()
: false;
}
@@ -54,7 +54,7 @@ void Export_Compatibility_API() {
"GMLIB_API",
"setPlayerNbtTags",
[](std::string const& uuid, CompoundTag* nbt, std::vector<std::string> tags) -> bool {
if (auto player = OfflinePlayer::getOfflinePlayer(mce::UUID::fromString(uuid))) {
if (auto player = OfflinePlayer::fromUuid(mce::UUID::fromString(uuid))) {
auto nbt2 = *player->getNbt();
GMCompoundTag::writeNbtTags(nbt2, *nbt, tags);
return player->setNbt(nbt2);
@@ -66,20 +66,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",
@@ -116,7 +117,7 @@ void Export_Compatibility_API() {
return false;
});
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);
return true;
}
@@ -143,12 +144,17 @@ void Export_Compatibility_API() {
}
return false;
});
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",
"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
return GMLIB_VERSION_TO_STRING(GMLIB_VERSION_MAJOR) "." GMLIB_VERSION_TO_STRING(
GMLIB_VERSION_MINOR
) "." GMLIB_VERSION_TO_STRING(GMLIB_VERSION_PATCH);
});
RemoteCall::exportAs(
@@ -182,8 +188,9 @@ void Export_Compatibility_API() {
RemoteCall::exportAs(
"GMLIB_API",
"updateOrCreateLanguageFile",
[](std::string const& code, std::unordered_map<std::string, std::string> lang, std::string const& path
) -> void {
[](std::string const& code,
std::unordered_map<std::string, std::string> lang,
std::string const& path) -> void {
if (GMLevel::getInstance()) {
I18nAPI::updateOrCreateLanguageFile(path, code, lang);
}
@@ -195,7 +202,7 @@ void Export_Compatibility_API() {
}
});
RemoteCall::exportAs("GMLIB_API", "getPlayerPosition", [](std::string const& uuid) -> std::pair<BlockPos, int> {
if (auto player = OfflinePlayer::getOfflinePlayer(mce::UUID::fromString(uuid))) {
if (auto player = OfflinePlayer::fromUuid(mce::UUID::fromString(uuid))) {
if (auto pos = player->getPlayerPosition()) {
return *pos;
}
@@ -209,8 +216,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::fromUuid(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 {
@@ -406,7 +415,7 @@ void Export_Compatibility_API() {
std::vector<std::unordered_map<std::string, std::string>> result;
for (auto& player : GMScoreboard::getInstance()->getAllPlayers()) {
result.push_back({
{"Type", "Player" },
{"Type", "Player" },
{"Uuid", player.getUUID().asString()}
});
}
@@ -418,7 +427,7 @@ void Export_Compatibility_API() {
}
for (auto& uniqueId : GMScoreboard::getInstance()->getAllEntities()) {
result.push_back({
{"Type", "Entity" },
{"Type", "Entity" },
{"UniqueId", std::to_string(uniqueId.rawID)}
});
}
@@ -440,25 +449,22 @@ void Export_Compatibility_API() {
RemoteCall::exportAs("GMLIB_API", "setWorldSpawn", [](std::pair<BlockPos, int> pos) -> bool {
if (pos.second != 0) return false;
GMLevel::getInstance()->getLevelData().setSpawnPos(pos.first);
auto pkt = SetSpawnPositionPacket();
auto pkt = SetSpawnPositionPacket();
pkt.mSpawnBlockPos = NetworkBlockPosition(pos.first);
pkt.mDimensionType = 0;
pkt.mSpawnPosType = SpawnPositionType::WorldSpawn;
pkt.mSpawnPosType = SpawnPositionType::WorldSpawn;
pkt.sendToClients();
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",
@@ -471,33 +477,47 @@ void Export_Compatibility_API() {
}
);
RemoteCall::exportAs("GMLIB_API", "getXuidByUuid", [](std::string const& uuid) -> std::string {
return UserCache::getXuidByUuid(mce::UUID::fromString(uuid)).value_or("");
if (auto uce = UserCache::getInstance()->from(mce::UUID::fromString(uuid))) {
return uce->mXuid;
}
return "";
});
RemoteCall::exportAs("GMLIB_API", "getXuidByName", [](std::string const& name) -> std::string {
return UserCache::getXuidByName(name).value_or("");
if (auto uce = UserCache::getInstance()->from(name, UserCache::QueryType::Name)) {
return uce->mXuid;
}
return "";
});
RemoteCall::exportAs("GMLIB_API", "getNameByUuid", [](std::string const& uuid) -> std::string {
return UserCache::getNameByUuid(mce::UUID::fromString(uuid)).value_or("");
if (auto uce = UserCache::getInstance()->from(mce::UUID::fromString(uuid))) {
return uce->mName;
}
return "";
});
RemoteCall::exportAs("GMLIB_API", "getNameByXuid", [](std::string const& xuid) -> std::string {
return UserCache::getNameByXuid(xuid).value_or("");
if (auto uce = UserCache::getInstance()->from(xuid, UserCache::QueryType::Xuid)) {
return uce->mName;
}
return "";
});
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("");
if (auto uce = UserCache::getInstance()->from(xuid, UserCache::QueryType::Xuid)) {
return uce->mUuid.asString();
}
return "";
});
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("");
if (auto uce = UserCache::getInstance()->from(name, UserCache::QueryType::Name)) {
return uce->mUuid.asString();
}
return "";
});
RemoteCall::exportAs(
"GMLIB_API",
"getAllPlayerInfo",
[]() -> std::vector<std::unordered_map<std::string, std::string>> {
std::vector<std::unordered_map<std::string, std::string>> result;
for (auto entry : UserCache::entries()){
for (auto entry : UserCache::getInstance()->entries()) {
result.push_back({
{"Name", entry.mName },
{"Xuid", entry.mXuid },
@@ -513,7 +533,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 +562,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 +583,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 +598,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)
@@ -607,23 +626,23 @@ void Export_Compatibility_API() {
switch (gameRule.mType) {
case GameRule::Type::Bool:
result.push_back({
{"Name", gameRule.mName },
{"Type", "Bool" },
{"Value", std::to_string(gameRule.mValue->mUnk29fff1.as<bool>())}
{"Name", gameRule.mName },
{"Type", "Bool" },
{"Value", std::to_string(gameRule.mValue->boolVal)}
});
break;
case GameRule::Type::Float:
result.push_back({
{"Name", gameRule.mName },
{"Type", "Float" },
{"Value", std::to_string(gameRule.mValue->mUnk768db5.as<float>())}
{"Name", gameRule.mName },
{"Type", "Float" },
{"Value", std::to_string(gameRule.mValue->floatVal)}
});
break;
case GameRule::Type::Int:
result.push_back({
{"Name", gameRule.mName },
{"Type", "Int" },
{"Value", std::to_string(gameRule.mValue->mUnk2ab4f3.as<int>())}
{"Name", gameRule.mName },
{"Type", "Int" },
{"Value", std::to_string(gameRule.mValue->intVal)}
});
break;
case GameRule::Type::Invalid:
@@ -634,7 +653,7 @@ void Export_Compatibility_API() {
}
);
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 "";
@@ -651,9 +670,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);
});
@@ -694,8 +711,8 @@ void Export_Compatibility_API() {
auto nbt = ((GMItemStack*)item)->getNbt();
if (value) {
(*nbt)["tags"]["minecraft:keep_on_death"] = true;
}else{
if (nbt->contains("tags") && (*nbt)["tags"].contains("minecraft:keep_on_death")){
} else {
if (nbt->contains("tags") && (*nbt)["tags"].contains("minecraft:keep_on_death")) {
(*nbt)["tags"].get<CompoundTag>().erase("minecraft:keep_on_death");
}
}
@@ -766,7 +783,7 @@ void Export_Compatibility_API() {
return entity->getOwnerId().rawID;
});
RemoteCall::exportAs("GMLIB_API", "getItemCategoryName", [](ItemStack const* item) -> std::string {
if (auto item2 = item->mItem){
if (auto item2 = item->mItem) {
return item2->buildCategoryDescriptionName();
}
return "";
@@ -775,7 +792,7 @@ void Export_Compatibility_API() {
return item->getCustomName();
});
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 "";
@@ -803,7 +820,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::fromUuid(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 +911,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(
@@ -953,4 +968,7 @@ void Export_Compatibility_API() {
RemoteCall::exportAs("GMLIB_API", "getEntityTypeId", [](Actor* entity) -> int {
return (int)entity->getEntityTypeId();
});
RemoteCall::exportAs("GMLIB_API", "getPlayerProtocolVersion", [](Player* player) -> int {
return ((GMPlayer*)player)->getNetworkProtocolVersion();
});
}
+5 -2
View File
@@ -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);
@@ -21,7 +22,7 @@ bool LegacyRemoteCallApi::load() {
logger->info(
"Loaded Version: {} with {}",
fmt::format(fg(fmt::color::pink), "GMLIB-" GMLIB_FILE_VERSION_STRING),
fmt::format(fg(fmt::color::light_green), "GMLIB-LegacyRemoteCallApi-" + LIB_VERSION.to_string())
fmt::format(fg(fmt::color::light_green), "GMLIB-LegacyRemoteCallApi-{}", LIB_VERSION.to_string())
);
logger->info("Author: GroupMountain");
logger->info("Repository: https://github.com/GroupMountain/GMLIB-LegacyRemoteCallApi");
@@ -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(); }
+139 -174
View File
@@ -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,
(Actor * mob, Actor * item, bool isCancelled),
(&event.self(), (Actor*)&event.itemActor(), event.isCancelled()),
event.setCancelled(result);
);
REGISTER_EVENT_LISTEN(ila::mc::ActorPickupItemBeforeEvent,
(Actor * mob, Actor * item, bool isCancelled),
(&event.self(), (Actor*)&event.itemActor(), event.isCancelled()),
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,
(Actor * entity, int toDimId, bool isCancelled),
(&event.self(), event.toDimensionId(), event.isCancelled()),
event.setCancelled(result);
);
REGISTER_EVENT_LISTEN(ila::mc::ActorChangeDimensionBeforeEvent,
(Actor * entity, int toDimId, bool isCancelled),
(&event.self(), event.toDimensionId(), event.isCancelled()),
event.setCancelled(result););
}
case doHash("gmlib::ActorChangeDimensionAfterEvent"): {
REGISTER_EVENT_LISTEN(
@@ -168,38 +161,36 @@ 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,144 +199,118 @@ 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,
(Actor * mob, bool isCancelled),
(&event.self(), event.isCancelled()),
event.setCancelled(result);
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););
}
case doHash("gmlib::DragonRespawnBeforeEvent"): {
REGISTER_EVENT_LISTEN(
ila::mc::DragonRespawnBeforeEvent,
(bool isCancelled),
(event.isCancelled()),
event.setCancelled(result);
);
REGISTER_EVENT_LISTEN(ila::mc::DragonRespawnBeforeEvent,
(bool isCancelled),
(event.isCancelled()),
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,
(std::pair<BlockPos, int> pos, bool isCancelled),
({event.pos(), event.blockSource().getDimensionId()}, event.isCancelled()),
event.setCancelled(result););
}
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::SpawnWanderingTraderBeforeEvent,
(std::pair<BlockPos, int> pos, bool isCancelled),
({event.pos(), event.blockSource().getDimensionId()}, event.isCancelled()),
event.setCancelled(result);
ila::mc::PlayerCloseContainerAfterEvent,
(Player * player, int containerId, bool serverInitiatedClose, bool),
(&event.self(), (int)event.containerId(), event.serverInitiatedClose(), false),
,
);
}
case doHash("gmlib::SpawnWanderingTraderAfterEvent"): {
REGISTER_EVENT_LISTEN(
ila::mc::SpawnWanderingTraderAfterEvent,
(std::pair<BlockPos, int> pos),
({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),
// ,
// );
// }
}
return -1;
}
+4 -2
View File
@@ -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();
+63 -77
View File
@@ -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 (auto context = magic_enum::enum_cast<RecipeUnlockingContext>(key)) {
return ICustomRecipe::UnlockingRequirement(*context);
}
return ICustomRecipe::UnlockingRequirement({ICustomRecipe::Ingredient(key)});
}
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,19 @@ 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(1, index++), ICustomRecipe::Ingredient{ing});
}
CustomRecipeRegistry::getInstance().registerShapedRecipe(
recipe_id,
shape,
types,
ItemInstance(result, count),
makeRecipeUnlockingKey(unlock)
);
}
);
RemoteCall::exportAs(
@@ -64,14 +57,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 +67,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 +80,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 +96,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 +113,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 +131,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 +161,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 {});
}
+7 -13
View File
@@ -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",
@@ -76,7 +70,7 @@ void Export_Legacy_GMLib_ServerAPI() {
}
);
RemoteCall::exportAs("GMLib_ServerAPI", "removeFakeList", [](const std::string& nameOrXuid) -> bool {
PlayerListAPI::resetListName(nameOrXuid);
PlayerListAPI::erase(nameOrXuid);
return true;
});
RemoteCall::exportAs("GMLib_ServerAPI", "removeAllFakeList", []() -> void { PlayerListAPI::clear(); });
+32 -12
View File
@@ -23,10 +23,14 @@ void registerPlayerPlaceholder(
[Call = RemoteCall::importAs<std::string(Player * pl, std::unordered_map<std::string, std::string>)>(
PluginName,
FuncName
)](optional_ref<GMActor> actor, std::unordered_map<std::string, std::string> const& params, auto&&...
)](optional_ref<Actor> actor, ll::StringMap<std::string> const& params, auto&&...
) -> std::optional<std::string> {
if (actor.has_value() && ((Actor*)actor.as_ptr())->isPlayer()) {
return Call((Player*)actor.as_ptr(), params);
std::unordered_map<std::string, std::string> paramMap;
for (auto& [key, val] : params) {
paramMap[key] = val;
}
return Call((Player*)actor.as_ptr(), paramMap);
}
return std::nullopt;
},
@@ -55,8 +59,13 @@ void registerServerPlaceholder(
[Call = RemoteCall::importAs<std::string(std::unordered_map<std::string, std::string>)>(
PluginName,
FuncName
)](auto, std::unordered_map<std::string, std::string> const& params, auto&&...
) -> std::optional<std::string> { return Call(params); },
)](auto, ll::StringMap<std::string> const& params, auto&&...) -> std::optional<std::string> {
std::unordered_map<std::string, std::string> paramMap;
for (auto& [key, val] : params) {
paramMap[key] = val;
}
return Call(paramMap);
},
mod
);
};
@@ -80,8 +89,8 @@ void registerStaticPlaceholder(
if (mod.expired()) return;
PlaceholderAPI::registerPlaceholder(
PAPIName,
[Call = RemoteCall::importAs<std::string()>(PluginName, FuncName)](auto&&...
) -> std::optional<std::string> { return Call(); },
[Call = RemoteCall::importAs<std::string()>(PluginName, FuncName)](auto&&...)
-> std::optional<std::string> { return Call(); },
mod
);
};
@@ -128,10 +137,13 @@ void registerPlaceholder(std::string const& placeholder, std::string const& func
std::string(Actor*, std::unordered_map<std::string, std::string>, std::string)>(
pluginName,
funcName
)](optional_ref<GMActor> actor,
std::unordered_map<std::string, std::string> const& params,
std::string const& language) -> std::optional<std::string> {
auto result = Call((Actor*)actor.as_ptr(), params, language);
)](optional_ref<Actor> actor, ll::StringMap<std::string> const& params, std::string const& language
) -> std::optional<std::string> {
std::unordered_map<std::string, std::string> paramMap;
for (auto& [key, val] : params) {
paramMap[key] = val;
}
auto result = Call((Actor*)actor.as_ptr(), paramMap, language);
return result == "<std::nullopt>" ? std::nullopt : std::optional(result);
},
mod
@@ -157,7 +169,11 @@ std::string getValue(
std::unordered_map<std::string, std::string> params,
std::string const& language
) {
return PlaceholderAPI::getValue(placeholder, std::nullopt, params, language).value_or("<std::nullopt>");
ll::StringMap<std::string> paramMap;
for (auto& [key, val] : params) {
paramMap[key] = val;
}
return PlaceholderAPI::getValue(placeholder, std::nullopt, paramMap, language).value_or("<std::nullopt>");
}
std::string getValueFromActor(
std::string const& placeholder,
@@ -165,7 +181,11 @@ std::string getValueFromActor(
std::unordered_map<std::string, std::string> params,
std::string const& language
) {
return PlaceholderAPI::getValue(placeholder, (GMActor*)actor, params, language).value_or("<std::nullopt>");
ll::StringMap<std::string> paramMap;
for (auto& [key, val] : params) {
paramMap[key] = val;
}
return PlaceholderAPI::getValue(placeholder, (GMActor*)actor, paramMap, language).value_or("<std::nullopt>");
}
} // namespace NewPapiRemoteCall
+5 -4
View File
@@ -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.2.0",
"info": {
"name": "GMLIB-LegacyRemoteCallApi",
"description": "Legacy RemoteCall API for GMLIB",
@@ -19,14 +19,15 @@
{
"platform": "win-x64",
"dependencies": {
"github.com/LiteLDev/LeviLamina": ">=1.1.1",
"github.com/GroupMountain/GMLIB-Release": ">=1.0.0-rc.3"
"github.com/LiteLDev/LeviLamina": ">=1.3.0",
"github.com/GroupMountain/GMLIB-Release": ">=1.3.0-rc.1",
"github.com/MiracleForest/iListenAttentively-Release": ">=0.6.0"
},
"assets": [
{
"type": "zip",
"urls": [
"https://github.com/GroupMountain/GMLIB-LegacyRemoteCallApi/releases/download/v$(version)/GMLIB-LegacyRemoteCallApi-windows-x64.zip"
"https://{{tooth}}/releases/download/v{{version}}/GMLIB-LegacyRemoteCallApi-windows-x64.zip"
],
"placements": [
{
+13 -15
View File
@@ -8,16 +8,17 @@ if not has_config("vs_runtime") then
set_runtimes("MD")
end
add_requires("levilamina", {configs = {target_type = "server"}})
add_requires("levilamina 1.3.0", {configs = {target_type = "server"}})
add_requires("legacyremotecall")
add_requires("gmlib")
add_requires("levibuildscript")
add_requires("ilistenattentively")
add_requires("ilistenattentively 0.6.0")
add_requires("gmlib 1.3.0-rc.1")
target("GMLIB-LegacyRemoteCallApi")
add_cxflags(
"/EHa",
"/utf-8"
"/utf-8",
"/bigobj"
)
add_defines(
"NOMINMAX",
@@ -33,22 +34,19 @@ target("GMLIB-LegacyRemoteCallApi")
add_packages(
"levilamina",
"legacyremotecall",
"gmlib",
"ilistenattentively"
"ilistenattentively",
"gmlib"
)
add_rules("@levibuildscript/linkrule")
add_rules("@levibuildscript/modpacker")
set_exceptions("none")
set_kind("shared")
set_languages("cxx20")
set_symbols("debug")
after_build(function (target)
local plugin_packer = import("scripts.after_build")
local plugin_define = {
pluginName = target:name(),
pluginFile = path.filename(target:targetfile()),
}
plugin_packer.pack_plugin(target,plugin_define)
local target_path = path.join("bin", target:name(), "lib")
if os.exists(target_path) then
os.rm(target_path)
end
os.cp("lib", target_path)
end)