Skip to content

Developer API

This page is aimed at mod developers who want to integrate with CobbleNav. CobbleNav is written in Kotlin and shares Cobblemon’s event system, so integrating feels the same as integrating with Cobblemon.

To compile against CobbleNav, add the CobbleNav jar for your loader as a dependency, for example through the Modrinth Maven (maven.modrinth:cobblemon-pokenav:<version>). All classes live in the com.metacontent.cobblenav package.

All events are Cobblemon EventObservables in com.metacontent.cobblenav.event.CobblenavEvents. Subscribe to them like any Cobblemon event:

CobblenavEvents.POKEMON_ENCOUNTERED.subscribe { event ->
// ...
}
Event Payload Fired when
REGISTER_CUSTOM_COLLECTORS CustomCollectorRegistrar The server is starting and the condition collectors are (re)built. Register your own collectors here.
FISH_TRAVEL_STARTED FishTravelStartedEvent(player) A fish starts travelling to a player’s Poké Rod bobber. CobbleNav uses it to close the FishingNav.
POKEMON_ENCOUNTERED PokemonEncounteredEvent(pokemon, player) A player encounters a Pokémon and it is registered in their Pokédex. player may be null. CobbleNav uses it to catalogue the spawn entry.

These events fire on the client while the PokéNav builds the detail panel of a spawn. Each one gives you the SpawnData being displayed and the mutable list of widgets, so you can add, remove or reorder entries.

Event Payload Section
CONDITION_SECTION_WIDGETS_CREATED SpawnDataWidgetsCreatedEvent(spawnData, widgets) Widgets inside the Conditions section
ANTICONDITION_SECTION_WIDGETS_CREATED SpawnDataWidgetsCreatedEvent(spawnData, widgets) Widgets inside the Anti-Conditions section
SPAWN_DATA_WIDGETS_CREATED SpawnDataWidgetsCreatedEvent(spawnData, widgets) The list of all sections of the panel

The lines shown for a spawn in the PokéNav (Biomes, Height, Weather, …) are produced by condition collectors. A collector reads one kind of Cobblemon SpawningCondition on the server and turns it into text. If your mod adds its own spawning condition type, or extra fields, you can add a collector so CobbleNav can display them.

There are two kinds:

Kind Base type Output
Condition collector ConditionCollector<T : SpawningCondition<*>> A colored line of text components.
Block condition collector BlockConditionCollector<T : SpawningCondition<*>> A set of block IDs, shown as block icons in the detail panel.
class MyConditionCollector : ConditionCollector<MySpawningCondition>() {
override val name = "mymod_moisture"
override val color = 0x3CB371
override val conditionClass = MySpawningCondition::class.java
override fun collectValues(
detail: SpawnDetail,
condition: MySpawningCondition,
player: ServerPlayer,
): List<MutableComponent>? {
val min = condition.minMoisture
val max = condition.maxMoisture
return formatValueRange(min, max)?.let { listOf(Component.literal(it)) }
}
}
  • collectValues runs on the server, once per spawn and condition. Return null to skip the line.
  • Multiple values are joined with , .
  • formatValueRange(min, max) is a helper that produces min - max, ≥min or ≤max.
  • To handle every condition type, extend GeneralConditionCollector instead; it uses SpawningCondition as its condition class.

A block collector only returns block IDs:

class MyBlockCollector : BlockConditionCollector<MySpawningCondition> {
override val name = "mymod_needed_blocks"
override val conditionClass = MySpawningCondition::class.java
override fun collect(condition: MySpawningCondition): Set<ResourceLocation> =
condition.neededBlocks?.toBlockSet() ?: emptySet()
}

toBlockSet() resolves Cobblemon’s block conditions (IDs and tags) into block IDs and respects hideNaturalBlockConditions.

Register your collectors from REGISTER_CUSTOM_COLLECTORS. The registrar’s methods can be chained:

CobblenavEvents.REGISTER_CUSTOM_COLLECTORS.subscribe { registrar ->
registrar
.register(MyConditionCollector())
.register(MyBlockCollector())
}

The event fires every time a server starts, so subscribe once during mod initialization.

Each line starts with a translatable label built from the collector name. Add it to your mod’s language file (including the trailing space):

assets/mymod/lang/en_us.json
{
"gui.cobblenav.spawn_data.mymod_moisture": "Moisture: "
}

CobbleNav registers two custom Pokémon properties. Every wild Pokémon spawned by Cobblemon’s spawner receives them automatically.

Property Example Description
cobblenavdetailid (alias detailid) detailid=pikachu-1 The ID of the spawn entry the Pokémon spawned from. Stored in the Pokémon’s persistent data.
spawn_bucket spawn_bucket=rare The bucket the Pokémon spawned from. Also exposed as the aspect bucket-<name>, e.g. bucket-rare.

Because they are regular Pokémon properties, they work everywhere properties are accepted, for example in /pokespawn, in the PokéFinder’s properties filter, or in spawn and evolution conditions that check aspects:

/pokespawn pikachu spawn_bucket=ultra-rare

From code, use SpawnDetailIdPropertyType.extract(pokemon) to read a Pokémon’s spawn entry ID and BucketSpeciesFeatureProvider.get(pokemon) to read its bucket.

A player’s Spawn Catalogue can be modified on the server through SpawnDataCatalogue.executeAndSave. The lambda returns whether the catalogue changed; if it did, the data is saved and synced to the player.

SpawnDataCatalogue.executeAndSave(player) { catalogue ->
catalogue.catalogue("pikachu-1")
}

On the client, the local player’s catalogue is available as CobblenavClient.spawnDataCatalogue.

If your mod adds a new Cobblemon SpawnDetail type, the PokéNav ignores it until you tell CobbleNav how to display it. Implement SpawnResultData and register it on both sides during initialization:

SpawnResultData.register(
MySpawnDetail.TYPE,
MySpawnResultData::transform,
MySpawnResultData::decode,
)

Use CobbleNav’s PokemonSpawnResultData and PokemonHerdSpawnResultData as reference implementations.