mirror of
https://gitlab.com/cable-mc/cobblemon.git
synced 2026-10-20 14:16:26 -04:00
Merge branch 'feature/change-the-rules' into 'main'
change how item interaction evolutions are processed Closes #1864 and #1874 See merge request cable-mc/cobblemon!2399
This commit is contained in:
@@ -88,6 +88,8 @@
|
||||
- Blank TM can now be inserted into the Disc Shelf
|
||||
- Recall animation now renders ball in hand with the player arm raised.
|
||||
- Made regional and Vivillon split-evo locations now mutually exclusive
|
||||
- Item evolutions now unlock **all** unlocked evolutions whose requirements are met instead of stopping after the first.
|
||||
- Item evolutions now unlock **all** locked evolutions whose requirements are met instead of stopping after the first.
|
||||
|
||||
### Fixes
|
||||
- Correctly grants "They're Minerals!" advancement when planting a type gem
|
||||
|
||||
@@ -1483,19 +1483,31 @@ open class PokemonEntity(
|
||||
|
||||
// Evolution item logic
|
||||
if (pokemon.getOwnerPlayer() == player) {
|
||||
fun evolutionUnlocked(): Boolean {
|
||||
stack.consume(1, player)
|
||||
this.level().playSoundServer(
|
||||
position = this.position(),
|
||||
sound = CobblemonSounds.ITEM_USE,
|
||||
volume = 1F,
|
||||
pitch = 1F
|
||||
)
|
||||
return true
|
||||
}
|
||||
val context = ItemInteractionEvolution.ItemInteractionContext(stack, player.level())
|
||||
pokemon.lockedEvolutions
|
||||
.filterIsInstance<ItemInteractionEvolution>()
|
||||
.forEach { evolution ->
|
||||
if (evolution.attemptEvolution(pokemon, context)) {
|
||||
stack.consume(1, player)
|
||||
this.level().playSoundServer(
|
||||
position = this.position(),
|
||||
sound = CobblemonSounds.ITEM_USE,
|
||||
volume = 1F,
|
||||
pitch = 1F
|
||||
)
|
||||
return true
|
||||
val lockedItemEvolutions = pokemon.lockedEvolutions.filterIsInstance<ItemInteractionEvolution>()
|
||||
// forced evolutions > check those first and do ONLY one if there's multiple
|
||||
lockedItemEvolutions.filter { !it.optional }.forEach {
|
||||
if (it.attemptEvolution(pokemon, context)) {
|
||||
return evolutionUnlocked()
|
||||
}
|
||||
}
|
||||
// optional evolutions > unlock all with single item use
|
||||
lockedItemEvolutions.filter { it.optional }
|
||||
// we unlock all evolutions that depend on this single item
|
||||
.map { evolution -> return@map evolution.attemptEvolution(pokemon, context) }
|
||||
.let {
|
||||
if (it.contains(true)) { // if any of the evolutions were unlocked, we take the item
|
||||
return evolutionUnlocked()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user