[Tutorial] How to make a block reduce fall damage of a player

Started by blueboi on

Topic category: User side tutorials

Joined Aug 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
[Tutorial] How to make a block reduce fall damage of a player

So I was playing around with coding blocks and found a way to make block reduce fall damage like hay block.

it is very simple so I decided to show how to do it:

1.First you want to create a block it doesn't matter what settings you choose for the block but be careful cuz you will have to lock the code and then you won't be able to go back and change the block settings.

2.Now you want to lock the code and open the [your-block-name].java by clicking at the block icon twice there is also json files there ignore them you won't need em for this tutorial.

3.Paste this code where all the other imports are in your block.java: 

import net.minecraft.world.World;
import net.minecraft.entity.Entity;

so it will look somewhat like this:

image

4.And now scroll all the way down and paste this code:           

public void onFallenUpon(World worldIn, BlockPos pos, Entity entityIn, float fallDistance) {
entityIn.onLivingFall(fallDistance,0.5F);
}

paste it so it will look somewhat like this:

image

You can now change the number near the fallDisctance, to whatever number you want the smaller the number is the smaller the fall damage will be when you hit the block.

when you're done choosing the number you can save by pressing ctrl+s and you should be golden.

I hope the tutorial helped you, if you have any problem lemme know ill try to help as much as I can.

Joined Aug 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
can someone make edit this…
Wed, 09/15/2021 - 00:47

can someone make edit this code and make it do 3 fall damage. I tried to myself but I couldn't figure it out. https://pastebin.com/CZJ4BmAJ

Joined Jul 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
How do you make it so that…
Tue, 03/28/2023 - 10:07

How do you make it so that fall damage is reduced if you are in a specific dimension?

 

Maybe if you are in a "moon" dimension and have set up a low gravity mechanic but fall damage is not affected.

Joined Jul 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I LOVE YOU
Tue, 07/16/2024 - 18:53

I LOVE YOU

Joined Jul 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Hi, this is only working in…
Fri, 07/19/2024 - 06:50

Hi, this is only working in the Overworld for some reason. The block in question generates in a custom dimension and it's not reducing the fall damage there, only in the Overworld. How do I fix this?

Joined Jul 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Oh, it /is/ working now,…
Fri, 07/19/2024 - 06:53

Oh, it /is/ working now, sorry, I don't know why it suddenly started working mid game