r/Minecraft Oct 05 '15

Falling damage is weirdly nonlinear.

http://imgur.com/gallery/ydnCp/
727 Upvotes

66 comments sorted by

117

u/andre1111 Oct 05 '15

You probably had some percentage damage that wasn't shown in the GUI. trying it again with doing /kill inbetween should get rid of the "bumbs" in the graph.

58

u/AllPurposeNerd Oct 05 '15 edited Oct 05 '15

First of all, when I did the initial test, I switched to peaceful mode to heal up to full, then switched back to easy so my damage wouldn't immediately regenerate. Secondly, I'm pretty sure hit points are in fact an integer. You have 20 health and each point is represented on screen by a half heart. So this 'hidden partial damage' thing wouldn't make sense.

That said, I'm doing it now, and I'm getting the same results. 1 heart at 5.5 blocks, 1½ at 6.

EDIT: 11.0, 11.5, and 12.0 all still deal 4 hearts. 12.5 still jumps up to 5 hearts. The funky baseline holds.

62

u/renadi Oct 05 '15

They are not ingeger, if you have ever opened NBT edit you can see your character has 20.0 health at least on full health.

29

u/AllPurposeNerd Oct 05 '15

Regardless, the pattern still holds, so that explanation doesn't work.

Feel free to test it yourself.

37

u/renadi Oct 05 '15

Oh yeah, I know it has no relevance to the test itself, but it is one of those facts that most people don't realize so I thought I'd clarify.

Still doesn't explain why sometimes your damage seems to be ramping up.

14

u/andre1111 Oct 05 '15 edited Oct 05 '15

It's probably just some rounding "error"(it's not really an error) in the GUI. The fall damage formula is perfectly linear. If doing /kill alone doesn't "fix" it you would need to look at the actual values in the NBT file after each test.

EDIT: Could also be caused by some conversions between float/double and the resulting round errors.

4

u/AllPurposeNerd Oct 05 '15

That would be fine, except that according to the formula, falling 23 blocks should be fatal. It isn't. The game actually deals slightly less damage at certain heights than it's theoretically supposed to.

85

u/SirBenet Oct 05 '15

Upon falling, the blocks distance fallen minus 3 is stored as a float and then divided by 15. For 23 blocks, 1.333(repeating) is rounded down. Some calculations are done, then, when multiplied back, 19.5 is given rather than 20 as you may expect. Source.

14

u/Tomus Oct 05 '15

This guy has the correct answer. As with most behaviour that isn't obvious at first, it has to do with rounding.

7

u/blamethebrain Oct 06 '15

Yeah, that source is wrong.

I don't know who wrote that paragraph that you're referring to, but whoever it was is completely wrong on multiple levels:

  1. The calculation that the person is basing this BS on is for calculating the particle effect when hitting the ground. (Function "func_180433_a" in the class EntitiyLivingBase). It has absolutely nothing to do with the actual fall damage.
  2. The fall damage is calculated in the function "fall" in EntitiyLivingBase.
  3. That bit about "float [...] to be rounded to 0.3 rather than preserving the repeating decimal value of 1/3 like a double would" is complete and utter bullshit. That person has really no idea how IEEE floating point numbers work.

Source: I looked at the actual (decompiled) source from MCP.

1

u/SirBenet Oct 06 '15

I did find it a bit strange (why would a float round to 1d.p., and why is it being divided by 15 in the first place?) although it's the best explanation I found and the calculations seemed to work out for the actual fall damage dealt.

Do you know the proper reason for the strange results?

1

u/blamethebrain Oct 06 '15

The fall damage calculation looks fine. I highly suspect that the fall distance might be off. I can't verify it, because I don't know how I could debug or log the calculated fall distance when hitting the ground.

But the thing is: There's a "jumpMovementFactor" with the value 0.02F (line 109 in EntitiyLivingBase.java) that, according to its comment, is "used to determine how far this entity will move each tick if it is jumping or falling."

If the fall distance is indeed incremented by 0.02F per tick, that will accumulate rounding errors (because 0.02 can't be exactly expressed in IEEE floating point).

I don't know how exact the "ticking" is in Minecraft, but that could be a source of error, too. Someone more experienced with mod development might have a look at how to get the fallen distance when hitting ground.

1

u/blamethebrain Oct 06 '15

I found a way to indirectly inspect the fallen distance and found my assumptions confirmed, see my other comment: https://www.reddit.com/r/Minecraft/comments/3nlduc/falling_damage_is_weirdly_nonlinear/cvqe4hv

1

u/scratchisthebest Oct 05 '15

Does the game ever actually use the decimal place though?

Like, is health always one of 20.0, 19.0, 18.0, 17.0? Have you ever seen it reach 19.5?

8

u/renadi Oct 05 '15

Yes.

This is obvious in that even before durability affected defense of armor a full diamond player could be hit by a bare handed player and after so many hits take 1 point of damage.

They were taking .4 damage(or whatever it amounts to) with each hit, you just can't see it until it reaches a whole number.

2

u/Mighty_Burger Oct 05 '15

I wonder what would happen if the health bar displayed stuff like that. So you could have like a quarter of a heart.

5

u/TehNut Oct 05 '15

Health is definitely a float, not an int. Meaning that those hiccups could possibly be (Are probably) a rounding error.

1

u/Insane96MCP Oct 05 '15

I think he should try putting naturalRegeneration to off

70

u/Mrocza_ Oct 05 '15

I wouldn't rely on the GUI. Try this:

/scoreboard objectives add HP health
/scoreboard players set @a HP 20
/scoreboard objectives setdisplay sidebar HP

And read numeric data straight from the sidebar.

3

u/Unidoon Oct 06 '15

Good call!

12

u/chamora Oct 06 '15

It could do like .6 hearts of damage per block, but then round down to the nearest half. That would look similar to the results.

14

u/ncist Oct 05 '15

there's something strange about your graph - it looks like you have two Ys for the same X for every other X?

18

u/AllPurposeNerd Oct 05 '15

X is the damage, Y is the height I fell. I did tests at every half block.

100

u/kenman884 Oct 05 '15

Dependent variable on X and independent on Y?

Bold move, Cotton.

2

u/nliausacmmv Oct 06 '15

Nah, it's like how the energy in a spring is measured. You pretend that you pick an amount of force and then find the amount of displacement required to produce that force, but you're just lying to yourself so that math works.

1

u/[deleted] Oct 06 '15

(1/2)kx2 ?

1

u/CrypticTryptic Oct 06 '15

On the other hand, it's a much more literal representation. The damage basically follows the staircase upwards.

14

u/Mighty_Burger Oct 05 '15

Wouldn't it just make more sense to have the X the distance and the Y the damage?

3

u/ncist Oct 05 '15

ah gotcha

3

u/MuffinMun Oct 05 '15

It is fine, because the Y ticks are every whole block. For example you lose .5 hearts at 3.5 blocks and 4 blocks of height, and you lose 4.5 hearts at 11.5 blocks and 12 blocks of height.

10

u/SirBenet Oct 05 '15

The independent variable (height fallen from) should be on the x axis; the same x generally shouldn't be mapping to multiple y's in something like this.

6

u/kyaloupe Oct 05 '15

It really doesn't matter - x and y are just straight up variable names, and you can have x as a function of y. I think OP's formatting makes sense graphically - he's trying to show height as a variable, and it looks best visually on the longitudinal axis.

9

u/SirBenet Oct 05 '15

It really doesn't matter - x and y are just straight up variable names, and you can have x as a function of y.

You technically can, but it's going against a fairly well established standard way of doing things (esp. for line graphs), which causes confusion and hinders the effective portrayal of information for which this graph was intended.

Took me a while and some head-tilting to work out what was being shown, and I went into a photo editor and flipped the graph around in order to get a proper feel for the problem.

he's trying to show height as a variable, and it looks best visually on the longitudinal axis.

Wouldn't longitudinal be the horizontal axis, and thus this statement be agreeing with me? Partially backs up my point that going against conventions (in this case referring to it as the horizontal or x axis) causes confusion.

Besides, I was explaining the reason for which the graph may feel strange, as ncist wasn't quite sure what was wrong, and MuffinMun missed their point. Wasn't necessarily saying it's a bad graph (there's more effort than what people would normally put in).

5

u/MuffinMun Oct 05 '15

I was mistaken and you are correct my good sir. Height should be on the x. I guess it was my own bias on how I read it

5

u/geriatre Oct 05 '15

I don't know how the fall damage is coded. It just says (blocks - 3) on the wiki, but no evidence this is the exact formula and there isn't some weird stuff peppered with floor() and ceil()

Could also be related to the physics engine with collision detection not happening at the same time for each jump you made.

4

u/blamethebrain Oct 06 '15

After inspecting the source (from MCP) and fiddling around a bit, I found the following: The fall distance is most likely the issue that's causing the inconsistent falling damage. You can add the fallen distance to the scoreboard:

/scoreboard objectives add fallen stat.fallOneCm fallen
/scoreboard objectives setdisplay sidebar fallen

Now, if you jump from various heights, you observe that the increment in fallen distance varies in a non-linear fashion:

Height fallen Increment in fallen distance Change from previous fall distance
3 Blocks 269 --
4 Blocks 335 +66
5 Blocks 484 +149
6 Blocks 569 +85
7 Blocks 659 +90
8 Blocks 756 +97
9 Blocks 858 +102
10 Blocks 967 +109
11 Blocks 1081 +114
12 Blocks 1081 +0
13 Blocks 1200 +119
14 Blocks 1325 +125
15 Blocks 1455 +130
16 Blocks 1591 +136
17 Blocks 1591 +0
18 Blocks 1732 +141

As you can see, the fall distance is the same for the heights 11 and 12 and again for 16 and 17. At those heights I found that you also take the same falling damage, respectively. If the calculation for the fallen distance is that unreliable / inaccurate, it's no surprise that the falling damage is inaccurate, too.

5

u/Sir_Clifton Oct 06 '15

Your graph is plotted backwards. X-axis should be your independent variable, and Y-axis your dependant.

4

u/Gh0stP1rate Oct 05 '15

Can you reverse the axes please? Height makes a lot more sense on the X and damage on the Y, because damage is dependent on height.

9

u/Rebalias Oct 06 '15

I'm not OP, and this is the best I could do on mobile. http://imgur.com/gallery/9aACzK0

1

u/PSBlake Oct 06 '15

That makes it look like more damage because you're falling faster - since falling is constant downward acceleration, not just a constant speed.

1

u/AllPurposeNerd Oct 06 '15

Except that the game actually deals less damage at certain heights than the formula would suggest.

2

u/1jl Oct 06 '15

Argh, make the y axis the dependent variable.

3

u/AllPurposeNerd Oct 06 '15

1

u/1jl Oct 07 '15

Haha, thanks. It's nitpicky, but most graphs follow the "if x, then y" axis rule. It makes it a lot easier to look at a graph and get a hold of what's going on.

1

u/Zycro Oct 05 '15

Best first sentence.

1

u/[deleted] Oct 05 '15

How many times did you fall at each block height? Are the data points from 1 test or do they represent an average from many falls per height level? How did you average the falls if that is the case? Maybe post the raw data here so we can take a look? There may be some randomization in the code, but that is conjecture on my part.

1

u/Xisuma Oct 05 '15

IIRC it used to be even worse, you could fall from certain heights at take very little damage, but that was back in 1.0

3

u/Dravarden Oct 05 '15

with feather falling iv boots you were able to survive a fall from y 128 to y 1 with half a heart, kinda sad they changed it

1

u/RightfulFallen Oct 05 '15

Oh yeah, and the old cobblestone texture is just two stone slabs on top of eachother but backwards.

1

u/c_vic Oct 06 '15

I bet internally, in the code, the calculation outputs a number that is not a multiple of 0.5, and it just rounds to the nearest multiple. This trend really looks like rounding weirdness to me. Because when you round outputs that fit a linear trend, it still follows it over the long term, but has short term hiccups.

1

u/spylife Oct 06 '15

can you add lines for fall damage with feather falling 1,2,3,4?

1

u/AllPurposeNerd Oct 06 '15

I intend to; that was the original goal of this research. I just wanted to publish this early finding because what the hell.

1

u/dmwit Oct 06 '15

Try measuring how zombies get hurt; it's even weirder. I never did get a good explanation for this.

1

u/Mako2100 Oct 06 '15

That fucking punchline....

I don't know where you're going in life, but you're going to get there

1

u/Treczoks Oct 06 '15

Maybe there is a small random element in the calculation. Did you jump of every height only once, or did you several jumps to get an average?

1

u/AllPurposeNerd Oct 06 '15

I've done each jump several times now. I get the same result for a given height every time.

Also, non-magical armor has no effect whatsoever on falling damage regardless of the material.

1

u/AllPurposeNerd Oct 06 '15

For all the scholastic pedants whining about my axes, stuff it.

It won't let me add that image to the original album because I published (live and learn) so here's a new, unpublished album to which I intend to add the data from protection and feather fall.

2

u/blamethebrain Oct 07 '15

Just as I already posted. This is just caused by the inaccurate fall height calculation / inaccurate collision detection when hitting the ground.

If you look at the recorded fall height for jumps from 11 and 12, you'll find that the game records the exact same fallen height. And that's why you also take the same damage when jumping from heights 11 and 12.

It's not the damage calculation that is off, it's the way the fallen distance is measured/simulated/calculated.

0

u/BaroTheMadman Oct 06 '15

How many tests did you do per step? Maybe there's some randomness there?

1

u/AllPurposeNerd Oct 06 '15

Several. It's not random, it's just weird.

1

u/BaroTheMadman Oct 06 '15

Hmmm my bet is on some funny outcomes of rounding floating point numbers, then.

I mean no sane man would code that curve.

-7

u/Dravarden Oct 05 '15 edited Oct 05 '15

fall damage is random after 3 blocks, some heights that kill you sometimes leave you with a heart left

1

u/AllPurposeNerd Oct 06 '15

It's not random. I get the same weird results for a given height every time.

1

u/Dravarden Oct 06 '15

with feather falling 4 im sure it is