#Issue with entityHurt.subscribe: Cannot read property 'subscribe' of undefined

1 messages · Page 1 of 1 (latest)

tame beacon
#

I encountered an error while trying to use the entityHurt before-event.
[Error Message] TypeError: Cannot read property 'subscribe' of undefined at <anonymous>

#
world.beforeEvents.entityHurt.subscribe((event) => {
    const attacker = event.damageSource.damagingEntity;
    const victim = event.hurtEntity;

    if (attacker instanceof Player && victim instanceof Player) {
        // Simple guild check logic
        const attackerGuild = attacker.getDynamicProperty("guild_name");
        const victimGuild = victim.getDynamicProperty("guild_name");

        if (attackerGuild && victimGuild && attackerGuild === victimGuild) {
            event.cancel = true;
        }
    }
});
woeful lake
tame beacon
woeful lake
#

Hence not available for 1.21.131

tame beacon