From 58910b56efca5555ac67acc54200f915ba66341d Mon Sep 17 00:00:00 2001 From: Rafa <32463720+Rafacasari@users.noreply.github.com> Date: Fri, 21 Jun 2024 07:00:24 -0300 Subject: [PATCH] 1.0.22 Fixed forms not having right type and other info Fixed network spam Fixed trade evolutions not working/having wrong text --- .../mod/cobbledex/CobbledexConstants.kt | 2 +- .../mod/cobbledex/client/gui/CobbledexGUI.kt | 20 +++++++------------ .../client/widget/PokemonEvolutionDisplay.kt | 6 ++++-- .../mod/cobbledex/items/CobbledexItem.kt | 6 +++--- .../server/packets/RequestCobbledexPacket.kt | 7 ++++--- .../template/SerializablePokemonEvolution.kt | 20 ++++++++----------- .../assets/cobbledex/lang/en_us.json | 5 +++-- gradle.properties | 2 +- 8 files changed, 31 insertions(+), 37 deletions(-) diff --git a/common/src/main/kotlin/com/rafacasari/mod/cobbledex/CobbledexConstants.kt b/common/src/main/kotlin/com/rafacasari/mod/cobbledex/CobbledexConstants.kt index 245342d..d9a35d4 100644 --- a/common/src/main/kotlin/com/rafacasari/mod/cobbledex/CobbledexConstants.kt +++ b/common/src/main/kotlin/com/rafacasari/mod/cobbledex/CobbledexConstants.kt @@ -11,7 +11,7 @@ object CobbledexConstants { return "${Cobbledex.MOD_ID}.errors.$name" } - val NotAPokemon by lazy { buildErrorMessage("NotAPokemon") } + val invalid_entity by lazy { buildErrorMessage("NotAPokemon") } val Cobbledex_Item = CobbledexItem(Item.Settings().maxCount(1).rarity(Rarity.COMMON)) } \ No newline at end of file diff --git a/common/src/main/kotlin/com/rafacasari/mod/cobbledex/client/gui/CobbledexGUI.kt b/common/src/main/kotlin/com/rafacasari/mod/cobbledex/client/gui/CobbledexGUI.kt index fbe9b49..2a5bc8b 100644 --- a/common/src/main/kotlin/com/rafacasari/mod/cobbledex/client/gui/CobbledexGUI.kt +++ b/common/src/main/kotlin/com/rafacasari/mod/cobbledex/client/gui/CobbledexGUI.kt @@ -79,7 +79,8 @@ class CobbledexGUI(var selectedPokemon: FormData?, var selectedAspects: Set? = null + private var lastLoadedForm: FormData? = null + private var lastLoadedSpawnDetails: List? = null private var lastLoadedPokemonDrops: List? = null @@ -379,21 +380,14 @@ class CobbledexGUI(var selectedPokemon: FormData?, var selectedAspects: Set): INetworkPacket { +class RequestCobbledexPacket internal constructor(val pokemon: Identifier, val aspects: Set, val form: String = ""): INetworkPacket { override val id = ID override fun encode(buffer: PacketByteBuf) { @@ -12,6 +12,7 @@ class RequestCobbledexPacket internal constructor(val pokemon: Identifier, val a buffer.writeCollection(aspects) { buff, value -> buff.writeString(value) } + buffer.writeString(form) } companion object{ @@ -21,8 +22,8 @@ class RequestCobbledexPacket internal constructor(val pokemon: Identifier, val a val aspects = buffer.readList { buff -> buff.readString() }.toSet() - - return RequestCobbledexPacket(identifier, aspects) + val form = buffer.readString() + return RequestCobbledexPacket(identifier, aspects, form) } } } \ No newline at end of file diff --git a/common/src/main/kotlin/com/rafacasari/mod/cobbledex/network/template/SerializablePokemonEvolution.kt b/common/src/main/kotlin/com/rafacasari/mod/cobbledex/network/template/SerializablePokemonEvolution.kt index 1e206d6..51e5a6e 100644 --- a/common/src/main/kotlin/com/rafacasari/mod/cobbledex/network/template/SerializablePokemonEvolution.kt +++ b/common/src/main/kotlin/com/rafacasari/mod/cobbledex/network/template/SerializablePokemonEvolution.kt @@ -74,19 +74,15 @@ class SerializablePokemonEvolution() : IEncodable { val item = Registries.ITEM.get(Identifier("cobblemon", "link_cable")) val itemStack = ItemStack(item) - val translation = Text.translatable("cobbledex.evolution.trade_or_link_cable", itemStack.name.bold()) + + val translation = tradePokemon?.species?.let { speciesName -> + val tradeSpecies = PokemonSpecies.getByName(speciesName) + if (tradeSpecies != null) + Text.translatable("cobbledex.evolution.trade_specific", tradeSpecies.translatedName.bold(), itemStack.name.bold()) + Text.translatable("cobbledex.evolution.trade_specific", speciesName.text().bold(), itemStack.name.bold()) + } ?: Text.translatable("cobbledex.evolution.trade_any", itemStack.name.bold()) + longTextDisplay.addItemEntry(itemStack, translation, false, disableTooltip = false) -// if (tradePokemonString.isNullOrEmpty()) { -// val item = Registries.ITEM.get(Identifier("cobblemon", "link_cable")) -// val itemStack = ItemStack(item) -// val translation = Text.translatable("cobbledex.evolution.trade_or_link_cable", itemStack.name.bold()) -// longTextDisplay.addItemEntry(itemStack, translation, false, disableTooltip = false) -// } else { -// longTextDisplay.addText(Text.translatable("cobbledex.evolution.trade"), false) -// tradePokemonString?.let { properties -> -// longTextDisplay.addText(properties.text(), false) -// } -// } } Unknown -> { 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 ab41d12..7188f83 100644 --- a/common/src/main/resources/assets/cobbledex/lang/en_us.json +++ b/common/src/main/resources/assets/cobbledex/lang/en_us.json @@ -23,8 +23,9 @@ "cobbledex.texts.no_evolution_found": "No evolution found for %s", "cobbledex.evolution.use_item": "Use a %s", - "cobbledex.evolution.trade": "Complete a trade", - "cobbledex.evolution.trade_or_link_cable": "Trade or use %s", + + "cobbledex.evolution.trade_any": "Complete any trade or use a %s", + "cobbledex.evolution.trade_specific": "Trade for an %s or use a %s", "cobbledex.evolution.damage_taken": "Need %s damage taken", "cobbledex.evolution.level": "Level: %s", diff --git a/gradle.properties b/gradle.properties index 146e88a..d9f8909 100644 --- a/gradle.properties +++ b/gradle.properties @@ -8,7 +8,7 @@ mod_id=cobbledex generated_file_name_addon=-1.20.1 archives_base_name=cobbledex-1.20.1 -mod_version=1.0.21 +mod_version=1.0.22 mod_description=A mod to track your progress on Cobblemon. Fabric and Forge compatible. mod_icon=assets/cobbledex/icon.png repository=https://github.com/rafacasari/cobbledex