customrealms / core

Core library for the CustomRealms runtime
https://customrealms.io/core
MIT License
35 stars 13 forks source link

Error on EntityDamageByEntityEvent #6

Closed connerdouglass closed 3 months ago

connerdouglass commented 2 years ago

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));

});
connerdouglass commented 2 years ago

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.

connerdouglass commented 2 years ago

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.