LiteLDev / LegacyScriptEngine

A plugin engine for running LLSE plugins on LeviLamina
https://lse.liteldev.com/
GNU General Public License v3.0
43 stars 8 forks source link

[Bug]: onMobHurt无故报错 #181

Closed WuHuiZhang6902 closed 4 weeks ago

WuHuiZhang6902 commented 4 weeks ago

Describe the bug

在生物受伤造成伤害对象为非实体情况下会报错,例如火焰灼烧,已经写了判断条件包括使用受伤原因进行屏蔽仍然报错 报错内容如下 17:42:15.671 ERROR [legacy-script-engine-quickjs] Event Callback Failed! 17:42:15.671 ERROR [legacy-script-engine-quickjs] Uncaught Exception Detected! 17:42:15.671 ERROR [legacy-script-engine-quickjs] In Event: onMobHurt 17:42:15.717 ERROR [legacy-script-engine-quickjs] Error occurred in Engine Message Loop!

To Reproduce

mc.listen("onMobHurt", (mob, source, damage, entityAttackType) => {
    if (entityAttackType === 0x02 && source?.isPlayer()) {
        const player = source.toPlayer();
        if (player) {
            if (damage > 5) {
                player.tell('检测到非法伤害值!');
                logger.warn(`玩家 ${player.realName} 检测到非法伤害值!伤害值: ${damage}`);
                // 进行拦截,返回 false
                return false;
            }
        }
    }
});

Expected behavior

修复问题

Screenshots

No response

Platform

Windows 10

BDS Version

1.21.3

LeviLamina Version

0.13.5

LegacyScriptEngine Version

0.8.18

Additional context

No response

ShrBox commented 4 weeks ago

无法复现,确认使用的是0.8.18吗

WuHuiZhang6902 commented 4 weeks ago

无法复现,确认使用的是0.8.18吗

十分抱歉,是0.8.15