aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorQuetz4l <aizektro@gmail.com>2024-03-24 23:02:42 +0200
committerGitHub <noreply@github.com>2024-03-24 22:02:42 +0100
commita469127b5c0423fb9e6ddb19dd4d881f4e49a609 (patch)
tree76873a7eb4fbd46dc54be4566678735f7353beb8 /src
parent60e4d7a1836a08be907e551b154de65c7832d165 (diff)
downloadGT5-Unofficial-a469127b5c0423fb9e6ddb19dd4d881f4e49a609.tar.gz
GT5-Unofficial-a469127b5c0423fb9e6ddb19dd4d881f4e49a609.tar.bz2
GT5-Unofficial-a469127b5c0423fb9e6ddb19dd4d881f4e49a609.zip
add info for lsc (#84)
* add info for lsc update bs and dep * add info for lsc-> change calculate function * add info for lsc-> optimization function
Diffstat (limited to 'src')
-rw-r--r--src/main/java/common/tileentities/GTMTE_LapotronicSuperCapacitor.java15
-rw-r--r--src/main/java/util/Util.java38
2 files changed, 50 insertions, 3 deletions
diff --git a/src/main/java/common/tileentities/GTMTE_LapotronicSuperCapacitor.java b/src/main/java/common/tileentities/GTMTE_LapotronicSuperCapacitor.java
index 9ec6529389..37b1489319 100644
--- a/src/main/java/common/tileentities/GTMTE_LapotronicSuperCapacitor.java
+++ b/src/main/java/common/tileentities/GTMTE_LapotronicSuperCapacitor.java
@@ -23,6 +23,8 @@ import static gregtech.api.metatileentity.BaseTileEntity.TOOLTIP_DELAY;
import static gregtech.api.util.GT_StructureUtility.buildHatchAdder;
import static gregtech.api.util.GT_StructureUtility.filterByMTEClass;
import static java.lang.Math.min;
+import static util.Util.toPercentageFrom;
+import static util.Util.toStandardForm;
import java.math.BigInteger;
import java.text.NumberFormat;
@@ -907,8 +909,11 @@ public class GTMTE_LapotronicSuperCapacitor extends
final ArrayList<String> ll = new ArrayList<>();
ll.add(EnumChatFormatting.YELLOW + "Operational Data:" + EnumChatFormatting.RESET);
- ll.add("Used Capacity: " + nf.format(stored) + "EU");
- ll.add("Total Capacity: " + nf.format(capacity) + "EU");
+ ll.add("EU Stored (exact): " + nf.format(stored) + "EU");
+ ll.add("EU Stored: " + toStandardForm(stored) + "EU");
+ ll.add("Used Capacity: " + toPercentageFrom(stored, capacity));
+ ll.add("Total Capacity (exact): " + nf.format(capacity) + "EU");
+ ll.add("Total Capacity: " + toStandardForm(capacity) + "EU");
ll.add("Passive Loss: " + nf.format(passiveDischargeAmount) + "EU/t");
ll.add("EU IN: " + GT_Utility.formatNumbers(inputLastTick) + "EU/t");
ll.add("EU OUT: " + GT_Utility.formatNumbers(outputLastTick) + "EU/t");
@@ -942,8 +947,12 @@ public class GTMTE_LapotronicSuperCapacitor extends
+ " Capacitors detected: "
+ getUMVCapacitorCount());
ll.add(
- "Total wireless EU: " + EnumChatFormatting.RED
+ "Total wireless EU (exact): " + EnumChatFormatting.RED
+ GT_Utility.formatNumbers(WirelessNetworkManager.getUserEU(global_energy_user_uuid)));
+ ll.add(
+ "Total wireless EU: " + EnumChatFormatting.RED
+ + toStandardForm(WirelessNetworkManager.getUserEU(global_energy_user_uuid)));
+
ll.add("---------------------------------------------");
final String[] a = new String[ll.size()];
diff --git a/src/main/java/util/Util.java b/src/main/java/util/Util.java
index 6a56dfa8aa..17bcf2b841 100644
--- a/src/main/java/util/Util.java
+++ b/src/main/java/util/Util.java
@@ -1,8 +1,14 @@
package util;
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.math.RoundingMode;
+import java.text.DecimalFormat;
+import java.text.DecimalFormatSymbols;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
+import java.util.Locale;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidStack;
@@ -12,6 +18,17 @@ import common.items.ErrorItem;
public class Util {
+ protected static final DecimalFormat percentFormatRound_6 = new DecimalFormat("0.000000%");
+ protected static final DecimalFormat percentFormatRound_2 = new DecimalFormat("0.00%");
+ protected static final BigDecimal Threshold_1 = BigDecimal.valueOf(0.01);
+ protected static DecimalFormat standardFormat;
+
+ static {
+ DecimalFormatSymbols dfs = new DecimalFormatSymbols(Locale.US);
+ dfs.setExponentSeparator("x10^");
+ standardFormat = new DecimalFormat("0.00E0", dfs);
+ }
+
public static ItemStack getStackofAmountFromOreDict(String oredictName, final int amount) {
final ArrayList<ItemStack> list = OreDictionary.getOres(oredictName);
if (!list.isEmpty()) {
@@ -48,4 +65,25 @@ public class Util {
}
return ret;
}
+
+ /* If the number is less than 1, we round by the 6, otherwise to 2 */
+ public static String toPercentageFrom(BigInteger value, BigInteger maxValue) {
+ BigDecimal result = new BigDecimal(value).setScale(6, RoundingMode.HALF_UP)
+ .divide(new BigDecimal(maxValue), RoundingMode.HALF_UP);
+ if (result.compareTo(Threshold_1) < 0) {
+ return percentFormatRound_6.format(result);
+ } else {
+ return percentFormatRound_2.format(result);
+ }
+ }
+
+ /* Get a string like this: 4.56*10^25 */
+ public static String toStandardForm(BigInteger number) {
+ if (BigInteger.ZERO.equals(number)) {
+ return "0";
+ }
+
+ return standardFormat.format(number);
+ }
+
}