Jump to content

Change damage of LivingAttackEvent


robertx555

Recommended Posts

I found 2 ways of doing this but they both seem the wrong way. I made my own stat system with nbt on items and if player has a total of say 50 dmg, i want the weapon to do 50 dmg. Here are the 2 ways i did this that i think are wrong

 

firstly i tried just setting mob health but that has issues, the mobs don't drop any items then. 

 

secondly, i tried using the attackentityfrom method and making it unique so i can identify it and not make an infinite loop, but this looks like a disaster in the making

 

		if (event.getSource().isDamageAbsolute())return;		

		event.getEntityLiving().attackEntityFrom(event.getSource().setDamageIsAbsolute(), combinedDMG);
		
		event.setCanceled(true);

 

Am i missing the true way of doing this? And no i can't just change the dmg of items, there is crit chance, lifesteal etc to calculate too. 

 

EDIT I THINK I FIGURED IT OUT, sec

Edited by robertx555
Link to comment
Share on other sites

Can close the thread, i read some other thread here 

 

the suggestion to  open type hierarchy made me realize LivingDamageEvent event exists and that i can change the amount there with setamount!

 

There is a class called ForgeHooks that contains all the events 

Edited by robertx555
Link to comment
Share on other sites

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.