LiteLDev / LegacyScriptEngine

A plugin engine for running LLSE plugins on LeviLamina
GNU General Public License v3.0
49 stars 8 forks source link

[Bug]: onMobHurt无故报错 #181

Closed WuHuiZhang6902 closed 3 months ago

WuHuiZhang6902 commented 3 months 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 3 months ago

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

WuHuiZhang6902 commented 3 months ago

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

十分抱歉,是0.8.15