diff --git a/src/main/java/lul/flummi/championoverlay/client/rendering/OverlayRenderer.java b/src/main/java/lul/flummi/championoverlay/client/rendering/OverlayRenderer.java index 3d8b5ac..a2fd971 100644 --- a/src/main/java/lul/flummi/championoverlay/client/rendering/OverlayRenderer.java +++ b/src/main/java/lul/flummi/championoverlay/client/rendering/OverlayRenderer.java @@ -38,29 +38,16 @@ public class OverlayRenderer { NbtCompound extraAttributes = tags.getCompound("ExtraAttributes"); if (extraAttributes == null) return; - - if (extraAttributes.contains("champion_combat_xp")) { - EnchantName = "Champion"; - ItemExp = extraAttributes.getDouble("champion_combat_xp"); - ExpInfo = ExpTools.getExpInformation(ExpTools.EnchantInfoChampion, ItemExp); + + for (int i = 0; i < ExpTools.internalNames.length; i++) { + String internalName = ExpTools.internalNames[i]; + if (extraAttributes.contains(internalName)) { + EnchantName = ExpTools.displayNames[i]; + ItemExp = extraAttributes.getDouble(internalName); + ExpInfo = ExpTools.getExpInformation(ExpTools.levelTable[i], ItemExp); + break; + } } - else if (extraAttributes.contains("farmed_cultivating")) { - EnchantName = "Cultivating"; - ItemExp = extraAttributes.getDouble("farmed_cultivating"); - ExpInfo = ExpTools.getExpInformation(ExpTools.EnchantInfoCultivation, ItemExp); - } - else if (extraAttributes.contains("expertise_kills")) { - EnchantName = "Expertise"; - ItemExp = extraAttributes.getDouble("expertise_kills"); - ExpInfo = ExpTools.getExpInformation(ExpTools.EnchantInfoExpertise, ItemExp); - } - else if (extraAttributes.contains("compact_blocks")) { - EnchantName = "Compact"; - ItemExp = extraAttributes.getDouble("compact_blocks"); - ExpInfo = ExpTools.getExpInformation(ExpTools.EnchantInfoCompact, ItemExp); - } - else - return; // show hud if(ItemExp > 0) { diff --git a/src/main/java/lul/flummi/championoverlay/utils/ExpTools.java b/src/main/java/lul/flummi/championoverlay/utils/ExpTools.java index 4be6f40..9c6fb4d 100644 --- a/src/main/java/lul/flummi/championoverlay/utils/ExpTools.java +++ b/src/main/java/lul/flummi/championoverlay/utils/ExpTools.java @@ -1,12 +1,17 @@ package lul.flummi.championoverlay.utils; public class ExpTools { - public static double[] EnchantInfoChampion = { 0, 50000, 100000, 250000, 500000, 1000000, 1500000, 2000000, 2500000, 3000000 }; - public static double[] EnchantInfoCultivation = { 0, 1000, 5000, 25000, 100000, 300000, 1500000, 5000000, 20000000, 100000000 }; - public static double[] EnchantInfoExpertise = { 0, 50, 100, 250, 500, 1000, 2500, 5500, 10000, 15000 }; - public static double[] EnchantInfoCompact = { 0, 100, 500, 1500, 5000, 15000, 50000, 150000, 500000, 1000000 }; public static String[] Levels = { "", "I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX", "X" }; + public static String[] internalNames = { "champion_combat_xp", "farmed_cultivating", "expertise_kills", "compact_blocks" }; + public static String[] displayNames = { "Champion", "Cultivating", "Expertise", "Compact" }; + public static double[][] levelTable = { + { 50000, 1, 2, 5, 10, 20, 30, 40, 50, 60 }, + { 1000, 1, 5, 25, 100, 3000, 15000, 50000, 20000, 100000 }, + { 50, 1, 2, 5, 10, 20, 50, 110, 200, 300 }, + { 100, 1, 5, 15, 50, 150, 500, 1500, 5000, 10000 } + }; + public static class ExpObject { public final double ExpRequired; public final double ExpPrevious; @@ -20,20 +25,21 @@ public class ExpTools { } public static ExpObject getExpInformation(double[] InfoTable, double itemExp) { - if (itemExp >= InfoTable[InfoTable.length - 1]) - return new ExpObject(-1, InfoTable[InfoTable.length - 1], Levels[Levels.length - 1]); + if (itemExp >= InfoTable[InfoTable.length - 1] * InfoTable[0]) + return new ExpObject(-1, InfoTable[InfoTable.length - 1] * InfoTable[0], Levels[Levels.length - 1]); double ExpRequired = 0; double ExpPrevious = 0; String EnchantLevel = Levels[0]; - for (int i = 0; i < InfoTable.length; i++) { - if (itemExp < InfoTable[i]) { - ExpRequired = InfoTable[i]; + for (int i = 1; i < InfoTable.length; i++) { + double j = InfoTable[0] * InfoTable[i]; + if (itemExp < j) { + ExpRequired = j; EnchantLevel = Levels[i]; break; } else - ExpPrevious = InfoTable[i]; + ExpPrevious = j; } return new ExpObject(ExpRequired, ExpPrevious, EnchantLevel); }