Posted September 8, 20178 yr Hey! I have created new damage source called fire and my goal is that I want to reduce this type of damage in the LivingHurtEvent if the target has resistance to this new source. Now the problem is that I am not able cause this new type of damage from my fire sword. I've tried adding "target.attackEntityFrom(new DamageSource("mymod.fire"), 10f)" to the hitEntity function in the fire sword, but this seems to cause two attacks. The original attack with the source of player and a new attack with the new source. So my question is it possible to change this fire swords damage source from player to fire, or is it possible to cancel first damage caused by player and just apply the fire damage?
September 8, 20178 yr Author I managed to solve this problem by adding damage source field to my ItemSword wrapper which the fire sword extends. Then in LivingHurtEvent I took the attacking entity from .getSource().getTrueSource() and checked if that entity is a player. If it is a player I'll check what he is wielding and if that item is instance of my ItemSword. If it was my ItemSword I can get the damage type from it and then apply the resistance as I wanted.
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.