From 0e3d816198424f00188a1fc155bc8ab960add0bd Mon Sep 17 00:00:00 2001 From: Rafa <32463720+Rafacasari@users.noreply.github.com> Date: Sat, 29 Jun 2024 08:56:21 -0300 Subject: [PATCH] 1.0.30 (Are we ready?) Added caught tracker on item hover --- .../mod/cobbledex/items/CobbledexItem.kt | 39 +++++++++++++++++-- .../assets/cobbledex/lang/en_us.json | 3 ++ 2 files changed, 39 insertions(+), 3 deletions(-) diff --git a/common/src/main/kotlin/com/rafacasari/mod/cobbledex/items/CobbledexItem.kt b/common/src/main/kotlin/com/rafacasari/mod/cobbledex/items/CobbledexItem.kt index c5c7066..58f30ea 100644 --- a/common/src/main/kotlin/com/rafacasari/mod/cobbledex/items/CobbledexItem.kt +++ b/common/src/main/kotlin/com/rafacasari/mod/cobbledex/items/CobbledexItem.kt @@ -28,6 +28,31 @@ class CobbledexItem(settings: Settings) : Item(settings) { get() { return CobbledexConstants.Client.discoveredList.size } + + + + val totalPokemonCaught: Int + get() { + return CobbledexConstants.Client.discoveredList.filter { + it.value.any { form -> form.value.status == DiscoveryRegister.RegisterType.CAUGHT} + }.size + } + +// val totalFormsDiscovered: Int +// get() { +// return CobbledexConstants.Client.discoveredList.flatMap { +// it.value.values +// }.size +// } +// +// val totalFormsCaught: Int +// get() { +// return CobbledexConstants.Client.discoveredList.flatMap { +// it.value.values +// }.filter { +// it.status == DiscoveryRegister.RegisterType.CAUGHT +// }.size +// } } private val totalPokemonCount: Int @@ -36,11 +61,19 @@ class CobbledexItem(settings: Settings) : Item(settings) { override fun appendTooltip(stack: ItemStack, world: World?, tooltip: MutableList, context: TooltipContext) { + val percentageDiscovered = "%.2f%%".format((totalPokemonDiscovered.toDouble() / totalPokemonCount) * 100) + val percentageCaught = "%.2f%%".format((totalPokemonCaught.toDouble() / totalPokemonCount) * 100) + val translationDiscovered = cobbledexTextTranslation("tooltip_description.discovered", totalPokemonDiscovered.toString().text().formatted(Formatting.GREEN), totalPokemonCount.toString(), percentageDiscovered) + val translationCaught = cobbledexTextTranslation("tooltip_description.caught", totalPokemonCaught.toString().text().formatted(Formatting.GREEN), totalPokemonCount.toString(), percentageCaught) + - val percentage = "%.2f%%".format((totalPokemonDiscovered.toDouble() / totalPokemonCount) * 100) - val translation = cobbledexTextTranslation("tooltip_description.discovered", totalPokemonDiscovered.toString().text().formatted(Formatting.GREEN), totalPokemonCount.toString(), percentage) - tooltip.add(translation) + tooltip.add(translationDiscovered) + tooltip.add(translationCaught) +// val formsDiscoveredTranslation = cobbledexTextTranslation("tooltip_description.total_forms_discovered", totalFormsDiscovered.toString().text().formatted(Formatting.GREEN)) +// val formsCaughtTranslation = cobbledexTextTranslation("tooltip_description.total_forms_caught", totalFormsCaught.toString().text().formatted(Formatting.GREEN)) +// tooltip.add(formsDiscoveredTranslation) +// tooltip.add(formsCaughtTranslation) tooltip.add(MutableText.of(TextContent.EMPTY)) if (Screen.hasShiftDown()) { diff --git a/common/src/main/resources/assets/cobbledex/lang/en_us.json b/common/src/main/resources/assets/cobbledex/lang/en_us.json index 9fb641a..5f89859 100644 --- a/common/src/main/resources/assets/cobbledex/lang/en_us.json +++ b/common/src/main/resources/assets/cobbledex/lang/en_us.json @@ -41,6 +41,9 @@ "cobbledex.texts.new_pokemon_discovered": "You've discovered a new Pokémon: %s", "cobbledex.texts.click_to_open_cobbledex": "Click to open in Cobbledex", "cobbledex.texts.tooltip_description.discovered": "Discovered: %s/%s (%s)", + "cobbledex.texts.tooltip_description.total_forms_discovered": "Forms discovered: %s", + "cobbledex.texts.tooltip_description.caught": "Caught: %s/%s (%s)", + "cobbledex.texts.tooltip_description.total_forms_caught": "Forms caught: %s", "cobbledex.texts.tooltip_description.press_shift": "Hold for instructions", "cobbledex.texts.tooltip_description.instructions1": "§a§lRight-Click§r a Pokémon to mark as seen", "cobbledex.texts.tooltip_description.instructions2": "§a§lRight-Click§r a Pokémon to open §lInformation GUI§r",