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:
Vendored
+67
@@ -0,0 +1,67 @@
|
||||
declare class PAPI {
|
||||
/** 注册一个玩家PAPI变量 */
|
||||
static registerPlayerPlaceholder(
|
||||
/** PAPI调用函数 */
|
||||
func: (
|
||||
/** 玩家对象 */
|
||||
player: Player
|
||||
) => string,
|
||||
/** 插件名字 */
|
||||
pluginsName: string,
|
||||
/** PAPI变量 */
|
||||
PAPIName: string
|
||||
): boolean;
|
||||
|
||||
/** 注册一个服务器PAPI变量 */
|
||||
static registerServerPlaceholder(
|
||||
/** PAPI调用函数 */
|
||||
func: () => string,
|
||||
/** 插件名字 */
|
||||
pluginsName: string,
|
||||
/** PAPI变量 */
|
||||
PAPIName: string
|
||||
): boolean;
|
||||
|
||||
/** 注册一个静态PAPI变量 */
|
||||
static registerStaticPlaceholder(
|
||||
/** PAPI调用函数 */
|
||||
func: () => string,
|
||||
/** 插件名字 */
|
||||
pluginsName: string,
|
||||
/** PAPI变量 */
|
||||
PAPIName: string,
|
||||
/** 更新时间 */
|
||||
UpdateInterval: number
|
||||
): boolean;
|
||||
|
||||
/** 获取一个服务器变量的值 */
|
||||
static getValue(
|
||||
/** PAPI名 */
|
||||
key: string
|
||||
): string;
|
||||
|
||||
/** 获取一个玩家变量的值 */
|
||||
static getValueByPlayer(
|
||||
/** PAPI名 */
|
||||
key: string,
|
||||
/** 玩家对象 */
|
||||
pl: Player
|
||||
): string;
|
||||
|
||||
/** 翻译带PAPI变量的字符串 */
|
||||
static translateString(
|
||||
/** 要翻译的字符串 */
|
||||
str: string,
|
||||
/** 玩家对象 */
|
||||
pl: Player | undefined
|
||||
): string;
|
||||
|
||||
/** 注销一个PAPI变量 */
|
||||
static unRegisterPlaceholder(
|
||||
/** PAPI名 */
|
||||
str: string
|
||||
): boolean;
|
||||
|
||||
/** 获取所有已注册的PAPI变量 */
|
||||
static getAllPAPI(): string[];
|
||||
}
|
||||
@@ -1,47 +1,101 @@
|
||||
const PlaceholderAPI = {
|
||||
/** 获取一个服务器变量的值 @type {function(string):string} */
|
||||
getValueAPI: ll.import("BEPlaceholderAPI", "GetValue"),
|
||||
/** 获取一个玩家变量的值 @type {function(string,Player):string} */
|
||||
getValueByPlayerAPI: ll.import("BEPlaceholderAPI", "GetValueWithPlayer"),
|
||||
/** 注册一个玩家变量 @type {function(string,string,string):boolean} */
|
||||
registerPlayerPlaceholderAPI: ll.import("BEPlaceholderAPI", "registerPlayerPlaceholder"),
|
||||
/** 注册一个服务器变量 @type {function(string,string,string):boolean} */
|
||||
registerServerPlaceholderAPI: ll.import("BEPlaceholderAPI", "registerServerPlaceholder"),
|
||||
/** 注册一个静态变量 @type {function(string,string,string,number):boolean} */
|
||||
registerStaticPlaceholderAPI: ll.import("BEPlaceholderAPI", "registerStaticPlaceholder"),
|
||||
/** 翻译包含PAPI服务器变量的字符串 @type {function(string):string} */
|
||||
translateStringAPI: ll.import("BEPlaceholderAPI", "translateString"),
|
||||
/** 翻译包含PAPI玩家变量的字符串 @type {function(string,Player):string} */
|
||||
translateStringWithPlayerAPI: ll.import("BEPlaceholderAPI", "translateStringWithPlayer"),
|
||||
/** 注销PAPI变量 @type {function(string):boolean} */
|
||||
unRegisterPlaceholderAPI: ll.import("BEPlaceholderAPI", "unRegisterPlaceholder"),
|
||||
/** 获取所有已注册的PAPI变量 @type {function():Array.<string>} */
|
||||
getAllPAPI: ll.import("BEPlaceholderAPI", "getAllPAPI")
|
||||
}
|
||||
|
||||
Function.prototype.getName = function () {
|
||||
return this.name || this.toString().match(/function\s*([^(]*)\(/)[1]
|
||||
Function.prototype.getName =
|
||||
/**
|
||||
* 获取函数名字
|
||||
* @returns {string}
|
||||
*/
|
||||
function () {
|
||||
return this.name || this.toString().match(/function\s*([^(]*)\(/)[1] || Math.ceil(Math.random() * 1000000).toString(16);
|
||||
}
|
||||
|
||||
/** PAPI变量类 */
|
||||
class PAPI {
|
||||
constructor() {
|
||||
throw new Error("Static class cannot be instantiated");
|
||||
}
|
||||
|
||||
/**
|
||||
* 注册一个玩家PAPI变量
|
||||
* @param {function} func 变量调用的函数
|
||||
* @param {string} PluginName 插件名字
|
||||
* @param {string} PAPIName PAPI变量名
|
||||
* @returns {boolean} 是否注册成功
|
||||
*/
|
||||
static registerPlayerPlaceholder(func, PluginName, PAPIName) {
|
||||
ll.export(func, PluginName, func.getName());
|
||||
return PlaceholderAPI.registerPlayerPlaceholderAPI(PluginName, func.getName(), PAPIName);
|
||||
}
|
||||
|
||||
/**
|
||||
* 注册一个服务器PAPI变量
|
||||
* @param {function} func 变量调用的函数
|
||||
* @param {string} PluginName 插件名字
|
||||
* @param {string} PAPIName PAPI变量名
|
||||
* @returns {boolean} 是否注册成功
|
||||
*/
|
||||
static registerServerPlaceholder(func, PluginName, PAPIName) {
|
||||
ll.export(func, PluginName, func.getName());
|
||||
return PlaceholderAPI.registerServerPlaceholderAPI(PluginName, func.getName(), PAPIName);
|
||||
}
|
||||
|
||||
/**
|
||||
* 注册一个静态PAPI变量
|
||||
* @param {function} func 变量调用的函数
|
||||
* @param {string} PluginName 插件名字
|
||||
* @param {string} PAPIName PAPI变量名
|
||||
* @param {number} [UpdateInterval=50] 更新间隔
|
||||
* @returns {boolean} 是否注册成功
|
||||
*/
|
||||
static registerStaticPlaceholder(func, PluginName, PAPIName, UpdateInterval = 50) {
|
||||
ll.export(func, PluginName, func.getName());
|
||||
return PlaceholderAPI.registerStaticPlaceholderAPI(PluginName, func.getName(), PAPIName, UpdateInterval);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取一个服务器变量的值
|
||||
* @param {string} key PAPI变量名
|
||||
* @returns {string} 值
|
||||
*/
|
||||
static getValue(key) {
|
||||
return PlaceholderAPI.getValueAPI(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取一个玩家变量的值
|
||||
* @param {string} key PAPI变量名
|
||||
* @param {Player} pl 玩家对象
|
||||
* @returns {string} 值
|
||||
*/
|
||||
static getValueByPlayer(key, pl) {
|
||||
return PlaceholderAPI.getValueByPlayerAPI(key, pl);
|
||||
}
|
||||
|
||||
/**
|
||||
* 翻译带PAPI变量的字符串
|
||||
* @param {string} str 字符串
|
||||
* @param {Player} pl 玩家对象
|
||||
* @returns {string} 翻译结果
|
||||
*/
|
||||
static translateString(str, pl = null) {
|
||||
if (pl) {
|
||||
return PlaceholderAPI.translateStringWithPlayerAPI(str, pl);
|
||||
@@ -49,10 +103,19 @@ class PAPI {
|
||||
return PlaceholderAPI.translateStringAPI(str);
|
||||
}
|
||||
|
||||
/**
|
||||
* 注销一个PAPI变量
|
||||
* @param {string} str PAPI变量名
|
||||
* @returns {boolean} 是否注销成功
|
||||
*/
|
||||
static unRegisterPlaceholder(str) {
|
||||
return PlaceholderAPI.unRegisterPlaceholderAPI(str);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取所有已注册的PAPI变量
|
||||
* @returns {Array.<string>} 已注册的PAPI变量数组
|
||||
*/
|
||||
static getAllPAPI() {
|
||||
return PlaceholderAPI.getAllPAPI();
|
||||
}
|
||||
|
||||
Vendored
+194
@@ -0,0 +1,194 @@
|
||||
/// <reference path="d:\dts/dts/helperlib/src/index.d.ts"/>
|
||||
|
||||
/** 事件监听接口 */
|
||||
declare class Event2 {
|
||||
/** 生物捡起物品 */
|
||||
static listen(
|
||||
/** 事件名 */
|
||||
event: "onMobDie",
|
||||
/** 监听函数 */
|
||||
listener: (
|
||||
/** 尝试捡起物品的实体对象 */
|
||||
entity: Entity,
|
||||
/** 掉落物实体对象 */
|
||||
itemEntity: Entity
|
||||
) => boolean | void
|
||||
): boolean;
|
||||
|
||||
/** 客户端登录后事件(不可以拦截) */
|
||||
static listen(
|
||||
/** 事件名 */
|
||||
event: "onClientLogin",
|
||||
/** 监听函数 */
|
||||
listener: (
|
||||
/** 玩家的游戏名字 */
|
||||
realName: string,
|
||||
/** 玩家的uuid */
|
||||
uuid: string,
|
||||
/** 玩家在服务端的xuid */
|
||||
serverXuid: string,
|
||||
/** 玩家在客户端的xuid */
|
||||
clientXuid: string
|
||||
) => void
|
||||
): boolean;
|
||||
|
||||
/** 天气改变事件事件 */
|
||||
static listen(
|
||||
/** 事件名 */
|
||||
event: "onWeatherChange",
|
||||
/** 监听函数 */
|
||||
listener: (
|
||||
/** 雷暴天气等级 */
|
||||
lightningLevel: number,
|
||||
/** 雨天天气等级 */
|
||||
rainLevel: number,
|
||||
/** 雷暴持续时间(刻) */
|
||||
lightningLastTick: number,
|
||||
/** 雨天持续时间(刻) */
|
||||
rainingLastTick: number
|
||||
) => boolean | void
|
||||
): boolean;
|
||||
|
||||
/** 掉落物尝试生成 */
|
||||
static listen(
|
||||
event: "onItemTrySpawn",
|
||||
listener: (
|
||||
/** 物品对象 */
|
||||
item: Item,
|
||||
/** 尝试生成的坐标对象 */
|
||||
pos: FloatPos,
|
||||
/** 创建掉落物的实体对象 */
|
||||
spawnerEntity: Entity
|
||||
) => boolean | void
|
||||
): boolean;
|
||||
|
||||
/** 掉落物生成完毕(不可以拦截) */
|
||||
static listen(
|
||||
/** 事件名 */
|
||||
event: "onItemTrySpawn",
|
||||
/** 回调函数 */
|
||||
listener: (
|
||||
/** 物品对象 */
|
||||
item: Item,
|
||||
/** 掉落物实体对象 */
|
||||
entity: Entity,
|
||||
/** 实体生成的坐标 */
|
||||
pos: FloatPos,
|
||||
/** 创建掉落物的实体对象 */
|
||||
spawnerEntity: Entity
|
||||
) => void
|
||||
): boolean;
|
||||
|
||||
/** 实体切换维度 */
|
||||
static listen(
|
||||
/** 事件名 */
|
||||
event: "onEntityChangeDim",
|
||||
/** 回调函数 */
|
||||
listener: (
|
||||
/** 切换维度的实体对象 */
|
||||
entity: Entity,
|
||||
/** 前往到的维度ID */
|
||||
dimid: number
|
||||
) => boolean | void
|
||||
): boolean;
|
||||
|
||||
/** 实体切换维度后(不可拦截) */
|
||||
static listen(
|
||||
/** 事件名 */
|
||||
event: "onEntityChangeDimAfter",
|
||||
/** 回调函数 */
|
||||
listener: (
|
||||
/** 切换维度的实体对象 */
|
||||
entity: Entity,
|
||||
/** 前往到的维度ID */
|
||||
fromDimid: number
|
||||
) => void
|
||||
): boolean;
|
||||
|
||||
/** 玩家下床 */
|
||||
static listen(
|
||||
/** 事件名 */
|
||||
event: "onLeaveBed",
|
||||
/** 回调函数 */
|
||||
listener: (
|
||||
/** 下床的玩家对象 */
|
||||
player: Player
|
||||
) => boolean | void
|
||||
): boolean;
|
||||
|
||||
/** 触发死亡信息(不可以拦截) */
|
||||
static listen(
|
||||
/** 事件名 */
|
||||
event: "onDeathMessage",
|
||||
/** 回调函数 */
|
||||
listener: (
|
||||
/** 死亡信息键名 */
|
||||
deathMsgKey: string,
|
||||
/** 死亡信息翻译参数 */
|
||||
deathMsgParams: Array.<string>,
|
||||
/** 死亡实体的实体对象 */
|
||||
entity: Entity
|
||||
) => void
|
||||
): boolean;
|
||||
|
||||
/** 实体受伤后事件 */
|
||||
static listen(
|
||||
/** 事件名 */
|
||||
event: "onMobHurted",
|
||||
/** 回调函数 */
|
||||
listener: (
|
||||
/** 受伤的实体对象 */
|
||||
entity: Entity,
|
||||
/** 造成伤害的实体对象 */
|
||||
source: Entity,
|
||||
/** 伤害值 */
|
||||
damage: number,
|
||||
/** 伤害类型 */
|
||||
cause: number
|
||||
) => void
|
||||
): boolean;
|
||||
|
||||
/** 末影人搬起方块 */
|
||||
static listen(
|
||||
/** 事件名 */
|
||||
event: "onEndermanTake",
|
||||
/** 回调函数 */
|
||||
listener: (
|
||||
/** 末影人实体对象 */
|
||||
entity: Entity
|
||||
) => boolean | void
|
||||
): boolean;
|
||||
|
||||
/** 末影龙重生事件 */
|
||||
static listen(
|
||||
/** 事件名 */
|
||||
event: "DragonRespawn",
|
||||
/** 回调函数 */
|
||||
listener: (
|
||||
/** 末影龙重生后的UniqueID */
|
||||
uniqueID: number
|
||||
) => boolean | void
|
||||
): boolean;
|
||||
|
||||
/** 弹射物实体尝试创建 */
|
||||
static listen(
|
||||
/** 事件名 */
|
||||
event: "ProjectileTryCreate",
|
||||
/** 回调函数 */
|
||||
listener: (
|
||||
/** 弹射物实体对象 */
|
||||
entity: Entity
|
||||
) => boolean | void
|
||||
): boolean;
|
||||
|
||||
/** 弹射物实体成功后(不可拦截) */
|
||||
static listen(
|
||||
/** 事件名 */
|
||||
event: "ProjectileCreate",
|
||||
/** 回调函数 */
|
||||
listener: (
|
||||
/** 弹射物实体对象 */
|
||||
entity: Entity
|
||||
) => void
|
||||
): boolean;
|
||||
}
|
||||
@@ -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);
|
||||
|
||||
Vendored
+1140
File diff suppressed because it is too large
Load Diff
+1190
-55
File diff suppressed because it is too large
Load Diff
@@ -599,8 +599,8 @@ void Export_Compatibility_API() {
|
||||
return result;
|
||||
}
|
||||
);
|
||||
RemoteCall::exportAs("GMLIB_API", "getBlockRuntimeId", [](std::string const& blockName) -> uint {
|
||||
if (auto block = Block::tryGetFromRegistry(blockName)) {
|
||||
RemoteCall::exportAs("GMLIB_API", "getBlockRuntimeId", [](std::string const& blockName, short legacyData) -> uint {
|
||||
if (auto block = Block::tryGetFromRegistry(blockName, legacyData)) {
|
||||
return block->getRuntimeId();
|
||||
}
|
||||
return 0;
|
||||
@@ -648,7 +648,10 @@ void Export_Compatibility_API() {
|
||||
return item->canDestroy(block);
|
||||
});
|
||||
RemoteCall::exportAs("GMLIB_API", "itemCanDestroyInCreative", [](ItemStack const* item) -> bool {
|
||||
return item->getItem()->canDestroyInCreative();
|
||||
if (auto itemDef = item->getItem()) {
|
||||
return itemDef->canDestroyInCreative();
|
||||
}
|
||||
return false;
|
||||
});
|
||||
RemoteCall::exportAs("GMLIB_API", "itemCanDestroySpecial", [](ItemStack const* item, Block const* block) -> bool {
|
||||
return item->canDestroySpecial(*block);
|
||||
@@ -678,4 +681,66 @@ void Export_Compatibility_API() {
|
||||
}
|
||||
return "tile.unknown.name";
|
||||
});
|
||||
RemoteCall::exportAs(
|
||||
"GMLIB_API",
|
||||
"getBlockLightEmission",
|
||||
[](std::string const& blockName, short legacyData) -> char {
|
||||
if (auto block = Block::tryGetFromRegistry(blockName, legacyData)) {
|
||||
return (char)block->getLightEmission().value;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
);
|
||||
RemoteCall::exportAs(
|
||||
"GMLIB_API",
|
||||
"getGameRules",
|
||||
[]() -> std::vector<std::unordered_map<std::string, std::string>> {
|
||||
auto gameRules = ll::service::getLevel()->getGameRules().getRules();
|
||||
std::vector<std::unordered_map<std::string, std::string>> result;
|
||||
for (auto& gameRule : gameRules) {
|
||||
std::unordered_map<std::string, std::string> data;
|
||||
data["Name"] = gameRule.getName();
|
||||
switch (gameRule.getType()) {
|
||||
case GameRule::Type::Bool:
|
||||
data["Type"] = "Bool";
|
||||
data["Value"] = std::to_string(gameRule.getBool());
|
||||
break;
|
||||
case GameRule::Type::Float:
|
||||
data["Type"] = "Float";
|
||||
data["Value"] = std::to_string(gameRule.getFloat());
|
||||
break;
|
||||
case GameRule::Type::Int:
|
||||
data["Type"] = "Int";
|
||||
data["Value"] = std::to_string(gameRule.getInt());
|
||||
break;
|
||||
case GameRule::Type::Invalid:
|
||||
break;
|
||||
}
|
||||
result.push_back(data);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
);
|
||||
RemoteCall::exportAs("GMLIB_API", "getLegalEnchants", [](ItemStack const* item) -> std::vector<int> {
|
||||
return EnchantUtils::getLegalEnchants(item->getItem());
|
||||
});
|
||||
RemoteCall::exportAs(
|
||||
"GMLIB_API",
|
||||
"applyEnchant",
|
||||
[](ItemStack const* item, int id, int level, bool allowNonVanilla) -> bool {
|
||||
return EnchantUtils::applyEnchant((ItemStackBase&)*item, (Enchant::Type)id, level, allowNonVanilla);
|
||||
}
|
||||
);
|
||||
RemoteCall::exportAs("GMLIB_API", "removeEnchants", [](ItemStack const* item) -> void {
|
||||
EnchantUtils::removeEnchants((ItemStack&)*item);
|
||||
});
|
||||
RemoteCall::exportAs("GMLIB_API", "hasEnchant", [](ItemStack const* item, int id) -> bool {
|
||||
return EnchantUtils::hasEnchant((Enchant::Type)id, (ItemStackBase&)*item);
|
||||
});
|
||||
RemoteCall::exportAs("GMLIB_API", "getEnchantLevel", [](ItemStack const* item, int id) -> int {
|
||||
return EnchantUtils::getEnchantLevel((Enchant::Type)id, (ItemStackBase&)*item);
|
||||
});
|
||||
RemoteCall::exportAs("GMLIB_API", "getEnchantNameAndLevel", [](int id, int level) -> std::string {
|
||||
return EnchantUtils::getEnchantNameAndLevel((Enchant::Type)id, level);
|
||||
});
|
||||
}
|
||||
+59
-5
@@ -7,7 +7,7 @@ void Export_Event_API() {
|
||||
"GMLIB_API",
|
||||
"callCustomEvent",
|
||||
[eventBus](std::string const& eventName, std::string const& eventId) -> bool {
|
||||
if (RemoteCall::hasFunc(eventName, eventId)) {
|
||||
if (!RemoteCall::hasFunc(eventName, eventId)) return false;
|
||||
switch (doHash(eventName)) {
|
||||
case doHash("onClientLogin"): {
|
||||
auto Call = RemoteCall::importAs<bool(
|
||||
@@ -70,8 +70,11 @@ void Export_Event_API() {
|
||||
return true;
|
||||
}
|
||||
case doHash("onItemTrySpawn"): {
|
||||
auto Call = RemoteCall::importAs<
|
||||
bool(const ItemStack* item, std::pair<Vec3, int> position, Actor* spawner)>(eventName, eventId);
|
||||
auto Call =
|
||||
RemoteCall::importAs<bool(const ItemStack* item, std::pair<Vec3, int> position, Actor* spawner)>(
|
||||
eventName,
|
||||
eventId
|
||||
);
|
||||
eventBus->emplaceListener<Event::EntityEvent::ItemActorSpawnBeforeEvent>(
|
||||
[Call](Event::EntityEvent::ItemActorSpawnBeforeEvent& ev) {
|
||||
auto pos = ev.getPosition();
|
||||
@@ -191,11 +194,62 @@ void Export_Event_API() {
|
||||
);
|
||||
return true;
|
||||
}
|
||||
case doHash("onEntityChangeDimAfter"): {
|
||||
auto Call = RemoteCall::importAs<bool(Actor * mob, int fromDimId)>(eventName, eventId);
|
||||
eventBus->emplaceListener<Event::EntityEvent::ActorChangeDimensionAfterEvent>(
|
||||
[Call](Event::EntityEvent::ActorChangeDimensionAfterEvent& ev) {
|
||||
bool result = true;
|
||||
try {
|
||||
result = Call(&ev.self(), ev.getFromDimensionId());
|
||||
} catch (...) {}
|
||||
}
|
||||
);
|
||||
return true;
|
||||
}
|
||||
case doHash("DragonRespawn"): {
|
||||
auto Call = RemoteCall::importAs<bool(int64 enderDragonUniqueID)>(eventName, eventId);
|
||||
eventBus->emplaceListener<Event::EntityEvent::DragonRespawnBeforeEvent>(
|
||||
[Call](Event::EntityEvent::DragonRespawnBeforeEvent& ev) {
|
||||
bool result = true;
|
||||
try {
|
||||
result = Call(ev.getEnderDragon().id);
|
||||
} catch (...) {}
|
||||
if (!result) {
|
||||
ev.cancel();
|
||||
}
|
||||
}
|
||||
);
|
||||
return true;
|
||||
}
|
||||
case doHash("ProjectileTryCreate"): {
|
||||
auto Call = RemoteCall::importAs<bool(Actor * mob)>(eventName, eventId);
|
||||
eventBus->emplaceListener<Event::EntityEvent::ProjectileCreateBeforeEvent>(
|
||||
[Call](Event::EntityEvent::ProjectileCreateBeforeEvent& ev) {
|
||||
bool result = true;
|
||||
try {
|
||||
result = Call(&ev.self());
|
||||
} catch (...) {}
|
||||
if (!result) {
|
||||
ev.cancel();
|
||||
}
|
||||
}
|
||||
);
|
||||
return true;
|
||||
}
|
||||
case doHash("ProjectileCreate"): {
|
||||
auto Call = RemoteCall::importAs<bool(Actor * mob)>(eventName, eventId);
|
||||
eventBus->emplaceListener<Event::EntityEvent::ProjectileCreateAfterEvent>(
|
||||
[Call](Event::EntityEvent::ProjectileCreateAfterEvent& ev) {
|
||||
try {
|
||||
Call(&ev.self());
|
||||
} catch (...) {}
|
||||
}
|
||||
);
|
||||
return true;
|
||||
}
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user