How to reduce Fall Damage

Started by Valirane on

Topic category: Help with Minecraft modding (Java Edition)

Joined Mar 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
How to reduce Fall Damage

I'm trying to create a procedure that reduces the fall distance when a player falls.  There is a procedure block for "Overwrite fall distance for <x>" but I can't find any useful way to implement it.  I can make it trigger on various triggers, except for the one that makes sense, "Entity Falls". 

 

I wrote a simple procedure triggering on "Entity Falls" that displays player health, fall distance, sets fall distance to 0, waits 1 tick and then displays the player health and fall distance again.  Walking off a 5 block cliff shows my starting 20 health followed by 18 after I take the fall damage. Fall distance remained a constant 4.82.  I can completely negate damage by either cancelling the event or disabling player damage and then re-enabling after the wait delay, but that is not what I'm looking for.  Why doesn't Overwrite Fall Distance work here?  If it doesn't work when falling, what good is it?

Joined May 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
The developers made it very…
Sat, 04/02/2022 - 09:46

The developers made it very simple -

1. A standalone procedure >> On Player Tick Update

2. Add >> Overwrite Fall Distance of entity with 0 blocks for the next tick

 

No matter the height, the player (or entity) will not be damaged for the next tick. Simple procedure, and yet very op. Better set it as conditional for wearing custom boots or holding item.

Joined Jul 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
^^ only do so if the player…
Sat, 04/02/2022 - 11:08

^^ only do so if the player has a certain amount of downwards motion else youll permenantly take 0 damage a tick

Joined Mar 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Is a Player Update Tick the…
Sat, 04/02/2022 - 15:05

Is a Player Update Tick the only way to get this to work?  I was trying to avoid calling my procedure 20 times a second since there will be several checks and calculations involved to figure out how much fall reduction is warranted, multiplied x4 armor slots.

 

It seems fall reduction is already locked in when using Entity Falls, even though the trigger clearly occurs prior to damage being dealt. I guess this all happens in the same tick and Override Fall Distance won't take effect until the next one.  Is there any way around this?

Joined Mar 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I'm currently trying to get…
Sat, 04/02/2022 - 16:53

I'm currently trying to get something working under a "Before Entity is Hurt" trigger.  Is there any way to check if the entity is Falling or if the damage source if from a Fall?  

 

Also, is there a way to edit a post to amend to the old one rather than double posting?  

Joined Mar 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
It took some workarounds,…
Sat, 04/02/2022 - 23:44

It took some workarounds, but I managed to get things working.

 

To track falling, I used a "Entity Falls" trigger to set a global player variable to the Fall Distance.  I used a Wait command to reset the variable to 0 on the next tick.

 

To reduce the fall damage I used a "Before Entity is Hurt" trigger that checks for a non zero value in the above global player variable.  Since I couldn't figure out how to adjust the damage "Amount" I used a custom code snippet to add Absorption health equal to the amount of damage that I want to negate, 1 per level of the relevant enchantment.  A few checks for existing Absorption health and capping it to the damage inflicted and I was in business.

Joined May 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Nice, you just turned your…
Sun, 04/03/2022 - 01:56

Nice, you just turned your own question into a tutorial. Great job!

Joined Mar 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
If anyone is interested in…
Sun, 04/03/2022 - 04:28

If anyone is interested in the custom code snippet, it uses a local number variable to set the Absorption level (gold hearts).

 

Set Absorption health level to <vCount>

				if (entity instanceof LivingEntity _entity)
					_entity.setAbsorptionAmount((float) vCount);

 

Joined Jul 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
haven't anyone thought to…
Mon, 07/31/2023 - 13:50

haven't anyone thought to make a potion effect that disables fall damage and is given to player every time player gets off a plane?

Joined Oct 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
About disabling fall damage,…
Mon, 07/31/2023 - 18:24

About disabling fall damage, if you are okay in using snapshot for making mod, 1st snapshot of mcreator 2023.3 added damage source to some triggers like for "Before entity is hurt". You can check what's the source of damage and and if its caused by fall and entity has potion effect u you want, cancel event.