@@ -53,7 +53,7 @@ These handy helpers are our bread and butter.
5353For example, if I want to apply a flat bonus, I would do it this way:
5454
5555``` kotlin
56- var shinyRate = Cobblemon .config.shinyRate
56+ val shinyRate = Cobblemon .config.shinyRate
5757val event = ShinyChanceCalculationEvent (shinyRate, pokemon)
5858event.addModifier(100f ) // add flat 100 increase
5959```
@@ -90,6 +90,23 @@ fun calculateShiny(player: ServerPlayer): Pokemon {
9090 val shinyRate = Cobblemon .config.shinyRate
9191 val event = ShinyChanceCalculationEvent (shinyRate, pokemon)
9292
93+ // Flat modifier
94+ event.addModifier(100f ) // add flat 100 increase
95+
96+ // Callable modifier
97+ event.addModificationFunction { chance, player, pokemon ->
98+ // For example, in this case I want to
99+ // modify the rate if the pokemon is holding a diamond.
100+
101+ // Early bail if criteria not met
102+ if (pokemon.heldItem().item != Items .DIAMOND ) {
103+ return @addModificationFunction chance
104+ }
105+
106+ // Return calculated chance otherwise
107+ return @addModificationFunction (chance + 100f )
108+ }
109+
93110 CobblemonEvents .SHINY_CHANCE_CALCULATION .post(event) { evt ->
94111 pokemon.shiny = evt.isShiny(player)
95112 }
0 commit comments