You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/notes/2026-01-07-cobblemon-shiny-rates.md
+10-2Lines changed: 10 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,11 +9,12 @@ slug: cobblemon-shiny-rates
9
9
date: 2026-01-07
10
10
---
11
11
12
+
12
13
Sometimes you want to modify the ✨*shiny*✨ rate of the species you are working with.
13
14
14
15
Use cases may vary. The typical scenario is when you are trying to give a player a species via methods other than natural spawning.
15
16
16
-
The code in this note is **Kotlin**. Your experience with **Java** may vary. Don't be afraid to ask questions in the Cobblemon Discord's #programming channel.
17
+
The code in this note is **Kotlin**. Your experience with **Java** may vary. Don't be afraid to ask questions in the Cobblemon Discord's `#programming` channel.
> The `return@addModificationFunction` is *specific to Kotlin* because we can explicitly tell Kotlin which function we want to return from.
79
83
84
+
80
85
Now that we are done modifying our chances, let's assemble it all together:
81
86
82
87
```kotlin
@@ -95,6 +100,9 @@ fun calculateShiny(player: ServerPlayer): Pokemon {
95
100
96
101
You may notice something: I check for ✨shiny✨ in the `post` handler of the event.
97
102
This is because there are other mods that can influence the shiny rate.
98
-
Checking it at that particular place ensures your mod will properly pick up other chance influences.
103
+
104
+
Checking it at that particular place ensures your mod will properly pick up other chance influences and in general is better for interop between different mods.
105
+
106
+
You can also ponder upon usage in this [example](https://github.com/gitoido-mc/rad-gyms/blob/1.7.1%2F0.4.x-main/common/src/main/kotlin/lol/gito/radgyms/common/util/CobblemonExtensions.kt#L16)
0 commit comments