2024-06-24 2:13
- 添加jsdoc注释和d.ts补全文件 - 修改getBlockRuntimeId接口,使其支持填写特殊值 - 添加getBlockLightEmission,getGameRules,applyEnchant,removeEnchants,hasEnchant,getEnchantLevel,getEnchantNameAndLevel接口 - 导出事件onEntityChangeDimAfter,DragonRespawn,ProjectileTryCreate,ProjectileCreate
This commit is contained in:
@@ -1,17 +1,30 @@
|
||||
/** 事件创建函数 @type {function(string,string):boolean} */
|
||||
const CallEvent = ll.import("GMLIB_API", "callCustomEvent");
|
||||
|
||||
/** 事件ID @type {number} */
|
||||
let NextEventId = 0;
|
||||
|
||||
/**
|
||||
* 获取事件ID标识名
|
||||
* @returns {string} 事件ID标识名
|
||||
*/
|
||||
function getNextEventId() {
|
||||
NextEventId++;
|
||||
return "GMLIB_Event_" + NextEventId;
|
||||
}
|
||||
|
||||
/** 事件类 */
|
||||
class Event {
|
||||
constructor() {
|
||||
throw new Error("Static class cannot be instantiated");
|
||||
}
|
||||
|
||||
/**
|
||||
* 监听事件
|
||||
* @param {string} event 事件名称
|
||||
* @param {function} callback 回调
|
||||
* @returns {boolean} 是否创建成功
|
||||
*/
|
||||
static listen(event, callback) {
|
||||
let eventId = getNextEventId();
|
||||
ll.export(callback, event, eventId);
|
||||
|
||||
Reference in New Issue
Block a user