Closed rmunn closed 7 years ago
It's actually pretty easy to find the incorrect values, if your text editor / IDE has a regex search feature. Just look for the pattern 0.#
, where #
is a single digit (i.e., a \d
that is not immediately followed by a second \d
), i.e. use a "negative lookahead assertion" to say that the \d
should not be followed by a second one. Since different regular-expression syntaxes write negative lookahead assertions differently, I can't give an example that will work in every IDE. But it should be pretty straightforward to write such a search expression.
Update: No need for a lookahead assertion, actually, since there's a trailing f
after each float thanks to Java syntax. Just search for the regex add(Product|Specialty).* 0\.\df
and you'll find all the affected chances. (All the ones where the chance was 10% and it stayed 10% are written as 0.10f
rather than 0.1f
so it's quite easy to tell which ones were intended to be 10% and which ones were intended to be 1%).
Thanks for the report! Would you mind making a PR? You should be able to edit the values in Github directly and submit a PR with your changes.
I'm at work right now, but I'll make a PR when I get home.
Note that it'll really be three PRs, since GitHub PRs only target a single branch and I want to fix this in all the active branches.
Fixed for the 1.10/1.11 version, the 1.10 branch is not active, so no need to make a pull request for that
Oh dear. I have a PR almost ready to push, and it conflicts with yours. I'm just now double-checking everything to make sure I got it right; I'll push it real soon, and we can work out the differences once it's pushed.
Okay, #19 is the one that conflicts. Most of them are trivial conflicts, e.g. where my code has 0.10 and your code has 0.1 (I changed every percentage number to two digits so that nobody would possibly wonder, later, if it was supposed to be 10% or 1%). But some of them are actual conflicts:
Apatite bee, frequency of apatite as a product. Old number was 10% (10 as an int, which became 0.1 correctly), and someone had changed it to 20% (0.2) at some point. I changed it to 0.20 to keep the same values, you changed it to 0.05 to reduce the frequency of apatite. Either one works, but someone who's not me should decide which of these values to keep.
Carbon bee (TE_COAL enum), frequency of carbon combs. Old number from the int-to-float change was 5%, but that had become 0.1 (10%) at some point before my patch. I just changed the number to 0.10 to keep it at 10% since I figured that was a deliberate change at some point in the past, but then the patch you just created has that number at 0.05 (5%) to match the frequency of coal. Either one, 10% or 5%, is fine, but again, someone who's not me needs to decide which of those values to keep.
Endearing bee, frequency of ender pearls. Here you kept the 0.5 (50%) value, whereas I changed it to 0.05 (5%). Looking back at commit 03068d7ddbac45ee49f7ab067138e5e886c0becf, the frequency of ender pearls was 5% (and they were, for some odd reason that I think was a bug, a product of winsome bees instead of endearing bees). The fact that they're now produced by endearing bees is, I think, correct, but here I'm pretty sure that the 0.05 value is correct, and the 0.5 value is wrong.
Botanic bees, frequency of petals. Here your number is 0.10 and mine is 0.01, and I'm pretty sure 0.01 is correct: the old numbers were 1 for botanic bees, 4 for blossom bees, and 16 for floral bees. So the float value for botanic should be 0.01, blossom should be 0.04, and floral should be 0.16 so that there's a proper improvement in the chance as you move down the breeding line.
That's it, I think. All the rest of the differences I found were trivial.
Apatite: 0.10, that sounds like a balanced number to me Carbon: Keep at 0.05, since that was the initial intended value (5%) Endearing speciality: I missed that one, whoops, good catch Botanic: Is already at 0.01 https://github.com/ForestryMC/MagicBees/blob/1.10/1.11-rewrite/src/main/java/magicbees/bees/EnumBeeSpecies.java#L1896
If there are no significant changes (except the wrong value for the Endearing speciality), it might be easier to not merge it, as there are 14 conflicts
Sorry for ruining your PR :(
No worries. :-) Now that there's been a decision, I'll rebase my commit on top of the current branch and push the rebased commit to the PR branch, and the PR will still be mergeable. (I write C# for my day job and I'm very familiar with Git, so that's not a problem at all for me).
I do think it would be a good idea to merge the PR eventually, since I've made a few more improvements like putting 0.10
/ 0.20
/ etc everywhere where the values 0.1
/ 0.2
/ etc were correct. That way there will never again be confusion over whether the 0.1
was supposed to be 10% or 1%. But I'm running out of time for non-work stuff today, so I'll have to wait until tomorrow to rebase this particular PR.
I've pushed a rebased version of #19 now, and it's mergeable. Its only remaining changes are the apatite, carbon and endearing chances, but I also kept in all the places where I changed 0.1 to 0.10, 0.2 to 0.20, and so on. That will allow anyone who reads the code later on to know that those were the intended values.
If you look back at commit 03068d7ddbac45ee49f7ab067138e5e886c0becf in the code history, you'll see that when MysteriousAges updated the MagicBees code from Forestry 3.4 to 3.6, he updated a lot of the bee-products code to use floating-point numbers instead of integers for the chance of producing a given product. (You might have to click on the "Load Diff" link to see the BeeProductHelper.java diff, since it's a large enough diff that GitHub won't display it by default). Previously, the Forestry API specified production chances as integers that represent a percentage (from 0 to 100), and after the 3.6 chances, production chances were floats between 0.0 and 1.0 instead. However, some of the updated values were incorrect: the integer 8 (representing 8%) in some cases became 0.8 (80%) when it should have been 0.08 (8%), so some specialty products ended up being produced ten times as often as intended. For example, here's the before-and-after part of the diff for the Arcane branch of bees:
Notice how Arcane bees now produce Enchanting Drops 90% of the time, instead of 9% of the time as originally intended: that final 0.9 value should have been 0.09.
I've looked back through the Git history, and the incorrect values are still there in the current commits of each of the active branches of the code:
1.11-rewrite
branch (permalink)mc-1.10
branch (permalink)mc-1.7.10
branch (permalink)(Note: the first link in each item above just points to the branch, so if code is added to that file in the future, the highlighted line numbers might not be correct any more. The "permalink" in each item goes to the actual commit hash, so its highlighted line number will always be correct).
You can easily figure out all the affected species by looking through the diff for commit 03068d7ddbac45ee49f7ab067138e5e886c0becf, but here's a list of affected species (and products) for your convenience: