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

Feature Request: Lua ATTACKED event #264

Open
JoshieGemFinder opened this issue Oct 1, 2024 · 3 comments
Open

Feature Request: Lua ATTACKED event #264

JoshieGemFinder opened this issue Oct 1, 2024 · 3 comments
Labels
enhancement New feature or request

Comments

@JoshieGemFinder
Copy link

JoshieGemFinder commented Oct 1, 2024

Request Description

Currently, the DAMAGE event only triggers after an entity takes damage; however, we sometimes want some action to occur when an attack attempt is made, regardless of whether it goes through or not (most notably, when you know that the attack will be cancelled out by some damage invulnerability). The ATTACKED event would be identical to the DAMAGE event, with the sole exception of it firing at the start of player damage handling, instead of at the end.

Note: I use ATTACKED since Forge has a LivingAttackEvent for this same purpose (fired before LivingDamageEvent, which is equivalent to figura's DAMAGE event), but PRE_DAMAGE is also a valid name for this event, and would fit the Figura event naming schema better

@JoshieGemFinder JoshieGemFinder added the enhancement New feature or request label Oct 1, 2024
@Riftlight
Copy link
Contributor

couldnt you just do this by going through everyone around you and checking if theyre both swinging their arm and have you as their targeted entity?

@JoshieGemFinder
Copy link
Author

couldnt you just do this by going through everyone around you and checking if theyre both swinging their arm and have you as their targeted entity?

There are several issues with this:

  1. This would give false positives if the player is swinging their arm for some other action and just happen to be looking at you
  2. This would be an inefficient solution and cause excessive overhead for something that could be easily replaced with an event
  3. That only works if it's a player that's attacking you, this wouldn't give you information about arrows, void, fire, or other sources of damage that an ATTACKED/PRE_DAMAGE event would give you

@JoshieGemFinder
Copy link
Author

After further investigation, I now see why this wasn't implemented originally: You can only get this information on the server side (which as a client-side-only mod, Figura didn't want to implement). I will leave the issue open in case anyone later figures out a way to make this work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants