Started by
Chadderbox
on
Topic category: Help with Minecraft modding (Java Edition)
The following procedure is supposed to return a number between 1 and 0, and then X it by 10 to make it a number between 1 and ten, yet it only returns a Gold Nugget. Could someone help me?
I haven't put this in bugs as I think it may be my stupidity with logic, and also after looking at the code, it is exactly what I would write (Math.random() * 10), so I have no clue what is going on here.'
Edit for if the image doesn't work: https://imgur.com/a/I3kTpQw
Edited by Chadderbox on Sat, 02/29/2020 - 09:25
The "anotherNum" variable isn't rounded, so it can have values between two integers too (for example, 2.3 or 7.6). This means it's almost impossible for it to be exactly 7. There should be a block under math with a "floor" operation: it rounds your random number to the integer right below, so its possible values will be exactly 0, 1 ... 9.
Another thing that isn't related is that the "else if number <= 8" is unnecessary: at that point the number is already <= 7, so a simple "else" is enough
Thanks! That helps a lot, I knew it was me being stupid! I should have looked more into the code.