Topic category: Help with Minecraft modding (Java Edition)
I have coal generator procedure and I want to create progress bar. The max cpacity of generator is 16000. So I want to change range from 0 to 16000 to from 0 to 20. So I am doing this: <energy> / 16000 * 20 = <progress>.
In calculator it's working, but not in MCreator. I have this block in my procedure: https://imgur.com/a/aO8jptH. But it don't work. I always get zero in "progress" tag and it changes to 20 only if block is fully charged. I created logs in console and i know that "get energy" block gives me true value. So MCreator thinks that eg. 1000 / 16000 * 20 = 0. This result is obviously incorrect becouse true result is 1,25. I am rounding it so it's should be 1. I'm doing something wrong or MCreator's division/multiplication is strange or broken?
Divide by 16000.0, or it will be rounded to int, which is rounded to 0.
This is how Java divides numbers.
So how I can do what I want?
He literally said divide by 16000.0
Oh, sorry i don't saw this 0 in the end.
Klemen's solution does not work for me.
I am attempting to divide the value of a gamerule by 100 to determine a percentage. With Klemen's solution, I should just have to change the number to 100.0, but if I try to add the .0 to the end of the number, it reverts to 100. It does not allow me to put 100.0. I also tried 16000.0 from the specific example above and that didn't work either.
How do I solve this in 2024.3?
I've managed to find a temporary solution by locking the procedure's code and changing the value in the code, but I need a long-term solution that isn't going to require me to lock the procedure.
Can you show specific procedure that is causing this?
There were some bug cases with this that were fixed in 2024.4