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

Started by blueboi on

Topic category: User side tutorials

Last seen on 13:45, 20. Aug 2022
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.

Last seen on 16:20, 15. Jun 2024
Joined Sep 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Thanks, I need this. Good…
Mon, 08/30/2021 - 10:41

Thanks, I need this. Good tutorial!

Last seen on 09:04, 1. Jan 2024
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

Last seen on 19:07, 1. Jun 2024
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.