blah
This commit is contained in:
parent
42dc328562
commit
2804531bf5
|
@ -11,6 +11,32 @@ import net.minecraft.item.ItemStack;
|
|||
import net.minecraft.nbt.NbtCompound;
|
||||
|
||||
public class OverlayRenderer {
|
||||
private record ExpObject(double ExpRequired, double ExpPrevious, String EnchantLevel) {}
|
||||
private static double[] EnchantInfoChampion = { 0, 50000, 100000, 250000, 500000, 1000000, 1500000, 2000000, 2500000, 3000000 };
|
||||
private static double[] EnchantInfoCultivation = { 0, 1000, 5000, 25000, 100000, 300000, 1500000, 5000000, 20000000, 100000000 };
|
||||
private static double[] EnchantInfoExpertise = { 0, 50, 100, 250, 500, 1000, 2500, 5500, 10000, 15000 };
|
||||
private static double[] EnchantInfoCompact = { 0, 100, 500, 1500, 5000, 15000, 50000, 150000, 500000, 1000000 };
|
||||
private static String[] Levels = { "", "I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX", "X" };
|
||||
|
||||
private 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]);
|
||||
|
||||
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];
|
||||
EnchantLevel = Levels[i];
|
||||
break;
|
||||
}
|
||||
else
|
||||
ExpPrevious = InfoTable[i];
|
||||
}
|
||||
return new ExpObject(ExpRequired, ExpPrevious, EnchantLevel);
|
||||
}
|
||||
|
||||
public static void renderOverlay(DrawContext context, float deltaTick) {
|
||||
MinecraftClient Instance = MinecraftClient.getInstance();
|
||||
ClientPlayerEntity player = Instance.player;
|
||||
|
@ -21,11 +47,9 @@ public class OverlayRenderer {
|
|||
ItemStack mainHandItem = player.getMainHandStack();
|
||||
|
||||
double ItemExp = 0;
|
||||
int ItemExpRequired = 0;
|
||||
String EnchantLevel = "null";
|
||||
String EnchantPercent = "0%";
|
||||
int ItemExpPrevious = 0;
|
||||
String EnchantName = "";
|
||||
ExpObject ExpInfo;
|
||||
|
||||
if (mainHandItem == null)
|
||||
return;
|
||||
|
@ -41,198 +65,37 @@ public class OverlayRenderer {
|
|||
if (extraAttributes.contains("champion_combat_xp")) {
|
||||
EnchantName = "Champion";
|
||||
ItemExp = extraAttributes.getDouble("champion_combat_xp");
|
||||
|
||||
if (ItemExp < 50000) {
|
||||
ItemExpRequired = 50000;
|
||||
EnchantLevel = "I";
|
||||
} else if (ItemExp < 100000) {
|
||||
ItemExpRequired = 100000;
|
||||
ItemExpPrevious = 50000;
|
||||
EnchantLevel = "II";
|
||||
} else if (ItemExp < 250000) {
|
||||
ItemExpRequired = 250000;
|
||||
ItemExpPrevious = 100000;
|
||||
EnchantLevel = "III";
|
||||
} else if (ItemExp < 500000) {
|
||||
ItemExpRequired = 500000;
|
||||
ItemExpPrevious = 250000;
|
||||
EnchantLevel = "IV";
|
||||
} else if (ItemExp < 1000000) {
|
||||
ItemExpRequired = 1000000;
|
||||
ItemExpPrevious = 500000;
|
||||
EnchantLevel = "V";
|
||||
} else if (ItemExp < 1500000) {
|
||||
ItemExpRequired = 1500000;
|
||||
ItemExpPrevious = 1000000;
|
||||
EnchantLevel = "VI";
|
||||
} else if (ItemExp < 2000000) {
|
||||
ItemExpRequired = 2000000;
|
||||
ItemExpPrevious = 1500000;
|
||||
EnchantLevel = "VII";
|
||||
} else if (ItemExp < 2500000) {
|
||||
ItemExpRequired = 2500000;
|
||||
ItemExpPrevious = 2000000;
|
||||
EnchantLevel = "VIII";
|
||||
} else if (ItemExp < 3000000) {
|
||||
ItemExpRequired = 3000000;
|
||||
ItemExpPrevious = 2500000;
|
||||
EnchantLevel = "IX";
|
||||
} else if (ItemExp > 3000000) {
|
||||
ItemExpRequired = -1;
|
||||
ItemExpPrevious = 3000000;
|
||||
EnchantLevel = "X";
|
||||
}
|
||||
ExpInfo = getExpInformation(EnchantInfoChampion, ItemExp);
|
||||
}
|
||||
else if (extraAttributes.contains("farmed_cultivating")) {
|
||||
EnchantName = "Cultivating";
|
||||
ItemExp = extraAttributes.getDouble("farmed_cultivating");
|
||||
|
||||
if (ItemExp < 1000) {
|
||||
ItemExpRequired = 1000;
|
||||
EnchantLevel = "I";
|
||||
} else if (ItemExp < 5000) {
|
||||
ItemExpRequired = 5000;
|
||||
ItemExpPrevious = 1000;
|
||||
EnchantLevel = "II";
|
||||
} else if (ItemExp < 25000) {
|
||||
ItemExpRequired = 25000;
|
||||
ItemExpPrevious = 5000;
|
||||
EnchantLevel = "III";
|
||||
} else if (ItemExp < 100000) {
|
||||
ItemExpRequired = 100000;
|
||||
ItemExpPrevious = 25000;
|
||||
EnchantLevel = "IV";
|
||||
} else if (ItemExp < 300000) {
|
||||
ItemExpRequired = 300000;
|
||||
ItemExpPrevious = 100000;
|
||||
EnchantLevel = "V";
|
||||
} else if (ItemExp < 1500000) {
|
||||
ItemExpRequired = 1500000;
|
||||
ItemExpPrevious = 300000;
|
||||
EnchantLevel = "VI";
|
||||
} else if (ItemExp < 5000000) {
|
||||
ItemExpRequired = 5000000;
|
||||
ItemExpPrevious = 1500000;
|
||||
EnchantLevel = "VII";
|
||||
} else if (ItemExp < 20000000) {
|
||||
ItemExpRequired = 20000000;
|
||||
ItemExpPrevious = 5000000;
|
||||
EnchantLevel = "VIII";
|
||||
} else if (ItemExp < 100000000) {
|
||||
ItemExpRequired = 100000000;
|
||||
ItemExpPrevious = 20000000;
|
||||
EnchantLevel = "IX";
|
||||
} else if (ItemExp > 100000000) {
|
||||
ItemExpRequired = -1;
|
||||
ItemExpPrevious = 100000000;
|
||||
EnchantLevel = "X";
|
||||
}
|
||||
ExpInfo = getExpInformation(EnchantInfoCultivation, ItemExp);
|
||||
}
|
||||
else if (extraAttributes.contains("expertise_kills")) {
|
||||
EnchantName = "Expertise";
|
||||
ItemExp = extraAttributes.getDouble("expertise_kills");
|
||||
|
||||
if (ItemExp < 50) {
|
||||
ItemExpRequired = 50;
|
||||
EnchantLevel = "I";
|
||||
} else if (ItemExp < 100) {
|
||||
ItemExpRequired = 100;
|
||||
ItemExpPrevious = 50;
|
||||
EnchantLevel = "II";
|
||||
} else if (ItemExp < 250) {
|
||||
ItemExpRequired = 250;
|
||||
ItemExpPrevious = 100;
|
||||
EnchantLevel = "III";
|
||||
} else if (ItemExp < 500) {
|
||||
ItemExpRequired = 500;
|
||||
ItemExpPrevious = 250;
|
||||
EnchantLevel = "IV";
|
||||
} else if (ItemExp < 1000) {
|
||||
ItemExpRequired = 1000;
|
||||
ItemExpPrevious = 500;
|
||||
EnchantLevel = "V";
|
||||
} else if (ItemExp < 2500) {
|
||||
ItemExpRequired = 2500;
|
||||
ItemExpPrevious = 1000;
|
||||
EnchantLevel = "VI";
|
||||
} else if (ItemExp < 5500) {
|
||||
ItemExpRequired = 5500;
|
||||
ItemExpPrevious = 2500;
|
||||
EnchantLevel = "VII";
|
||||
} else if (ItemExp < 10000) {
|
||||
ItemExpRequired = 10000;
|
||||
ItemExpPrevious = 5500;
|
||||
EnchantLevel = "VIII";
|
||||
} else if (ItemExp < 15000) {
|
||||
ItemExpRequired = 15000;
|
||||
ItemExpPrevious = 10000;
|
||||
EnchantLevel = "IX";
|
||||
} else if (ItemExp > 15000) {
|
||||
ItemExpRequired = -1;
|
||||
ItemExpPrevious = 15000;
|
||||
EnchantLevel = "X";
|
||||
}
|
||||
ExpInfo = getExpInformation(EnchantInfoExpertise, ItemExp);
|
||||
}
|
||||
else if (extraAttributes.contains("compact_blocks")) {
|
||||
EnchantName = "Compact";
|
||||
ItemExp = extraAttributes.getDouble("compact_blocks");
|
||||
|
||||
if (ItemExp < 100) {
|
||||
ItemExpRequired = 100;
|
||||
EnchantLevel = "I";
|
||||
} else if (ItemExp < 500) {
|
||||
ItemExpRequired = 500;
|
||||
ItemExpPrevious = 100;
|
||||
EnchantLevel = "II";
|
||||
} else if (ItemExp < 1500) {
|
||||
ItemExpRequired = 1500;
|
||||
ItemExpPrevious = 500;
|
||||
EnchantLevel = "III";
|
||||
} else if (ItemExp < 5000) {
|
||||
ItemExpRequired = 5000;
|
||||
ItemExpPrevious = 1500;
|
||||
EnchantLevel = "IV";
|
||||
} else if (ItemExp < 15000) {
|
||||
ItemExpRequired = 15000;
|
||||
ItemExpPrevious = 5000;
|
||||
EnchantLevel = "V";
|
||||
} else if (ItemExp < 50000) {
|
||||
ItemExpRequired = 50000;
|
||||
ItemExpPrevious = 15000;
|
||||
EnchantLevel = "VI";
|
||||
} else if (ItemExp < 150000) {
|
||||
ItemExpRequired = 150000;
|
||||
ItemExpPrevious = 50000;
|
||||
EnchantLevel = "VII";
|
||||
} else if (ItemExp < 500000) {
|
||||
ItemExpRequired = 500000;
|
||||
ItemExpPrevious = 150000;
|
||||
EnchantLevel = "VIII";
|
||||
} else if (ItemExp < 1000000) {
|
||||
ItemExpRequired = 1000000;
|
||||
ItemExpPrevious = 500000;
|
||||
EnchantLevel = "IX";
|
||||
} else if (ItemExp > 1000000) {
|
||||
ItemExpRequired = -1;
|
||||
ItemExpPrevious = 15000;
|
||||
EnchantLevel = "X";
|
||||
}
|
||||
ExpInfo = getExpInformation(EnchantInfoCompact, ItemExp);
|
||||
}
|
||||
/*else {
|
||||
System.out.println(extraAttributes);
|
||||
}*/
|
||||
else
|
||||
return;
|
||||
|
||||
// show hud
|
||||
if(ItemExp > 0) {
|
||||
EnchantPercent = new DecimalFormat("##.00")
|
||||
.format((ItemExp - ItemExpPrevious) / (ItemExpRequired - ItemExpPrevious) * 100);
|
||||
EnchantPercent = new DecimalFormat("##0.00")
|
||||
.format((ItemExp - ExpInfo.ExpPrevious) / (ExpInfo.ExpRequired - ExpInfo.ExpPrevious) * 100);
|
||||
|
||||
NumberFormat format = NumberFormat.getIntegerInstance();
|
||||
|
||||
TextRenderer textRenderer = Instance.textRenderer;
|
||||
String text = EnchantName + " " + EnchantLevel + ": "
|
||||
String text = EnchantName + " " + ExpInfo.EnchantLevel + ": "
|
||||
+ format.format(ItemExp) + " / "
|
||||
+ (ItemExpRequired == -1 ? "Maxed" : format.format(ItemExpRequired) + " (" + EnchantPercent + "%)");
|
||||
+ (ExpInfo.EnchantLevel == "X" ? "Maxed" : format.format(ExpInfo.ExpRequired) + " (" + EnchantPercent + "%)");
|
||||
int width = context.getScaledWindowWidth();
|
||||
int height = context.getScaledWindowHeight();
|
||||
int textWidth = textRenderer.getWidth(text);
|
||||
|
|
Loading…
Reference in New Issue
Block a user