Request : Get damage that would be done from a LivingEntity to another LivingEntity using a specific ItemStack
NatoBoram opened this issue ยท 5 comments
I tried to extract the damage formula used by PlayerEntity.attack()
, but honestly, it's bad.
This is a request to obtain a build-in function inside Fabric API to be able to calculate the damage that an ItemStack
would do to a LivingEntity
when used by another LivingEntity
, taking account all modifiers, enchantments, effects, and armours.
In case anyone was crazy enough to take a shot at this:
On a case of feasibility, this could be quite challenging since entities could override the damage process themselves, which would make a universal injection into a LivingEntity near impossible in most cases.
Yeah, that's precisely why I needed some kind of API. I was trying to get the most effective item in the inventory against the clicked mob, but I realized that formulas were hard-coded into the function that actually removed the LivingEntity
's health then scattered some more with enchanting stuff. r/ProgrammingHorror stuff, honestly.
One idea I thought of is possibly creating a dummy entity with all the same attributes and properties and applying the damage to the dummy to calculate. Though it's definitely a hack and probably a bad way to approach it.