Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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.

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.

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);
			}
		}
	}
}




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.

  • Author

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 ?

  • Author

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()

  • Author

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;
}
}

Guest
This topic is now closed to further replies.

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.