Hi Folks, I'm currently trying to build a function that will apply some NBT changes to items in a players inventory, on kill of certain entities, when using a certain tool.
I've been able to get the entity & damage source without any issues but I cannot work out how to get the player instance successfully.
This is what I have currently:
const addSoulsOnKill = (event) => {
const entity = event.getEntity().type
if ( entity === "player") return
const source = event.getSource().type
if (source !== "player") return
const player = event.getPlayer() ?? event.getSource().getPlayer()
// Error occurred while handling event 'EntityEvents.death': TypeError: dev.latvian.mods.rhino.Undefined@0 is not a function, it is undefined.
// have also tried event.getServer().getPlayer() but get a similar error
}
EntityEvents.death(event => {
addSoulsOnKill(event)
}