#Issue with entityHurt.subscribe: Cannot read property 'subscribe' of undefined
1 messages · Page 1 of 1 (latest)
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;
}
}
});
Are you in preview with beta apis turned on?
Yes, I have the 'Beta APIs' toggle turned on in my world experiments, and I am using the Official Stable Version (1.21.131), not the Preview version.
It was introduced in Preview 26.0
Hence not available for 1.21.131
Got it, thanks for the info! Since I can't use beforeEvents yet, is there any other way to cancel or mitigate damage between players in 1.21.131
Edit player.json