Jump to content

Recommended Posts

Posted

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?

Posted

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.