Skip to content

Comments

Add EntityLungeEvent#13637

Open
Dueris wants to merge 2 commits intoPaperMC:mainfrom
Dueris:feat/lunge-event
Open

Add EntityLungeEvent#13637
Dueris wants to merge 2 commits intoPaperMC:mainfrom
Dueris:feat/lunge-event

Conversation

@Dueris
Copy link

@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

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

Copy link
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
Author

Dueris commented Feb 18, 2026

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

@Dueris
Copy link
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
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
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
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.

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: Changes required

Development

Successfully merging this pull request may close these issues.

5 participants