Shadows-of-Fire / Shadows-of-Greg

An addon for GregTech Community Edition with the goal of making it much more complicated and realistic through the use of GregTech 5 Unofficial and GregTech 6 features.
GNU General Public License v3.0
16 stars 30 forks source link

[Feature Request] Add commas to energy stored in fusion reactors. #151

Open royalmustard opened 3 years ago

royalmustard commented 3 years ago

By adding commas ever 3 digits, the amount of energy stored in fusion reactors should become way more readable.

Exaxxion commented 3 years ago

I agree that some manner of formatting would be useful here, but it should be implemented using locale-sensitive number formatting rather than specifically commas.

warjort commented 3 years ago

The normal way to do this would be:

I18n.format("translation.key", number);

where the translation key is

translation.key=EU %,d

The %,d will automatically add the locale specific separator.

Unfortunately, this only works on the client. For multiblocks, the screen output is constructed on the server which means you have to do:

new TextComponentTranslatable("translation.key", number);

But TextComponentTranslatable doesn't support %,d I don't know why, but somebody at mojang decided to trap this formatting and other formatting and convert it to %s

You can't even subclass TextComponentTranslatable because the network serialization is hardwired.

It might be possible to write a coremod that changes the allowable formats by changing the final variable TextComponentTranslatable.STRING_VARIABLE_PATTERN but who knows what that would break?