diff options
2 files changed, 24 insertions, 5 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/bestiary/BestiaryPage.kt b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/bestiary/BestiaryPage.kt index 896a8fb5..2691f23c 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/bestiary/BestiaryPage.kt +++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/bestiary/BestiaryPage.kt @@ -58,11 +58,11 @@ data class MobLevelData(val level: Int, val maxLevel: Boolean) class BestiaryPage(instance: GuiProfileViewer?) : GuiProfileViewerPage(instance) { private var selectedCategory = "dynamic" - private var lastSelectedCategory = "" private var selectedSubCategory = "" private var tooltipToDisplay: MutableList<String> = mutableListOf() private var bestiaryLevel = 0.0 private var computedCategories: MutableList<Category> = mutableListOf() + private var lastProfileName = "" private val bestiaryTexture = ResourceLocation("notenoughupdates:pv_bestiary_tab.png") private val mobListXCount = 9 @@ -74,8 +74,9 @@ class BestiaryPage(instance: GuiProfileViewer?) : GuiProfileViewerPage(instance) val guiLeft = GuiProfileViewer.getGuiLeft() val guiTop = GuiProfileViewer.getGuiTop() - val selectedProfile = selectedProfile ?: return + val selectedProfile = GuiProfileViewer.getSelectedProfile() ?: return val profileInfo = selectedProfile.profileJson + val profileName = GuiProfileViewer.getProfileName() if (!hasMigrated(profileInfo) || Constants.BESTIARY == null) { Utils.drawStringCentered( @@ -85,13 +86,28 @@ class BestiaryPage(instance: GuiProfileViewer?) : GuiProfileViewerPage(instance) true, 0 ) + lastProfileName = profileName return } - // Do the initial parsing only once - if (computedCategories.isEmpty()) { + // Do the initial parsing only once or on profile switch + if (computedCategories.isEmpty() || lastProfileName != profileName) { computedCategories = parseBestiaryData(profileInfo) bestiaryLevel = calculateTotalBestiaryTiers(computedCategories).toDouble() } + + if (computedCategories.isEmpty() || Constants.BESTIARY == null) { + Utils.drawStringCentered( + "${EnumChatFormatting.RED}No valid bestiary data!", + guiLeft + 431 / 2f, + (guiTop + 101).toFloat(), + true, + 0 + ) + lastProfileName = profileName + return + } + lastProfileName = profileName + val bestiarySize = computedCategories.size val bestiaryXSize = (350f / (bestiarySize - 1 + 0.0000001f)).toInt() diff --git a/src/main/kotlin/io/github/moulberry/notenoughupdates/miscfeatures/inventory/MuseumCheapestItemOverlay.kt b/src/main/kotlin/io/github/moulberry/notenoughupdates/miscfeatures/inventory/MuseumCheapestItemOverlay.kt index 8a711230..e968a4c7 100644 --- a/src/main/kotlin/io/github/moulberry/notenoughupdates/miscfeatures/inventory/MuseumCheapestItemOverlay.kt +++ b/src/main/kotlin/io/github/moulberry/notenoughupdates/miscfeatures/inventory/MuseumCheapestItemOverlay.kt @@ -412,7 +412,10 @@ object MuseumCheapestItemOverlay { tooltip.add("") } - if (NotEnoughUpdates.INSTANCE.manager.getRecipesFor(line.internalNames[0]).isNotEmpty()) { + if (line.internalNames.isEmpty()) { + tooltip.add("${EnumChatFormatting.RED}Could not determine item!") + } + else if (NotEnoughUpdates.INSTANCE.manager.getRecipesFor(line.internalNames[0]).isNotEmpty()) { tooltip.add("${EnumChatFormatting.YELLOW}${EnumChatFormatting.BOLD}Click to open recipe!") } else { tooltip.add("${EnumChatFormatting.RED}${EnumChatFormatting.BOLD}No recipe available!") |