diff options
author | Futuremappermydud <54294576+Futuremappermydud@users.noreply.github.com> | 2022-07-11 08:45:05 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-11 14:45:05 +0200 |
commit | d4b8c67c9a8dec5f4f84f6385052e584d9cdcc01 (patch) | |
tree | 060815fd4421c7bc660ae7bdb33555ebb25ec2da /src/main | |
parent | 04d6f54c067a5cdab61186eb37f67fef11affa57 (diff) | |
download | NotEnoughUpdates-d4b8c67c9a8dec5f4f84f6385052e584d9cdcc01.tar.gz NotEnoughUpdates-d4b8c67c9a8dec5f4f84f6385052e584d9cdcc01.tar.bz2 NotEnoughUpdates-d4b8c67c9a8dec5f4f84f6385052e584d9cdcc01.zip |
SignCalculator use decimal points in rendered text (#182)
* SignCalculator use decimal points in rendered text
this was really bugging me
* Update /neucalc
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/java/io/github/moulberry/notenoughupdates/commands/misc/CalculatorCommand.java | 5 | ||||
-rw-r--r-- | src/main/java/io/github/moulberry/notenoughupdates/miscgui/SignCalculator.java | 4 |
2 files changed, 7 insertions, 2 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/commands/misc/CalculatorCommand.java b/src/main/java/io/github/moulberry/notenoughupdates/commands/misc/CalculatorCommand.java index e73e3b32..05e2087d 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/commands/misc/CalculatorCommand.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/commands/misc/CalculatorCommand.java @@ -26,6 +26,7 @@ import net.minecraft.command.ICommandSender; import net.minecraft.util.ChatComponentText; import net.minecraft.util.EnumChatFormatting; +import java.text.DecimalFormat; import java.math.BigDecimal; import java.util.Arrays; import java.util.List; @@ -55,9 +56,11 @@ public class CalculatorCommand extends ClientCommandBase { String source = String.join(" ", args); try { BigDecimal calculate = Calculator.calculate(source); + DecimalFormat formatter = new DecimalFormat("#,###.00"); + String lr = formatter.format(calculate); sender.addChatMessage(new ChatComponentText( EnumChatFormatting.YELLOW + "[NEU] " + EnumChatFormatting.WHITE + source + " = " + EnumChatFormatting.GREEN + - calculate.toPlainString() + lr )); } catch (Calculator.CalculatorException e) { sender.addChatMessage(new ChatComponentText( diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/SignCalculator.java b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/SignCalculator.java index 115458c9..f3d4237d 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/SignCalculator.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/SignCalculator.java @@ -31,6 +31,7 @@ import net.minecraft.util.EnumChatFormatting; import net.minecraftforge.client.event.GuiScreenEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import java.text.DecimalFormat; import java.math.BigDecimal; import java.util.Objects; @@ -76,7 +77,8 @@ public class SignCalculator { public String getRenderedString() { if (lastResult != null) { - String lr = lastResult.toPlainString(); + DecimalFormat formatter = new DecimalFormat("#,###.00"); + String lr = formatter.format(lastResult); if (Minecraft.getMinecraft().fontRendererObj.getStringWidth(lr) > 90) { return EnumChatFormatting.WHITE + lastSource + " = " + EnumChatFormatting.RED + "Result too long"; } |