Skip to content

Game-start lifecycle

GameStart is two helpers every minigame ends up calling at the start of every round: prepareLevel resets time to morning and clears weather; preparePlayer puts the player in survival, full HP, full food, empty inventory. Both go through the command stack so engine code doesn’t break when Mojang shifts the signature of ServerLevel.setDayTime or setWeatherParameters between versions.

  • A round is about to start and you want the world in a known state.
  • A player is being teleported into the arena and you want a clean loadout.
  • You’re integrating settings (WorldSettings.daylightCycle) — apply those before calling prepareLevel.
package me.zlex.conduit.lifecycle;
public final class GameStart {
public static void prepareLevel(ServerLevel level);
public static void preparePlayer(ServerPlayer player);
}
import me.zlex.conduit.instance.GameInstance;
import me.zlex.conduit.lifecycle.GameStart;
import me.zlex.conduit.teleport.SafeTeleport;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.phys.Vec3;
public final class MyRoundStart {
public static void start(GameInstance inst, Collection<ServerPlayer> players) {
GameStart.prepareLevel(inst.level());
Vec3 spawn = new Vec3(0.5, 65, 0.5);
for (ServerPlayer p : players) {
SafeTeleport.teleport(p, inst.level(), spawn, 0f, 0f, arrived -> {
GameStart.preparePlayer(arrived);
});
}
}
}
  • Run prepareLevel after applying your game rules (doDaylightCycle, doWeatherCycle) so the time-set is final.
  • preparePlayer wipes the inventory. If you want to keep something (a kit item), stash via PlayerInventoryStash before calling.
  • Both helpers are no-ops if the input is null — safe to call from a handler that may not have a level yet.