#how to fix this

1 messages · Page 1 of 1 (latest)

final zinc
#

it doesn't work

misty coral
#

If you want to detect specifically a entity hitting another entity, then its better to use entityHitEntity event

#

If you are still going to use entityHurt, then you can get the damaging entity with mob.damageSource.damagingEntity

final zinc
#

ok

misty coral
# final zinc

That will happen if a entity gets jurt by any reason except for another entity

#

You need to check first if damager is not undefined

misty coral
#
// @ts-nocheck
import { world, system, Vector } from "@minecraft/server";

world.afterEvents.entityHurt.subscribe((mob)=>{
  const damager = mob.damageSource.damagingEntity;
  if (!damager) return;
  const victim = mob.hurtEntity;

  if (damager.typeId === "sfnewmob:viking_miniboss") {
    const leapProperty = damager.getProperty('sf:jump');
    if (leapProperty === 3) {
      minibossLandDamage(damager,victim);
      console.warn("Leap3 Func");
    }
  } else if (damager.typeId === "sfnewmob:viking_minibossaxe") {
    minibossAxeDamage(damager,victim);
    console.warn("AxeDamage Func");
  }
});