Skip to content
On this page
Common

KattonLootTableModificationApi

top.katton.api.modcommon/src/main/kotlin/top/katton/api/mod/KattonLootTableModificationApi.kt
Returns the JSON form of an existing loot table, or `null` when the table is not registered or the server is offline.

getLootTable

getLootTableCommonFunction
kotlin
@ApiStatus.Experimental
@ApiStatus.Experimental fun getLootTable(lootTableId: String): JsonObject?

Returns the JSON form of an existing loot table, or null when the table is not registered or the server is offline.

Reads from server.reloadableRegistries(), which is where loot tables live in MC 1.21.5+, then re-encodes through [LootTable.DIRECT_CODEC].

modifyLootTable

modifyLootTableCommonFunction
kotlin
@ApiStatus.Experimental
@ApiStatus.Experimental fun modifyLootTable(lootTableId: String, configure: LootTableModificationConfig.() -> Unit): Boolean

Mutates an existing loot table by reading its current JSON, applying the configured changes, and re-registering it through [ServerDatapackManager].

Requires a running server. Returns false and logs a warning when the server is offline or the loot table cannot be resolved.

LootTableModificationConfig

LootTableModificationConfigCommonClass
kotlin
class LootTableModificationConfig internal constructor(private val json: JsonObject)

Mutation API over a loot table JSON document. The modifications are applied directly to the underlying JSON tree; no schema validation beyond what Minecraft's codec already does on re-registration.

LootTableModificationConfig.pool

LootTableModificationConfig.poolCommonFunction
kotlin
fun pool(block: LootPoolBuilderJson.() -> Unit)

Adds a new pool built through the existing [LootPoolBuilderJson] DSL.

LootTableModificationConfig.rawPool

LootTableModificationConfig.rawPoolCommonFunction
kotlin
fun rawPool(poolJson: JsonObject)

Adds a raw pool JSON object as-is. Useful when migrating existing datapack payloads.

LootTableModificationConfig.removePool

LootTableModificationConfig.removePoolCommonFunction
kotlin
fun removePool(index: Int)

Removes a pool by zero-based index. Indices are interpreted against the pool list as it exists at apply time, after additions and other removals have not yet been applied.

LootTableModificationConfig.removeItem

LootTableModificationConfig.removeItemCommonFunction
kotlin
fun removeItem(itemId: String)

Removes every item entry referencing the given item id from every pool. Tag entries (type: minecraft:tag) are not touched.

LootPoolBuilderJson

LootPoolBuilderJsonCommonClass
kotlin
class LootPoolBuilderJson internal constructor()

Lightweight pool builder that reuses the JSON shape produced by [top.katton.api.datapack.LootPoolBuilder] without depending on it directly, so the mod-API namespace stays self-contained.

LootPoolBuilderJson.rolls

LootPoolBuilderJson.rollsCommonProperty
kotlin
var rolls: Int

Pool roll count. Defaults to 1.

LootPoolBuilderJson.addItem

LootPoolBuilderJson.addItemCommonFunction
kotlin
fun addItem(itemId: String, weight: Int = 1, quality: Int = 0)

Adds a single item entry to this pool.

LootPoolBuilderJson.addTag

LootPoolBuilderJson.addTagCommonFunction
kotlin
fun addTag(tagId: String, weight: Int = 1, expand: Boolean = false)

Adds a tag-based entry to this pool.

LootPoolBuilderJson.addEmpty

LootPoolBuilderJson.addEmptyCommonFunction
kotlin
fun addEmpty(weight: Int = 1)

Adds an empty (drop-nothing) entry to this pool.