From f8f7940839d43f3c8ed3dd9d60599d002870763e Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Sat, 29 Oct 2016 12:23:01 +0200 Subject: [PATCH] Added digit separators for large numbers, closes #305 --- .../actuallyadditions/mod/inventory/gui/EnergyDisplay.java | 4 +++- .../actuallyadditions/mod/inventory/gui/FluidDisplay.java | 5 ++++- .../actuallyadditions/mod/items/base/ItemEnergy.java | 6 +++++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/EnergyDisplay.java b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/EnergyDisplay.java index fc436daec..153ef82a1 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/EnergyDisplay.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/EnergyDisplay.java @@ -22,6 +22,7 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.text.TextFormatting; import net.minecraftforge.fml.client.config.GuiUtils; +import java.text.NumberFormat; import java.util.ArrayList; import java.util.List; @@ -102,7 +103,8 @@ public class EnergyDisplay extends Gui{ } private String getOverlayText(){ - return this.rfReference.getEnergyStored()+"/"+this.rfReference.getMaxEnergyStored()+(this.displayTesla ? " T" : " RF"); + NumberFormat format = NumberFormat.getInstance(); + return format.format(this.rfReference.getEnergyStored())+"/"+format.format(this.rfReference.getMaxEnergyStored())+(this.displayTesla ? " T" : " RF"); } private void changeDisplayMode(){ diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/FluidDisplay.java b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/FluidDisplay.java index 9a0042014..fad6f0215 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/FluidDisplay.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/FluidDisplay.java @@ -21,6 +21,7 @@ import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidTank; import net.minecraftforge.fml.client.config.GuiUtils; +import java.text.NumberFormat; import java.util.Collections; public class FluidDisplay extends Gui{ @@ -103,7 +104,9 @@ public class FluidDisplay extends Gui{ } private String getOverlayText(){ + NumberFormat format = NumberFormat.getInstance(); FluidStack stack = this.fluidReference.getFluid(); - return stack == null || stack.getFluid() == null ? "0/"+this.fluidReference.getCapacity()+" mB" : this.fluidReference.getFluidAmount()+"/"+this.fluidReference.getCapacity()+" mB "+stack.getLocalizedName(); + String cap = format.format(this.fluidReference.getCapacity()); + return stack == null || stack.getFluid() == null ? "0/"+cap+" mB" : format.format(this.fluidReference.getFluidAmount())+"/"+cap+" mB "+stack.getLocalizedName(); } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/base/ItemEnergy.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/base/ItemEnergy.java index 8e773bae6..0ed142248 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/base/ItemEnergy.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/base/ItemEnergy.java @@ -12,6 +12,7 @@ package de.ellpeck.actuallyadditions.mod.items.base; import cofh.api.energy.ItemEnergyContainer; import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; +import de.ellpeck.actuallyadditions.mod.data.PlayerData; import de.ellpeck.actuallyadditions.mod.util.ItemUtil; import de.ellpeck.actuallyadditions.mod.util.compat.ItemTeslaWrapper; import net.minecraft.creativetab.CreativeTabs; @@ -24,6 +25,7 @@ import net.minecraftforge.common.capabilities.ICapabilityProvider; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; +import java.text.NumberFormat; import java.util.List; public abstract class ItemEnergy extends ItemEnergyContainer{ @@ -64,7 +66,9 @@ public abstract class ItemEnergy extends ItemEnergyContainer{ @Override public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean bool){ - list.add(this.getEnergyStored(stack)+"/"+this.getMaxEnergyStored(stack)+" RF"); + NumberFormat format = NumberFormat.getInstance(); + boolean tesla = PlayerData.getDataFromPlayer(player).theCompound.getBoolean("DisplayTesla"); + list.add(format.format(this.getEnergyStored(stack))+"/"+format.format(this.getMaxEnergyStored(stack))+(tesla ? " T" : " RF")); } @Override