diff options
author | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-05-18 12:37:20 +0200 |
---|---|---|
committer | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-05-18 12:37:20 +0200 |
commit | 76d9ac63df01111c0f067fb9f50ebbbc8a8a7d41 (patch) | |
tree | ca268d7e840368c55c6df6212abc441d4ec4823c /src/main/java/at | |
parent | 26c7d6e52a87cecba7da9af7975363cf798eb110 (diff) | |
download | skyhanni-76d9ac63df01111c0f067fb9f50ebbbc8a8a7d41.tar.gz skyhanni-76d9ac63df01111c0f067fb9f50ebbbc8a8a7d41.tar.bz2 skyhanni-76d9ac63df01111c0f067fb9f50ebbbc8a8a7d41.zip |
Reading the current pet additionally from the pet inventory Fixes #111
Diffstat (limited to 'src/main/java/at')
-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 |