Strange division in MCreator

Started by kamik1979 on

Topic category: Help with modding (Java Edition)

Last seen on 20:23, 19. Nov 2020
Joined Feb 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Strange division in MCreator

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…
Tue, 11/17/2020 - 14:32

Divide by 16000.0, or it will be rounded to int, which is rounded to 0.

This is how Java divides numbers.

Last seen on 20:23, 19. Nov 2020
Joined Feb 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
So how I can do what I want?
Tue, 11/17/2020 - 17:15

So how I can do what I want?

Last seen on 14:43, 2. Aug 2022
Joined Nov 2018
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
He literally said divide by…
Tue, 11/17/2020 - 18:02

He literally said divide by 16000.0

Last seen on 20:23, 19. Nov 2020
Joined Feb 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Oh, sorry i don't saw this 0…
Wed, 11/18/2020 - 09:49

Oh, sorry i don't saw this 0 in the end.