diff options
author | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2022-09-28 12:13:10 +0200 |
---|---|---|
committer | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2022-09-28 12:13:10 +0200 |
commit | f7441f5d4404d52299b37a84ff0ec1e14ac7fa92 (patch) | |
tree | 56810f234a4f244d4d9434a25cd3e088467b98b2 /src/main/java/at/hannibal2 | |
parent | a38f1a3f6fac894f62ed6f80a332a167a030ea4c (diff) | |
download | skyhanni-f7441f5d4404d52299b37a84ff0ec1e14ac7fa92.tar.gz skyhanni-f7441f5d4404d52299b37a84ff0ec1e14ac7fa92.tar.bz2 skyhanni-f7441f5d4404d52299b37a84ff0ec1e14ac7fa92.zip |
stats tuning
Diffstat (limited to 'src/main/java/at/hannibal2')
3 files changed, 200 insertions, 4 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java index 7d70c156d..1456a78f0 100644 --- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java +++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java @@ -21,10 +21,7 @@ import at.hannibal2.skyhanni.features.end.VoidlingExtremistColor; import at.hannibal2.skyhanni.features.fishing.SeaCreatureManager; import at.hannibal2.skyhanni.features.fishing.SeaCreatureMessageShortener; import at.hannibal2.skyhanni.features.fishing.TrophyFishMessages; -import at.hannibal2.skyhanni.features.inventory.HideNotClickableItems; -import at.hannibal2.skyhanni.features.inventory.ItemDisplayOverlayFeatures; -import at.hannibal2.skyhanni.features.inventory.ItemStars; -import at.hannibal2.skyhanni.features.inventory.RngMeterInventory; +import at.hannibal2.skyhanni.features.inventory.*; import at.hannibal2.skyhanni.features.itemabilities.FireVeilWandParticles; import at.hannibal2.skyhanni.features.itemabilities.abilitycooldown.ItemAbilityCooldown; import at.hannibal2.skyhanni.features.minion.MinionFeatures; @@ -152,6 +149,7 @@ public class SkyHanniMod { registerEvent(new PlayerChatFilter()); registerEvent(new HideArmor()); registerEvent(new SlayerQuestWarning()); + registerEvent(new StatsTuning()); Commands.init(); diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/Inventory.java b/src/main/java/at/hannibal2/skyhanni/config/features/Inventory.java index ad0a32b74..7e7b35bf5 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/Inventory.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/Inventory.java @@ -87,4 +87,32 @@ public class Inventory { @ConfigEditorBoolean @ConfigAccordionId(id = 1) public boolean rngMeterSelectedDrop = false; + + @ConfigOption(name = "Stats Tuning", desc = "") + @ConfigEditorAccordion(id = 2) + public boolean statsTuning = false; + + @Expose + @ConfigOption(name = "Selected Stats", desc = "Show the tuning stats in the Thaumaturgy inventory.") + @ConfigEditorBoolean + @ConfigAccordionId(id = 2) + public boolean statsTuningSelectedStats = false; + + @Expose + @ConfigOption(name = "Tuning Points", desc = "Show the amount of selected tuning points in the stats tuning inventory.") + @ConfigEditorBoolean + @ConfigAccordionId(id = 2) + public boolean statsTuningPoints = false; + + @Expose + @ConfigOption(name = "Selected Template", desc = "Highlight the selected template in the stats tuning inventory.") + @ConfigEditorBoolean + @ConfigAccordionId(id = 2) + public boolean statsTuningSelectedTemplate = false; + + @Expose + @ConfigOption(name = "Template Stats", desc = "Show the type of stats for the tuning point templates.") + @ConfigEditorBoolean + @ConfigAccordionId(id = 2) + public boolean statsTuningTemplateStats = false; } diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/StatsTuning.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/StatsTuning.kt new file mode 100644 index 000000000..95b323719 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/StatsTuning.kt @@ -0,0 +1,170 @@ +package at.hannibal2.skyhanni.features.inventory + +import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.events.GuiContainerEvent +import at.hannibal2.skyhanni.events.GuiRenderItemEvent +import at.hannibal2.skyhanni.utils.InventoryUtils +import at.hannibal2.skyhanni.utils.ItemUtils.getLore +import at.hannibal2.skyhanni.utils.ItemUtils.name +import at.hannibal2.skyhanni.utils.LorenzColor +import at.hannibal2.skyhanni.utils.LorenzUtils +import at.hannibal2.skyhanni.utils.RenderUtils.highlight +import net.minecraft.client.Minecraft +import net.minecraft.client.gui.inventory.GuiChest +import net.minecraft.client.renderer.GlStateManager +import net.minecraft.inventory.ContainerChest +import net.minecraftforge.fml.common.eventhandler.EventPriority +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +import java.util.regex.Pattern + +class StatsTuning { + + private val patternStatPoints = Pattern.compile("§7Stat has: §e(\\d+) point(s)?") + + @SubscribeEvent + fun onRenderTemplates(event: GuiRenderItemEvent.RenderOverlayEvent.Post) { + if (!LorenzUtils.inSkyblock) return + + val screen = Minecraft.getMinecraft().currentScreen + if (screen !is GuiChest) return + val chest = screen.inventorySlots as ContainerChest + val chestName = chest.lowerChestInventory.displayName.unformattedText.trim() + + var stackTip = "" + var offsetX = 0 + + val stack = event.stack ?: return + if (SkyHanniMod.feature.inventory.statsTuningTemplateStats) { + if (chestName == "Stats Tuning") { + val name = stack.name ?: return + if (name == "§aLoad") { + var grab = false + val list = mutableListOf<String>() + for (line in stack.getLore()) { + if (line == "§7You are loading:") { + grab = true + continue + } + if (grab) { + if (line == "") { + grab = false + continue + } + val text = line.split(":")[0] + list.add(text) + } + } + if (list.isNotEmpty()) { + stackTip = list.joinToString(" + ") + offsetX = 20 + } + } + } + } + if (SkyHanniMod.feature.inventory.statsTuningSelectedStats) { + if (chestName == "Accessory Bag Thaumaturgy") { + val name = stack.name ?: return + if (name == "§aStats Tuning") { + var grab = false + val list = mutableListOf<String>() + for (line in stack.getLore()) { + if (line == "§7Your tuning:") { + grab = true + continue + } + if (grab) { + if (line == "") { + grab = false + continue + } + val text = line.split(":")[0].split(" ")[0] + "§7" + list.add(text) + } + } + if (list.isNotEmpty()) { + stackTip = list.joinToString(" + ") + offsetX = 3 + } + } + } + } + + + if (stackTip.isNotEmpty()) { + GlStateManager.disableLighting() + GlStateManager.disableDepth() + GlStateManager.disableBlend() + event.fontRenderer.drawStringWithShadow( + stackTip, + (event.x + 17 + offsetX).toFloat(), + (event.y + 9 + -5).toFloat(), + 16777215 + ) + GlStateManager.enableLighting() + GlStateManager.enableDepth() + } + } + + @SubscribeEvent + fun onRenderTuningPoints(event: GuiRenderItemEvent.RenderOverlayEvent.Post) { + if (!LorenzUtils.inSkyblock) return + + val screen = Minecraft.getMinecraft().currentScreen + if (screen !is GuiChest) return + val chest = screen.inventorySlots as ContainerChest + val chestName = chest.lowerChestInventory.displayName.unformattedText.trim() + + var stackTip = "" + + val stack = event.stack ?: return + if (SkyHanniMod.feature.inventory.statsTuningPoints) { + if (chestName == "Stats Tuning") { + for (line in stack.getLore()) { + val matcher = patternStatPoints.matcher(line) + if (matcher.matches()) { + val points = matcher.group(1) + stackTip = points + } + } + } + } + + + if (stackTip.isNotEmpty()) { + GlStateManager.disableLighting() + GlStateManager.disableDepth() + GlStateManager.disableBlend() + event.fontRenderer.drawStringWithShadow( + stackTip, + (event.x + 17 - event.fontRenderer.getStringWidth(stackTip)).toFloat(), + (event.y + 9).toFloat(), + 16777215 + ) + GlStateManager.enableLighting() + GlStateManager.enableDepth() + } + } + + @SubscribeEvent(priority = EventPriority.LOW) + fun onDrawSelectedTemplate(event: GuiContainerEvent.BackgroundDrawnEvent) { + if (!LorenzUtils.inSkyblock) return + + if (event.gui !is GuiChest) return + val guiChest = event.gui + val chest = guiChest.inventorySlots as ContainerChest + val chestName = chest.lowerChestInventory.displayName.unformattedText.trim() + + if (SkyHanniMod.feature.inventory.statsTuningSelectedTemplate) { + if (chestName == "Stats Tuning") { + for (slot in InventoryUtils.getItemsInOpenChest()) { + val stack = slot.stack + val lore = stack.getLore() + + if (lore.any { it == "§aCurrently selected!" }) { + slot highlight LorenzColor.GREEN + } + } + } + } + } +}
\ No newline at end of file |