Klasse GameSession

java.lang.Object
de.luckymcdev.foundryengine.common.game.GameSession

public class GameSession extends Object
A single game session with configurable tick and lifecycle handlers.
  • Konstruktorübersicht

    Konstruktoren
    Konstruktor
    Beschreibung
    GameSession(net.minecraft.resources.Identifier id, GameData data)
     
  • Methodenübersicht

    Modifikator und Typ
    Methode
    Beschreibung
    boolean
    Returns 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.
    Returns the persistent data for this session.
    net.minecraft.resources.Identifier
    id()
    Returns the unique identifier for this session.
    void
    Loads the session data from persistent storage.
    void
    load(Path dataDir)
    Loads 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.
    void
    onClientTick(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.
    void
    onCommonTick(net.minecraft.world.level.Level level)
    Called on every common tick for this session.
    void
    Called once when the session data is first initialized.
    onInit(Runnable handler)
    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.
    void
    onServerTick(net.minecraft.server.MinecraftServer server, net.minecraft.server.level.ServerLevel level)
    Called on every server tick for this session.
    void
    Called when the session is starting.
    Sets the starting handler for this session.
    void
    Called when the session is stopping.
    Sets the stopping handler for this session.
    Returns the game-defined public state.
    publicState(GameState publicState)
    Sets the game-defined public state.
    void
    Saves the session data to persistent storage.
    void
    save(Path dataDir)
    Saves the session data to a world-specific directory.

    Von Klasse geerbte Methoden Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Konstruktordetails

    • GameSession

      public GameSession(net.minecraft.resources.Identifier id, GameData data)
  • Methodendetails

    • id

      public net.minecraft.resources.Identifier id()
      Returns the unique identifier for this session.
    • data

      public GameData data()
      Returns the persistent data for this session.
    • publicState

      public GameState publicState()
      Returns the game-defined public state.
    • publicState

      public GameSession publicState(GameState publicState)
      Sets the game-defined public state.
    • autoStart

      public boolean autoStart()
      Returns true if this session should auto-start when the world loads.
    • autoStart

      public GameSession autoStart(boolean 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

      public GameSession onCommonTick(Consumer<net.minecraft.world.level.Level> handler)
      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

      public GameSession onStarting(Runnable handler)
      Sets the starting handler for this session.
    • onStopping

      public GameSession onStopping(Runnable handler)
      Sets the stopping handler for this session.
    • onInit

      public GameSession onInit(Runnable handler)
      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 via load(Path)/save(Path), falling back to Common.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

      public void load(Path dataDir)
      Loads the session data from a world-specific directory.
    • save

      public void save()
      Saves the session data to persistent storage. See load() for the world-path vs. cache-dir fallback semantics.
    • save

      public void save(Path dataDir)
      Saves the session data to a world-specific directory.