core
core copied to clipboard
Error on EntityDamageByEntityEvent
I was trying to build an event handler for the EntityDamageByEntityEvent and ran into this error in the PaperMC console:
[09:56:54 ERROR]: [my-plugin] [STDERR] My CustomRealms Plugin:3: object is not an instance of declaring class
Here's my code:
ServerEvents.register(EntityDamageByEntityEvent, event => {
const damager = event.getDamager();
if (!damager) return;
if (damager.getType() !== EntityType.PLAYER) return;
event.getEntity().setVelocity(new Vector(0, 100, 0));
});
This error message comes from Java when a function is called with reflection, with parameters that don't match the function declaration. We need to figure out which function call triggers that error.
I've narrowed this down. It seems to occur on event.getDamager() and only when the damager is not a living entity. More debugging is needed.