Compare commits
31 Commits
v1.0.0-rc.1
...
v1.4.1
@@ -11,6 +11,8 @@ jobs:
|
|||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
- uses: xmake-io/github-action-setup-xmake@v1
|
- uses: xmake-io/github-action-setup-xmake@v1
|
||||||
|
with:
|
||||||
|
xmake-version: 3.0.0
|
||||||
|
|
||||||
- run: |
|
- run: |
|
||||||
xmake repo -u
|
xmake repo -u
|
||||||
|
|||||||
@@ -11,6 +11,8 @@ jobs:
|
|||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
- uses: xmake-io/github-action-setup-xmake@v1
|
- uses: xmake-io/github-action-setup-xmake@v1
|
||||||
|
with:
|
||||||
|
xmake-version: 3.0.0
|
||||||
|
|
||||||
- run: |
|
- run: |
|
||||||
xmake repo -u
|
xmake repo -u
|
||||||
|
|||||||
+15
-40
@@ -1,47 +1,22 @@
|
|||||||
const PlaceholderAPI = {
|
const PlaceholderAPI = {
|
||||||
/** 获取一个服务器变量的值 @type {function(string):string} */
|
/** 获取一个服务器变量的值 @type {function(string):string} */
|
||||||
getValueAPI: ll.import("BEPlaceholderAPI", "GetValue"),
|
getValueAPI: ll.imports("BEPlaceholderAPI", "GetValue"),
|
||||||
/** 获取一个玩家变量的值 @type {function(string,Player):string} */
|
/** 获取一个玩家变量的值 @type {function(string,Player):string} */
|
||||||
getValueByPlayerAPI: ll.import("BEPlaceholderAPI", "GetValueWithPlayer"),
|
getValueByPlayerAPI: ll.imports("BEPlaceholderAPI", "GetValueWithPlayer"),
|
||||||
/** 注册一个玩家变量 @type {function(string,string,string):boolean} */
|
/** 注册一个玩家变量 @type {function(string,string,string):boolean} */
|
||||||
registerPlayerPlaceholderAPI: ll.import("BEPlaceholderAPI", "registerPlayerPlaceholder"),
|
registerPlayerPlaceholderAPI: ll.imports("BEPlaceholderAPI", "registerPlayerPlaceholder"),
|
||||||
/** 注册一个服务器变量 @type {function(string,string,string):boolean} */
|
/** 注册一个服务器变量 @type {function(string,string,string):boolean} */
|
||||||
registerServerPlaceholderAPI: ll.import("BEPlaceholderAPI", "registerServerPlaceholder"),
|
registerServerPlaceholderAPI: ll.imports("BEPlaceholderAPI", "registerServerPlaceholder"),
|
||||||
/** 注册一个静态变量 @type {function(string,string,string,number):boolean} */
|
/** 注册一个静态变量 @type {function(string,string,string,number):boolean} */
|
||||||
registerStaticPlaceholderAPI: ll.import("BEPlaceholderAPI", "registerStaticPlaceholder"),
|
registerStaticPlaceholderAPI: ll.imports("BEPlaceholderAPI", "registerStaticPlaceholder"),
|
||||||
/** 翻译包含PAPI服务器变量的字符串 @type {function(string):string} */
|
/** 翻译包含PAPI服务器变量的字符串 @type {function(string):string} */
|
||||||
translateStringAPI: ll.import("BEPlaceholderAPI", "translateString"),
|
translateStringAPI: ll.imports("BEPlaceholderAPI", "translateString"),
|
||||||
/** 翻译包含PAPI玩家变量的字符串 @type {function(string,Player):string} */
|
/** 翻译包含PAPI玩家变量的字符串 @type {function(string,Player):string} */
|
||||||
translateStringWithPlayerAPI: ll.import("BEPlaceholderAPI", "translateStringWithPlayer"),
|
translateStringWithPlayerAPI: ll.imports("BEPlaceholderAPI", "translateStringWithPlayer"),
|
||||||
/** 注销PAPI变量 @type {function(string):boolean} */
|
/** 注销PAPI变量 @type {function(string):boolean} */
|
||||||
unRegisterPlaceholderAPI: ll.import("BEPlaceholderAPI", "unRegisterPlaceholder"),
|
unRegisterPlaceholderAPI: ll.imports("BEPlaceholderAPI", "unRegisterPlaceholder"),
|
||||||
/** 获取所有已注册的PAPI变量 @type {function():Array.<string>} */
|
/** 获取所有已注册的PAPI变量 @type {function():Array.<string>} */
|
||||||
getAllPAPI: ll.import("BEPlaceholderAPI", "getAllPAPI")
|
getAllPAPI: ll.imports("BEPlaceholderAPI", "getAllPAPI")
|
||||||
}
|
|
||||||
|
|
||||||
Function.prototype.getName =
|
|
||||||
/**
|
|
||||||
* 获取函数名字
|
|
||||||
* @returns {string}
|
|
||||||
*/
|
|
||||||
function () {
|
|
||||||
return this.name || this.toString().match(/function\s*([^(]*)\(/)?.[1] || getStringHashCode(this.toString()).toString(16);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取字符串哈希值
|
|
||||||
* @param {string} str 字符串
|
|
||||||
* @returns {number}
|
|
||||||
*/
|
|
||||||
function getStringHashCode(str) {
|
|
||||||
let hash = 0, chr;
|
|
||||||
if (str.length === 0) return hash;
|
|
||||||
for (let i = 0; i < str.length; i++) {
|
|
||||||
chr = str.charCodeAt(i);
|
|
||||||
hash = ((hash << 5) - hash) + chr;
|
|
||||||
hash |= 0;
|
|
||||||
}
|
|
||||||
return hash;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** PAPI变量类 */
|
/** PAPI变量类 */
|
||||||
@@ -58,8 +33,8 @@ class PAPI {
|
|||||||
* @returns {boolean} 是否注册成功
|
* @returns {boolean} 是否注册成功
|
||||||
*/
|
*/
|
||||||
static registerPlayerPlaceholder(func, PluginName, PAPIName) {
|
static registerPlayerPlaceholder(func, PluginName, PAPIName) {
|
||||||
ll.export(func, PluginName, func.getName());
|
ll.export(func, PluginName, `Placeholder_${PAPIName}`);
|
||||||
PlaceholderAPI.registerPlayerPlaceholderAPI(PluginName, func.getName(), PAPIName);
|
PlaceholderAPI.registerPlayerPlaceholderAPI(PluginName, `Placeholder_${PAPIName}`, PAPIName);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -70,8 +45,8 @@ class PAPI {
|
|||||||
* @returns {boolean} 是否注册成功
|
* @returns {boolean} 是否注册成功
|
||||||
*/
|
*/
|
||||||
static registerServerPlaceholder(func, PluginName, PAPIName) {
|
static registerServerPlaceholder(func, PluginName, PAPIName) {
|
||||||
ll.export(func, PluginName, func.getName());
|
ll.export(func, PluginName, `Placeholder_${PAPIName}`);
|
||||||
PlaceholderAPI.registerServerPlaceholderAPI(PluginName, func.getName(), PAPIName);
|
PlaceholderAPI.registerServerPlaceholderAPI(PluginName, `Placeholder_${PAPIName}`, PAPIName);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -83,8 +58,8 @@ class PAPI {
|
|||||||
* @returns {boolean} 是否注册成功
|
* @returns {boolean} 是否注册成功
|
||||||
*/
|
*/
|
||||||
static registerStaticPlaceholder(func, PluginName, PAPIName, UpdateInterval = 50) {
|
static registerStaticPlaceholder(func, PluginName, PAPIName, UpdateInterval = 50) {
|
||||||
ll.export(func, PluginName, func.getName());
|
ll.export(func, PluginName, `Placeholder_${PAPIName}`);
|
||||||
PlaceholderAPI.registerStaticPlaceholderAPI(PluginName, func.getName(), PAPIName, UpdateInterval);
|
PlaceholderAPI.registerStaticPlaceholderAPI(PluginName, `Placeholder_${PAPIName}`, PAPIName, UpdateInterval);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
+40
-3
@@ -2,13 +2,50 @@
|
|||||||
* @returns {string}
|
* @returns {string}
|
||||||
*/
|
*/
|
||||||
const getPluginName = () => {
|
const getPluginName = () => {
|
||||||
|
// quickjs
|
||||||
try {
|
try {
|
||||||
throw new Error("getPluginName");
|
throw new Error("getPluginName");
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
return error.stack.trim().match(/plugins\\(.*)\\.*\.js:[0-9]+\)$/i)?.[1]
|
const /** @type {string} */ line = error.stack.trim().split("\n").pop().trim();
|
||||||
|| error.stack.trim().match(/at <anonymous> \(([^\\|/]+)(.*?):\d+:\d+\)$/i)?.[1]
|
if (line.includes("<anonymous>")) {
|
||||||
|| "Unknown";
|
return line.slice(
|
||||||
|
line.indexOf("(") + 1,
|
||||||
|
line.indexOf("\\")
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
if (line.includes("<eval>")) {
|
||||||
|
return line.slice(
|
||||||
|
line.indexOf("/", line.indexOf("/") + 1) + 1,
|
||||||
|
line.indexOf("\\")
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// nodejs
|
||||||
|
try {
|
||||||
|
const path = require('path');
|
||||||
|
const selfFileName = path.basename(__filename);
|
||||||
|
const pluginDirectory = Object.entries(
|
||||||
|
require('module')._pathCache
|
||||||
|
).find(
|
||||||
|
([key, _]) =>
|
||||||
|
key.includes(selfFileName)
|
||||||
|
)[0].split("\u0000")[1];
|
||||||
|
const directories = pluginDirectory.split("\\");
|
||||||
|
const pluginName = directories[directories.findIndex(value => value === "plugins") + 1].trim();
|
||||||
|
if (pluginName) return pluginName;
|
||||||
|
} catch { }
|
||||||
|
try {
|
||||||
|
throw new Error("getPluginName");
|
||||||
|
} catch (error) {
|
||||||
|
const /** @type {string} */ line = error.stack.trim().split("\n").pop().trim();
|
||||||
|
if (line.includes(".js") && /:\d+:\d+$/.test(line)) {
|
||||||
|
const directories = line.split("\\");
|
||||||
|
const pluginName = directories[directories.findIndex(value => value === "plugins") + 1].trim();
|
||||||
|
if (pluginName) return pluginName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return "Unknown";
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
|||||||
+24
-24
@@ -1,4 +1,4 @@
|
|||||||
// // const getNextCallbackId = ll.import("GMLIB_FormAPI", "getNextFormCallbackId");
|
// // const getNextCallbackId = ll.imports("GMLIB_FormAPI", "getNextFormCallbackId");
|
||||||
|
|
||||||
// class ServerSettingForm {
|
// class ServerSettingForm {
|
||||||
// constructor() {
|
// constructor() {
|
||||||
@@ -6,35 +6,35 @@
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
// static getDefaultPriority() {
|
// static getDefaultPriority() {
|
||||||
// return ll.import("GMLIB_ServerSettingForm", "getDefaultPriority")();
|
// return ll.imports("GMLIB_ServerSettingForm", "getDefaultPriority")();
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// static hasTitle() {
|
// static hasTitle() {
|
||||||
// return ll.import("GMLIB_ServerSettingForm", "hasTitle")();
|
// return ll.imports("GMLIB_ServerSettingForm", "hasTitle")();
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// static getTitle() {
|
// static getTitle() {
|
||||||
// return ll.import("GMLIB_ServerSettingForm", "getTitle")();
|
// return ll.imports("GMLIB_ServerSettingForm", "getTitle")();
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// static setTitle(title, forceModify = false) {
|
// static setTitle(title, forceModify = false) {
|
||||||
// return ll.import("GMLIB_ServerSettingForm", "setTitle")(title, forceModify);
|
// return ll.imports("GMLIB_ServerSettingForm", "setTitle")(title, forceModify);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// static hasIcon() {
|
// static hasIcon() {
|
||||||
// return ll.import("GMLIB_ServerSettingForm", "hasIcon")();
|
// return ll.imports("GMLIB_ServerSettingForm", "hasIcon")();
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// static getIconData() {
|
// static getIconData() {
|
||||||
// return hasIcon() ? ll.import("GMLIB_ServerSettingForm", "getIconData")() : null;
|
// return hasIcon() ? ll.imports("GMLIB_ServerSettingForm", "getIconData")() : null;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// static getIconType() {
|
// static getIconType() {
|
||||||
// return ll.import("GMLIB_ServerSettingForm", "getIconType")();
|
// return ll.imports("GMLIB_ServerSettingForm", "getIconType")();
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// static setIcon(data, type = 0, forceModify = false) {
|
// 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(
|
// static addLabel(
|
||||||
@@ -44,7 +44,7 @@
|
|||||||
// ) {
|
// ) {
|
||||||
// let detectorId = getNextCallbackId();
|
// let detectorId = getNextCallbackId();
|
||||||
// ll.export(playerDetector, "GMLIB_FORM_CALLBACK", detectorId);
|
// 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);
|
// ll.export(callback, "GMLIB_FORM_CALLBACK", callbackId);
|
||||||
// let detectorId = getNextCallbackId();
|
// let detectorId = getNextCallbackId();
|
||||||
// ll.export(playerDetector, "GMLIB_FORM_CALLBACK", detectorId);
|
// 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(
|
// static addToggle(
|
||||||
@@ -74,7 +74,7 @@
|
|||||||
// ll.export(callback, "GMLIB_FORM_CALLBACK", callbackId);
|
// ll.export(callback, "GMLIB_FORM_CALLBACK", callbackId);
|
||||||
// let detectorId = getNextCallbackId();
|
// let detectorId = getNextCallbackId();
|
||||||
// ll.export(playerDetector, "GMLIB_FORM_CALLBACK", detectorId);
|
// 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(
|
// static addDropdown(
|
||||||
@@ -89,7 +89,7 @@
|
|||||||
// ll.export(callback, "GMLIB_FORM_CALLBACK", callbackId);
|
// ll.export(callback, "GMLIB_FORM_CALLBACK", callbackId);
|
||||||
// let detectorId = getNextCallbackId();
|
// let detectorId = getNextCallbackId();
|
||||||
// ll.export(playerDetector, "GMLIB_FORM_CALLBACK", detectorId);
|
// 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(
|
// static addSlider(
|
||||||
@@ -106,7 +106,7 @@
|
|||||||
// ll.export(callback, "GMLIB_FORM_CALLBACK", callbackId);
|
// ll.export(callback, "GMLIB_FORM_CALLBACK", callbackId);
|
||||||
// let detectorId = getNextCallbackId();
|
// let detectorId = getNextCallbackId();
|
||||||
// ll.export(playerDetector, "GMLIB_FORM_CALLBACK", detectorId);
|
// 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(
|
// static addStepSlider(
|
||||||
@@ -121,57 +121,57 @@
|
|||||||
// ll.export(callback, "GMLIB_FORM_CALLBACK", callbackId);
|
// ll.export(callback, "GMLIB_FORM_CALLBACK", callbackId);
|
||||||
// let detectorId = getNextCallbackId();
|
// let detectorId = getNextCallbackId();
|
||||||
// ll.export(playerDetector, "GMLIB_FORM_CALLBACK", detectorId);
|
// 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) {
|
// static removeElement(id) {
|
||||||
// return ll.import("GMLIB_ServerSettingForm", "removeElement")(id);
|
// return ll.imports("GMLIB_ServerSettingForm", "removeElement")(id);
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// class NpcDialogueForm {
|
// class NpcDialogueForm {
|
||||||
// constructor(npcName, sceneName, dialogue) {
|
// 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) {
|
// 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) {
|
// sendTo(pl, callback = (pl, index, type) => { }, free = true) {
|
||||||
// let callbackId = getNextCallbackId();
|
// let callbackId = getNextCallbackId();
|
||||||
// ll.export(callback, "GMLIB_FORM_CALLBACK", callbackId);
|
// 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) {
|
// if (free) {
|
||||||
// this.destroy();
|
// this.destroy();
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// destroy() {
|
// destroy() {
|
||||||
// ll.import("GMLIB_NpcDialogueForm", "destroyForm")(this.mFormId);
|
// ll.imports("GMLIB_NpcDialogueForm", "destroyForm")(this.mFormId);
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// class ChestForm {
|
// class ChestForm {
|
||||||
// constructor(npcName, sceneName, dialogue) {
|
// 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) {
|
// addButton(button) {
|
||||||
// return ll.import("GMLIB_NpcDialogueForm", "addButton")(this.mFormId, button);
|
// return ll.imports("GMLIB_NpcDialogueForm", "addButton")(this.mFormId, button);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// sendTo(pl, free = true) {
|
// sendTo(pl, free = true) {
|
||||||
// //let callbackId = getNextCallbackId();
|
// //let callbackId = getNextCallbackId();
|
||||||
// //ll.export(callback, "GMLIB_FORM_CALLBACK", callbackId);
|
// //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) {
|
// //if (free) {
|
||||||
// // this.destroy();
|
// // this.destroy();
|
||||||
// //}
|
// //}
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// destroy() {
|
// destroy() {
|
||||||
// //ll.import("GMLIB_NpcDialogueForm", "destroyForm")(this.mFormId);
|
// //ll.imports("GMLIB_NpcDialogueForm", "destroyForm")(this.mFormId);
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
|||||||
Vendored
+196
-164
@@ -183,19 +183,34 @@ export class Minecraft {
|
|||||||
pos: IntPos
|
pos: IntPos
|
||||||
): void;
|
): void;
|
||||||
|
|
||||||
/** 启用教育版内容 */
|
/**
|
||||||
|
* @deprecated 已删
|
||||||
|
* 启用教育版内容
|
||||||
|
*/
|
||||||
static setEducationFeatureEnabled(): void;
|
static setEducationFeatureEnabled(): void;
|
||||||
|
|
||||||
/** 注册Ability命令 */
|
/**
|
||||||
|
* @deprecated 已删
|
||||||
|
* 注册Ability命令
|
||||||
|
*/
|
||||||
static registerAbilityCommand(): void;
|
static registerAbilityCommand(): void;
|
||||||
|
|
||||||
/** 启用Xbox成就 */
|
/**
|
||||||
|
* @deprecated 已删
|
||||||
|
* 启用Xbox成就
|
||||||
|
*/
|
||||||
static setEnableAchievement(): void;
|
static setEnableAchievement(): void;
|
||||||
|
|
||||||
/** 信任所有玩家皮肤 */
|
/**
|
||||||
|
* @deprecated 已删
|
||||||
|
* 信任所有玩家皮肤
|
||||||
|
*/
|
||||||
static setForceTrustSkins(): void;
|
static setForceTrustSkins(): void;
|
||||||
|
|
||||||
/** 启用资源包双端共存 */
|
/**
|
||||||
|
* @deprecated 已删
|
||||||
|
* 启用资源包双端共存
|
||||||
|
*/
|
||||||
static enableCoResourcePack(): void;
|
static enableCoResourcePack(): void;
|
||||||
|
|
||||||
/** 获取存档名称 */
|
/** 获取存档名称 */
|
||||||
@@ -206,13 +221,19 @@ export class Minecraft {
|
|||||||
name: string
|
name: string
|
||||||
): boolean;
|
): boolean;
|
||||||
|
|
||||||
/** 设置假种子 */
|
/**
|
||||||
|
* @deprecated 已删
|
||||||
|
* 设置假种子
|
||||||
|
*/
|
||||||
static setFakeSeed(
|
static setFakeSeed(
|
||||||
/** 要设置的假种子 */
|
/** 要设置的假种子 */
|
||||||
seed: number | undefined
|
seed: number | undefined
|
||||||
): void;
|
): void;
|
||||||
|
|
||||||
/** 启用错误方块清理 */
|
/**
|
||||||
|
* @deprecated 已删
|
||||||
|
* 启用错误方块清理
|
||||||
|
*/
|
||||||
static setUnknownBlockCleaner(): void;
|
static setUnknownBlockCleaner(): void;
|
||||||
|
|
||||||
/** 强制生成实体 */
|
/** 强制生成实体 */
|
||||||
@@ -309,7 +330,10 @@ export class Minecraft {
|
|||||||
/** 移除所有虚假列表玩家 */
|
/** 移除所有虚假列表玩家 */
|
||||||
static removeAllFakeLists(): boolean;
|
static removeAllFakeLists(): boolean;
|
||||||
|
|
||||||
/** 启用I18n修复 */
|
/**
|
||||||
|
* @deprecated 已删
|
||||||
|
* 启用I18n修复
|
||||||
|
*/
|
||||||
static setFixI18nEnabled(): void;
|
static setFixI18nEnabled(): void;
|
||||||
|
|
||||||
/** 保存NBT至文件 */
|
/** 保存NBT至文件 */
|
||||||
@@ -359,7 +383,7 @@ export class Minecraft {
|
|||||||
): string;
|
): string;
|
||||||
|
|
||||||
/** 通过附魔ID获取附魔命名空间ID */
|
/** 通过附魔ID获取附魔命名空间ID */
|
||||||
static getMaxPlayers(
|
static getEnchantTypeNameFromId(
|
||||||
/** 附魔ID */
|
/** 附魔ID */
|
||||||
id: number
|
id: number
|
||||||
): string | null;
|
): string | null;
|
||||||
@@ -367,6 +391,14 @@ export class Minecraft {
|
|||||||
/** 获取最大玩家数 */
|
/** 获取最大玩家数 */
|
||||||
static getMaxPlayers(): number;
|
static getMaxPlayers(): number;
|
||||||
|
|
||||||
|
/** 设置最大玩家数 */
|
||||||
|
static setMaxPlayers(
|
||||||
|
/** 最大玩家数 */
|
||||||
|
count: number,
|
||||||
|
/** 是否忽略原版限制 */
|
||||||
|
ignoreVanillaLimit?: boolean
|
||||||
|
): void;
|
||||||
|
|
||||||
/** 玩家是否拥有NBT */
|
/** 玩家是否拥有NBT */
|
||||||
static hasPlayerNbt(
|
static hasPlayerNbt(
|
||||||
/** 玩家的uuid */
|
/** 玩家的uuid */
|
||||||
@@ -1349,161 +1381,158 @@ export class GMLIB_BinaryStream {
|
|||||||
|
|
||||||
export enum ActorType {
|
export enum ActorType {
|
||||||
Undefined = 1,
|
Undefined = 1,
|
||||||
TypeMask = 0b11111111,
|
TypeMask = 255,
|
||||||
None = 0,
|
Mob = 256,
|
||||||
Mob = 1 << 8,
|
PathfinderMob = 768,
|
||||||
PathfinderMob = 1 << 9 | Mob,
|
Monster = 2816,
|
||||||
UnknownType = 1 << 10,
|
Animal = 4864,
|
||||||
Monster = 1 << 11 | PathfinderMob,
|
TamableAnimal = 21248,
|
||||||
Animal = 1 << 12 | PathfinderMob,
|
Ambient = 33024,
|
||||||
WaterAnimal = 1 << 13 | PathfinderMob,
|
UndeadMob = 68352,
|
||||||
TamableAnimal = 1 << 14 | Animal,
|
ZombieMonster = 199424,
|
||||||
Ambient = 1 << 15 | Mob,
|
Arthropod = 264960,
|
||||||
UndeadMob = 1 << 16 | Monster,
|
Minecart = 524288,
|
||||||
ZombieMonster = 1 << 17 | UndeadMob,
|
SkeletonMonster = 1116928,
|
||||||
Arthropod = 1 << 18 | Monster,
|
EquineAnimal = 2118400,
|
||||||
Minecart = 1 << 19,
|
Projectile = 4194304,
|
||||||
SkeletonMonster = 1 << 20 | UndeadMob,
|
AbstractArrow = 8388608,
|
||||||
EquineAnimal = 1 << 21 | TamableAnimal,
|
WaterAnimal = 8960,
|
||||||
Projectile = 1 << 22,
|
VillagerBase = 16777984,
|
||||||
AbstractArrow = 1 << 23,
|
Chicken = 4874,
|
||||||
VillagerBase = 1 << 24 | PathfinderMob,
|
Cow = 4875,
|
||||||
|
Pig = 4876,
|
||||||
Chicken = 10 | Animal,
|
Sheep = 4877,
|
||||||
Cow = 11 | Animal,
|
Wolf = 21262,
|
||||||
Pig = 12 | Animal,
|
Villager = 16777999,
|
||||||
Sheep = 13 | Animal,
|
MushroomCow = 4880,
|
||||||
Wolf = 14 | TamableAnimal,
|
Squid = 8977,
|
||||||
Villager = 15 | VillagerBase,
|
Rabbit = 4882,
|
||||||
MushroomCow = 16 | Animal,
|
Bat = 33043,
|
||||||
Squid = 17 | WaterAnimal,
|
IronGolem = 788,
|
||||||
Rabbit = 18 | Animal,
|
SnowGolem = 789,
|
||||||
Bat = 19 | Ambient,
|
Ocelot = 21270,
|
||||||
IronGolem = 20 | PathfinderMob,
|
Horse = 2118423,
|
||||||
SnowGolem = 21 | PathfinderMob,
|
PolarBear = 4892,
|
||||||
Ocelot = 22 | TamableAnimal,
|
Llama = 4893,
|
||||||
Horse = 23 | EquineAnimal,
|
Parrot = 21278,
|
||||||
Donkey = 24 | EquineAnimal,
|
Dolphin = 8991,
|
||||||
Mule = 25 | EquineAnimal,
|
Donkey = 2118424,
|
||||||
SkeletonHorse = 26 | EquineAnimal | UndeadMob,
|
Mule = 2118425,
|
||||||
ZombieHorse = 27 | EquineAnimal | UndeadMob,
|
SkeletonHorse = 2186010,
|
||||||
PolarBear = 28 | Animal,
|
ZombieHorse = 2186011,
|
||||||
Llama = 29 | Animal,
|
Zombie = 199456,
|
||||||
Parrot = 30 | TamableAnimal,
|
Creeper = 2849,
|
||||||
Dolphin = 31 | WaterAnimal,
|
Skeleton = 1116962,
|
||||||
Zombie = 32 | ZombieMonster,
|
Spider = 264995,
|
||||||
Creeper = 33 | Monster,
|
PigZombie = 68388,
|
||||||
Skeleton = 34 | SkeletonMonster,
|
Slime = 2853,
|
||||||
Spider = 35 | Arthropod,
|
EnderMan = 2854,
|
||||||
PigZombie = 36 | UndeadMob,
|
Silverfish = 264999,
|
||||||
Slime = 37 | Monster,
|
CaveSpider = 265000,
|
||||||
EnderMan = 38 | Monster,
|
Ghast = 2857,
|
||||||
Silverfish = 39 | Arthropod,
|
LavaSlime = 2858,
|
||||||
CaveSpider = 40 | Arthropod,
|
Blaze = 2859,
|
||||||
Ghast = 41 | Monster,
|
ZombieVillager = 199468,
|
||||||
LavaSlime = 42 | Monster,
|
Witch = 2861,
|
||||||
Blaze = 43 | Monster,
|
Stray = 1116974,
|
||||||
ZombieVillager = 44 | ZombieMonster,
|
Husk = 199471,
|
||||||
Witch = 45 | Monster,
|
WitherSkeleton = 1116976,
|
||||||
Stray = 46 | SkeletonMonster,
|
Guardian = 2865,
|
||||||
Husk = 47 | ZombieMonster,
|
ElderGuardian = 2866,
|
||||||
WitherSkeleton = 48 | SkeletonMonster,
|
Npc = 307,
|
||||||
Guardian = 49 | Monster,
|
WitherBoss = 68404,
|
||||||
ElderGuardian = 50 | Monster,
|
Dragon = 2869,
|
||||||
Npc = 51 | Mob,
|
Shulker = 2870,
|
||||||
WitherBoss = 52 | UndeadMob,
|
Endermite = 265015,
|
||||||
Dragon = 53 | Monster,
|
Agent = 312,
|
||||||
Shulker = 54 | Monster,
|
Vindicator = 2873,
|
||||||
Endermite = 55 | Arthropod,
|
Phantom = 68410,
|
||||||
Agent = 56 | Mob,
|
IllagerBeast = 2875,
|
||||||
Vindicator = 57 | Monster,
|
ArmorStand = 317,
|
||||||
Phantom = 58 | UndeadMob,
|
TripodCamera = 318,
|
||||||
IllagerBeast = 59 | Monster,
|
Player = 319,
|
||||||
UNUSED60 = 60,
|
ItemEntity = 64,
|
||||||
ArmorStand = 61 | Mob,
|
PrimedTnt = 65,
|
||||||
TripodCamera = 62 | Mob,
|
FallingBlock = 66,
|
||||||
Player = 63 | Mob,
|
MovingBlock = 67,
|
||||||
ItemEntity = 64 | None,
|
ExperiencePotion = 4194372,
|
||||||
PrimedTnt = 65 | None,
|
Experience = 69,
|
||||||
FallingBlock = 66 | None,
|
EyeOfEnder = 70,
|
||||||
MovingBlock = 67 | None,
|
EnderCrystal = 71,
|
||||||
ExperiencePotion = 68 | Projectile,
|
FireworksRocket = 72,
|
||||||
Experience = 69 | None,
|
Trident = 12582985,
|
||||||
EyeOfEnder = 70 | None,
|
Turtle = 4938,
|
||||||
EnderCrystal = 71 | None,
|
Cat = 21323,
|
||||||
FireworksRocket = 72 | None,
|
ShulkerBullet = 4194380,
|
||||||
Trident = 73 | Projectile | AbstractArrow,
|
FishingHook = 77,
|
||||||
Turtle = 74 | Animal,
|
Chalkboard = 78,
|
||||||
Cat = 75 | TamableAnimal,
|
DragonFireball = 4194383,
|
||||||
ShulkerBullet = 76 | Projectile,
|
Arrow = 12582992,
|
||||||
FishingHook = 77 | None,
|
Snowball = 4194385,
|
||||||
Chalkboard = 78 | None,
|
ThrownEgg = 4194386,
|
||||||
DragonFireball = 79 | Projectile,
|
Painting = 83,
|
||||||
Arrow = 80 | Projectile | AbstractArrow,
|
LargeFireball = 4194389,
|
||||||
Snowball = 81 | Projectile,
|
ThrownPotion = 4194390,
|
||||||
ThrownEgg = 82 | Projectile,
|
Enderpearl = 4194391,
|
||||||
Painting = 83 | None,
|
LeashKnot = 88,
|
||||||
MinecartRideable = 84 | Minecart,
|
WitherSkull = 4194393,
|
||||||
LargeFireball = 85 | Projectile,
|
BoatRideable = 90,
|
||||||
ThrownPotion = 86 | Projectile,
|
WitherSkullDangerous = 4194395,
|
||||||
Enderpearl = 87 | Projectile,
|
LightningBolt = 93,
|
||||||
LeashKnot = 88 | None,
|
SmallFireball = 4194398,
|
||||||
WitherSkull = 89 | Projectile,
|
AreaEffectCloud = 95,
|
||||||
BoatRideable = 90 | None,
|
LingeringPotion = 4194405,
|
||||||
WitherSkullDangerous = 91 | Projectile,
|
LlamaSpit = 4194406,
|
||||||
UNUSED92 = 92,
|
EvocationFang = 4194407,
|
||||||
LightningBolt = 93 | None,
|
EvocationIllager = 2920,
|
||||||
SmallFireball = 94 | Projectile,
|
Vex = 2921,
|
||||||
AreaEffectCloud = 95 | None,
|
MinecartRideable = 524372,
|
||||||
MinecartHopper = 96 | Minecart,
|
MinecartHopper = 524384,
|
||||||
MinecartTNT = 97 | Minecart,
|
MinecartTNT = 524385,
|
||||||
MinecartChest = 98 | Minecart,
|
MinecartChest = 524386,
|
||||||
MinecartFurnace = 99 | Minecart,
|
MinecartFurnace = 524387,
|
||||||
MinecartCommandBlock = 100 | Minecart,
|
MinecartCommandBlock = 524388,
|
||||||
LingeringPotion = 101 | Projectile,
|
IceBomb = 4194410,
|
||||||
LlamaSpit = 102 | Projectile,
|
Balloon = 107,
|
||||||
EvocationFang = 103 | Projectile,
|
Pufferfish = 9068,
|
||||||
EvocationIllager = 104 | Monster,
|
Salmon = 9069,
|
||||||
Vex = 105 | Monster,
|
Drowned = 199534,
|
||||||
IceBomb = 106 | Projectile,
|
Tropicalfish = 9071,
|
||||||
Balloon = 107 | None,
|
Fish = 9072,
|
||||||
Pufferfish = 108 | WaterAnimal,
|
Panda = 4977,
|
||||||
Salmon = 109 | WaterAnimal,
|
Pillager = 2930,
|
||||||
Drowned = 110 | ZombieMonster,
|
VillagerV2 = 16778099,
|
||||||
Tropicalfish = 111 | WaterAnimal,
|
ZombieVillagerV2 = 199540,
|
||||||
Fish = 112 | WaterAnimal,
|
Shield = 117,
|
||||||
Panda = 113 | Animal,
|
WanderingTrader = 886,
|
||||||
Pillager = 114 | Monster,
|
Lectern = 119,
|
||||||
VillagerV2 = 115 | VillagerBase,
|
ElderGuardianGhost = 2936,
|
||||||
ZombieVillagerV2 = 116 | ZombieMonster,
|
Fox = 4985,
|
||||||
Shield = 117 | None,
|
Bee = 378,
|
||||||
WanderingTrader = 118 | PathfinderMob,
|
Piglin = 379,
|
||||||
Lectern = 119 | None,
|
Hoglin = 4988,
|
||||||
ElderGuardianGhost = 120 | Monster,
|
Strider = 4989,
|
||||||
Fox = 121 | Animal,
|
Zoglin = 68478,
|
||||||
Bee = 122 | Mob,
|
PiglinBrute = 383,
|
||||||
Piglin = 123 | Mob,
|
Goat = 4992,
|
||||||
Hoglin = 124 | Animal,
|
GlowSquid = 9089,
|
||||||
Strider = 125 | Animal,
|
Axolotl = 4994,
|
||||||
Zoglin = 126 | UndeadMob,
|
Warden = 2947,
|
||||||
PiglinBrute = 127 | Mob,
|
Frog = 4996,
|
||||||
Goat = 128 | Animal,
|
Tadpole = 9093,
|
||||||
GlowSquid = 129 | WaterAnimal,
|
Allay = 390,
|
||||||
Axolotl = 130 | Animal,
|
ChestBoatRideable = 218,
|
||||||
Warden = 131 | Monster,
|
TraderLlama = 5021,
|
||||||
Frog = 132 | Animal,
|
Camel = 5002,
|
||||||
Tadpole = 133 | WaterAnimal,
|
Sniffer = 5003,
|
||||||
Allay = 134 | Mob,
|
Breeze = 2956,
|
||||||
ChestBoatRideable = 136 | BoatRideable,
|
BreezeWindChargeProjectile = 4194445,
|
||||||
TraderLlama = 137 | Llama,
|
Armadillo = 5006,
|
||||||
Camel = 138 | Animal,
|
WindChargeProjectile = 4194447,
|
||||||
Sniffer = 139 | Animal,
|
Bogged = 1117072,
|
||||||
Breeze = 140 | Monster,
|
OminousItemSpawner = 145,
|
||||||
BreezeWindChargeProjectile = 141 | Projectile,
|
Creaking = 2962,
|
||||||
Armadillo = 142 | Animal,
|
HappyGhast = 5011,
|
||||||
WindChargeProjectile = 143 | Projectile,
|
|
||||||
Bogged = 144 | SkeletonMonster,
|
|
||||||
OminousItemSpawner = 145
|
|
||||||
}
|
}
|
||||||
|
|
||||||
interface Player {
|
interface Player {
|
||||||
@@ -1556,6 +1585,9 @@ interface Player {
|
|||||||
slot: number
|
slot: number
|
||||||
): Item;
|
): Item;
|
||||||
|
|
||||||
|
/** (GMLIB & Glacie)获取客户端版本协议*/
|
||||||
|
getNetworkProtocolVersion(): number
|
||||||
|
|
||||||
/** (GMLIB)发送更新更新物品数据包 */
|
/** (GMLIB)发送更新更新物品数据包 */
|
||||||
sendInventorySlotPacket(
|
sendInventorySlotPacket(
|
||||||
/** 容器ID */
|
/** 容器ID */
|
||||||
|
|||||||
+394
-376
File diff suppressed because it is too large
Load Diff
+42
-30
@@ -1,40 +1,52 @@
|
|||||||
/// <reference path='d:/dts/dts/helperlib/src/index.d.ts'/>
|
/// <reference path='d:/dts/dts/helperlib/src/index.d.ts'/>
|
||||||
|
|
||||||
const getPluginName = () => {
|
const getPluginName = () => {
|
||||||
|
// quickjs
|
||||||
try {
|
try {
|
||||||
throw new Error("getPluginName");
|
throw new Error("getPluginName");
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
return error.stack.trim().match(/plugins\\(.*)\\.*\.js:[0-9]+\)$/i)?.[1]
|
const /** @type {string} */ line = error.stack.trim().split("\n").pop().trim();
|
||||||
|| error.stack.trim().match(/at <anonymous> \(([^\\|/]+)(.*?):\d+:\d+\)$/i)?.[1]
|
if (line.includes("<anonymous>")) {
|
||||||
|| "Unknown";
|
return line.slice(
|
||||||
|
line.indexOf("(") + 1,
|
||||||
|
line.indexOf("\\")
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (line.includes("<eval>")) {
|
||||||
|
return line.slice(
|
||||||
|
line.indexOf("/", line.indexOf("/") + 1) + 1,
|
||||||
|
line.indexOf("\\")
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
Function.prototype.getName =
|
// nodejs
|
||||||
/**
|
try {
|
||||||
* 获取函数名字
|
const path = require('path');
|
||||||
* @returns {string}
|
const selfFileName = path.basename(__filename);
|
||||||
*/
|
const pluginDirectory = Object.entries(
|
||||||
function () {
|
require('module')._pathCache
|
||||||
return this.name || this.toString().match(/function\s*([^(]*)\(/)?.[1] || getStringHashCode(this.toString()).toString(16);
|
).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";
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取字符串哈希值
|
|
||||||
* @param {string} str 字符串
|
|
||||||
* @returns {number}
|
|
||||||
*/
|
|
||||||
function getStringHashCode(str) {
|
|
||||||
let hash = 0, chr;
|
|
||||||
if (str.length === 0) return hash;
|
|
||||||
for (let i = 0; i < str.length; i++) {
|
|
||||||
chr = str.charCodeAt(i);
|
|
||||||
hash = ((hash << 5) - hash) + chr;
|
|
||||||
hash |= 0;
|
|
||||||
}
|
|
||||||
return hash;
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
translate(value, actor = undefined, language = "") {
|
translate(value, actor = undefined, language = "") {
|
||||||
return actor instanceof LLSE_Entity
|
return actor instanceof LLSE_Entity
|
||||||
@@ -46,8 +58,8 @@ module.exports = {
|
|||||||
ll.exports((...args) => {
|
ll.exports((...args) => {
|
||||||
if(!args[0].uniqueId) args[0] = undefined;
|
if(!args[0].uniqueId) args[0] = undefined;
|
||||||
return callback(...args) ?? "<std::nullopt>";
|
return callback(...args) ?? "<std::nullopt>";
|
||||||
}, pluginName, callback.getName());
|
}, pluginName, `Placeholder_${placeholder}`);
|
||||||
ll.imports("PlaceholderAPI", "registerPlaceholder")(placeholder, callback.getName(), pluginName);
|
ll.imports("PlaceholderAPI", "registerPlaceholder")(placeholder, `Placeholder_${placeholder}`, pluginName);
|
||||||
},
|
},
|
||||||
unregisterPlaceholder(placeholder) {
|
unregisterPlaceholder(placeholder) {
|
||||||
return ll.imports("PlaceholderAPI", "unregisterPlaceholder")(placeholder);
|
return ll.imports("PlaceholderAPI", "unregisterPlaceholder")(placeholder);
|
||||||
@@ -56,7 +68,7 @@ module.exports = {
|
|||||||
return ll.imports("PlaceholderAPI", "unregisterPlaceholderFromModName")(placeholder);
|
return ll.imports("PlaceholderAPI", "unregisterPlaceholderFromModName")(placeholder);
|
||||||
},
|
},
|
||||||
getValue(placeholder, actor = undefined, params = {}, language = "") {
|
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
|
const result = actor instanceof LLSE_Entity
|
||||||
? ll.imports("PlaceholderAPI", "getValueFromActor")(placeholder, actor, params, language)
|
? ll.imports("PlaceholderAPI", "getValueFromActor")(placeholder, actor, params, language)
|
||||||
: ll.imports("PlaceholderAPI", "getValue")(placeholder, params, language);
|
: ll.imports("PlaceholderAPI", "getValue")(placeholder, params, language);
|
||||||
|
|||||||
+6
-3
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "${pluginName}",
|
"name": "${modName}",
|
||||||
"entry": "${pluginFile}",
|
"entry": "${modFile}",
|
||||||
"version": "1.0.0-rc.1",
|
"version": "${modVersion}",
|
||||||
"author": "GroupMountain",
|
"author": "GroupMountain",
|
||||||
"type": "native",
|
"type": "native",
|
||||||
"passive": true,
|
"passive": true,
|
||||||
@@ -11,6 +11,9 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "LegacyRemoteCall"
|
"name": "LegacyRemoteCall"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "iListenAttentively"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -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
|
|
||||||
}
|
|
||||||
@@ -1,6 +1,4 @@
|
|||||||
#include "Global.h"
|
#include "Global.h"
|
||||||
#include <gmlib/mc/network/BinaryStream.h>
|
|
||||||
#include <mc/world/item/NetworkItemStackDescriptor.h>
|
|
||||||
|
|
||||||
class LegacyScriptBinaryStreamManager {
|
class LegacyScriptBinaryStreamManager {
|
||||||
private:
|
private:
|
||||||
@@ -80,6 +78,7 @@ void Export_BinaryStream_API() {
|
|||||||
EXPORTAPI("writeItem", ItemStack*, bs->writeNetworkItemStackDescriptor(NetworkItemStackDescriptor(*value)));
|
EXPORTAPI("writeItem", ItemStack*, bs->writeNetworkItemStackDescriptor(NetworkItemStackDescriptor(*value)));
|
||||||
EXPORTAPI("writeString", std::string const&, bs->writeString(value));
|
EXPORTAPI("writeString", std::string const&, bs->writeString(value));
|
||||||
EXPORTAPI("writeCompoundTag", CompoundTag*, bs->writeCompoundTag(*value));
|
EXPORTAPI("writeCompoundTag", CompoundTag*, bs->writeCompoundTag(*value));
|
||||||
|
EXPORTAPI("writeUnsignedChar", uchar, bs->writeUnsignedChar(value));
|
||||||
EXPORTAPI2(writeBool);
|
EXPORTAPI2(writeBool);
|
||||||
EXPORTAPI2(writeByte);
|
EXPORTAPI2(writeByte);
|
||||||
EXPORTAPI2(writeDouble);
|
EXPORTAPI2(writeDouble);
|
||||||
@@ -88,7 +87,6 @@ void Export_BinaryStream_API() {
|
|||||||
EXPORTAPI2(writeSignedInt);
|
EXPORTAPI2(writeSignedInt);
|
||||||
EXPORTAPI2(writeSignedInt64);
|
EXPORTAPI2(writeSignedInt64);
|
||||||
EXPORTAPI2(writeSignedShort);
|
EXPORTAPI2(writeSignedShort);
|
||||||
EXPORTAPI2(writeUnsignedChar);
|
|
||||||
EXPORTAPI2(writeUnsignedInt);
|
EXPORTAPI2(writeUnsignedInt);
|
||||||
EXPORTAPI2(writeUnsignedInt64);
|
EXPORTAPI2(writeUnsignedInt64);
|
||||||
EXPORTAPI2(writeUnsignedShort);
|
EXPORTAPI2(writeUnsignedShort);
|
||||||
|
|||||||
+123
-96
@@ -1,17 +1,17 @@
|
|||||||
#include "Global.h"
|
#include "Global.h"
|
||||||
|
#include "mc/platform/UUID.h"
|
||||||
#include <regex>
|
#include <regex>
|
||||||
|
|
||||||
ActorUniqueID parseScriptUniqueID(std::string const& uniqueId) {
|
ActorUniqueID parseScriptUniqueID(std::string const& uniqueId) {
|
||||||
return StringUtils::isInteger(uniqueId) ? ActorUniqueID(std::stoll(uniqueId)) : ActorUniqueID::INVALID_ID();
|
return string_utils::isInteger(uniqueId) ? ActorUniqueID(std::stoll(uniqueId)) : ActorUniqueID::INVALID_ID();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Export_Compatibility_API() {
|
void Export_Compatibility_API() {
|
||||||
RemoteCall::exportAs("GMLIB_API", "unregisterRecipe", [](std::string const& id) -> bool {
|
RemoteCall::exportAs("GMLIB_API", "unregisterRecipe", [](std::string const& id) -> bool {
|
||||||
// return GMLevel::getInstance().has_value() ? GMLIB::Mod::CustomRecipe::unregisterRecipe(id) : false;
|
return CustomRecipeRegistry::getInstance().unregisterRecipe(id, true);
|
||||||
throw std::runtime_error("GMLIB_API::unregisterRecipe is not implemented");
|
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "setCustomPackPath", [](std::string const& path) -> void {
|
RemoteCall::exportAs("GMLIB_API", "setCustomPackPath", [](std::string const& path) -> void {
|
||||||
AddonsLoaderUtils::addCustomPackPath(path);
|
AddonsLoader::addCustomPackPath(path);
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "getServerMspt", []() -> double {
|
RemoteCall::exportAs("GMLIB_API", "getServerMspt", []() -> double {
|
||||||
return GMLevel::getInstance().transform(
|
return GMLevel::getInstance().transform(
|
||||||
@@ -19,14 +19,14 @@ void Export_Compatibility_API() {
|
|||||||
).value_or(0.0);
|
).value_or(0.0);
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "getServerCurrentTps", []() -> float {
|
RemoteCall::exportAs("GMLIB_API", "getServerCurrentTps", []() -> float {
|
||||||
return GMLevel::getInstance()
|
return GMLevel::getInstance().transform(
|
||||||
.transform([](GMLevel& level) -> float { return level.getServerCurrentTps(); })
|
[](GMLevel& level) -> float { return level.getServerCurrentTps(); }
|
||||||
.value_or(0.0);
|
).value_or(0.0);
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "getServerAverageTps", []() -> double {
|
RemoteCall::exportAs("GMLIB_API", "getServerAverageTps", []() -> double {
|
||||||
return GMLevel::getInstance()
|
return GMLevel::getInstance().transform(
|
||||||
.transform([](GMLevel& level) -> double { return level.getServerAverageTps(); })
|
[](GMLevel& level) -> double { return level.getServerAverageTps(); }
|
||||||
.value_or(0.0);
|
).value_or(0.0);
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "getAllPlayerUuids", []() -> std::vector<std::string> {
|
RemoteCall::exportAs("GMLIB_API", "getAllPlayerUuids", []() -> std::vector<std::string> {
|
||||||
std::vector<std::string> result;
|
std::vector<std::string> result;
|
||||||
@@ -36,7 +36,7 @@ void Export_Compatibility_API() {
|
|||||||
return result;
|
return result;
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "getPlayerNbt", [](std::string const& uuid) -> std::unique_ptr<CompoundTag> {
|
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 std::make_unique<CompoundTag>(*player->getNbt());
|
||||||
}
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
@@ -45,7 +45,8 @@ void Export_Compatibility_API() {
|
|||||||
"GMLIB_API",
|
"GMLIB_API",
|
||||||
"setPlayerNbt",
|
"setPlayerNbt",
|
||||||
[](std::string const& uuid, CompoundTag* nbt, bool forceCreate) -> bool {
|
[](std::string const& uuid, CompoundTag* nbt, bool forceCreate) -> bool {
|
||||||
if (auto player = OfflinePlayer::getOfflinePlayer(mce::UUID::fromString(uuid))) return player->setNbt(*nbt);
|
auto player = OfflinePlayer::fromUuid(mce::UUID::fromString(uuid));
|
||||||
|
if (player&&player->hasNbt()) return player->setNbt(*nbt);
|
||||||
return forceCreate ? OfflinePlayer::createNewPlayerNbt(mce::UUID::fromString(uuid), *nbt).has_value()
|
return forceCreate ? OfflinePlayer::createNewPlayerNbt(mce::UUID::fromString(uuid), *nbt).has_value()
|
||||||
: false;
|
: false;
|
||||||
}
|
}
|
||||||
@@ -54,7 +55,7 @@ void Export_Compatibility_API() {
|
|||||||
"GMLIB_API",
|
"GMLIB_API",
|
||||||
"setPlayerNbtTags",
|
"setPlayerNbtTags",
|
||||||
[](std::string const& uuid, CompoundTag* nbt, std::vector<std::string> tags) -> bool {
|
[](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();
|
auto nbt2 = *player->getNbt();
|
||||||
GMCompoundTag::writeNbtTags(nbt2, *nbt, tags);
|
GMCompoundTag::writeNbtTags(nbt2, *nbt, tags);
|
||||||
return player->setNbt(nbt2);
|
return player->setNbt(nbt2);
|
||||||
@@ -66,20 +67,21 @@ void Export_Compatibility_API() {
|
|||||||
return OfflinePlayer::deletePlayerNbt(mce::UUID::fromString(uuid));
|
return OfflinePlayer::deletePlayerNbt(mce::UUID::fromString(uuid));
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "getAllExperiments", []() -> std::vector<int> {
|
RemoteCall::exportAs("GMLIB_API", "getAllExperiments", []() -> std::vector<int> {
|
||||||
// std::vector<int> result;
|
return {36, 45, 38, 48, 47, 53, 56, 45, 40};
|
||||||
// for (auto& key : GMLevel::getAllExperiments()) {
|
|
||||||
// result.push_back((int)key);
|
|
||||||
// }
|
|
||||||
// return result;
|
|
||||||
throw std::runtime_error("GMLIB_API::getAllExperiments is not implemented");
|
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "getExperimentTranslateKey", [](int id) -> std::string {
|
RemoteCall::exportAs("GMLIB_API", "getExperimentTranslateKey", [](int id) -> std::string {
|
||||||
// std::string result;
|
static std::unordered_map<int, std::string> mMap = {
|
||||||
// try {
|
{36, "createWorldScreen.experimentalbiomes" },
|
||||||
// result = Experiments::getExperimentTextID(AllExperiments(id));
|
{45, "createWorldScreen.experimentalCreatorFeatures" },
|
||||||
// } catch (...) {}
|
{38, "createWorldScreen.experimentalGameTest" },
|
||||||
// return result;
|
{48, "createWorldScreen.experimentalThirdPersonCameras" },
|
||||||
throw std::runtime_error("GMLIB_API::getExperimentTranslateKey is not implemented");
|
{47, "createWorldScreen.experimentalFocusTargetCamera" },
|
||||||
|
{53, "createWorldScreen.experimentalVillagerTradesRebalance" },
|
||||||
|
{56, "createWorldScreen.experimentalDataDrivenJigsawStructures"},
|
||||||
|
{45, "createWorldScreen.experimentalCameraAimAssist" },
|
||||||
|
{40, "createWorldScreen.experimentalY2025Drop1" }
|
||||||
|
};
|
||||||
|
return mMap.contains(id) ? mMap[id] : "";
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs(
|
RemoteCall::exportAs(
|
||||||
"GMLIB_API",
|
"GMLIB_API",
|
||||||
@@ -143,12 +145,17 @@ void Export_Compatibility_API() {
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "isVersionMatched", [](std::uint16_t a, std::uint16_t b, std::uint16_t c) -> bool {
|
RemoteCall::exportAs(
|
||||||
|
"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, "", "");
|
return LIB_VERSION >= ll::data::Version(a, b, c, "", "");
|
||||||
});
|
}
|
||||||
|
);
|
||||||
RemoteCall::exportAs("GMLIB_API", "getVersion_LRCA", []() -> std::string { return LIB_VERSION.to_string(); });
|
RemoteCall::exportAs("GMLIB_API", "getVersion_LRCA", []() -> std::string { return LIB_VERSION.to_string(); });
|
||||||
RemoteCall::exportAs("GMLIB_API", "getVersion_GMLIB", []() -> std::string {
|
RemoteCall::exportAs("GMLIB_API", "getVersion_GMLIB", []() -> std::string {
|
||||||
return GMLIB_VERSION_TO_STRING(GMLIB_VERSION_MAJOR) "." GMLIB_VERSION_TO_STRING(GMLIB_VERSION_MINOR
|
return GMLIB_VERSION_TO_STRING(GMLIB_VERSION_MAJOR) "." GMLIB_VERSION_TO_STRING(
|
||||||
|
GMLIB_VERSION_MINOR
|
||||||
) "." GMLIB_VERSION_TO_STRING(GMLIB_VERSION_PATCH);
|
) "." GMLIB_VERSION_TO_STRING(GMLIB_VERSION_PATCH);
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs(
|
RemoteCall::exportAs(
|
||||||
@@ -182,8 +189,9 @@ void Export_Compatibility_API() {
|
|||||||
RemoteCall::exportAs(
|
RemoteCall::exportAs(
|
||||||
"GMLIB_API",
|
"GMLIB_API",
|
||||||
"updateOrCreateLanguageFile",
|
"updateOrCreateLanguageFile",
|
||||||
[](std::string const& code, std::unordered_map<std::string, std::string> lang, std::string const& path
|
[](std::string const& code,
|
||||||
) -> void {
|
std::unordered_map<std::string, std::string> lang,
|
||||||
|
std::string const& path) -> void {
|
||||||
if (GMLevel::getInstance()) {
|
if (GMLevel::getInstance()) {
|
||||||
I18nAPI::updateOrCreateLanguageFile(path, code, lang);
|
I18nAPI::updateOrCreateLanguageFile(path, code, lang);
|
||||||
}
|
}
|
||||||
@@ -195,7 +203,7 @@ void Export_Compatibility_API() {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "getPlayerPosition", [](std::string const& uuid) -> std::pair<BlockPos, int> {
|
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()) {
|
if (auto pos = player->getPlayerPosition()) {
|
||||||
return *pos;
|
return *pos;
|
||||||
}
|
}
|
||||||
@@ -209,8 +217,10 @@ void Export_Compatibility_API() {
|
|||||||
"GMLIB_API",
|
"GMLIB_API",
|
||||||
"setPlayerPosition",
|
"setPlayerPosition",
|
||||||
[](std::string const& uuid, std::pair<BlockPos, int> pos) -> bool {
|
[](std::string const& uuid, std::pair<BlockPos, int> pos) -> bool {
|
||||||
// return GMPlayer::setPlayerPosition(mce::UUID::fromString(uuid), pos.first, pos.second);
|
if (auto player = OfflinePlayer::fromUuid(mce::UUID::fromString(uuid))) {
|
||||||
throw std::runtime_error("GMLIB_API::setPlayerPosition is not implemented");
|
return player->setPosition(pos.first, pos.second);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
RemoteCall::exportAs("GMLIB_API", "playerHasScore", [](std::string const& uuid, std::string const& obj) -> bool {
|
RemoteCall::exportAs("GMLIB_API", "playerHasScore", [](std::string const& uuid, std::string const& obj) -> bool {
|
||||||
@@ -448,17 +458,14 @@ void Export_Compatibility_API() {
|
|||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "getPlayerSpawnPoint", [](Player* pl) -> std::pair<BlockPos, int> {
|
RemoteCall::exportAs("GMLIB_API", "getPlayerSpawnPoint", [](Player* pl) -> std::pair<BlockPos, int> {
|
||||||
// auto res = ((GMPlayer*)pl)->getSpawnPoint();
|
return {pl->mPlayerRespawnPoint->mSpawnBlockPos, pl->mPlayerRespawnPoint->mDimension.get()};
|
||||||
// return {res.first, res.second};
|
|
||||||
throw std::runtime_error("GMLIB_API::getPlayerSpawnPoint is not implemented");
|
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "setPlayerSpawnPoint", [](Player* pl, std::pair<BlockPos, int> pos) -> void {
|
RemoteCall::exportAs("GMLIB_API", "setPlayerSpawnPoint", [](Player* pl, std::pair<BlockPos, int> pos) -> void {
|
||||||
// ((GMPlayer*)pl)->setSpawnPoint(pos.first, pos.second);
|
pl->setRespawnPosition(pos.first, pos.second);
|
||||||
throw std::runtime_error("GMLIB_API::setPlayerSpawnPoint is not implemented");
|
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "clearPlayerSpawnPoint", [](Player* pl) -> void {
|
RemoteCall::exportAs("GMLIB_API", "clearPlayerSpawnPoint", [](Player* pl) -> void {
|
||||||
// ((GMPlayer*)pl)->clearSpawnPoint();
|
pl->mPlayerRespawnPoint->mSpawnBlockPos = BlockPos::MIN();
|
||||||
throw std::runtime_error("GMLIB_API::clearPlayerSpawnPoint is not implemented");
|
pl->mPlayerRespawnPoint->mDimension = VanillaDimensions::Undefined();
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs(
|
RemoteCall::exportAs(
|
||||||
"GMLIB_API",
|
"GMLIB_API",
|
||||||
@@ -471,33 +478,47 @@ void Export_Compatibility_API() {
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
RemoteCall::exportAs("GMLIB_API", "getXuidByUuid", [](std::string const& uuid) -> std::string {
|
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 {
|
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 {
|
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 {
|
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 {
|
RemoteCall::exportAs("GMLIB_API", "getUuidByXuid", [](std::string const& xuid) -> std::string {
|
||||||
return UserCache::getUuidByXuid(xuid)
|
if (auto uce = UserCache::getInstance()->from(xuid, UserCache::QueryType::Xuid)) {
|
||||||
.transform([](mce::UUID&& uuid) -> std::string { return uuid.asString(); })
|
return uce->mUuid.asString();
|
||||||
.value_or("");
|
}
|
||||||
|
return "";
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "getUuidByName", [](std::string const& name) -> std::string {
|
RemoteCall::exportAs("GMLIB_API", "getUuidByName", [](std::string const& name) -> std::string {
|
||||||
return UserCache::getUuidByName(name)
|
if (auto uce = UserCache::getInstance()->from(name, UserCache::QueryType::Name)) {
|
||||||
.transform([](mce::UUID&& uuid) -> std::string { return uuid.asString(); })
|
return uce->mUuid.asString();
|
||||||
.value_or("");
|
}
|
||||||
|
return "";
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs(
|
RemoteCall::exportAs(
|
||||||
"GMLIB_API",
|
"GMLIB_API",
|
||||||
"getAllPlayerInfo",
|
"getAllPlayerInfo",
|
||||||
[]() -> std::vector<std::unordered_map<std::string, std::string>> {
|
[]() -> std::vector<std::unordered_map<std::string, std::string>> {
|
||||||
std::vector<std::unordered_map<std::string, std::string>> result;
|
std::vector<std::unordered_map<std::string, std::string>> result;
|
||||||
for (auto entry : UserCache::entries()){
|
for (auto entry : UserCache::getInstance()->entries()) {
|
||||||
result.push_back({
|
result.push_back({
|
||||||
{"Name", entry.mName },
|
{"Name", entry.mName },
|
||||||
{"Xuid", entry.mXuid },
|
{"Xuid", entry.mXuid },
|
||||||
@@ -513,7 +534,7 @@ void Export_Compatibility_API() {
|
|||||||
.value_or(0);
|
.value_or(0);
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "getBlockTranslateKey", [](Block const* block) -> std::string {
|
RemoteCall::exportAs("GMLIB_API", "getBlockTranslateKey", [](Block const* block) -> std::string {
|
||||||
return block->getLegacyBlock().mDescriptionId;
|
return block->getLegacyBlock().mDescriptionId.get() + ".name";
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "getItemTranslateKey", [](ItemStack* item) -> std::string {
|
RemoteCall::exportAs("GMLIB_API", "getItemTranslateKey", [](ItemStack* item) -> std::string {
|
||||||
return item->getDescriptionId();
|
return item->getDescriptionId();
|
||||||
@@ -539,11 +560,10 @@ void Export_Compatibility_API() {
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
RemoteCall::exportAs("GMLIB_API", "getBlockDestroySpeed", [](Block const* block) -> float {
|
RemoteCall::exportAs("GMLIB_API", "getBlockDestroySpeed", [](Block const* block) -> float {
|
||||||
return block->mDirectData->mUnkc08fbd.as<float>();
|
return block->mDirectData->mDestroySpeed;
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "getDestroyBlockSpeed", [](ItemStack const* item, Block const* block) -> float {
|
RemoteCall::exportAs("GMLIB_API", "getDestroyBlockSpeed", [](ItemStack const* item, Block const* block) -> float {
|
||||||
// return item->getDestroySpeed(*block);
|
return item->getItem()->getDestroySpeed(*item, *block);
|
||||||
throw std::runtime_error("GMLIB_API::getDestroyBlockSpeed is not implemented");
|
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs(
|
RemoteCall::exportAs(
|
||||||
"GMLIB_API",
|
"GMLIB_API",
|
||||||
@@ -554,7 +574,7 @@ void Export_Compatibility_API() {
|
|||||||
);
|
);
|
||||||
RemoteCall::exportAs("GMLIB_API", "itemCanDestroyBlock", [](ItemStack const* item, Block const* block) -> bool {
|
RemoteCall::exportAs("GMLIB_API", "itemCanDestroyBlock", [](ItemStack const* item, Block const* block) -> bool {
|
||||||
return std::ranges::any_of(item->mCanDestroy, [block](BlockLegacy const* blockLegacy) {
|
return std::ranges::any_of(item->mCanDestroy, [block](BlockLegacy const* blockLegacy) {
|
||||||
return block->getTypeName() == blockLegacy->getTypeName();
|
return blockLegacy && block->getTypeName() == blockLegacy->getTypeName();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "itemCanDestroyInCreative", [](ItemStack const* item) -> bool {
|
RemoteCall::exportAs("GMLIB_API", "itemCanDestroyInCreative", [](ItemStack const* item) -> bool {
|
||||||
@@ -564,8 +584,10 @@ void Export_Compatibility_API() {
|
|||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "itemCanDestroySpecial", [](ItemStack const* item, Block const* block) -> bool {
|
RemoteCall::exportAs("GMLIB_API", "itemCanDestroySpecial", [](ItemStack const* item, Block const* block) -> bool {
|
||||||
// return item->canDestroySpecial(*block);
|
if (auto itemDef = item->getItem(); itemDef) {
|
||||||
throw std::runtime_error("GMLIB_API::itemCanDestroySpecial is not implemented");
|
return itemDef->canDestroySpecial(*block);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "blockCanDropWithAnyTool", [](Block const* block) -> bool {
|
RemoteCall::exportAs("GMLIB_API", "blockCanDropWithAnyTool", [](Block const* block) -> bool {
|
||||||
return !block->getLegacyBlock().mRequiresCorrectToolForDrops;
|
return !block->getLegacyBlock().mRequiresCorrectToolForDrops;
|
||||||
@@ -580,9 +602,10 @@ void Export_Compatibility_API() {
|
|||||||
RemoteCall::exportAs("GMLIB_API", "playerAttack", [](Player* player, Actor* entity) -> bool {
|
RemoteCall::exportAs("GMLIB_API", "playerAttack", [](Player* player, Actor* entity) -> bool {
|
||||||
return player->attack(*entity, SharedTypes::Legacy::ActorDamageCause::EntityAttack);
|
return player->attack(*entity, SharedTypes::Legacy::ActorDamageCause::EntityAttack);
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "playerPullInEntity", [](Player* player, Actor* entity) -> bool {
|
RemoteCall::exportAs("GMLIB_API", "playerPullInEntity", [](Player* player, Actor* entity) -> void {
|
||||||
// return player->pullInEntity(*entity);
|
if (auto component = player->getEntityContext().tryGetComponent<RideableComponent>()) {
|
||||||
throw std::runtime_error("GMLIB_API::playerPullInEntity is not implemented");
|
component->pullInEntity(*player, *entity);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "getBlockTranslateKeyFromName", [](std::string const& blockName) -> std::string {
|
RemoteCall::exportAs("GMLIB_API", "getBlockTranslateKeyFromName", [](std::string const& blockName) -> std::string {
|
||||||
return Block::tryGetFromRegistry(blockName)
|
return Block::tryGetFromRegistry(blockName)
|
||||||
@@ -594,7 +617,7 @@ void Export_Compatibility_API() {
|
|||||||
"getBlockLightEmission",
|
"getBlockLightEmission",
|
||||||
[](std::string const& blockName, short legacyData) -> char {
|
[](std::string const& blockName, short legacyData) -> char {
|
||||||
return Block::tryGetFromRegistry(blockName)
|
return Block::tryGetFromRegistry(blockName)
|
||||||
.transform([](const Block& block) -> char { return block.mDirectData->mUnkda4e0e.as<char>(); })
|
.transform([](const Block& block) -> char { return block.mDirectData->mLightEmission->mValue; })
|
||||||
.value_or(-1);
|
.value_or(-1);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@@ -609,21 +632,21 @@ void Export_Compatibility_API() {
|
|||||||
result.push_back({
|
result.push_back({
|
||||||
{"Name", gameRule.mName },
|
{"Name", gameRule.mName },
|
||||||
{"Type", "Bool" },
|
{"Type", "Bool" },
|
||||||
{"Value", std::to_string(gameRule.mValue->mUnk29fff1.as<bool>())}
|
{"Value", std::to_string(gameRule.mValue->boolVal)}
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case GameRule::Type::Float:
|
case GameRule::Type::Float:
|
||||||
result.push_back({
|
result.push_back({
|
||||||
{"Name", gameRule.mName },
|
{"Name", gameRule.mName },
|
||||||
{"Type", "Float" },
|
{"Type", "Float" },
|
||||||
{"Value", std::to_string(gameRule.mValue->mUnk768db5.as<float>())}
|
{"Value", std::to_string(gameRule.mValue->floatVal)}
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case GameRule::Type::Int:
|
case GameRule::Type::Int:
|
||||||
result.push_back({
|
result.push_back({
|
||||||
{"Name", gameRule.mName },
|
{"Name", gameRule.mName },
|
||||||
{"Type", "Int" },
|
{"Type", "Int" },
|
||||||
{"Value", std::to_string(gameRule.mValue->mUnk2ab4f3.as<int>())}
|
{"Value", std::to_string(gameRule.mValue->intVal)}
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case GameRule::Type::Invalid:
|
case GameRule::Type::Invalid:
|
||||||
@@ -651,9 +674,7 @@ void Export_Compatibility_API() {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
RemoteCall::exportAs("GMLIB_API", "removeEnchants", [](ItemStack* item) -> void {
|
RemoteCall::exportAs("GMLIB_API", "removeEnchants", [](ItemStack* item) -> void { item->removeEnchants(); });
|
||||||
item->removeEnchants();
|
|
||||||
});
|
|
||||||
RemoteCall::exportAs("GMLIB_API", "hasEnchant", [](ItemStack* item, std::string const& typeName) -> bool {
|
RemoteCall::exportAs("GMLIB_API", "hasEnchant", [](ItemStack* item, std::string const& typeName) -> bool {
|
||||||
return EnchantUtils::hasEnchant(Enchant::mEnchantNameToType()[HashedString(typeName)], *item);
|
return EnchantUtils::hasEnchant(Enchant::mEnchantNameToType()[HashedString(typeName)], *item);
|
||||||
});
|
});
|
||||||
@@ -693,10 +714,10 @@ void Export_Compatibility_API() {
|
|||||||
RemoteCall::exportAs("GMLIB_API", "setItemShouldKeepOnDeath", [](ItemStack const* item, bool value) -> void {
|
RemoteCall::exportAs("GMLIB_API", "setItemShouldKeepOnDeath", [](ItemStack const* item, bool value) -> void {
|
||||||
auto nbt = ((GMItemStack*)item)->getNbt();
|
auto nbt = ((GMItemStack*)item)->getNbt();
|
||||||
if (value) {
|
if (value) {
|
||||||
(*nbt)["tags"]["minecraft:keep_on_death"] = true;
|
(*nbt)["tag"]["minecraft:keep_on_death"] = true;
|
||||||
} else {
|
} else {
|
||||||
if (nbt->contains("tags") && (*nbt)["tags"].contains("minecraft:keep_on_death")){
|
if (nbt->contains("tag") && (*nbt)["tag"].contains("minecraft:keep_on_death")) {
|
||||||
(*nbt)["tags"].get<CompoundTag>().erase("minecraft:keep_on_death");
|
(*nbt)["tag"].get<CompoundTag>().erase("minecraft:keep_on_death");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
((GMItemStack*)item)->setNbt(*nbt);
|
((GMItemStack*)item)->setNbt(*nbt);
|
||||||
@@ -803,7 +824,9 @@ void Export_Compatibility_API() {
|
|||||||
return magic_enum::enum_name(container->mContainerType).data();
|
return magic_enum::enum_name(container->mContainerType).data();
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "hasPlayerNbt", [](std::string const& uuid) -> bool {
|
RemoteCall::exportAs("GMLIB_API", "hasPlayerNbt", [](std::string const& uuid) -> bool {
|
||||||
return OfflinePlayer::getOfflinePlayer(mce::UUID::fromString(uuid)).transform([&](auto&& player) -> bool { return player.hasNbt(); }).value_or(false);
|
return OfflinePlayer::fromUuid(mce::UUID::fromString(uuid))
|
||||||
|
.transform([&](auto&& player) -> bool { return player.hasNbt(); })
|
||||||
|
.value_or(false);
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "getItemMaxCount", [](ItemStack const* item) -> int {
|
RemoteCall::exportAs("GMLIB_API", "getItemMaxCount", [](ItemStack const* item) -> int {
|
||||||
return item->getMaxStackSize();
|
return item->getMaxStackSize();
|
||||||
@@ -814,36 +837,39 @@ void Export_Compatibility_API() {
|
|||||||
RemoteCall::exportAs("GMLIB_API", "getPlayerDestroyBlockProgress", [](Player* player, Block const* block) -> float {
|
RemoteCall::exportAs("GMLIB_API", "getPlayerDestroyBlockProgress", [](Player* player, Block const* block) -> float {
|
||||||
return player->getDestroyProgress(*block);
|
return player->getDestroyProgress(*block);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
static constexpr size_t effectMaxCount = 36;
|
||||||
|
|
||||||
RemoteCall::exportAs("GMLIB_API", "getEntityEffectVisible", [](Actor* entity, int effectId) -> bool {
|
RemoteCall::exportAs("GMLIB_API", "getEntityEffectVisible", [](Actor* entity, int effectId) -> bool {
|
||||||
if (effectId < 0 || !MobEffect::mMobEffects()[effectId]) return false;
|
if (effectId <= 0 || effectId > effectMaxCount || !MobEffect::mMobEffects()[effectId]) return false;
|
||||||
if (auto effect = entity->getEffect(*MobEffect::mMobEffects()[effectId])) {
|
if (auto effect = entity->getEffect(*MobEffect::mMobEffects()[effectId])) {
|
||||||
return effect->mEffectVisible;
|
return effect->mEffectVisible;
|
||||||
}
|
}
|
||||||
return 0;
|
return false;
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "getEntityEffectDuration", [](Actor* entity, int effectId) -> int {
|
RemoteCall::exportAs("GMLIB_API", "getEntityEffectDuration", [](Actor* entity, int effectId) -> int {
|
||||||
if (effectId < 0 || !MobEffect::mMobEffects()[effectId]) return false;
|
if (effectId <= 0 || effectId > effectMaxCount|| !MobEffect::mMobEffects()[effectId]) return false;
|
||||||
if (auto effect = entity->getEffect(*MobEffect::mMobEffects()[effectId])) {
|
if (auto effect = entity->getEffect(*MobEffect::mMobEffects()[effectId])) {
|
||||||
return effect->mDuration->mValue;
|
return effect->mDuration->mValue;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "getEntityEffectDurationEasy", [](Actor* entity, int effectId) -> int {
|
RemoteCall::exportAs("GMLIB_API", "getEntityEffectDurationEasy", [](Actor* entity, int effectId) -> int {
|
||||||
if (effectId < 0 || !MobEffect::mMobEffects()[effectId]) return false;
|
if (effectId <= 0 || effectId > effectMaxCount || !MobEffect::mMobEffects()[effectId]) return false;
|
||||||
if (auto effect = entity->getEffect(*MobEffect::mMobEffects()[effectId])) {
|
if (auto effect = entity->getEffect(*MobEffect::mMobEffects()[effectId])) {
|
||||||
return effect->mDurationEasy->transform([](auto&& duration) -> int { return duration.mValue; }).value_or(0);
|
return effect->mDurationEasy->transform([](auto&& duration) -> int { return duration.mValue; }).value_or(0);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "getEntityEffectDurationHard", [](Actor* entity, int effectId) -> int {
|
RemoteCall::exportAs("GMLIB_API", "getEntityEffectDurationHard", [](Actor* entity, int effectId) -> int {
|
||||||
if (effectId < 0 || !MobEffect::mMobEffects()[effectId]) return false;
|
if (effectId <= 0 || effectId > effectMaxCount || !MobEffect::mMobEffects()[effectId]) return false;
|
||||||
if (auto effect = entity->getEffect(*MobEffect::mMobEffects()[effectId])) {
|
if (auto effect = entity->getEffect(*MobEffect::mMobEffects()[effectId])) {
|
||||||
return effect->mDurationHard->transform([](auto&& duration) -> int { return duration.mValue; }).value_or(0);
|
return effect->mDurationHard->transform([](auto&& duration) -> int { return duration.mValue; }).value_or(0);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "getEntityEffectDurationNormal", [](Actor* entity, int effectId) -> int {
|
RemoteCall::exportAs("GMLIB_API", "getEntityEffectDurationNormal", [](Actor* entity, int effectId) -> int {
|
||||||
if (effectId < 0 || !MobEffect::mMobEffects()[effectId]) return false;
|
if (effectId <= 0 || effectId > effectMaxCount|| !MobEffect::mMobEffects()[effectId]) return false;
|
||||||
if (auto effect = entity->getEffect(*MobEffect::mMobEffects()[effectId])) {
|
if (auto effect = entity->getEffect(*MobEffect::mMobEffects()[effectId])) {
|
||||||
return effect->mDurationNormal->transform(
|
return effect->mDurationNormal->transform(
|
||||||
[](auto&& duration) -> int { return duration.mValue; }
|
[](auto&& duration) -> int { return duration.mValue; }
|
||||||
@@ -852,21 +878,23 @@ void Export_Compatibility_API() {
|
|||||||
return 0;
|
return 0;
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "getEntityEffectAmplifier", [](Actor* entity, int effectId) -> int {
|
RemoteCall::exportAs("GMLIB_API", "getEntityEffectAmplifier", [](Actor* entity, int effectId) -> int {
|
||||||
if (effectId < 0 || !MobEffect::mMobEffects()[effectId]) return false;
|
if (effectId <= 0 || effectId > effectMaxCount || !MobEffect::mMobEffects()[effectId]) return false;
|
||||||
if (auto effect = entity->getEffect(*MobEffect::mMobEffects()[effectId])) {
|
if (auto effect = entity->getEffect(*MobEffect::mMobEffects()[effectId])) {
|
||||||
return effect->mAmplifier;
|
return effect->mAmplifier;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "getEntityEffectAmbient", [](Actor* entity, int effectId) -> bool {
|
RemoteCall::exportAs("GMLIB_API", "getEntityEffectAmbient", [](Actor* entity, int effectId) -> bool {
|
||||||
if (effectId < 0 || !MobEffect::mMobEffects()[effectId]) return false;
|
if (effectId <= 0 || effectId > effectMaxCount || !MobEffect::mMobEffects()[effectId]) return false;
|
||||||
if (auto effect = entity->getEffect(*MobEffect::mMobEffects()[effectId])) {
|
if (auto effect = entity->getEffect(*MobEffect::mMobEffects()[effectId])) {
|
||||||
return effect->mAmbient;
|
return effect->mAmbient;
|
||||||
}
|
}
|
||||||
return 0;
|
return false;
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "entityHasEffect", [](Actor* entity, int effectId) -> bool {
|
RemoteCall::exportAs("GMLIB_API", "entityHasEffect", [](Actor* entity, int effectId) -> bool {
|
||||||
return effectId > 0x24 ? false : entity->hasEffect(*MobEffect::mMobEffects()[effectId]);
|
return effectId <= 0 || effectId > effectMaxCount || !MobEffect::mMobEffects()[effectId]
|
||||||
|
? false
|
||||||
|
: entity->hasEffect(*MobEffect::mMobEffects()[effectId]);
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "getGameDifficulty", []() -> int {
|
RemoteCall::exportAs("GMLIB_API", "getGameDifficulty", []() -> int {
|
||||||
return ll::service::getLevel().transform(
|
return ll::service::getLevel().transform(
|
||||||
@@ -892,20 +920,16 @@ void Export_Compatibility_API() {
|
|||||||
"GMLIB_API",
|
"GMLIB_API",
|
||||||
"registerCustomShapelessRecipe",
|
"registerCustomShapelessRecipe",
|
||||||
[](std::string const& recipe_id, std::vector<std::string> ingredients, ItemStack* result) -> void {
|
[](std::string const& recipe_id, std::vector<std::string> ingredients, ItemStack* result) -> void {
|
||||||
// if (!GMLevel::getInstance().has_value()) return;
|
if (!GMLevel::getInstance().has_value()) return;
|
||||||
// std::vector<Recipes::Type> types;
|
std::vector<ICustomRecipe::Ingredient> types;
|
||||||
// char rt = 'A';
|
for (auto& ing : ingredients) {
|
||||||
// for (auto& ing : ingredients) {
|
types.push_back(ICustomRecipe::Ingredient{ing});
|
||||||
// auto ingredient = RecipeIngredient{ing, 0,1};
|
}
|
||||||
// types.push_back(Recipes::Type{
|
CustomRecipeRegistry::getInstance().registerShapelessRecipe(
|
||||||
// (Item*)ingredient.getItem(),
|
recipe_id,
|
||||||
// ingredient.getBlock(),
|
types,
|
||||||
// ingredient,
|
ItemInstance(*result->getItem(), result->mCount, result->mAuxValue, result->mUserData.get())
|
||||||
// rt++
|
);
|
||||||
// });
|
|
||||||
// }
|
|
||||||
// GMLIB::Mod::CustomRecipe::registerShapelessCraftingTableRecipe(recipe_id, types, *result);
|
|
||||||
throw std::runtime_error("GMLIB_API::registerCustomShapelessRecipe is not implemented");
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
RemoteCall::exportAs(
|
RemoteCall::exportAs(
|
||||||
@@ -953,4 +977,7 @@ void Export_Compatibility_API() {
|
|||||||
RemoteCall::exportAs("GMLIB_API", "getEntityTypeId", [](Actor* entity) -> int {
|
RemoteCall::exportAs("GMLIB_API", "getEntityTypeId", [](Actor* entity) -> int {
|
||||||
return (int)entity->getEntityTypeId();
|
return (int)entity->getEntityTypeId();
|
||||||
});
|
});
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "getPlayerProtocolVersion", [](Player* player) -> int {
|
||||||
|
return ((GMPlayer*)player)->getNetworkProtocolVersion();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
+5
-2
@@ -9,11 +9,12 @@ LegacyRemoteCallApi& LegacyRemoteCallApi::getInstance() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool LegacyRemoteCallApi::load() {
|
bool LegacyRemoteCallApi::load() {
|
||||||
|
(void)CustomRecipeRegistry::getInstance();
|
||||||
Export_Legacy_GMLib_ModAPI();
|
Export_Legacy_GMLib_ModAPI();
|
||||||
Export_Legacy_GMLib_ServerAPI();
|
Export_Legacy_GMLib_ServerAPI();
|
||||||
Export_Compatibility_API();
|
Export_Compatibility_API();
|
||||||
ExportPAPI();
|
ExportPAPI();
|
||||||
// Export_Event_API();
|
Export_Event_API();
|
||||||
Export_BinaryStream_API();
|
Export_BinaryStream_API();
|
||||||
// Export_Form_API();
|
// Export_Form_API();
|
||||||
auto logger = ll::io::LoggerRegistry::getInstance().getOrCreate(PLUGIN_NAME);
|
auto logger = ll::io::LoggerRegistry::getInstance().getOrCreate(PLUGIN_NAME);
|
||||||
@@ -21,7 +22,7 @@ bool LegacyRemoteCallApi::load() {
|
|||||||
logger->info(
|
logger->info(
|
||||||
"Loaded Version: {} with {}",
|
"Loaded Version: {} with {}",
|
||||||
fmt::format(fg(fmt::color::pink), "GMLIB-" GMLIB_FILE_VERSION_STRING),
|
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("Author: GroupMountain");
|
||||||
logger->info("Repository: https://github.com/GroupMountain/GMLIB-LegacyRemoteCallApi");
|
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() {
|
ll::thread::ThreadPoolExecutor const& getThreadPoolExecutor() {
|
||||||
return gmlib::LegacyRemoteCallApi::getInstance().getThreadPoolExecutor();
|
return gmlib::LegacyRemoteCallApi::getInstance().getThreadPoolExecutor();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ll::io::Logger& getLogger() { return gmlib::LegacyRemoteCallApi::getInstance().getSelf().getLogger(); }
|
||||||
+129
-164
@@ -88,10 +88,7 @@ void Export_Event_API() {
|
|||||||
std::string const& uuid,
|
std::string const& uuid,
|
||||||
std::string const& serverXuid,
|
std::string const& serverXuid,
|
||||||
std::string const& clientXuid),
|
std::string const& clientXuid),
|
||||||
(event.realName(),
|
(event.realName(), event.uuid().asString(), event.serverAuthXuid(), event.clientAuthXuid()),
|
||||||
event.uuid().asString(),
|
|
||||||
event.serverAuthXuid(),
|
|
||||||
event.clientAuthXuid()),
|
|
||||||
if (result) event.disConnectClient();
|
if (result) event.disConnectClient();
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -116,12 +113,10 @@ void Export_Event_API() {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
case doHash("gmlib::MobPickupItemBeforeEvent"): {
|
case doHash("gmlib::MobPickupItemBeforeEvent"): {
|
||||||
REGISTER_EVENT_LISTEN(
|
REGISTER_EVENT_LISTEN(ila::mc::ActorPickupItemBeforeEvent,
|
||||||
ila::mc::ActorPickupItemBeforeEvent,
|
|
||||||
(Actor * mob, Actor * item, bool isCancelled),
|
(Actor * mob, Actor * item, bool isCancelled),
|
||||||
(&event.self(), (Actor*)&event.itemActor(), event.isCancelled()),
|
(&event.self(), (Actor*)&event.itemActor(), event.isCancelled()),
|
||||||
event.setCancelled(result);
|
event.setCancelled(result););
|
||||||
);
|
|
||||||
}
|
}
|
||||||
case doHash("gmlib::MobPickupItemAfterEvent"): {
|
case doHash("gmlib::MobPickupItemAfterEvent"): {
|
||||||
REGISTER_EVENT_LISTEN(
|
REGISTER_EVENT_LISTEN(
|
||||||
@@ -146,19 +141,17 @@ void Export_Event_API() {
|
|||||||
REGISTER_EVENT_LISTEN(
|
REGISTER_EVENT_LISTEN(
|
||||||
ila::mc::SpawnItemActorAfterEvent,
|
ila::mc::SpawnItemActorAfterEvent,
|
||||||
(Actor * item, std::pair<Vec3, int> position, int64 spawnerUniqueId),
|
(Actor * item, std::pair<Vec3, int> position, int64 spawnerUniqueId),
|
||||||
(event.itemActor(),
|
(&event.itemActor(),
|
||||||
{event.pos(), event.blockSource().getDimensionId().id},
|
{event.pos(), event.blockSource().getDimensionId().id},
|
||||||
event.spawner() ? event.spawner()->getOrCreateUniqueID().rawID : -1),
|
event.spawner() ? event.spawner()->getOrCreateUniqueID().rawID : -1),
|
||||||
,
|
,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
case doHash("gmlib::ActorChangeDimensionBeforeEvent"): {
|
case doHash("gmlib::ActorChangeDimensionBeforeEvent"): {
|
||||||
REGISTER_EVENT_LISTEN(
|
REGISTER_EVENT_LISTEN(ila::mc::ActorChangeDimensionBeforeEvent,
|
||||||
ila::mc::ActorChangeDimensionBeforeEvent,
|
|
||||||
(Actor * entity, int toDimId, bool isCancelled),
|
(Actor * entity, int toDimId, bool isCancelled),
|
||||||
(&event.self(), event.toDimensionId(), event.isCancelled()),
|
(&event.self(), event.toDimensionId(), event.isCancelled()),
|
||||||
event.setCancelled(result);
|
event.setCancelled(result););
|
||||||
);
|
|
||||||
}
|
}
|
||||||
case doHash("gmlib::ActorChangeDimensionAfterEvent"): {
|
case doHash("gmlib::ActorChangeDimensionAfterEvent"): {
|
||||||
REGISTER_EVENT_LISTEN(
|
REGISTER_EVENT_LISTEN(
|
||||||
@@ -168,38 +161,36 @@ void Export_Event_API() {
|
|||||||
,
|
,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
// case doHash("gmlib::PlayerStartSleepBeforeEvent"): {
|
case doHash("gmlib::PlayerStartSleepBeforeEvent"): {
|
||||||
// REGISTER_EVENT_LISTEN(
|
REGISTER_EVENT_LISTEN(ila::mc::PlayerStartSleepBeforeEvent,
|
||||||
// GMLIB::Event::PlayerEvent::PlayerStartSleepBeforeEvent,
|
(Player * entity, BlockPos pos, bool isCancelled),
|
||||||
// (Player * entity, BlockPos pos, bool isCancelled),
|
(&event.self(), event.pos(), event.isCancelled()),
|
||||||
// (&event.self(), event.getPosition(), event.isCancelled()),
|
event.setCancelled(result););
|
||||||
// event.setCancelled(result);
|
}
|
||||||
// );
|
case doHash("gmlib::PlayerStartSleepAfterEvent"): {
|
||||||
// }
|
REGISTER_EVENT_LISTEN(
|
||||||
// case doHash("gmlib::PlayerStartSleepAfterEvent"): {
|
ila::mc::PlayerStartSleepAfterEvent,
|
||||||
// REGISTER_EVENT_LISTEN(
|
(Player * entity, BlockPos pos, int result),
|
||||||
// GMLIB::Event::PlayerEvent::PlayerStartSleepAfterEvent,
|
(&event.self(), event.pos(), (int)event.result()),
|
||||||
// (Player * entity, BlockPos pos, int result),
|
,
|
||||||
// (&event.self(), event.getPosition(), (int)event.getResult()),
|
);
|
||||||
// ,
|
}
|
||||||
// );
|
case doHash("gmlib::PlayerStopSleepBeforeEvent"): {
|
||||||
// }
|
REGISTER_EVENT_LISTEN(
|
||||||
// case doHash("gmlib::PlayerStopSleepBeforeEvent"): {
|
ila::mc::PlayerStopSleepBeforeEvent,
|
||||||
// REGISTER_EVENT_LISTEN(
|
(Player * entity, bool forcefulWakeUp, bool updateLevelList, bool isCancelled),
|
||||||
// GMLIB::Event::PlayerEvent::PlayerStopSleepBeforeEvent,
|
(&event.self(), event.forcefulWakeUp(), event.updateLevelList(), false),
|
||||||
// (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(
|
||||||
// case doHash("gmlib::PlayerStopSleepAfterEvent"): {
|
ila::mc::PlayerStopSleepAfterEvent,
|
||||||
// REGISTER_EVENT_LISTEN(
|
(Player * entity, bool forcefulWakeUp, bool updateLevelList, bool),
|
||||||
// GMLIB::Event::PlayerEvent::PlayerStopSleepAfterEvent,
|
(&event.self(), event.forcefulWakeUp(), event.updateLevelList(), false),
|
||||||
// (Player * entity, bool forcefulWakeUp, bool updateLevelList, bool),
|
,
|
||||||
// (&event.self(), event.isForcefulWakeUp(), event.isUpdateLevelList(), false),
|
);
|
||||||
// ,
|
}
|
||||||
// );
|
|
||||||
// }
|
|
||||||
case doHash("gmlib::DeathMessageAfterEvent"): {
|
case doHash("gmlib::DeathMessageAfterEvent"): {
|
||||||
REGISTER_EVENT_LISTEN(
|
REGISTER_EVENT_LISTEN(
|
||||||
ila::mc::DeathMessageAfterEvent,
|
ila::mc::DeathMessageAfterEvent,
|
||||||
@@ -208,144 +199,118 @@ void Export_Event_API() {
|
|||||||
,
|
,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
// case doHash("gmlib::MobHurtAfterEvent"): {
|
case doHash("gmlib::MobHurtAfterEvent"): {
|
||||||
// REGISTER_EVENT_LISTEN(
|
|
||||||
// GMLIB::Event::EntityEvent::MobHurtAfterEvent,
|
|
||||||
// (Actor * mob, Actor * source, float damage, int cause),
|
|
||||||
// (&event.self(), source, -event.getDamage(), (int)damageSource.getCause()),
|
|
||||||
// ,
|
|
||||||
// auto& damageSource = event.getSource();
|
|
||||||
// Actor* source = nullptr;
|
|
||||||
// if (damageSource.isEntitySource()) {
|
|
||||||
// auto uniqueId = damageSource.getDamagingEntityUniqueID();
|
|
||||||
// source = ll::service::getLevel()->fetchEntity(uniqueId, false);
|
|
||||||
// if (source->getOwner()) source = source->getOwner();
|
|
||||||
// }
|
|
||||||
// );
|
|
||||||
// }
|
|
||||||
case doHash("gmlib::EndermanTakeBlockBeforeEvent"): {
|
|
||||||
REGISTER_EVENT_LISTEN(
|
REGISTER_EVENT_LISTEN(
|
||||||
ila::mc::EndermanTakeBlockBeforeEvent,
|
ila::mc::MobHealthChangeAfterEvent,
|
||||||
|
(Actor * mob, 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),
|
(Actor * mob, bool isCancelled),
|
||||||
(&event.self(), event.isCancelled()),
|
(&event.self(), event.isCancelled()),
|
||||||
event.setCancelled(result);
|
event.setCancelled(result););
|
||||||
);
|
|
||||||
}
|
}
|
||||||
case doHash("gmlib::DragonRespawnBeforeEvent"): {
|
case doHash("gmlib::DragonRespawnBeforeEvent"): {
|
||||||
REGISTER_EVENT_LISTEN(
|
REGISTER_EVENT_LISTEN(ila::mc::DragonRespawnBeforeEvent,
|
||||||
ila::mc::DragonRespawnBeforeEvent,
|
|
||||||
(bool isCancelled),
|
(bool isCancelled),
|
||||||
(event.isCancelled()),
|
(event.isCancelled()),
|
||||||
event.setCancelled(result);
|
event.setCancelled(result););
|
||||||
);
|
|
||||||
}
|
}
|
||||||
case doHash("gmlib::DragonRespawnAfterEvent"): {
|
case doHash("gmlib::DragonRespawnAfterEvent"): {
|
||||||
|
REGISTER_EVENT_LISTEN(ila::mc::DragonRespawnAfterEvent, (Actor * mob), (&event.self()), );
|
||||||
|
}
|
||||||
|
case doHash("gmlib::ProjectileCreateBeforeEvent"): {
|
||||||
|
REGISTER_EVENT_LISTEN(ila::mc::ProjectileCreateBeforeEvent,
|
||||||
|
(Actor * mob, int64 uniqueId, bool isCancelled),
|
||||||
|
(&event.self(), event.self().getOwnerId().rawID, event.isCancelled()),
|
||||||
|
event.setCancelled(result););
|
||||||
|
}
|
||||||
|
case doHash("gmlib::ProjectileCreateAfterEvent"): {
|
||||||
REGISTER_EVENT_LISTEN(
|
REGISTER_EVENT_LISTEN(
|
||||||
ila::mc::DragonRespawnAfterEvent,
|
ila::mc::ProjectileCreateAfterEvent,
|
||||||
(Actor * mob),
|
(Actor * mob, int64 uniqueId),
|
||||||
(&event.self()),
|
(&event.self(), event.self().getOwnerId().rawID),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
// case doHash("gmlib::ProjectileCreateBeforeEvent"): {
|
|
||||||
// REGISTER_EVENT_LISTEN(
|
|
||||||
// ila::mc::ProjectileCreateBeforeEvent,
|
|
||||||
// (Actor * mob, int64 uniqueId, bool isCancelled),
|
|
||||||
// (&event.self(),
|
|
||||||
// event.getShooter() ? event.getShooter()->getOrCreateUniqueID().rawID : -1,
|
|
||||||
// event.isCancelled()),
|
|
||||||
// event.setCancelled(result);
|
|
||||||
// );
|
|
||||||
// }
|
|
||||||
// case doHash("gmlib::ProjectileCreateAfterEvent"): {
|
|
||||||
// REGISTER_EVENT_LISTEN(
|
|
||||||
// GMLIB::Event::EntityEvent::ProjectileCreateAfterEvent,
|
|
||||||
// (Actor * mob, int64 uniqueId),
|
|
||||||
// (&event.self(), event.getShooter() ? event.getShooter()->getOrCreateUniqueID().rawID : -1),
|
|
||||||
// );
|
|
||||||
// }
|
|
||||||
case doHash("gmlib::SpawnWanderingTraderBeforeEvent"): {
|
case doHash("gmlib::SpawnWanderingTraderBeforeEvent"): {
|
||||||
REGISTER_EVENT_LISTEN(
|
REGISTER_EVENT_LISTEN(ila::mc::SpawnWanderingTraderBeforeEvent,
|
||||||
ila::mc::SpawnWanderingTraderBeforeEvent,
|
|
||||||
(std::pair<BlockPos, int> pos, bool isCancelled),
|
(std::pair<BlockPos, int> pos, bool isCancelled),
|
||||||
({event.pos(), event.blockSource().getDimensionId()}, event.isCancelled()),
|
({event.pos(), event.blockSource().getDimensionId()}, event.isCancelled()),
|
||||||
event.setCancelled(result);
|
event.setCancelled(result););
|
||||||
);
|
|
||||||
}
|
}
|
||||||
case doHash("gmlib::SpawnWanderingTraderAfterEvent"): {
|
case doHash("gmlib::HandleRequestActionBeforeEvent"): {
|
||||||
|
// clang-format off
|
||||||
REGISTER_EVENT_LISTEN(
|
REGISTER_EVENT_LISTEN(
|
||||||
ila::mc::SpawnWanderingTraderAfterEvent,
|
ila::mc::PlayerRequestItemActionBeforeEvent,
|
||||||
(std::pair<BlockPos, int> pos),
|
(
|
||||||
({event.pos(), event.blockSource().getDimensionId()}),
|
Player * player,
|
||||||
|
std::string const& actionType,
|
||||||
|
int count,
|
||||||
|
std::string const& sourceContainerNetId,
|
||||||
|
int sourceSlot,
|
||||||
|
std::string const& destinationContainerNetId,
|
||||||
|
int destinationSlot,
|
||||||
|
bool isCancelled
|
||||||
|
),
|
||||||
|
(
|
||||||
|
(Player*)&event.self(),
|
||||||
|
magic_enum::enum_name(event.actionType()).data(),
|
||||||
|
event.amount(),
|
||||||
|
magic_enum::enum_name(event.src().mFullContainerName.mName).data(),
|
||||||
|
(int)event.src().mSlot,
|
||||||
|
magic_enum::enum_name(event.dst().mFullContainerName.mName).data(),
|
||||||
|
(int)event.dst().mSlot,
|
||||||
|
event.isCancelled()
|
||||||
|
),
|
||||||
|
event.setCancelled(result);,
|
||||||
|
);
|
||||||
|
// clang-format on
|
||||||
|
}
|
||||||
|
case doHash("gmlib::HandleRequestActionAfterEvent"): {
|
||||||
|
// clang-format off
|
||||||
|
REGISTER_EVENT_LISTEN(
|
||||||
|
ila::mc::PlayerRequestItemActionAfterEvent,
|
||||||
|
(
|
||||||
|
Player * player,
|
||||||
|
std::string const& actionType,
|
||||||
|
int count,
|
||||||
|
std::string const& sourceContainerNetId,
|
||||||
|
int sourceSlot,
|
||||||
|
std::string const& destinationContainerNetId,
|
||||||
|
int destinationSlot
|
||||||
|
),
|
||||||
|
(
|
||||||
|
(Player*)&event.self(),
|
||||||
|
magic_enum::enum_name(event.actionType()).data(),
|
||||||
|
event.amount(),
|
||||||
|
magic_enum::enum_name(event.src().mFullContainerName.mName).data(),
|
||||||
|
(int)event.src().mSlot,
|
||||||
|
magic_enum::enum_name(event.dst().mFullContainerName.mName).data(),
|
||||||
|
(int)event.dst().mSlot
|
||||||
|
),
|
||||||
|
,
|
||||||
|
);
|
||||||
|
// clang-format on
|
||||||
|
}
|
||||||
|
case doHash("gmlib::ContainerClosePacketSendAfterEvent"): {
|
||||||
|
REGISTER_EVENT_LISTEN(
|
||||||
|
ila::mc::PlayerCloseContainerAfterEvent,
|
||||||
|
(Player * player, int containerId, bool serverInitiatedClose, bool),
|
||||||
|
(&event.self(), (int)event.containerId(), event.serverInitiatedClose(), false),
|
||||||
|
,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
// 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;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|||||||
+7
-2
@@ -1,10 +1,14 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
// clang-format off
|
// clang-format off
|
||||||
#define GMLIB_Gloabl_Using
|
#pragma warning(push)
|
||||||
|
#pragma warning(disable : 4996)
|
||||||
|
#define GMLIB_GLOBAL_USING
|
||||||
#include <gmlib/GlobalUsing.h>
|
#include <gmlib/GlobalUsing.h>
|
||||||
#include <gmlib/include_all.h>
|
#include <gmlib/include_all.h>
|
||||||
#include <ila/include_all.h>
|
#include <ila/include_all.h>
|
||||||
#include <RemoteCallAPI.h>
|
#include <RemoteCallAPI.h>
|
||||||
|
using namespace gmlib::mod;
|
||||||
|
#pragma warning(pop)
|
||||||
// clang-format on
|
// clang-format on
|
||||||
|
|
||||||
#define PLUGIN_NAME fmt::format(fg(fmt::color::light_green), "GMLIB-LRCA")
|
#define PLUGIN_NAME fmt::format(fg(fmt::color::light_green), "GMLIB-LRCA")
|
||||||
@@ -12,7 +16,7 @@
|
|||||||
#define LIB_VERSION_MAJOR 1
|
#define LIB_VERSION_MAJOR 1
|
||||||
#define LIB_VERSION_MINOR 0
|
#define LIB_VERSION_MINOR 0
|
||||||
#define LIB_VERSION_PATCH 0
|
#define LIB_VERSION_PATCH 0
|
||||||
#define LIB_VERSION_PRERELEASE "rc.1"
|
#define LIB_VERSION_PRERELEASE std::nullopt
|
||||||
|
|
||||||
#ifdef LIB_VERSION_PRERELEASE
|
#ifdef LIB_VERSION_PRERELEASE
|
||||||
#define LIB_VERSION ll::data::Version(LIB_VERSION_MAJOR, LIB_VERSION_MINOR, LIB_VERSION_PATCH, LIB_VERSION_PRERELEASE)
|
#define LIB_VERSION ll::data::Version(LIB_VERSION_MAJOR, LIB_VERSION_MINOR, LIB_VERSION_PATCH, LIB_VERSION_PRERELEASE)
|
||||||
@@ -27,4 +31,5 @@ extern void ExportPAPI();
|
|||||||
extern void Export_Event_API();
|
extern void Export_Event_API();
|
||||||
extern void Export_BinaryStream_API();
|
extern void Export_BinaryStream_API();
|
||||||
extern ll::thread::ThreadPoolExecutor const& getThreadPoolExecutor();
|
extern ll::thread::ThreadPoolExecutor const& getThreadPoolExecutor();
|
||||||
|
extern ll::io::Logger& getLogger();
|
||||||
// extern void Export_Form_API();
|
// extern void Export_Form_API();
|
||||||
+63
-77
@@ -1,12 +1,10 @@
|
|||||||
#include "Global.h"
|
#include "Global.h"
|
||||||
#include <gmlib/mc/world/Level.h>
|
|
||||||
#include <mc/world/item/crafting/RecipeIngredient.h>
|
|
||||||
|
|
||||||
std::unordered_set<std::string> HardCodedKeys = {"AlwaysUnlocked", "PlayerHasManyItems", "PlayerInWater", "None"};
|
ICustomRecipe::UnlockingRequirement makeRecipeUnlockingKey(std::string const& key) {
|
||||||
|
if (auto context = magic_enum::enum_cast<RecipeUnlockingContext>(key)) {
|
||||||
std::variant<std::string, std::vector<RecipeIngredient>> makeRecipeUnlockingKey(std::string const& key) {
|
return ICustomRecipe::UnlockingRequirement(*context);
|
||||||
if (HardCodedKeys.count(key)) return key;
|
}
|
||||||
return std::vector<RecipeIngredient>({RecipeIngredient(key, 0, 1)});
|
return ICustomRecipe::UnlockingRequirement({ICustomRecipe::Ingredient(key)});
|
||||||
}
|
}
|
||||||
|
|
||||||
void Export_Legacy_GMLib_ModAPI() {
|
void Export_Legacy_GMLib_ModAPI() {
|
||||||
@@ -19,18 +17,13 @@ void Export_Legacy_GMLib_ModAPI() {
|
|||||||
std::string const& result,
|
std::string const& result,
|
||||||
int count,
|
int count,
|
||||||
std::string const& unlock) -> void {
|
std::string const& unlock) -> void {
|
||||||
// if (!GMLIB_Level::getInstance().has_value()) return;
|
if (!GMLevel::getInstance().has_value()) return;
|
||||||
// std::vector<RecipeIngredient> types;
|
std::vector<ICustomRecipe::Ingredient> types;
|
||||||
// for (auto ing : ingredients) {
|
for (auto& ing : ingredients) {
|
||||||
// types.emplace_back(ing, 0, 1);
|
types.emplace_back(ICustomRecipe::Ingredient{ing, 1});
|
||||||
// }
|
}
|
||||||
// GMLIB::Mod::JsonRecipe::registerShapelessCraftingTableRecipe(
|
CustomRecipeRegistry::getInstance()
|
||||||
// recipe_id,
|
.registerShapelessRecipe(recipe_id, types, ItemInstance(result, count), makeRecipeUnlockingKey(unlock));
|
||||||
// types,
|
|
||||||
// RecipeIngredient(result, 0, count),
|
|
||||||
// makeRecipeUnlockingKey(unlock)
|
|
||||||
// );
|
|
||||||
throw std::runtime_error("GMLib_ModAPI::registerShapelessRecipe is not implemented");
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
RemoteCall::exportAs(
|
RemoteCall::exportAs(
|
||||||
@@ -42,19 +35,19 @@ void Export_Legacy_GMLib_ModAPI() {
|
|||||||
std::string const& result,
|
std::string const& result,
|
||||||
int count,
|
int count,
|
||||||
std::string const& unlock) -> void {
|
std::string const& unlock) -> void {
|
||||||
// if (!GMLIB_Level::getInstance().has_value()) return;
|
if (!GMLevel::getInstance().has_value()) return;
|
||||||
// std::vector<RecipeIngredient> types;
|
ICustomShapedRecipe::ShapedIngredients types;
|
||||||
// for (auto ing : ingredients) {
|
char index = 'A';
|
||||||
// types.push_back(RecipeIngredient(ing, 0, 1));
|
for (auto& ing : ingredients) {
|
||||||
// }
|
types.add(std::string(1, index++), ICustomRecipe::Ingredient{ing});
|
||||||
// GMLIB::Mod::JsonRecipe::registerShapedCraftingTableRecipe(
|
}
|
||||||
// recipe_id,
|
CustomRecipeRegistry::getInstance().registerShapedRecipe(
|
||||||
// shape,
|
recipe_id,
|
||||||
// types,
|
shape,
|
||||||
// RecipeIngredient(result, 0, count),
|
types,
|
||||||
// makeRecipeUnlockingKey(unlock)
|
ItemInstance(result, count),
|
||||||
// );
|
makeRecipeUnlockingKey(unlock)
|
||||||
throw std::runtime_error("GMLib_ModAPI::registerShapedRecipe is not implemented");
|
);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
RemoteCall::exportAs(
|
RemoteCall::exportAs(
|
||||||
@@ -64,14 +57,9 @@ void Export_Legacy_GMLib_ModAPI() {
|
|||||||
std::string const& input,
|
std::string const& input,
|
||||||
std::string const& output,
|
std::string const& output,
|
||||||
std::vector<std::string> tags) -> void {
|
std::vector<std::string> tags) -> void {
|
||||||
// if (!GMLIB_Level::getInstance().has_value()) return;
|
if (!GMLevel::getInstance().has_value()) return;
|
||||||
// GMLIB::Mod::JsonRecipe::registerFurnaceRecipe(
|
CustomRecipeRegistry::getInstance()
|
||||||
// recipe_id,
|
.registerFurnaceRecipe(ICustomRecipe::Ingredient{input}, ItemInstance{output}, tags);
|
||||||
// RecipeIngredient(input, 0, 1),
|
|
||||||
// RecipeIngredient(output, 0, 1),
|
|
||||||
// tags
|
|
||||||
// );
|
|
||||||
throw std::runtime_error("GMLib_ModAPI::registerFurnaceRecipe is not implemented");
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
RemoteCall::exportAs(
|
RemoteCall::exportAs(
|
||||||
@@ -79,10 +67,12 @@ void Export_Legacy_GMLib_ModAPI() {
|
|||||||
"registerBrewingMixRecipe",
|
"registerBrewingMixRecipe",
|
||||||
[](std::string const& recipe_id, std::string const& input, std::string const& output, std::string const& reagent
|
[](std::string const& recipe_id, std::string const& input, std::string const& output, std::string const& reagent
|
||||||
) -> void {
|
) -> void {
|
||||||
// if (!GMLIB_Level::getInstance().has_value()) return;
|
if (!GMLevel::getInstance().has_value()) return;
|
||||||
// GMLIB::Mod::JsonRecipe::registerBrewingMixRecipe(recipe_id, input, output, RecipeIngredient(reagent, 0,
|
CustomRecipeRegistry::getInstance().registerBrewingRecipe(
|
||||||
// 1));
|
ICustomRecipe::Ingredient{input},
|
||||||
throw std::runtime_error("GMLib_ModAPI::registerBrewingMixRecipe is not implemented");
|
ICustomRecipe::Ingredient{reagent},
|
||||||
|
ICustomRecipe::Ingredient{output}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
RemoteCall::exportAs(
|
RemoteCall::exportAs(
|
||||||
@@ -90,14 +80,12 @@ void Export_Legacy_GMLib_ModAPI() {
|
|||||||
"registerBrewingContainerRecipe",
|
"registerBrewingContainerRecipe",
|
||||||
[](std::string const& recipe_id, std::string const& input, std::string const& output, std::string const& reagent
|
[](std::string const& recipe_id, std::string const& input, std::string const& output, std::string const& reagent
|
||||||
) -> void {
|
) -> void {
|
||||||
// if (!GMLIB_Level::getInstance().has_value()) return;
|
if (!GMLevel::getInstance().has_value()) return;
|
||||||
// GMLIB::Mod::JsonRecipe::registerBrewingContainerRecipe(
|
CustomRecipeRegistry::getInstance().registerBrewingRecipe(
|
||||||
// recipe_id,
|
ICustomRecipe::Ingredient{input},
|
||||||
// RecipeIngredient(input, 0, 1),
|
ICustomRecipe::Ingredient{reagent},
|
||||||
// RecipeIngredient(output, 0, 1),
|
ICustomRecipe::Ingredient{output}
|
||||||
// RecipeIngredient(reagent, 0, 1)
|
);
|
||||||
// );
|
|
||||||
throw std::runtime_error("GMLib_ModAPI::registerBrewingContainerRecipe is not implemented");
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
RemoteCall::exportAs(
|
RemoteCall::exportAs(
|
||||||
@@ -108,15 +96,14 @@ void Export_Legacy_GMLib_ModAPI() {
|
|||||||
std::string const& base,
|
std::string const& base,
|
||||||
std::string const& addition,
|
std::string const& addition,
|
||||||
std::string const& result) -> void {
|
std::string const& result) -> void {
|
||||||
// if (!GMLIB_Level::getInstance().has_value()) return;
|
if (!GMLevel::getInstance().has_value()) return;
|
||||||
// GMLIB::Mod::JsonRecipe::registerSmithingTransformRecipe(
|
CustomRecipeRegistry::getInstance().registerSmithingTransformRecipe(
|
||||||
// recipe_id,
|
recipe_id,
|
||||||
// smithing_template,
|
ICustomRecipe::Ingredient{smithing_template},
|
||||||
// base,
|
ICustomRecipe::Ingredient{base},
|
||||||
// addition,
|
ICustomRecipe::Ingredient{addition},
|
||||||
// result
|
ItemInstance{result}
|
||||||
// );
|
);
|
||||||
throw std::runtime_error("GMLib_ModAPI::registerSmithingTransformRecipe is not implemented");
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
RemoteCall::exportAs(
|
RemoteCall::exportAs(
|
||||||
@@ -126,9 +113,13 @@ void Export_Legacy_GMLib_ModAPI() {
|
|||||||
std::string const& smithing_template,
|
std::string const& smithing_template,
|
||||||
std::string const& base,
|
std::string const& base,
|
||||||
std::string const& addition) -> void {
|
std::string const& addition) -> void {
|
||||||
// if (!GMLIB_Level::getInstance().has_value()) return;
|
if (!GMLevel::getInstance().has_value()) return;
|
||||||
// GMLIB::Mod::JsonRecipe::registerSmithingTrimRecipe(recipe_id, smithing_template, base, addition);
|
CustomRecipeRegistry::getInstance().registerSmithingTrimRecipe(
|
||||||
throw std::runtime_error("GMLib_ModAPI::registerSmithingTrimRecipe is not implemented");
|
recipe_id,
|
||||||
|
ICustomRecipe::Ingredient{smithing_template},
|
||||||
|
ICustomRecipe::Ingredient{base},
|
||||||
|
ICustomRecipe::Ingredient{addition}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
RemoteCall::exportAs(
|
RemoteCall::exportAs(
|
||||||
@@ -140,19 +131,17 @@ void Export_Legacy_GMLib_ModAPI() {
|
|||||||
std::string const& output,
|
std::string const& output,
|
||||||
int output_data,
|
int output_data,
|
||||||
int output_count) -> void {
|
int output_count) -> void {
|
||||||
// if (!GMLIB_Level::getInstance().has_value()) return;
|
if (!GMLevel::getInstance().has_value()) return;
|
||||||
// GMLIB::Mod::JsonRecipe::registerStoneCutterRecipe(
|
CustomRecipeRegistry::getInstance().registerStoneCutterRecipe(
|
||||||
// recipe_id,
|
recipe_id,
|
||||||
// RecipeIngredient(input, 0, 1),
|
ICustomRecipe::Ingredient{input, 1, input_data},
|
||||||
// RecipeIngredient(output, 0, 1)
|
{output, output_count, output_data}
|
||||||
// );
|
);
|
||||||
throw std::runtime_error("GMLib_ModAPI::registerStoneCutterRecipe is not implemented");
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
// 错误方块清理
|
// 错误方块清理
|
||||||
RemoteCall::exportAs("GMLib_ModAPI", "setUnknownBlockCleaner", []() -> void {
|
RemoteCall::exportAs("GMLib_ModAPI", "setUnknownBlockCleaner", []() -> void {
|
||||||
// GMLIB::Mod::VanillaFix::setAutoCleanUnknownBlockEnabled();
|
getLogger().error("setUnknownBlockCleaner is not implemented");
|
||||||
throw std::runtime_error("GMLib_ModAPI::setUnknownBlockCleaner is not implemented");
|
|
||||||
});
|
});
|
||||||
// 实验性
|
// 实验性
|
||||||
RemoteCall::exportAs("GMLib_ModAPI", "registerExperimentsRequire", [](int experiment_id) -> void {
|
RemoteCall::exportAs("GMLib_ModAPI", "registerExperimentsRequire", [](int experiment_id) -> void {
|
||||||
@@ -172,8 +161,5 @@ void Export_Legacy_GMLib_ModAPI() {
|
|||||||
.transform([&](GMLevel& level) { return level.getExperimentEnabled((AllExperiments)experiment_id); })
|
.transform([&](GMLevel& level) { return level.getExperimentEnabled((AllExperiments)experiment_id); })
|
||||||
.value_or(false);
|
.value_or(false);
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLib_ModAPI", "setFixI18nEnabled", []() -> void {
|
RemoteCall::exportAs("GMLib_ModAPI", "setFixI18nEnabled", []() -> void {});
|
||||||
// GMLIB::Mod::VanillaFix::setFixI18nEnabled();
|
|
||||||
throw std::runtime_error("GMLib_ModAPI::setFixI18nEnabled is not implemented");
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
+12
-13
@@ -2,24 +2,19 @@
|
|||||||
|
|
||||||
void Export_Legacy_GMLib_ServerAPI() {
|
void Export_Legacy_GMLib_ServerAPI() {
|
||||||
RemoteCall::exportAs("GMLib_ServerAPI", "setEducationFeatureEnabled", []() -> void {
|
RemoteCall::exportAs("GMLib_ServerAPI", "setEducationFeatureEnabled", []() -> void {
|
||||||
// GMLIB_Level::tryEnableEducationEdition();
|
getLogger().error("GMLib_ServerAPI::setEducationFeatureEnabled is not implemented");
|
||||||
throw std::runtime_error("GMLib_ServerAPI::setEducationFeatureEnabled is not implemented");
|
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLib_ServerAPI", "registerAbilityCommand", []() -> void {
|
RemoteCall::exportAs("GMLib_ServerAPI", "registerAbilityCommand", []() -> void {
|
||||||
// GMLIB_Level::tryRegisterAbilityCommand();
|
getLogger().error("GMLib_ServerAPI::registerAbilityCommand is not implemented");
|
||||||
throw std::runtime_error("GMLib_ServerAPI::registerAbilityCommand is not implemented");
|
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLib_ServerAPI", "setEnableAchievement", []() -> void {
|
RemoteCall::exportAs("GMLib_ServerAPI", "setEnableAchievement", []() -> void {
|
||||||
// GMLIB_Level::setForceAchievementsEnabled();
|
getLogger().error("GMLib_ServerAPI::setEnableAchievement is not implemented");
|
||||||
throw std::runtime_error("GMLib_ServerAPI::setEnableAchievement is not implemented");
|
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLib_ServerAPI", "setForceTrustSkins", []() -> void {
|
RemoteCall::exportAs("GMLib_ServerAPI", "setForceTrustSkins", []() -> void {
|
||||||
// GMLIB_Level::trustAllSkins();
|
getLogger().error("GMLib_ServerAPI::setForceTrustSkins is not implemented");
|
||||||
throw std::runtime_error("GMLib_ServerAPI::setForceTrustSkins is not implemented");
|
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLib_ServerAPI", "enableCoResourcePack", []() -> void {
|
RemoteCall::exportAs("GMLib_ServerAPI", "enableCoResourcePack", []() -> void {
|
||||||
// GMLIB_Level::requireServerResourcePackAndAllowClientResourcePack();
|
getLogger().error("GMLib_ServerAPI::enableCoResourcePack is not implemented");
|
||||||
throw std::runtime_error("GMLib_ServerAPI::enableCoResourcePack is not implemented");
|
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLib_ServerAPI", "getLevelName", []() -> std::string {
|
RemoteCall::exportAs("GMLib_ServerAPI", "getLevelName", []() -> std::string {
|
||||||
return GMLevel::getInstance().transform(
|
return GMLevel::getInstance().transform(
|
||||||
@@ -37,8 +32,7 @@ void Export_Legacy_GMLib_ServerAPI() {
|
|||||||
.value_or("");
|
.value_or("");
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLib_ServerAPI", "setFakeSeed", [](int64_t seed) -> void {
|
RemoteCall::exportAs("GMLib_ServerAPI", "setFakeSeed", [](int64_t seed) -> void {
|
||||||
// return GMLIB_Level::setFakeSeed(seed);
|
getLogger().error("GMLib_ServerAPI::setFakeSeed is not implemented");
|
||||||
throw std::runtime_error("GMLib_ServerAPI::setFakeSeed is not implemented");
|
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs(
|
RemoteCall::exportAs(
|
||||||
"GMLib_ServerAPI",
|
"GMLib_ServerAPI",
|
||||||
@@ -76,7 +70,7 @@ void Export_Legacy_GMLib_ServerAPI() {
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
RemoteCall::exportAs("GMLib_ServerAPI", "removeFakeList", [](const std::string& nameOrXuid) -> bool {
|
RemoteCall::exportAs("GMLib_ServerAPI", "removeFakeList", [](const std::string& nameOrXuid) -> bool {
|
||||||
PlayerListAPI::resetListName(nameOrXuid);
|
PlayerListAPI::erase(nameOrXuid);
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLib_ServerAPI", "removeAllFakeList", []() -> void { PlayerListAPI::clear(); });
|
RemoteCall::exportAs("GMLib_ServerAPI", "removeAllFakeList", []() -> void { PlayerListAPI::clear(); });
|
||||||
@@ -85,4 +79,9 @@ void Export_Legacy_GMLib_ServerAPI() {
|
|||||||
[](GMLevel& level) -> int { return level.getMaxPlayerCount(); }
|
[](GMLevel& level) -> int { return level.getMaxPlayerCount(); }
|
||||||
).value_or(0);
|
).value_or(0);
|
||||||
});
|
});
|
||||||
|
RemoteCall::exportAs("GMLib_ServerAPI", "setMaxPlayers", [&](int count, bool ignoreVanillaLimit) {
|
||||||
|
if (auto level = GMLevel::getInstance(); level) {
|
||||||
|
level->setMaxPlayerCount(count, ignoreVanillaLimit);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
+32
-12
@@ -23,10 +23,14 @@ void registerPlayerPlaceholder(
|
|||||||
[Call = RemoteCall::importAs<std::string(Player * pl, std::unordered_map<std::string, std::string>)>(
|
[Call = RemoteCall::importAs<std::string(Player * pl, std::unordered_map<std::string, std::string>)>(
|
||||||
PluginName,
|
PluginName,
|
||||||
FuncName
|
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> {
|
) -> std::optional<std::string> {
|
||||||
if (actor.has_value() && ((Actor*)actor.as_ptr())->isPlayer()) {
|
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;
|
return std::nullopt;
|
||||||
},
|
},
|
||||||
@@ -55,8 +59,13 @@ void registerServerPlaceholder(
|
|||||||
[Call = RemoteCall::importAs<std::string(std::unordered_map<std::string, std::string>)>(
|
[Call = RemoteCall::importAs<std::string(std::unordered_map<std::string, std::string>)>(
|
||||||
PluginName,
|
PluginName,
|
||||||
FuncName
|
FuncName
|
||||||
)](auto, std::unordered_map<std::string, std::string> const& params, auto&&...
|
)](auto, ll::StringMap<std::string> const& params, auto&&...) -> std::optional<std::string> {
|
||||||
) -> std::optional<std::string> { return Call(params); },
|
std::unordered_map<std::string, std::string> paramMap;
|
||||||
|
for (auto& [key, val] : params) {
|
||||||
|
paramMap[key] = val;
|
||||||
|
}
|
||||||
|
return Call(paramMap);
|
||||||
|
},
|
||||||
mod
|
mod
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
@@ -80,8 +89,8 @@ void registerStaticPlaceholder(
|
|||||||
if (mod.expired()) return;
|
if (mod.expired()) return;
|
||||||
PlaceholderAPI::registerPlaceholder(
|
PlaceholderAPI::registerPlaceholder(
|
||||||
PAPIName,
|
PAPIName,
|
||||||
[Call = RemoteCall::importAs<std::string()>(PluginName, FuncName)](auto&&...
|
[Call = RemoteCall::importAs<std::string()>(PluginName, FuncName)](auto&&...)
|
||||||
) -> std::optional<std::string> { return Call(); },
|
-> std::optional<std::string> { return Call(); },
|
||||||
mod
|
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)>(
|
std::string(Actor*, std::unordered_map<std::string, std::string>, std::string)>(
|
||||||
pluginName,
|
pluginName,
|
||||||
funcName
|
funcName
|
||||||
)](optional_ref<GMActor> actor,
|
)](optional_ref<Actor> actor, ll::StringMap<std::string> const& params, std::string const& language
|
||||||
std::unordered_map<std::string, std::string> const& params,
|
) -> std::optional<std::string> {
|
||||||
std::string const& language) -> std::optional<std::string> {
|
std::unordered_map<std::string, std::string> paramMap;
|
||||||
auto result = Call((Actor*)actor.as_ptr(), params, language);
|
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);
|
return result == "<std::nullopt>" ? std::nullopt : std::optional(result);
|
||||||
},
|
},
|
||||||
mod
|
mod
|
||||||
@@ -157,7 +169,11 @@ std::string getValue(
|
|||||||
std::unordered_map<std::string, std::string> params,
|
std::unordered_map<std::string, std::string> params,
|
||||||
std::string const& language
|
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 getValueFromActor(
|
||||||
std::string const& placeholder,
|
std::string const& placeholder,
|
||||||
@@ -165,7 +181,11 @@ std::string getValueFromActor(
|
|||||||
std::unordered_map<std::string, std::string> params,
|
std::unordered_map<std::string, std::string> params,
|
||||||
std::string const& language
|
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
|
} // namespace NewPapiRemoteCall
|
||||||
|
|
||||||
|
|||||||
+5
-4
@@ -2,7 +2,7 @@
|
|||||||
"format_version": 3,
|
"format_version": 3,
|
||||||
"format_uuid": "289f771f-2c9a-4d73-9f3f-8492495a924d",
|
"format_uuid": "289f771f-2c9a-4d73-9f3f-8492495a924d",
|
||||||
"tooth": "github.com/GroupMountain/GMLIB-LegacyRemoteCallApi",
|
"tooth": "github.com/GroupMountain/GMLIB-LegacyRemoteCallApi",
|
||||||
"version": "1.0.0-rc.1",
|
"version": "1.4.1",
|
||||||
"info": {
|
"info": {
|
||||||
"name": "GMLIB-LegacyRemoteCallApi",
|
"name": "GMLIB-LegacyRemoteCallApi",
|
||||||
"description": "Legacy RemoteCall API for GMLIB",
|
"description": "Legacy RemoteCall API for GMLIB",
|
||||||
@@ -19,14 +19,15 @@
|
|||||||
{
|
{
|
||||||
"platform": "win-x64",
|
"platform": "win-x64",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"github.com/LiteLDev/LeviLamina": ">=1.1.1",
|
"github.com/LiteLDev/LeviLamina": ">=1.3.0",
|
||||||
"github.com/GroupMountain/GMLIB-Release": ">=1.0.0-rc.3"
|
"github.com/GroupMountain/GMLIB-Release": ">=1.3.0-rc.1",
|
||||||
|
"github.com/MiracleForest/iListenAttentively-Release": ">=0.6.0"
|
||||||
},
|
},
|
||||||
"assets": [
|
"assets": [
|
||||||
{
|
{
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"urls": [
|
"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": [
|
"placements": [
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -8,16 +8,17 @@ if not has_config("vs_runtime") then
|
|||||||
set_runtimes("MD")
|
set_runtimes("MD")
|
||||||
end
|
end
|
||||||
|
|
||||||
add_requires("levilamina", {configs = {target_type = "server"}})
|
add_requires("levilamina 1.4.1", {configs = {target_type = "server"}})
|
||||||
add_requires("legacyremotecall")
|
add_requires("legacyremotecall")
|
||||||
add_requires("gmlib")
|
|
||||||
add_requires("levibuildscript")
|
add_requires("levibuildscript")
|
||||||
add_requires("ilistenattentively")
|
add_requires("ilistenattentively 0.7.0")
|
||||||
|
add_requires("gmlib 1.4.3")
|
||||||
|
|
||||||
target("GMLIB-LegacyRemoteCallApi")
|
target("GMLIB-LegacyRemoteCallApi")
|
||||||
add_cxflags(
|
add_cxflags(
|
||||||
"/EHa",
|
"/EHa",
|
||||||
"/utf-8"
|
"/utf-8",
|
||||||
|
"/bigobj"
|
||||||
)
|
)
|
||||||
add_defines(
|
add_defines(
|
||||||
"NOMINMAX",
|
"NOMINMAX",
|
||||||
@@ -33,22 +34,19 @@ target("GMLIB-LegacyRemoteCallApi")
|
|||||||
add_packages(
|
add_packages(
|
||||||
"levilamina",
|
"levilamina",
|
||||||
"legacyremotecall",
|
"legacyremotecall",
|
||||||
"gmlib",
|
"ilistenattentively",
|
||||||
"ilistenattentively"
|
"gmlib"
|
||||||
)
|
)
|
||||||
add_rules("@levibuildscript/linkrule")
|
add_rules("@levibuildscript/linkrule")
|
||||||
|
add_rules("@levibuildscript/modpacker")
|
||||||
set_exceptions("none")
|
set_exceptions("none")
|
||||||
set_kind("shared")
|
set_kind("shared")
|
||||||
set_languages("cxx20")
|
set_languages("cxx20")
|
||||||
set_symbols("debug")
|
set_symbols("debug")
|
||||||
|
|
||||||
after_build(function (target)
|
after_build(function (target)
|
||||||
local plugin_packer = import("scripts.after_build")
|
local target_path = path.join("bin", target:name(), "lib")
|
||||||
|
if os.exists(target_path) then
|
||||||
local plugin_define = {
|
os.rm(target_path)
|
||||||
pluginName = target:name(),
|
end
|
||||||
pluginFile = path.filename(target:targetfile()),
|
os.cp("lib", target_path)
|
||||||
}
|
|
||||||
|
|
||||||
plugin_packer.pack_plugin(target,plugin_define)
|
|
||||||
end)
|
end)
|
||||||
Reference in New Issue
Block a user