This commit is contained in:
Flummi 2024-05-01 20:29:44 +02:00
parent c048d26b65
commit 6ad8a7a484

View File

@ -10,7 +10,6 @@ import net.minecraft.client.network.ClientPlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NbtCompound;
@SuppressWarnings("resource")
public class OverlayRenderer {
public static void renderOverlay(DrawContext context, float deltaTick) {
MinecraftClient Instance = MinecraftClient.getInstance();
@ -21,76 +20,174 @@ public class OverlayRenderer {
ItemStack mainHandItem = player.getMainHandStack();
double ItemCombatXp = 0;
int ChampionExp = 0;
String ChampionLevel = "null";
String ChampionPercent = "0%";
int ChampionExpCumu = 0;
double ItemExp = 0;
int ItemExpRequired = 0;
String EnchantLevel = "null";
String EnchantPercent = "0%";
int ItemExpPrevious = 0;
String EnchantName = "";
if (mainHandItem != null) {
NbtCompound tags = mainHandItem.getNbt();
if (tags == null || !tags.contains("ExtraAttributes", 10))
return;
if (mainHandItem == null)
return;
NbtCompound extraAttributes = tags.getCompound("ExtraAttributes");
if (extraAttributes == null || !extraAttributes.contains("champion_combat_xp"))
return;
NbtCompound tags = mainHandItem.getNbt();
if (tags == null || !tags.contains("ExtraAttributes", 10))
return;
ItemCombatXp = extraAttributes.getDouble("champion_combat_xp");
NbtCompound extraAttributes = tags.getCompound("ExtraAttributes");
if (extraAttributes == null)
return;
if (extraAttributes.contains("champion_combat_xp")) {
EnchantName = "Champion";
ItemExp = extraAttributes.getDouble("champion_combat_xp");
if (ItemCombatXp < 50000) {
ChampionExp = 50000;
ChampionLevel = "I";
} else if (ItemCombatXp < 100000) {
ChampionExp = 100000;
ChampionExpCumu = 50000;
ChampionLevel = "II";
} else if (ItemCombatXp < 250000) {
ChampionExp = 250000;
ChampionExpCumu = 100000;
ChampionLevel = "III";
} else if (ItemCombatXp < 500000) {
ChampionExp = 500000;
ChampionExpCumu = 250000;
ChampionLevel = "IV";
} else if (ItemCombatXp < 1000000) {
ChampionExp = 1000000;
ChampionExpCumu = 500000;
ChampionLevel = "V";
} else if (ItemCombatXp < 1500000) {
ChampionExp = 1500000;
ChampionExpCumu = 1000000;
ChampionLevel = "VI";
} else if (ItemCombatXp < 2000000) {
ChampionExp = 2000000;
ChampionExpCumu = 1500000;
ChampionLevel = "VII";
} else if (ItemCombatXp < 2500000) {
ChampionExp = 2500000;
ChampionExpCumu = 2000000;
ChampionLevel = "VIII";
} else if (ItemCombatXp < 3000000) {
ChampionExp = 3000000;
ChampionExpCumu = 2500000;
ChampionLevel = "IX";
} else if (ItemCombatXp > 3000000) {
ChampionExp = -1;
ChampionExpCumu = 3000000;
ChampionLevel = "X";
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";
}
ChampionPercent = new DecimalFormat("##.00")
.format((ItemCombatXp - ChampionExpCumu) / (ChampionExp - ChampionExpCumu) * 100);
}
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";
}
}
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";
}
}
/*else {
System.out.println(extraAttributes);
}*/
// show hud
if(ItemCombatXp > 0) {
if(ItemExp > 0) {
EnchantPercent = new DecimalFormat("##.00")
.format((ItemExp - ItemExpPrevious) / (ItemExpRequired - ItemExpPrevious) * 100);
NumberFormat format = NumberFormat.getIntegerInstance();
TextRenderer textRenderer = Instance.textRenderer;
String text = "Champion " + ChampionLevel + ": "
+ format.format(ItemCombatXp) + " / "
+ (ChampionExp == -1 ? "Maxed" : format.format(ChampionExp) + " (" + ChampionPercent + "%)");
String text = EnchantName + " " + EnchantLevel + ": "
+ format.format(ItemExp) + " / "
+ (ItemExpRequired == -1 ? "Maxed" : format.format(ItemExpRequired) + " (" + EnchantPercent + "%)");
int width = context.getScaledWindowWidth();
int height = context.getScaledWindowHeight();
int textWidth = textRenderer.getWidth(text);