Jump to content

Negating fall damage


freshhh

Recommended Posts

Is there any way to negate fall damage done by leaping potions ? I'm fairly new to modding and still got tons to learn so if anyone could hook me up with an example :D.

 

Register an event hander to handle the LivingFallEvent.

Not sure what you'd do after that, though.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

All you need to do is make a event handler and register it then add this code.

 

@ForgeSubscribe
public void entityAttacked(LivingAttackEvent event)
{
	EntityLiving attackedEnt = event.entityLiving;
	DamageSource attackSource = event.source;
	if(attackedEnt instanceof EntityPlayer)
	{

		if(attackSource == DamageSource.fall)
		{
			if(attackedEnt.getActivePotionEffect(Potion.jump)!=null)
			{
				event.setCanceled(true);
			}
		}
	}
}




Link to comment
Share on other sites

All you need to do is make a event handler and register it then add this code.

 

@ForgeSubscribe
public void entityAttacked(LivingAttackEvent event)
{
	EntityLiving attackedEnt = event.entityLiving;
	DamageSource attackSource = event.source;
	if(attackedEnt instanceof EntityPlayer)
	{

		if(attackSource == DamageSource.fall)
		{
			if(attackedEnt.getActivePotionEffect(Potion.jump)!=null)
			{
				event.setCanceled(true);
			}
		}
	}
}




 

Or you could register on the LivingFallEvent....then you don't need to check the damage source.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

Cool, thanks ! Another big thing learnt today, eventhandlers will come in handy in the future, didn't know of them before :D Another question : is it possible to make it so that I will not get damage only when my jump is lesser than 10 blocks and if it is aboe 10 blocks the player will take damage ?

Link to comment
Share on other sites

falldamage accumulates over time when entities fall. 

i dont know how to get that value, but you could use the fmllog.getlogger.info(""+falldamagevalue); to print that value once you find how to get it. this way you could add a check like

if (falldamage < 10.0){

negate falldamage;

}

I can't seem to find such commands, closest I can get is FMLLog.getLogger()

Link to comment
Share on other sites

I've actualy managed to do it myself this time by mixing codes of three seperate treads together, might not be perfect, but it does work !

public class JumpEventHandler {
@ForgeSubscribe
public void livingFall(LivingFallEvent event)
{
    if (!(event.entityLiving instanceof EntityPlayer)) return;
    EntityPlayer eventPlayer = (EntityPlayer)event.entityLiving;
    	if(event.entityLiving.getActivePotionEffect(Potion.jump)!=null)
    	{
    		if(event.distance < 10)
    event.distance = 0.1F;
}
}

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

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