FiguraMC / Figura

Extensively customize your character with Figura!
https://modrinth.com/mod/figura
GNU Lesser General Public License v2.1
253 stars 46 forks source link

Feature Request: Lua ATTACKED event #264

Open JoshieGemFinder opened 1 month ago

JoshieGemFinder commented 1 month ago

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

Riftlight commented 1 month ago

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 commented 1 month ago

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 commented 1 month ago

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.