Skip to content

Listen to EntityPushedByEntityAttackEvent for knockback/push#2193

Merged
wizjany merged 1 commit intoEngineHub:version/7.0.xfrom
Wertik:fix/mace-aoe-knockback
Mar 16, 2025
Merged

Listen to EntityPushedByEntityAttackEvent for knockback/push#2193
wizjany merged 1 commit intoEngineHub:version/7.0.xfrom
Wertik:fix/mace-aoe-knockback

Conversation

@Wertik
Copy link
Copy Markdown
Contributor

@Wertik Wertik commented Mar 12, 2025

Listening to the push event instead of EntityKnockbackByEntity includes other sources of knockback/push in the internal DamageEntityEvent.

For spigot, after this PR is merged, WG should handle mace AoE knockback as it is.

This is primarily to include the Mace AoE knockback in the pvp flag, but affects other sources of push/knockback as well. Essentially all calls of Entity#push (ex.: ender dragon pushes, arrows, creaking, ravagers). I don't think this should cause any unexpected behaviour, but another opinion would be great.

I tested the effect of this on the pvp flag. It does prevent the knockback/push of the Mace AoE when pvp is denied, but does send a "cannot pvp here" message. Not sure if that's wanted here as it might be confusing since the player is not attacking anyone directly.

Closes #2190

Listening to the push event instead of EntityKnockbackByEntity includes other sources of knockback/push in the internal DamageEntityEvent.
@wizjany
Copy link
Copy Markdown
Collaborator

wizjany commented Mar 12, 2025

As far as I can tell from your comment, the EKBE handler will fire on an EPBEAE as well. Why do we need to change the event here? It seems that EKBE should be a superset of EPBEAE, not a subset?

edit: ok had to pull up the javadocs. I don't understand the naming ig but the hierarchy is

io.papermc.paper.event.entity.EntityKnockbackEvent
    io.papermc.paper.event.entity.EntityPushedByEntityAttackEvent
        com.destroystokyo.paper.event.entity.EntityKnockbackByEntityEvent

As far as the PVP messages, if that's something that gets spammy, the internal DamageEntityEvent can be setSilent in the common knockback handler. I don't think it makes sense to make it indirect as the knockback pretty directly comes from the player's attack imo.

@Wertik
Copy link
Copy Markdown
Contributor Author

Wertik commented Mar 12, 2025

As far as I can tell from your comment, the EKBE handler will fire on an EPBEAE as well. Why do we need to change the event here? It seems that EKBE should be a superset of EPBEAE, not a subset?

edit: ok had to pull up the javadocs. I don't understand the naming ig but the hierarchy is

io.papermc.paper.event.entity.EntityKnockbackEvent
    io.papermc.paper.event.entity.EntityPushedByEntityAttackEvent
        com.destroystokyo.paper.event.entity.EntityKnockbackByEntityEvent

As far as the PVP messages, if that's something that gets spammy, the internal DamageEntityEvent can be setSilent in the common knockback handler. I don't think it makes sense to make it indirect as the knockback pretty directly comes from the player's attack imo.

I can see how my comments and code there might be confusing. I had a listener for EKBE to catch them all. Could've been EPBEAE instead.

The naming of the events doesn't help, I had troubles distinguishing when they should get called as well. There's no explanation in the javadocs about the difference between EKBBEE (EntityByEntity) and EPBEAE.

If I got it right you agreed with the choice after looking at the hierarchy?

It might get spammy when there are more players around (message for each player), but since that rarely happens I think we're ok. My main concern was the possible confusion, it's a minor thing though and if you lean that way that's all I need, let's keep it verbose.

edit: btw. Spigot PR got merged, I'll test tomorrow (GMT+1), but it should work as it is

@Wertik
Copy link
Copy Markdown
Contributor Author

Wertik commented Mar 13, 2025

Adding a log to the SpigotListener for EKBEE....

[09:58:13] [Server thread/INFO]: Target: SHEEP Source: PLAYER
[09:58:13] [Server thread/INFO]: Target: PLAYER Source: SHEEP

Doesn't look right, time to reopen on spigot

@Wertik
Copy link
Copy Markdown
Contributor Author

Wertik commented Mar 13, 2025

Fixed on spigot's end, was being called with the wrong entity as attacker. If you agree with the event change for paper it should be good to go.

@wizjany wizjany merged commit 98b5220 into EngineHub:version/7.0.x Mar 16, 2025
Euphillya added a commit to Euphillya/WorldGuard-Folia that referenced this pull request Mar 24, 2025
EngineHub@a949b10 Skip the hopper doing the pulling. (EngineHub#2186)
EngineHub@4ec325e Use chest-access for hoppers pulling from entities. (EngineHub#2191)
EngineHub@656cda4 Point readme to compiling file so we don't have to update two places.
EngineHub@65792ec Restore previous behavior of ride/interact. (EngineHub#2196)
EngineHub@98b5220 Listen to EntityPushedByEntityAttackEvent for knockback/push (EngineHub#2193)
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.

Mace smash attack AoE knockback not handled

2 participants