#EntityEvent.hurt error

10 messages · Page 1 of 1 (latest)

fading monolith
#

I trying to make a event to apply slowness, poison to mob target or heal the player with entityHurt, but it's giving the erro "Unknown event 'EntityEvents.hurt' Someone can help?

tight islandBOT
#

Once your ticket has been resolved, please close it with </ticket close:1054771505520717835> command!

fading monolith
#
  const player = event.source.player

  if (!player) return

  const item = player.mainHandItem

  if (!item.hasTag('kubejs:fire_netherite_sword')) return

  if (event.source.isIndirect()) return

  player.heal(2)
})``` the code i'm trying to use and the error
sinful pike
#

In 1.21.1, EntityEvents.hurt does not exist\

#

Instead, there are two events firing at appropriate moments around the moment of being damaged:

  • EntityEvents.beforeHurt
  • EntityEvents.afterHurt
fading monolith
#

Ow thanks

fading monolith
#

Even using this nothing happens when i hit the target ```EntityEvents.afterHurt('minecraft:zombie', event => {
const source = event.source
const player = source.player

if (!player) return

const item = player.mainHandItem
const target = event.entity

// evita dano indireto
if (source.isIndirect()) return

if (item.hasTag('kubejs:ice_tools')) {
target.potionEffects.add('minecraft:slowness', 100, 2)
}

if (item.hasTag('kubejs:fairy_tools')) {
player.heal(1)
}

})```

random trail
#

try adding console.log() statements throughout your code to see where it fails

fading monolith
#

i found the error, is source.isIndirect

devout lintelBOT
#

Please close your ticket (with </ticket close:1054771505520717835> or the button atop this thread) once you resolved your issue!
This also helps others that would like to help out, as they don't have to look into this thread to check if it has been resolved by now.

Do you have any other questions regarding your issue? Feel free to ask!
Note: You should create a new post for unrelated issues.