Skip to content
On this page

Calling Vanilla Commands

Katton's datapack-caller APIs live in top.katton.api.dpcaller. They are designed for datapack developers who already know vanilla commands and want a familiar bridge into Kotlin.

Use these helpers when the thing you are doing is still naturally a Minecraft command: changing a scoreboard, sending chat text, applying effects, teleporting, summoning particles, or running a vanilla function.

Basic Example

kotlin
import top.katton.api.ServerPhase
import top.katton.api.ServerScriptEntrypoint
import top.katton.api.dpcaller.getOrCreateObjective
import top.katton.api.dpcaller.setScore

@ServerScriptEntrypoint(ServerPhase.READY)
fun scoreboardExampleMain() {
    // Get or create the scoreboard objective.
    val obj = getOrCreateObjective("myscore")
    // Set the score of "test" to 100.
    setScore("test", obj, 100)
}

In a datapack, the command parser handles everything as text. In Katton, you call a function with typed arguments. That gives you editor completion, normal variables, and fewer quoting problems.

When to Use Command Helpers

Use a command helper when...Prefer Kotlin or events when...
You are doing a direct vanilla operationYou are calculating, branching, or looping
You need behavior that already exists as a commandYou want to react to an in-game event
You are migrating a known-good mcfunction graduallyYou need direct access to entity or server objects

API Reference

Start with the common datapack-caller pages: