diff options
Diffstat (limited to 'src/main/java/io')
-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"; } |