#EntityEvent.hurt error
10 messages · Page 1 of 1 (latest)
Once your ticket has been resolved, please close it with </ticket close:1054771505520717835> command!
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
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.beforeHurtEntityEvents.afterHurt
Ow thanks
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)
}
})```
try adding console.log() statements throughout your code to see where it fails
i found the error, is source.isIndirect
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.