Klasse GameSession
java.lang.Object
de.luckymcdev.foundryengine.common.game.GameSession
A single game session with configurable tick and lifecycle handlers.
-
Konstruktorübersicht
Konstruktoren -
Methodenübersicht
Modifikator und TypMethodeBeschreibungbooleanReturns true if this session should auto-start when the world loads.autoStart(boolean autoStart) Sets whether this session should auto-start when the world loads.data()Returns the persistent data for this session.net.minecraft.resources.Identifierid()Returns the unique identifier for this session.voidload()Loads the session data from persistent storage.voidLoads the session data from a world-specific directory.onClientTick(BiConsumer<net.minecraft.client.Minecraft, net.minecraft.client.multiplayer.ClientLevel> handler) Sets the client tick handler for this session.voidonClientTick(net.minecraft.client.Minecraft client, net.minecraft.world.level.Level level) Called on every client tick for this session.onCommonTick(Consumer<net.minecraft.world.level.Level> handler) Sets the common tick handler for this session.voidonCommonTick(net.minecraft.world.level.Level level) Called on every common tick for this session.voidonInit()Called once when the session data is first initialized.Sets the one-time initialization handler for this session.onServerTick(BiConsumer<net.minecraft.server.MinecraftServer, net.minecraft.server.level.ServerLevel> handler) Sets the server tick handler for this session.voidonServerTick(net.minecraft.server.MinecraftServer server, net.minecraft.server.level.ServerLevel level) Called on every server tick for this session.voidCalled when the session is starting.onStarting(Runnable handler) Sets the starting handler for this session.voidCalled when the session is stopping.onStopping(Runnable handler) Sets the stopping handler for this session.Returns the game-defined public state.publicState(GameState publicState) Sets the game-defined public state.voidsave()Saves the session data to persistent storage.voidSaves the session data to a world-specific directory.
-
Konstruktordetails
-
GameSession
-
-
Methodendetails
-
id
public net.minecraft.resources.Identifier id()Returns the unique identifier for this session. -
data
Returns the persistent data for this session. -
publicState
Returns the game-defined public state. -
publicState
Sets the game-defined public state. -
autoStart
public boolean autoStart()Returns true if this session should auto-start when the world loads. -
autoStart
Sets whether this session should auto-start when the world loads. -
onCommonTick
public void onCommonTick(net.minecraft.world.level.Level level) Called on every common tick for this session. -
onClientTick
public void onClientTick(net.minecraft.client.Minecraft client, net.minecraft.world.level.Level level) Called on every client tick for this session. This cast is needed due to env separation -
onServerTick
public void onServerTick(net.minecraft.server.MinecraftServer server, net.minecraft.server.level.ServerLevel level) Called on every server tick for this session. -
onStarting
public void onStarting()Called when the session is starting. -
onStopping
public void onStopping()Called when the session is stopping. -
onInit
public void onInit()Called once when the session data is first initialized. -
onCommonTick
Sets the common tick handler for this session. -
onClientTick
public GameSession onClientTick(BiConsumer<net.minecraft.client.Minecraft, net.minecraft.client.multiplayer.ClientLevel> handler) Sets the client tick handler for this session. -
onServerTick
public GameSession onServerTick(BiConsumer<net.minecraft.server.MinecraftServer, net.minecraft.server.level.ServerLevel> handler) Sets the server tick handler for this session. -
onStarting
Sets the starting handler for this session. -
onStopping
Sets the stopping handler for this session. -
onInit
Sets the one-time initialization handler for this session. -
load
public void load()Loads the session data from persistent storage. Uses the world data path previously set viaload(Path)/save(Path), falling back toCommon.GAME(the shared cache dir) only when no world path has been provided — that fallback exists purely to keep direct script-driven calls working and should be avoided for world-scoped data. -
load
Loads the session data from a world-specific directory. -
save
public void save()Saves the session data to persistent storage. Seeload()for the world-path vs. cache-dir fallback semantics. -
save
Saves the session data to a world-specific directory.
-