Skip to content

withMinecraftServer

inline fun withMinecraftServer(crossinline block: MinecraftServer.() -> Unit)

Runs block against the running MinecraftServer, if there is one.

withMinecraftClient's counterpart, with one deliberate difference: no onServer around it. That would be wrong rather than merely redundant - onServer means "this is the dedicated server distribution", and a single-player client is running a perfectly real integrated server that such a guard would skip.

The client one carries an onClient for a reason that has no counterpart here, and it is about which jar is loaded rather than which logical side is running: Minecraft does not exist on a dedicated server distribution, so merely naming it there fails to link. MinecraftServer ships on both, so there is nothing to keep out and a null check is the whole of what is needed.