Skip to content

Add EntityLungeEvent#13637

Merged
Warriorrrr merged 6 commits intoPaperMC:mainfrom
Dueris:feat/lunge-event
Apr 11, 2026
Merged

Add EntityLungeEvent#13637
Warriorrrr merged 6 commits intoPaperMC:mainfrom
Dueris:feat/lunge-event

Conversation

@Dueris
Copy link
Copy Markdown
Contributor

@Dueris Dueris commented Feb 14, 2026

Feature implementation for #13634

@Dueris Dueris requested a review from a team as a code owner February 14, 2026 22:06
@github-project-automation github-project-automation Bot moved this to Awaiting review in Paper PR Queue Feb 14, 2026
@Warriorrrr Warriorrrr added type: feature Request for a new Feature. scope: api labels Feb 15, 2026
@JavierFlores09
Copy link
Copy Markdown

Maybe name it similarly to EntityAttemptSmashAttack/EntityAttemptSpinAttack for consistency, EntityAttemptLungeAttack

Copy link
Copy Markdown
Member

@Warriorrrr Warriorrrr left a comment

Choose a reason for hiding this comment

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

My fault for not testing this with an unenchanted spear, but this event seems to currently also be fired when a spear doesn't have lunge at all, which doesn't seem intended (at least, there's no way to differentiate whether an entity is actually going to lunge or not).

Going into the direction of an attempt lunge event might be nice, i.e. being able to make the player lunge despite not having enough food or not having the enchantment.

@github-project-automation github-project-automation Bot moved this from Awaiting review to Changes required in Paper PR Queue Feb 16, 2026
HaHaWTH

This comment was marked as resolved.

@Dueris
Copy link
Copy Markdown
Contributor Author

Dueris commented Feb 18, 2026

Will do. Been a bit busy IRL but will try and get to that tonight

@Dueris
Copy link
Copy Markdown
Contributor Author

Dueris commented Feb 19, 2026

I don't think making it so that the player is able to lunge despite not having the enchantment is very possible, given how the method actually works.

public static void doLungeEffects(ServerLevel level, Entity entity) {
    if (entity instanceof LivingEntity livingEntity) {
        // runIterationOnItem applies the passed EnchantmentInSlotVisitor if the enchantment is *present*
        runIterationOnItem(
            entity.getWeaponItem(),
            EquipmentSlot.MAINHAND,
            livingEntity,
            (enchantment, level1, item) -> enchantment.value().doLunge(level, level1, item, entity)
        );
    }
}

If say, we were to try and attempt to allow the player to lunge without the enchantment, we would need to try to potentially enchant the item beforehand with the lunge enchantment so that it can actually do it, but then we need to consider what level we should do(or if the level should even be configurable), and also what would happen if a plugin were to enchant the item itself during the event. It's just a tiny bit weird and complex to implement correctly.

As such, I suggest instead we potentially move towards what JavierFlores09 said, and make it into an ATTEMPT to lunge, and also pass if it will lunge or not. Allowing modification of the result, making it pass and lunge without food requirements or without enchantment requirements, is far too difficult to implement given the current structure of the Vanilla enchantment system, and if attempted, would be messy.

I am going to conduct changes locally right now to implement the ATTEMPT approach, however if anyone else has any ideas as to making the functionality of passing without the requirements of the lunge enchantment work, please do share.

@Dueris
Copy link
Copy Markdown
Contributor Author

Dueris commented Feb 19, 2026

Actually, I am going to move the event to Enchantment#doLunge, in the lambda, where it is confirmed that the player will lunge, as it seems more logically appropriate given the existing restrictions. It is also possible to pass significantly more information there.

EDIT: It is also possible to effect the lunge power at that point.

HaHaWTH

This comment was marked as outdated.

@HaHaWTH

This comment was marked as resolved.

@Dueris
Copy link
Copy Markdown
Contributor Author

Dueris commented Feb 19, 2026

Isn't that where the insert is currently? I may be wrong but looking at your screenshot, that is where I inserted I believe

@HaHaWTH
Copy link
Copy Markdown
Contributor

HaHaWTH commented Feb 19, 2026

Isn't that where the insert is currently? I may be wrong but looking at your screenshot, that is where I inserted I believe

Oh sorry, I was reviewing the previous commits, that is solved now.

@Dueris
Copy link
Copy Markdown
Contributor Author

Dueris commented Mar 18, 2026

Is there any reason why this is still in the PR queue? It's been approved for quite a while now, and another PR was merged significantly faster, of which also adds an event like this does.

I also have many people I know asking on the progress of this PR, since this was made for many personal clients of mine.

Anyway, wanting to know generally why this is still in the queue given it has been approved for a while now.

@Uhuli
Copy link
Copy Markdown
Contributor

Uhuli commented Apr 5, 2026

I think its because of the ongoing update to 26.1 (26.1.1)

@Warriorrrr
Copy link
Copy Markdown
Member

The update work did indeed get in the way of this being merged earlier

@Warriorrrr Warriorrrr merged commit 67a54b3 into PaperMC:main Apr 11, 2026
4 checks passed
@github-project-automation github-project-automation Bot moved this from Changes required to Merged in Paper PR Queue Apr 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope: api type: feature Request for a new Feature.

Projects

Status: Merged

Development

Successfully merging this pull request may close these issues.

7 participants