diff options
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/misc/CurrentPetDisplay.kt | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/CurrentPetDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/CurrentPetDisplay.kt index bb21b7da6..936aa04ae 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/CurrentPetDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/CurrentPetDisplay.kt @@ -3,10 +3,13 @@ package at.hannibal2.skyhanni.features.misc import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.data.ProfileStorageData import at.hannibal2.skyhanni.events.GuiRenderEvent +import at.hannibal2.skyhanni.events.InventoryOpenEvent import at.hannibal2.skyhanni.events.LorenzChatEvent +import at.hannibal2.skyhanni.utils.ItemUtils.getLore import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.LorenzUtils.between import at.hannibal2.skyhanni.utils.RenderUtils.renderString +import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher import at.hannibal2.skyhanni.utils.StringUtils.matchRegex import net.minecraftforge.fml.common.eventhandler.SubscribeEvent @@ -39,6 +42,24 @@ class CurrentPetDisplay { } @SubscribeEvent + fun onInventoryOpen(event: InventoryOpenEvent) { + val config = ProfileStorageData.profileSpecific ?: return + + val inventoryNamePattern = "(?:\\(\\d+/\\d+\\))? Pets".toPattern() + if (!inventoryNamePattern.matcher(event.inventoryName).matches()) return + + val lore = event.inventoryItems[4]?.getLore() ?: return + val selectedPetPattern = "§7§7Selected pet: (?<pet>.*)".toPattern() + for (line in lore) { + selectedPetPattern.matchMatcher(line) { + val newPet = group("pet") + config.currentPet = if (newPet != "§cNone") newPet else "" + } + } + } + + + @SubscribeEvent fun onRenderOverlay(event: GuiRenderEvent.GameOverlayRenderEvent) { if (!LorenzUtils.inSkyBlock) return |