Merge branch '#1374-fix-evolution-mid-battle' into 'main'

[#1374] Fixed Pokémon being able to evolve mid-battle

Closes #1374

See merge request cable-mc/cobblemon!1491
This commit is contained in:
Hiroku
2025-01-24 04:46:36 +00:00
3 changed files with 6 additions and 5 deletions
+2 -2
View File
@@ -166,6 +166,7 @@
- Fixed type formatting in Pokédex scanner mode when dual types require two lines
- Fix trading sometimes crashing the game/server
- Wild shiny sounds now respect the `shinyNoticeParticlesDistance` config setting.
- Fixed Pokémon being able to evolve mid-battle
### Developer
- Updated the Pokédex data updated events to always include a Pokemon instance, and optionally a DisguiseData instance.
@@ -2091,5 +2092,4 @@ Thank you so much to all of our community translators that bring the mod to the
- Added species, ability, and move translations for `ko_ko`, `jp_jp`, `fr_fr`, `es_es`, `it_it`, and `zh_cn`.
## [1.0.0 (November 12th, 2022)](#1-0-0)
- Initial release.
- Initial release.
@@ -163,8 +163,8 @@ class Summary private constructor(party: Collection<Pokemon?>, private val edita
},
text = lang("ui.evolve"),
resource = evolveButtonResource,
renderRequirement = { selectedPokemon.evolutionProxy.client().isNotEmpty() },
clickRequirement = { selectedPokemon.evolutionProxy.client().isNotEmpty() }
renderRequirement = { selectedPokemon.evolutionProxy.client().isNotEmpty() && CobblemonClient.battle == null },
clickRequirement = { selectedPokemon.evolutionProxy.client().isNotEmpty() && CobblemonClient.battle == null }
)
)
@@ -10,6 +10,7 @@ package com.cobblemon.mod.common.net.serverhandling.evolution
import com.cobblemon.mod.common.api.net.ServerNetworkPacketHandler
import com.cobblemon.mod.common.net.messages.server.pokemon.update.evolution.AcceptEvolutionPacket
import com.cobblemon.mod.common.util.isInBattle
import com.cobblemon.mod.common.util.party
import net.minecraft.server.MinecraftServer
import net.minecraft.server.level.ServerPlayer
@@ -17,7 +18,7 @@ import net.minecraft.server.level.ServerPlayer
object AcceptEvolutionHandler : ServerNetworkPacketHandler<AcceptEvolutionPacket> {
override fun handle(packet: AcceptEvolutionPacket, server: MinecraftServer, player: ServerPlayer) {
val pokemon = player.party()[packet.pokemonUUID] ?: return
if (pokemon.entity?.isBusy == true) return
if (player.isInBattle() || pokemon.entity?.isBusy == true) return
val evolution = pokemon.evolutionProxy.server().firstOrNull { evolution -> evolution.id.equals(packet.evolutionId, true) } ?: return
pokemon.evolutionProxy.server().start(evolution)
}