Conversation
|
Maybe name it similarly to EntityAttemptSmashAttack/EntityAttemptSpinAttack for consistency, EntityAttemptLungeAttack |
Warriorrrr
left a comment
There was a problem hiding this comment.
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.
|
Will do. Been a bit busy IRL but will try and get to that tonight |
|
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. |
|
Actually, I am going to move the event to EDIT: It is also possible to effect the lunge power at that point. |
This comment was marked as resolved.
This comment was marked as resolved.
|
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. |
Feature implementation for #13634