Topic category: User side tutorials
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:
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:
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.
Thanks, I need this. Good tutorial!
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
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.
I LOVE YOU
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?
Oh, it /is/ working now, sorry, I don't know why it suddenly started working mid game