From aafc6802b16f7f5b92f7ebcfaff263781f6f9546 Mon Sep 17 00:00:00 2001 From: bowser0000 Date: Sat, 29 Aug 2020 00:30:35 -0400 Subject: Optimize xp to skill level --- src/main/java/me/Danker/utils/Utils.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/main/java/me/Danker/utils') diff --git a/src/main/java/me/Danker/utils/Utils.java b/src/main/java/me/Danker/utils/Utils.java index f0a612e..2dfa9c3 100644 --- a/src/main/java/me/Danker/utils/Utils.java +++ b/src/main/java/me/Danker/utils/Utils.java @@ -22,6 +22,10 @@ import net.minecraft.util.StringUtils; public class Utils { public static boolean inSkyblock = false; + static int[] skillXPPerLevel = {0, 50, 125, 200, 300, 500, 750, 1000, 1500, 2000, 3500, 5000, 7500, 10000, 15000, 20000, 30000, 50000, + 75000, 100000, 200000, 300000, 400000, 500000, 600000, 700000, 800000, 900000, 1000000, 1100000, + 1200000, 1300000, 1400000, 1500000, 1600000, 1700000, 1800000, 1900000, 2000000, 2100000, 2200000, + 2300000, 2400000, 2500000, 2600000, 2750000, 2900000, 3100000, 3400000, 3700000, 4000000}; public static int getItems(String item) { Minecraft mc = Minecraft.getMinecraft(); @@ -167,4 +171,14 @@ public class Utils { return timeFormatted; } + public static double xpToSkillLevel(double xp) { + for (int i = 0, xpAdded = 0; i < skillXPPerLevel.length; i++) { + xpAdded += skillXPPerLevel[i]; + if (xp < xpAdded) { + return (i - 1) + (xp - (xpAdded - skillXPPerLevel[i])) / skillXPPerLevel[i]; + } + } + return 50D; + } + } -- cgit