Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1.15.1 cannot be cast to entity player warning #36

Closed
DrakePork opened this issue Dec 26, 2019 · 7 comments
Closed

1.15.1 cannot be cast to entity player warning #36

DrakePork opened this issue Dec 26, 2019 · 7 comments

Comments

@DrakePork
Copy link

DrakePork commented Dec 26, 2019

I know you dont have a 1.15 version out yet but uh after updating to 1.15 I started getting this warning in console when people hit mobs with custom enchants.
Pastebin

@Zedly
Copy link
Owner

Zedly commented May 4, 2020

This error is now fixed!

@Zedly Zedly closed this as completed May 4, 2020
@Geolykt
Copy link

Geolykt commented Jul 8, 2020

I might be wrong, but looking at the code it shouldn't be fixed:

public boolean onBeingHit(EntityDamageByEntityEvent evt, int level, boolean usedHand) {
    if (!(evt.getEntity() instanceof LivingEntity) ||
        !ADAPTER.attackEntity((LivingEntity) evt.getEntity(), (Player) evt.getDamager(), 0)) {
        return true;
    }
}

We have already established that evt.getEntity() is not of instance of LivingEntity, so why cast it into a LivingEntity?
The same goes for evt.getDamager(). I assume evt.getDamager() and evt.getEntity() were mixed up?

@Zedly
Copy link
Owner

Zedly commented Aug 21, 2020

Hi, should I have mentioned that the fix is on the dev branch? Sorry if this caused confusion. The offending code was removed in 4b51a7d. Thanks for keeping me informed!

@Geolykt
Copy link

Geolykt commented Aug 21, 2020

I'm a bit confused since I swear that this commit was pushed just a few hours ago. Anyways, I will try to reproduce it (once I am able to set up a 1.16.2 testing environment) and then make an update statement.
anyways, thanks

@Geolykt
Copy link

Geolykt commented Aug 21, 2020

Checked, and the issue (on the dev branch) should still occour. However, this test has been done logically, and not in a bukkit environment, which is quite different

@Zedly
Copy link
Owner

Zedly commented Aug 21, 2020

The typecast in onBeingHit is safe because the type is checked in WatcherEnchant.java:154. I will change the type of the parameter in onBeingHit to Player, though.

@Zedly
Copy link
Owner

Zedly commented Aug 21, 2020

Nevermind that's not how the code works. It's been a while since I looked at it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants