diff options
author | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-02-24 20:52:54 +0100 |
---|---|---|
committer | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-02-24 20:52:54 +0100 |
commit | ff29d43793b8ebee6c88f46c182e5a5ea6c51049 (patch) | |
tree | a293c9bf843242ceb95c180088d6ed9708b619ec | |
parent | eb7f8ac4b8ddcb420e6e63cfda9d8db9941d1bf5 (diff) | |
download | skyhanni-ff29d43793b8ebee6c88f46c182e5a5ea6c51049.tar.gz skyhanni-ff29d43793b8ebee6c88f46c182e5a5ea6c51049.tar.bz2 skyhanni-ff29d43793b8ebee6c88f46c182e5a5ea6c51049.zip |
Fixed errors and flickering with the garden visitor item need list rendering.
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/garden/GardenVisitorFeatures.kt | 22 | ||||
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt | 2 |
2 files changed, 15 insertions, 9 deletions
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 7cae1bf81..d43bac5b6 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenVisitorFeatures.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenVisitorFeatures.kt @@ -24,6 +24,7 @@ class GardenVisitorFeatures { private val display = mutableListOf<List<Any>>() private var lastClickedNpc = 0 private var nearby = false + private var tick = 0 @SubscribeEvent fun onChatPacket(event: InventoryOpenEvent) { @@ -63,9 +64,14 @@ class GardenVisitorFeatures { } private fun update() { + val list = drawDisplay() display.clear() + display.addAll(list) + } - if (!SkyHanniMod.feature.garden.visitorNeedsDisplay) return + private fun drawDisplay(): List<List<Any>> { + val newDisplay = mutableListOf<List<Any>>() + if (!SkyHanniMod.feature.garden.visitorNeedsDisplay) return newDisplay val requiredItems = mutableMapOf<String, Int>() val newVisitors = mutableListOf<String>() @@ -80,27 +86,27 @@ class GardenVisitorFeatures { } } if (requiredItems.isNotEmpty()) { - display.add(Collections.singletonList("§7Visitor items needed:")) + newDisplay.add(Collections.singletonList("§7Visitor items needed:")) for ((name, amount) in requiredItems) { val internalName = NEUItems.getInternalName(name) val itemStack = NEUItems.getItemStack(internalName) - display.add(listOf(" §7- ", itemStack, "$name §8x$amount")) + newDisplay.add(listOf(" §7- ", itemStack, "$name §8x$amount")) } } if (newVisitors.isNotEmpty()) { if (requiredItems.isNotEmpty()) { - display.add(Collections.singletonList("")) + newDisplay.add(Collections.singletonList("")) } val amount = newVisitors.size val visitorLabel = if (amount == 1) "visitor" else "visitors" - display.add(Collections.singletonList("§e$amount §7new $visitorLabel:")) + newDisplay.add(Collections.singletonList("§e$amount §7new $visitorLabel:")) for (visitor in newVisitors) { - display.add(Collections.singletonList(" §7- $visitor")) + newDisplay.add(Collections.singletonList(" §7- $visitor")) } } - } - var tick = 0 + return newDisplay + } @SubscribeEvent fun onTooltip(event: ItemTooltipEvent) { diff --git a/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt index a72483cb1..cec4cfb3c 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt @@ -475,7 +475,7 @@ object RenderUtils { if (list.isEmpty()) return var offsetY = 0 - for (line in list) { + for (line in list.toMutableList()) { renderLine(line, offsetY) offsetY += 10 + extraSpace + 2 } |