use of com.wynntils.core.framework.enums.SkillPoint in project Wynntils by Wynntils.
the class SkillPointOverlay method onRenderItemOverlay.
@SubscribeEvent
public void onRenderItemOverlay(RenderEvent.DrawItemOverlay e) {
if (!Reference.onWorld || !Utils.isCharacterInfoPage(McIf.mc().currentScreen))
return;
ItemStack stack = e.getStack();
// display name also checks for tag compound
if (stack.isEmpty() || !stack.hasDisplayName())
return;
String lore = TextFormatting.getTextWithoutFormattingCodes(ItemUtils.getStringLore(stack));
String name = TextFormatting.getTextWithoutFormattingCodes(stack.getDisplayName());
String value = e.getOverlayText();
// Skill Points
if (!name.contains("Upgrade"))
return;
Matcher spm = SKILLPOINT_PATTERN.matcher(lore);
if (!spm.find())
return;
SkillPoint skillPoint = SkillPoint.findSkillPoint(name);
if (skillPoint != null) {
value = spm.group(1);
if (UtilitiesConfig.Items.INSTANCE.colorSkillPointNumberOverlay)
e.setOverlayTextColor(MinecraftChatColors.fromTextFormatting(skillPoint.getColor()));
ScreenRenderer.beginGL(e.getX(), e.getY());
{
GlStateManager.translate(0, 0, 500);
RenderHelper.disableStandardItemLighting();
renderer.drawString(skillPoint.getColoredSymbol(), 2, 0, CommonColors.WHITE, SmartFontRenderer.TextAlignment.LEFT_RIGHT, SmartFontRenderer.TextShadow.NONE);
RenderHelper.enableGUIStandardItemLighting();
}
ScreenRenderer.endGL();
}
e.setOverlayText(value);
}
use of com.wynntils.core.framework.enums.SkillPoint in project Wynntils by Wynntils.
the class ItemSpecificationOverlay method renderOverlay.
private void renderOverlay(GuiContainer gui) {
if (!Reference.onWorld)
return;
for (Slot s : gui.inventorySlots.inventorySlots) {
ItemStack stack = s.getStack();
// display name also checks for tag compound
if (stack.isEmpty() || !stack.hasDisplayName())
continue;
List<String> lore = ItemUtils.getLore(stack);
String name = StringUtils.normalizeBadString(stack.getDisplayName());
// name and lore fixing
stack.setStackDisplayName(name);
List<String> fixedLore = new ArrayList<>();
for (String line : lore) {
fixedLore.add(StringUtils.normalizeBadString(line));
}
ItemUtils.replaceLore(stack, fixedLore);
String destinationName = null;
CustomColor color = null;
int xOffset = 2;
float scale = 1f;
if (UtilitiesConfig.Items.INSTANCE.unidentifiedSpecification) {
Pattern unidentifiedItem = Pattern.compile("^§.Unidentified (.*)");
Matcher m = unidentifiedItem.matcher(name);
if (m.find()) {
ItemType type = ItemType.from(m.group(1));
if (type != null) {
// Draw an icon representing the type on top
ScreenRenderer.beginGL(0, 0);
GlStateManager.translate(0, 0, 270);
RenderHelper.disableStandardItemLighting();
float scaleFactor = 0.75f;
ScreenRenderer.scale(scaleFactor);
renderer.drawRect(Textures.UIs.hud_overlays, (int) ((gui.getGuiLeft() + s.xPos) / scaleFactor) + 3, (int) ((gui.getGuiTop() + s.yPos) / scaleFactor) + 3, type.getTextureX(), type.getTextureY(), 16, 16);
ScreenRenderer.endGL();
} else {
// This is an un-id:ed but named item
destinationName = "";
color = MinecraftChatColors.GRAY;
}
}
}
if (UtilitiesConfig.Items.INSTANCE.potionSpecification) {
if (name.startsWith("§aPotion of §")) {
SkillPoint skillPoint = SkillPoint.findSkillPoint(name);
destinationName = skillPoint.getSymbol();
color = MinecraftChatColors.fromTextFormatting(skillPoint.getColor());
}
}
if (UtilitiesConfig.Items.INSTANCE.keySpecification) {
Pattern dungeonKey = Pattern.compile("§6(.*) Key");
Matcher m = dungeonKey.matcher(name);
// Lore line is different on TM keys
if (m.find() && lore.size() > 0 && (lore.get(0).equals("§7Grants access to the") || (lore.size() > 4 && lore.get(4).equals("§7Grants access to the")))) {
StringBuilder builder = new StringBuilder();
for (String part : m.group(1).split(" ")) {
builder.append(part.charAt(0));
}
destinationName = builder.toString();
color = MinecraftChatColors.GOLD;
}
Pattern brokenDungeonKey = Pattern.compile("Broken (.*) Key");
Matcher m2 = brokenDungeonKey.matcher(name);
if (m2.find()) {
StringBuilder builder = new StringBuilder();
for (String part : m2.group(1).split(" ")) {
builder.append(part.charAt(0));
}
destinationName = builder.toString();
color = MinecraftChatColors.DARK_RED;
}
// I'm not sure if this happens anymore, but keep it for now
Pattern corruptedDungeonKey = Pattern.compile("§4(?:Broken )?(?:Corrupted )?(.*) Key");
Matcher m3 = corruptedDungeonKey.matcher(name);
if (m3.find()) {
StringBuilder builder = new StringBuilder();
for (String part : m3.group(1).split(" ")) {
builder.append(part.charAt(0));
}
destinationName = builder.toString();
color = MinecraftChatColors.DARK_RED;
}
}
if (UtilitiesConfig.Items.INSTANCE.transportationSpecification) {
Pattern boatPass = Pattern.compile("§b(.*) (?:Boat )?Pass");
Matcher m = boatPass.matcher(name);
if (m.find() && lore.get(0).equals("§7Use this at the §fV.S.S. Seaskipper")) {
destinationName = m.group(1).substring(0, 1);
color = MinecraftChatColors.BLUE;
}
Pattern cityTeleport = Pattern.compile("^§b(.*) Teleport Scroll$");
Matcher m2 = cityTeleport.matcher(name);
if (m2.find()) {
destinationName = m2.group(1);
if (destinationName.equals("Dungeon")) {
color = MinecraftChatColors.GOLD;
for (String loreLine : lore) {
Pattern dungeonTeleport = Pattern.compile("§3- §7Teleports to: §f(.*)");
Matcher m3 = dungeonTeleport.matcher(StringUtils.normalizeBadString(loreLine));
if (m3.find()) {
// Make sure we print "F" for "the Forgery"
destinationName = m3.group(1).replace("the ", "");
break;
}
}
} else {
color = MinecraftChatColors.AQUA;
}
destinationName = destinationName.substring(0, 1);
}
}
if (UtilitiesConfig.Items.INSTANCE.powderSpecification) {
Pattern powder = Powder.POWDER_NAME_PATTERN;
Matcher m = powder.matcher(StringUtils.normalizeBadString(name));
if (m.matches()) {
if (UtilitiesConfig.Items.INSTANCE.romanNumeralItemTier) {
destinationName = m.group(2);
} else {
destinationName = ItemLevelOverlay.romanToArabic(m.group(2));
}
color = Powder.determineChatColor(m.group(1));
xOffset = -1;
scale = UtilitiesConfig.Items.INSTANCE.specificationTierSize;
}
}
if (UtilitiesConfig.Items.INSTANCE.amplifierSpecification) {
if (CorkianAmplifierManager.isAmplifier(stack)) {
if (UtilitiesConfig.Items.INSTANCE.romanNumeralItemTier) {
destinationName = CorkianAmplifierManager.getAmplifierTier(stack);
} else {
destinationName = ItemLevelOverlay.romanToArabic(CorkianAmplifierManager.getAmplifierTier(stack));
}
color = MinecraftChatColors.AQUA;
xOffset = -1;
scale = UtilitiesConfig.Items.INSTANCE.specificationTierSize;
}
}
if (UtilitiesConfig.Items.INSTANCE.emeraldPouchSpecification) {
if (EmeraldPouchManager.isEmeraldPouch(stack)) {
if (UtilitiesConfig.Items.INSTANCE.romanNumeralItemTier) {
destinationName = EmeraldPouchManager.getPouchTier(stack);
} else {
destinationName = ItemLevelOverlay.romanToArabic(EmeraldPouchManager.getPouchTier(stack));
}
color = MinecraftChatColors.GREEN;
xOffset = -1;
scale = UtilitiesConfig.Items.INSTANCE.specificationTierSize;
}
}
if (destinationName != null) {
ScreenRenderer.beginGL((int) (gui.getGuiLeft() / scale), (int) (gui.getGuiTop() / scale));
GlStateManager.translate(0, 0, 260);
GlStateManager.scale(scale, scale, 1);
RenderHelper.disableStandardItemLighting();
// Make a modifiable copy
color = new CustomColor(color);
color.setA(0.8f);
renderer.drawString(destinationName, (s.xPos + xOffset) / scale, (s.yPos + 1) / scale, color, SmartFontRenderer.TextAlignment.LEFT_RIGHT, SmartFontRenderer.TextShadow.OUTLINE);
ScreenRenderer.endGL();
}
}
}
use of com.wynntils.core.framework.enums.SkillPoint in project Wynntils by Wynntils.
the class ConsumableTimerOverlay method addConsumable.
public static void addConsumable(ItemStack stack) {
// display name also checks for the nbt data
if (stack.isEmpty() || !stack.hasDisplayName())
return;
// foods and scrolls have DIAMOND_AXE as their items
if (stack.getItem() != Items.DIAMOND_AXE && stack.getItem() != Items.POTIONITEM && stack.getItem() != Items.SPLASH_POTION)
return;
// vanilla potions needs a special verification, they DON'T start with dark aqua
if (!stack.getDisplayName().startsWith(DARK_AQUA.toString())) {
String displayName = TextFormatting.getTextWithoutFormattingCodes(stack.getDisplayName());
SkillPoint sp = SkillPoint.findSkillPoint(displayName);
ConsumableContainer consumable;
if (sp == null) {
if (displayName.contains("Potion of Mana")) {
consumable = new ConsumableContainer(AQUA + "✺ Mana");
} else {
return;
}
} else {
consumable = new ConsumableContainer(sp.getAsName());
}
List<String> itemLore = ItemUtils.getLore(stack);
for (String line : itemLore) {
line = TextFormatting.getTextWithoutFormattingCodes(line);
// duration | - Duration: <group1> Seconds
Matcher m = DURATION_PATTERN.matcher(line);
if (m.matches() && m.group(1) != null) {
consumable.setExpirationTime(McIf.getSystemTime() + (Integer.parseInt(m.group(1)) * 1000));
// currentMillis + (seconds * 1000)
continue;
}
// effects | - Effect: <id>
m = EFFECT_PATTERN.matcher(line);
if (m.matches()) {
String id = m.group(1);
// continues if id is null or empty
if (id == null || id.isEmpty())
continue;
// removing skill point symbols
for (SkillPoint skillPoint : SkillPoint.values()) {
id = id.replace(skillPoint.getSymbol() + " ", "");
}
m = ItemIdentificationOverlay.ID_PATTERN.matcher(id);
// continues if the effect is not a valid id
if (!m.matches())
continue;
verifyIdentification(m, consumable);
continue;
}
// mana | - Mana: <group1> <mana symbol>
m = MANA_PATTERN.matcher(line);
if (m.matches() && m.group(1) != null) {
consumable.addEffect("Mana", Integer.parseInt(m.group(1)), IdentificationModifier.INTEGER);
}
}
activeConsumables.add(consumable);
updateActiveEffects();
return;
}
// crafted items
String name;
if (stack.getItem() == Items.POTIONITEM || stack.getItem() == Items.SPLASH_POTION)
name = LIGHT_PURPLE + "Ⓛ Potion";
else if (// food, 69 <= damage <= 75
stack.getItemDamage() >= 69 && stack.getItemDamage() <= 75)
name = GOLD + "Ⓐ Food";
else if (// scrolls, 42 <= damage <= 44
stack.getItemDamage() >= 42 && stack.getItemDamage() <= 44)
name = YELLOW + "Ⓔ Scroll";
else
// breaks if not valid
return;
ConsumableContainer consumable = new ConsumableContainer(name);
List<String> itemLore = ItemUtils.getLore(stack);
for (String line : itemLore) {
// remove colors
line = TextFormatting.getTextWithoutFormattingCodes(line);
// duration | - Duration: <group1> Seconds
Matcher m = DURATION_PATTERN.matcher(line);
if (m.matches() && m.group(1) != null) {
consumable.setExpirationTime(McIf.getSystemTime() + (Integer.parseInt(m.group(1)) * 1000));
// currentMillis + (seconds * 1000)
continue;
}
// effects | <Value><Suffix> <ID>
m = ItemIdentificationOverlay.ID_PATTERN.matcher(line);
// continues if not a valid effect
if (!m.matches())
continue;
verifyIdentification(m, consumable);
}
if (!consumable.isValid())
return;
// check for duplicates to avoid doubling timers
for (ConsumableContainer c : activeConsumables) {
if (Math.abs(consumable.getExpirationTime() - c.getExpirationTime()) <= 1000) {
// check within a second
for (String cEf : c.getEffects().keySet()) {
if (consumable.getEffects().containsKey(cEf) && c.getEffects().get(cEf).getCurrentAmount() == consumable.getEffects().get(cEf).getCurrentAmount()) {
// consumable has already been added, ignore this one
return;
}
}
}
}
activeConsumables.add(consumable);
updateActiveEffects();
}
Aggregations