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

Add EntityKnockbackByEntityEvent #1162

Merged
merged 1 commit into from Jun 21, 2018

Conversation

Brokkonaut
Copy link
Contributor

This event is called when an entity receives knockback by another entity. The knockback can be modified in the event. If the event is cancelled the entity is not knocked back.

Copy link
Member

@aikar aikar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this approach is fine, but it is different than how I did my own event:

https://github.com/starlis/empirecraft/blob/master/patches/server/0032-EntityKnockbackEvent.patch

I did it at obtaining the knockback level.

But this also accounts for explosions which is good. I can prob drop my own for how i use it and rework my code around this.

But all I can mainly see is desire to change entity and override getEntity() to be LivingEntity

+ private final Vector acceleration;
+ private boolean cancelled = false;
+
+ public EntityKnockbackByEntityEvent(Entity entity, Entity hitBy, Vector acceleration) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think a non living entity can be hit by knockback, since the impl is in EntityLiving...

entity should be LivingEntity.

I wish hitBy also was, but this also fires for explosions too, so Entity is valid there.

@Brokkonaut Brokkonaut force-pushed the feature-entityknockbackevent branch from 9fa2ede to 996a9ec Compare June 18, 2018 18:57
@Brokkonaut
Copy link
Contributor Author

Ok, I changed the Entity to LivingEntity

This event is called when an entity receives knockback by another entity. The knockback acceleration can be modified in the event. If the event is cancelled the entity is not knocked back at all.
@Brokkonaut Brokkonaut force-pushed the feature-entityknockbackevent branch from 996a9ec to 61dd628 Compare June 18, 2018 22:14
@aikar aikar merged commit a5285de into PaperMC:master Jun 21, 2018
@Brokkonaut Brokkonaut deleted the feature-entityknockbackevent branch July 4, 2018 00:14
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

Successfully merging this pull request may close these issues.

None yet

2 participants