McJtyMods / RFTools

A set of blocks and items to help with RF in general. Currently contains a Dimension Builder, Teleportation System, Shield System, RF monitor, an RF network debug tool and an automatic crafter
MIT License
228 stars 88 forks source link

Use decimal, integer, or rational arithmetic in RFTools Spawner #1602

Open saulrh opened 6 years ago

saulrh commented 6 years ago

It's been pointed out several times that floats can't properly represent decimal fractions and that the resulting rounding problems cause annoyances in the RFTools Spawner. For example, #1146 and #946. It is correct to conclude that there will always be rounding errors in e.g. 1.0f - 0.1f. However, there are simple arithmetics that could be used that would not have this rounding problem. Several possibilities, some of which wouldn't even require code changes:

xbony2 commented 6 years ago

This patch has been relayed to me by someone without an account. According to them "that version is no longer compatible with rftools original, due changes to packets" but maybe it could be useful, I dunno.

saulrh commented 6 years ago

I don't have a minecraft dev env set up so I can't say anything about whether the patch works, but I can at least reformat it and put it in git so it's readable. It appears to implement proposal 3, fixed-point arithmetic, doing computations in longs with a hard-coded (magic number) scale factor of 2520. https://github.com/McJty/RFTools/compare/1.12...saulrh:spawner-fixed-point-arith