Skip to content

requireMinecraftServer

val requireMinecraftServer: MinecraftServer

The running MinecraftServer, for code that cannot execute without one - a block entity tick, a command, anything reached from a ServerLevel.

requireMinecraftClient's counterpart, and the same trade: an assertion naming the situation, rather than a NullPointerException from wherever the value was first dereferenced. Reach for minecraftServer itself where its absence is an ordinary answer - a client that has not opened a world has no server, and that is not an error.