Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EMC/s numeric display is not working as intended when you are losing EMC over time #16

Closed
James103 opened this issue Mar 18, 2022 · 4 comments
Labels
1.15 Issues pertaining to the 1.15 version 1.16 Issues pertaining to the 1.16 version bug Something isn't working Fixed The issue has been fixed.

Comments

@James103
Copy link

James103 commented Mar 18, 2022

As of mod version 1.0.11 for Minecraft 1.16.5, losing EMC over time shows two minus signs in front of the number, like below:

To reproduce:

  1. Use a Transmutation Table or something similar to put in some items.
  2. Wait 5 seconds.
  3. Use a Transmutation Table or similar to take out many items.
  4. Notice that the EMC display shows you are losing EMC, but with 2 minus signs instead of 1.
    image

To reproduce with larger numbers, which cause the number to not be shortened when required:

  1. emc set @s 1000000000000
  2. Wait 5 seconds
  3. emc set @s 100000000000
  4. Notice that the EMC display shows you are losing EMC, but the number is not formatted.
    image

This may be caused by the following line of code prepending a negative sign to a negative number that formats to a string generated by the EMCFormat.INSTANCE.format function which already contains a leading negative sign:

if(!change.equals(BigInteger.ZERO)) str += " " + (change.compareTo(BigInteger.ZERO) > 0 ? (TextFormatting.GREEN + "+") : (TextFormatting.RED + "-")) + EMCFormat.INSTANCE.format(change.doubleValue()) + "/s";

@DonovanDMC
Copy link
Owner

Pretty sure I even saw this issue while fixing #15 and just paid no mind to it, this seems like an easy fix that I should be able to get done once I'm back at home later

@DonovanDMC DonovanDMC added bug Something isn't working 1.16 Issues pertaining to the 1.16 version 1.15 Issues pertaining to the 1.15 version labels Mar 19, 2022
@James103
Copy link
Author

The number format breaking for negative numbers is because the format function does not check that the number is negative before formatting the number.

@DonovanDMC
Copy link
Owner

DonovanDMC commented Mar 20, 2022

Fixed in [1.16] 1.0.12

@DonovanDMC
Copy link
Owner

DonovanDMC commented Mar 20, 2022

Backported to 1.15 in [1.15] 1.0.11

@DonovanDMC DonovanDMC added the Fixed The issue has been fixed. label Mar 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1.15 Issues pertaining to the 1.15 version 1.16 Issues pertaining to the 1.16 version bug Something isn't working Fixed The issue has been fixed.
Projects
None yet
Development

No branches or pull requests

2 participants