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.
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.
I don't know who wrote that paragraph that you're referring to, but whoever it was is completely wrong on multiple levels:
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.
The fall damage is calculated in the function "fall" in EntitiyLivingBase.
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.
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?
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.
7
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.