TheIllusiveC4 / Champions

A Minecraft mod introducing elite mobs with enhanced stats and abilities
Other
25 stars 18 forks source link

[1.16.5] Reflective's DamageSource is the Player attacking #133

Closed VanyaBaou closed 1 year ago

VanyaBaou commented 2 years ago

https://github.com/TheIllusiveC4/Champions/blob/1.16.x/src/main/java/top/theillusivec4/champions/common/affix/ReflectiveAffix.java#L47

Setting the attacker for the DamageSource causes a lot of issues with the damage being dealt

The Player can boost the damage being dealt (to themselves) again because some enchants or items wont check things like it being "reflective" or the source of damage to the player being themselves

It also prevents having "when receiving damage" effects on the player from applying to the mob reflecting, and those effects usually end up applying to the player instead

An example is the Vorpal enchant (Random chance for 5x damage), it can proc on the initial hit, and then when reflecting the damage to the player it can have that damage 5x again

Another example is the Slicers Dice from Meet Your Fight, it will proc on damage reflected to yourself

Lots of other things like that happen, but i wont go into detail cause hopefully I wrote this decent enough to make sense lol

Please change the source of the reflective damage to the mob that is being attacked

TheIllusiveC4 commented 2 years ago

I'll have to think about this, because I want to keep the source of the damage as the player since that's what's actually happening. The mob isn't really attacking the player, the mod itself is just replicating the player's attack and using it on them. Just in theory, the attack should state the player as the source and never the mob.

However, I understand the issues that you've outlined with the current implementation. If it comes down to it, I'd rather change it than leave it as is if I had to choose. I'm just wondering if there's a way I can simply change the logic so that the damage is still done but it doesn't run the damage calculations from mods twice.

If it's not too much trouble, can you list all of the issues that can arise in your experience and the mods that they're from? For instance, I'm not sure which mod the Vorpal enchantment is from. I need to do some research on this topic and that would help me immensely.

VanyaBaou commented 2 years ago

I don't really see any way to make it function fine with other mod's damage calculations with those mods modifying their code, since many just check "is it LivingEntity? yes. does it have Enchant? yes. do calculation" basically none check for "is DamageSource the Victim of the Attack?"

Some examples:

Slicer's Dice from Meet Your Fight

Vorpal is in Ensorcellation, but it is closed source, but I have had people state it is activating on Reflective damage and one-shotting them

Worn Mirror from Lost Trinkets (instantly kills user when damage is reflected)

TheIllusiveC4 commented 2 years ago

I don't really see any way to make it function fine with other mod's damage calculations with those mods modifying their code, since many just check "is it LivingEntity? yes. does it have Enchant? yes. do calculation" basically none check for "is DamageSource the Victim of the Attack?"

Since these calculations occur inside events, I was briefly considering a way to replicate the initial damage calculations without firing the events a second time or perhaps even overriding the damage calculations on the second pass.

However, looking at those examples, that's clearly not a feasible route and there would be too many side-effects to take into consideration. So I'm just going to accept the initial solution of simply changing the damage source entity.