diff options
4 files changed, 23 insertions, 35 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/data/HyPixelData.kt b/src/main/java/at/hannibal2/skyhanni/data/HyPixelData.kt index 9d620f565..2893e67a4 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/HyPixelData.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/HyPixelData.kt @@ -29,7 +29,7 @@ class HyPixelData { var profile = "" fun readSkyBlockArea(): String { - return ScoreboardData.sidebarLinesFormatted() + return ScoreboardData.sidebarLinesFormatted .firstOrNull { it.startsWith(" §7⏣ ") } ?.substring(5)?.removeColor() ?: "invalid" @@ -101,7 +101,7 @@ class HyPixelData { stranded = false bingo = false - for (line in ScoreboardData.sidebarLinesFormatted()) { + for (line in ScoreboardData.sidebarLinesFormatted) { when (line) { " §7Ⓑ §7Bingo", // No Rank " §bⒷ §bBingo", // Rank 1 diff --git a/src/main/java/at/hannibal2/skyhanni/data/ScoreboardData.kt b/src/main/java/at/hannibal2/skyhanni/data/ScoreboardData.kt index 91cef39a9..6da73b554 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/ScoreboardData.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/ScoreboardData.kt @@ -1,6 +1,5 @@ package at.hannibal2.skyhanni.data -import at.hannibal2.skyhanni.utils.StringUtils.removeColor import net.minecraft.client.Minecraft import net.minecraft.scoreboard.Score import net.minecraft.scoreboard.ScorePlayerTeam @@ -28,9 +27,9 @@ class ScoreboardData { "\uD83C\uDF82", ) - fun sidebarLinesFormatted(): List<String> { + fun formatLines(rawList: List<String>): List<String> { val list = mutableListOf<String>() - for (line in sidebarLinesRaw) { + for (line in rawList) { val seperator = splitIcons.find { line.contains(it) } ?: continue val split = line.split(seperator) val start = split[0] @@ -46,6 +45,9 @@ class ScoreboardData { return list } + var sidebarLinesFormatted: List<String> = emptyList() + + // TODO remove these two var sidebarLines: List<String> = emptyList() var sidebarLinesRaw: List<String> = emptyList() } @@ -54,13 +56,14 @@ class ScoreboardData { fun onTick(event: TickEvent.ClientTickEvent) { if (event.phase != TickEvent.Phase.START) return - val list = fetchScoreboardLines() - sidebarLines = list.map { cleanSB(it) }.reversed() - sidebarLinesRaw = list.reversed() + val list = fetchScoreboardLines().reversed() + sidebarLines = list.map { cleanSB(it) } + sidebarLinesRaw = list + sidebarLinesFormatted = formatLines(list) } private fun cleanSB(scoreboard: String): String { - return scoreboard.removeColor().toCharArray().filter { it.code in 21..126 }.joinToString(separator = "") + return scoreboard.toCharArray().filter { it.code in 21..126 || it.code == 167 }.joinToString(separator = "") } fun fetchScoreboardLines(): List<String> { diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenVisitorFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenVisitorFeatures.kt index 3eb69a2ef..42d58ea8a 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenVisitorFeatures.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenVisitorFeatures.kt @@ -3,6 +3,7 @@ package at.hannibal2.skyhanni.features.garden import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.config.features.Garden import at.hannibal2.skyhanni.data.IslandType +import at.hannibal2.skyhanni.data.ScoreboardData.Companion.sidebarLinesFormatted import at.hannibal2.skyhanni.data.SendTitleHelper import at.hannibal2.skyhanni.events.* import at.hannibal2.skyhanni.mixins.hooks.RenderLivingEntityHelper @@ -26,7 +27,7 @@ class GardenVisitorFeatures { private val visitors = mutableMapOf<String, Visitor>() private val display = mutableListOf<List<Any>>() private var lastClickedNpc = 0 - private var nearby = false + private var onBarnPlot = false private var tick = 0 private val copperPattern = Pattern.compile(" §8\\+§c(.*) Copper") private val config: Garden get() = SkyHanniMod.feature.garden @@ -129,8 +130,6 @@ class GardenVisitorFeatures { @SubscribeEvent fun onTooltip(event: ItemTooltipEvent) { if (!isEnabled()) return - if (!nearby) return - if (!inVisitorInventory) return val name = event.itemStack.name ?: return if (name != "§aAccept Offer") return @@ -215,27 +214,12 @@ class GardenVisitorFeatures { @SubscribeEvent fun onTick(event: TickEvent.ClientTickEvent) { if (!isEnabled()) return - if (!config.visitorNeedsDisplay && !config.visitorHighlight && !config.visitorShowPrice) return - if (tick++ % 60 != 0) return - - val defaultVanillaSkin = LorenzVec(8.4, 72.0, -14.1) - val castleSkin = LorenzVec(-5, 75, 18) - val bambooSkin = LorenzVec(-12, 72, -25) - val hiveSkin = LorenzVec(-17, 71, -19) - val cubeSkin = LorenzVec(-17, 71, -19) - - // TODO Only check current one, ignore others. - val list = mutableListOf<LorenzVec>() - list.add(defaultVanillaSkin) - list.add(castleSkin) - list.add(bambooSkin) - list.add(hiveSkin) - list.add(cubeSkin) - - val playerLocation = LocationUtils.playerLocation() - nearby = list.map { playerLocation.distance(it) < 15 }.any { it } - - if (nearby && config.visitorHighlight) { + if (!config.visitorNeedsDisplay && !config.visitorHighlight) return + if (tick++ % 30 != 0) return + + onBarnPlot = sidebarLinesFormatted.contains(" §7⏣ §aThe Garden") + + if (onBarnPlot && config.visitorHighlight) { checkVisitorsReady() } } @@ -341,7 +325,8 @@ class GardenVisitorFeatures { if (!config.visitorNeedsDisplay) return if (config.visitorNeedsOnlyWhenClose) { - if (!nearby) return + //TODO check if on barn plot (sidebar) + if (!onBarnPlot) return } config.visitorNeedsPos.renderStringsAndItems(display) diff --git a/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerQuestWarning.kt b/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerQuestWarning.kt index 7656f3c0a..16ae900a5 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerQuestWarning.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerQuestWarning.kt @@ -82,7 +82,7 @@ class SlayerQuestWarning { var slayBoss = false var slayerTypeName = "" var nextIsType = false - for (line in ScoreboardData.sidebarLinesFormatted()) { + for (line in ScoreboardData.sidebarLinesFormatted) { if (nextIsType) { slayerTypeName = line.removeColor() nextIsType = false |