minecraftClient¶
val minecraftClient: Minecraft?
The running Minecraft, or null where there is none.
Nullable because it genuinely is: there are two ordinary situations with no client behind them - a dedicated server, and a data run, which loads mods on the client distribution and never constructs a game.
That it was ever declared otherwise is an accident of annotation, not a judgement about reliability. GameInstance.getServer() carries @Nullable, so minecraftServer had no choice but to be honest; getClient() carries nothing, so it arrives as a platform type that Kotlin will let you call whatever you like - and calling it non-null laundered the null into a type promising it could not happen. The two are equally absent, equally often.
Code that only ever runs while a client is drawing wants requireMinecraftClient; code that merely might be on a client wants withClientInstance.