Number From Text Not Working Correctly

Started by Derper93 on

Topic category: Help with modding (Java Edition)

Last seen on 05:26, 11. Jul 2021
Joined Nov 2018
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Number From Text Not Working Correctly
Mon, 06/28/2021 - 00:07 (edited)

Previous Title: Wireless Energy Transfer not Sending Energy

I've been attempting to set up a wireless energy transfer system via a linking tool (storing the receiving block's coordinates, then adding them to an NBT tag on the sending block). I've checked all the way through, the tag's correct, it separates the sub-strings correctly, and the extraction & send tests go through. But, it never actually sends or removes any energy, no matter the configuration of the blocks. Some help, please?

Image of the Energy Sending Procedure

EDIT: After some review, it seems that the offset coordinates (the variables ending in -off) aren't different from the raw xyz coordinates, despite the fact that the NBT logic goes through and sends out the offset value. Does anyone know why the additions aren't working?

BIG EDIT: I've gone and done some more testing, and as it turns out, despite the fact that the substring block is sending out [whatever number formatted as #.#], number from text always outputs 0. Due to this, and the fact that there weren't any replies before this point, I'm instead changing this post to trying to figure out how to get number from text to actually get a number from text. Any help is greatly appreciated.

BIG EDIT 2: I've now dived into the actual code of the procedure, and apparently number from text uses parseInt and only parseInt. As such, if the input isn't an integer, it just returns the default 0. So, if you ever decide that you want to make a number with decimals into a string and back into a number with decimals without some sort of multiplication workaround, go into the code and replace the Integer.parseInt with Double.parseDouble, and the Int convert just above each with Double convert.

My code is now functional. I hope this helps someone in the future struggling with the same issue. If an MCreator dev sees this, I'd recommend expanding the functionality of the number from text block to choose between doubles and integers.

Edited by Derper93 on Mon, 06/28/2021 - 00:07