diff --git a/CHANGELOG.md b/CHANGELOG.md index a2d4066dd402..6968a28c5875 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -46,6 +46,7 @@ + Added blocks/second display to crop milestone gui and made all crop milestone gui elements customizable/toggleable. + Added farming armor drops counter. + Added **Colored Name** - Show the visitor name in the color of the rarity. ++ Added **Visitor Item Preview** - Show the base type for the required items next to new visitors (Note that some visitors may require any crop) ### Features from other Mods diff --git a/FEATURES.md b/FEATURES.md index 4f3951894661..8d6b451b5074 100644 --- a/FEATURES.md +++ b/FEATURES.md @@ -194,6 +194,7 @@ + Blocks/Second display in crop milestone gui. + Farming armor drops counter + **Colored Name** - Show the visitor name in the color of the rarity. ++ **Visitor Item Preview** - Show the base type for the required items next to new visitors (Note that some visitors may require any crop) ## Commands - /wiki (using hypixel-skyblock.fandom.com instead of Hypixel wiki) diff --git a/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt b/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt index 53ac4f37ea5f..048f4968af66 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt +++ b/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt @@ -53,6 +53,7 @@ object Commands { registerCommand("shreloadbingodata") { BingoCardDisplay.command() } registerCommand("shprintbingohelper") { BingoNextStepHelper.command() } registerCommand("shsetapikey") { ApiDataLoader.command(it) } + registerCommand("shtestgardenvisitors") { LorenzTest.testGardenVisitors() } } private fun registerCommand(name: String, function: (Array) -> Unit) { diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/Garden.java b/src/main/java/at/hannibal2/skyhanni/config/features/Garden.java index 559bb68d3439..eacdea6cd460 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/Garden.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/Garden.java @@ -88,6 +88,12 @@ public class Garden { @ConfigAccordionId(id = 3) public boolean visitorNeedsShowPrice = true; + @Expose + @ConfigOption(name = "Item Preview", desc = "Show the base type for the required items next to new visitors. §cNote that some visitors may require any crop.") + @ConfigEditorBoolean + @ConfigAccordionId(id = 3) + public boolean visitorItemPreview = true; + @Expose @ConfigOption(name = "Visitor Inventory", desc = "") @ConfigAccordionId(id = 1) diff --git a/src/main/java/at/hannibal2/skyhanni/features/damageindicator/DamageIndicatorManager.kt b/src/main/java/at/hannibal2/skyhanni/features/damageindicator/DamageIndicatorManager.kt index eb9367776dd4..cc751e526e54 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/damageindicator/DamageIndicatorManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/damageindicator/DamageIndicatorManager.kt @@ -668,7 +668,7 @@ class DamageIndicatorManager { 270_000 / 2, 270_000 -> 1 0 -> 0 else -> { - LorenzTest.text = "thorn has ${LorenzUtils.formatDouble(realHealth.toDouble())} hp!" + LorenzTest.displayLine = "thorn has ${LorenzUtils.formatDouble(realHealth.toDouble())} hp!" LorenzUtils.error( "Unexpected health of thorn in m4! (${ LorenzUtils.formatDouble( diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenVisitorColorNames.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenVisitorColorNames.kt index 090cfd1b5c44..cf0df59e840c 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenVisitorColorNames.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenVisitorColorNames.kt @@ -11,13 +11,18 @@ class GardenVisitorColorNames { @SubscribeEvent fun onRepoReload(event: RepositoryReloadEvent) { try { - val map = mutableMapOf() + val mapColor = mutableMapOf() + val mapItems = mutableMapOf>() val garden = event.getConstant("Garden")!! for ((name, element) in garden["visitors"].asJsonObject.entrySet()) { - val rarity = element.asJsonObject["rarity"].asString - map[name] = getColor(rarity) + val jsonObject = element.asJsonObject + val rarity = jsonObject["rarity"].asString + mapColor[name] = getColor(rarity) + mapItems[name] = jsonObject["need_items"].asJsonArray.map { it.asString } + } - visitorColor = map + visitorColor = mapColor + visitorItems = mapItems } catch (e: Exception) { e.printStackTrace() @@ -25,8 +30,9 @@ class GardenVisitorColorNames { } } - companion object{ + companion object { private var visitorColor = mapOf() // name -> color code + var visitorItems = mapOf>() fun getColoredName(name: String): String { if (!SkyHanniMod.feature.garden.visitorColoredName) return name 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 16edfec8990d..5ecdad087d7e 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenVisitorFeatures.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenVisitorFeatures.kt @@ -139,7 +139,28 @@ class GardenVisitorFeatures { newDisplay.add(Collections.singletonList("§e$amount §7new $visitorLabel:")) for (visitor in newVisitors) { val displayName = GardenVisitorColorNames.getColoredName(visitor) - newDisplay.add(Collections.singletonList(" §7- $displayName")) + + val list = mutableListOf() + list.add(" §7- $displayName") + + if (config.visitorItemPreview) { + val items = GardenVisitorColorNames.visitorItems[visitor.removeColor()]!! + list.add(" ") + if (items.isEmpty()) { + list.add("§7(§fAny§7)") + } else { + for (item in items) { + try { + val internalName = NEUItems.getInternalName(item) + list.add(NEUItems.getItemStack(internalName)) + } catch (e: Exception) { + list.add(" '$item' ") + } + } + } + } + + newDisplay.add(list) } } diff --git a/src/main/java/at/hannibal2/skyhanni/test/LorenzTest.kt b/src/main/java/at/hannibal2/skyhanni/test/LorenzTest.kt index bc008f43ae42..9f78e54520ab 100644 --- a/src/main/java/at/hannibal2/skyhanni/test/LorenzTest.kt +++ b/src/main/java/at/hannibal2/skyhanni/test/LorenzTest.kt @@ -5,8 +5,10 @@ import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.events.PlaySoundEvent import at.hannibal2.skyhanni.events.ReceiveParticleEvent +import at.hannibal2.skyhanni.features.garden.GardenVisitorColorNames import at.hannibal2.skyhanni.utils.* import at.hannibal2.skyhanni.utils.RenderUtils.renderString +import at.hannibal2.skyhanni.utils.RenderUtils.renderStringsAndItems import net.minecraft.nbt.NBTTagCompound import net.minecraftforge.common.MinecraftForge import net.minecraftforge.event.entity.player.ItemTooltipEvent @@ -16,7 +18,8 @@ import java.io.File class LorenzTest { companion object { - var text = "" + var displayLine = "" + var displayList = listOf>() var a = 1.0 var b = 60.0 @@ -64,6 +67,50 @@ class LorenzTest { // } } + fun testGardenVisitors() { + if (displayList.isNotEmpty()) { + displayList = mutableListOf() + return + } + + val bigList = mutableListOf>() + var list = mutableListOf() + var i = 0 + var errors = 0 + for (item in GardenVisitorColorNames.visitorItems) { + val name = item.key + i++ + if (i == 5) { + i = 0 + bigList.add(list) + list = mutableListOf() + } + + val coloredName = GardenVisitorColorNames.getColoredName(name) + list.add("$coloredName§7 (") + for (itemName in item.value) { + try { + val internalName = NEUItems.getInternalName(itemName) + list.add(NEUItems.getItemStack(internalName)) + } catch (e: Exception) { + LorenzUtils.debug("itemName '$itemName' is invalid for visitor '$name'") + errors++ + } + } + if (item.value.isEmpty()) { + list.add("Any") + } + list.add("§7) ") + } + bigList.add(list) + displayList = bigList + if (errors == 0) { + LorenzUtils.debug("Test garden visitor renderer: no errors") + } else { + LorenzUtils.debug("Test garden visitor renderer: $errors errors") + } + } + fun reloadListeners() { val blockedFeatures = try { File("config/skyhanni/blocked-features.txt").readLines().toList() @@ -131,7 +178,8 @@ class LorenzTest { if (!LorenzUtils.inSkyBlock) return if (!SkyHanniMod.feature.dev.debugEnabled) return - SkyHanniMod.feature.dev.debugPos.renderString(text, posLabel = "Test") + SkyHanniMod.feature.dev.debugPos.renderString(displayLine, posLabel = "Test") + SkyHanniMod.feature.dev.debugPos.renderStringsAndItems(displayList, posLabel = "Test Display") } @SubscribeEvent