muh
This commit is contained in:
parent
2804531bf5
commit
2ad8838768
|
@ -10,33 +10,10 @@ import net.minecraft.client.network.ClientPlayerEntity;
|
|||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NbtCompound;
|
||||
|
||||
import lul.flummi.championoverlay.utils.ExpTools;
|
||||
import lul.flummi.championoverlay.utils.ExpTools.ExpObject;
|
||||
|
||||
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;
|
||||
|
@ -49,7 +26,7 @@ public class OverlayRenderer {
|
|||
double ItemExp = 0;
|
||||
String EnchantPercent = "0%";
|
||||
String EnchantName = "";
|
||||
ExpObject ExpInfo;
|
||||
ExpObject ExpInfo = null;
|
||||
|
||||
if (mainHandItem == null)
|
||||
return;
|
||||
|
@ -65,22 +42,22 @@ public class OverlayRenderer {
|
|||
if (extraAttributes.contains("champion_combat_xp")) {
|
||||
EnchantName = "Champion";
|
||||
ItemExp = extraAttributes.getDouble("champion_combat_xp");
|
||||
ExpInfo = getExpInformation(EnchantInfoChampion, ItemExp);
|
||||
ExpInfo = ExpTools.getExpInformation(ExpTools.EnchantInfoChampion, ItemExp);
|
||||
}
|
||||
else if (extraAttributes.contains("farmed_cultivating")) {
|
||||
EnchantName = "Cultivating";
|
||||
ItemExp = extraAttributes.getDouble("farmed_cultivating");
|
||||
ExpInfo = getExpInformation(EnchantInfoCultivation, ItemExp);
|
||||
ExpInfo = ExpTools.getExpInformation(ExpTools.EnchantInfoCultivation, ItemExp);
|
||||
}
|
||||
else if (extraAttributes.contains("expertise_kills")) {
|
||||
EnchantName = "Expertise";
|
||||
ItemExp = extraAttributes.getDouble("expertise_kills");
|
||||
ExpInfo = getExpInformation(EnchantInfoExpertise, ItemExp);
|
||||
ExpInfo = ExpTools.getExpInformation(ExpTools.EnchantInfoExpertise, ItemExp);
|
||||
}
|
||||
else if (extraAttributes.contains("compact_blocks")) {
|
||||
EnchantName = "Compact";
|
||||
ItemExp = extraAttributes.getDouble("compact_blocks");
|
||||
ExpInfo = getExpInformation(EnchantInfoCompact, ItemExp);
|
||||
ExpInfo = ExpTools.getExpInformation(ExpTools.EnchantInfoCompact, ItemExp);
|
||||
}
|
||||
else
|
||||
return;
|
||||
|
|
40
src/main/java/lul/flummi/championoverlay/utils/ExpTools.java
Normal file
40
src/main/java/lul/flummi/championoverlay/utils/ExpTools.java
Normal file
|
@ -0,0 +1,40 @@
|
|||
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 class ExpObject {
|
||||
public final double ExpRequired;
|
||||
public final double ExpPrevious;
|
||||
public final String EnchantLevel;
|
||||
|
||||
public ExpObject(double ExpRequired, double ExpPrevious, String EnchantLevel) {
|
||||
this.ExpRequired = ExpRequired;
|
||||
this.ExpPrevious = ExpPrevious;
|
||||
this.EnchantLevel = EnchantLevel;
|
||||
}
|
||||
}
|
||||
|
||||
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]);
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user