Skip to content

Zig: Server, ticks and system information

Functions

props.srvBdsVersion

Zig
pub fn srvBdsVersion(allocator: std.mem.Allocator) core.Error![]u8

PIER_SRV_BDS_VERSION: Common::getGameVersionString

  • Parameters:
    • allocator : std.mem.Allocator
  • Return type: core.Error![]u8
  • Slots: server_info_str

props.srvProtocolVersion

Zig
pub fn srvProtocolVersion(allocator: std.mem.Allocator) core.Error![]u8

PIER_SRV_PROTOCOL_VERSION: LevelData::mNetworkVersion: the protocol the level was last written by. Says how old the save is, not what the server speaks.

  • Parameters:
    • allocator : std.mem.Allocator
  • Return type: core.Error![]u8
  • Slots: server_info_str

props.srvLevelProtocolVersion

Zig
pub fn srvLevelProtocolVersion(allocator: std.mem.Allocator) core.Error![]u8

PIER_SRV_LEVEL_PROTOCOL_VERSION: "major.minor.patch" of the running build, from CurrentGameSemVersion. Lets a mod carry its own version→protocol table instead of waiting for a Pier release.

  • Parameters:
    • allocator : std.mem.Allocator
  • Return type: core.Error![]u8
  • Slots: server_info_str

props.srvGameSemVersion

Zig
pub fn srvGameSemVersion(allocator: std.mem.Allocator) core.Error![]u8

PIER_SRV_GAME_SEM_VERSION: PIER_SRV_GAME_SEM_VERSION

  • Parameters:
    • allocator : std.mem.Allocator
  • Return type: core.Error![]u8
  • Slots: server_info_str

props.srvLoaderVersion

Zig
pub fn srvLoaderVersion(allocator: std.mem.Allocator) core.Error![]u8

PIER_SRV_LOADER_VERSION: ll::getLoaderVersion, the running LeviLamina

  • Parameters:
    • allocator : std.mem.Allocator
  • Return type: core.Error![]u8
  • Slots: server_info_str

props.srvLevelName

Zig
pub fn srvLevelName(allocator: std.mem.Allocator) core.Error![]u8

PIER_SRV_LEVEL_NAME: LevelData::mLevelName, the world name

  • Parameters:
    • allocator : std.mem.Allocator
  • Return type: core.Error![]u8
  • Slots: server_info_str

props.srvIsHardcore

Zig
pub fn srvIsHardcore(allocator: std.mem.Allocator) core.Error![]u8

PIER_SRV_IS_HARDCORE: LevelData::mIsHardcore, "1" or "0"

  • Parameters:
    • allocator : std.mem.Allocator
  • Return type: core.Error![]u8
  • Slots: server_info_str

props.srvWorldStartCount

Zig
pub fn srvWorldStartCount(allocator: std.mem.Allocator) core.Error![]u8

PIER_SRV_WORLD_START_COUNT: LevelData::mWorldStartCount, how many times the world was opened

  • Parameters:
    • allocator : std.mem.Allocator
  • Return type: core.Error![]u8
  • Slots: server_info_str

props.srvEducationFeatures

Zig
pub fn srvEducationFeatures(allocator: std.mem.Allocator) core.Error![]u8

PIER_SRV_EDUCATION_FEATURES: LevelData::mEducationFeaturesEnabled, "1" or "0"

  • Parameters:
    • allocator : std.mem.Allocator
  • Return type: core.Error![]u8
  • Slots: server_info_str

props.sysOsName

Zig
pub fn sysOsName(allocator: std.mem.Allocator) core.Error![]u8

PIER_SYS_OS_NAME: sys_utils::getSystemName

  • Parameters:
    • allocator : std.mem.Allocator
  • Return type: core.Error![]u8
  • Slots: sys_info_str

props.sysOsVersion

Zig
pub fn sysOsVersion(allocator: std.mem.Allocator) core.Error![]u8

PIER_SYS_OS_VERSION: sys_utils::getSystemVersion β†’ string

  • Parameters:
    • allocator : std.mem.Allocator
  • Return type: core.Error![]u8
  • Slots: sys_info_str

props.sysLocale

Zig
pub fn sysLocale(allocator: std.mem.Allocator) core.Error![]u8

PIER_SYS_LOCALE: sys_utils::getSystemLocaleCode

  • Parameters:
    • allocator : std.mem.Allocator
  • Return type: core.Error![]u8
  • Slots: sys_info_str

props.sysLocalTime

Zig
pub fn sysLocalTime(allocator: std.mem.Allocator) core.Error![]u8

PIER_SYS_LOCAL_TIME: sys_utils::getLocalTime β†’ SNBT {year,month,day,hour,minute,second,ms}

  • Parameters:
    • allocator : std.mem.Allocator
  • Return type: core.Error![]u8
  • Slots: sys_info_str

props.sysProcessId

Zig
pub fn sysProcessId(allocator: std.mem.Allocator) core.Error![]u8

PIER_SYS_PROCESS_ID: the id of the server process

  • Parameters:
    • allocator : std.mem.Allocator
  • Return type: core.Error![]u8
  • Slots: sys_info_str

server.gamingStatus

Zig
pub fn gamingStatus() core.Error!GamingStatus

Which stage the server is in. Thread safe: any thread may ask.

server.currentTick

Zig
pub fn currentTick() core.Error!u64

The current server tick. NoAnswer while the level is not ready.

server.playerCount

Zig
pub fn playerCount() core.Error!i32

How many players are connected.

server.isSimPaused

Zig
pub fn isSimPaused() core.Error!bool

Whether the simulation is paused.

server.tickDeltaTime

Zig
pub fn tickDeltaTime() core.Error!f64

The wall-clock period of the last frame in seconds. At 20 TPS it is 0.05.

server.tps

Zig
pub fn tps() core.Error!f64

Ticks per second over the last 5 seconds of wall clock.

  • Return type: core.Error!f64
  • Slots: get_tps

server.tpsOver

Zig
pub fn tpsOver(window_seconds: i32) core.Error!f64

As tps, over a window of window_seconds, from 1 to 60 and clipped by the host.

  • Parameters:
    • window_seconds : i32
  • Return type: core.Error!f64
  • Slots: get_tps

server.mspt

Zig
pub fn mspt() core.Error!f64

Milliseconds spent computing each tick, averaged over the last 5 seconds.

  • Return type: core.Error!f64
  • Slots: get_mspt

server.msptOver

Zig
pub fn msptOver(window_seconds: i32) core.Error!f64

As mspt, over a window of window_seconds, from 1 to 60 and clipped by the host.

  • Parameters:
    • window_seconds : i32
  • Return type: core.Error!f64
  • Slots: get_mspt

server.setTickFreeze

Zig
pub fn setTickFreeze(on: bool) core.Error!void

Freezes or unfreezes the world.

  • Parameters:
    • on : bool
  • Return type: core.Error!void
  • Slots: tick_freeze

server.stepTicks

Zig
pub fn stepTicks(n: u32) core.Error!void

Valid only while frozen: lets n more frames through.

  • Parameters:
    • n : u32
  • Return type: core.Error!void
  • Slots: tick_step

server.setTickWarp

Zig
pub fn setTickWarp(factor: f64) core.Error!void

The time warp. 0 < factor <= 100, below 1 is slow motion and 1.0 is normal.

  • Parameters:
    • factor : f64
  • Return type: core.Error!void
  • Slots: tick_warp

server.beginProfile

Zig
pub fn beginProfile(ticks: u32) core.Error!void

Opens a sampling window of ticks frames, from 1 to 12000. Only one window at a time.

  • Parameters:
    • ticks : u32
  • Return type: core.Error!void
  • Slots: profile_begin

server.takeProfile

Zig
pub fn takeProfile(allocator: Allocator) core.Error!?[]u8

Takes the sampling report as SNBT, owned by the caller; null while the window is still open or none was armed. The report is handed out once per window.

  • Parameters:
    • allocator : Allocator
  • Return type: core.Error!?[]u8
  • Slots: profile_take

server.env

Zig
pub fn env(allocator: Allocator, name: []const u8) core.Error![]u8

Reads an environment variable of this process, owned by the caller.

  • Parameters:
    • allocator : Allocator
    • name : []const u8
  • Return type: core.Error![]u8
  • Slots: sys_get_env

server.setEnv

Zig
pub fn setEnv(name: []const u8, value: []const u8) core.Error!void

Sets an environment variable. It affects this process only.

  • Parameters:
    • name : []const u8
    • value : []const u8
  • Return type: core.Error!void
  • Slots: sys_set_env

server.isWine

Zig
pub fn isWine() core.Error!bool

Whether this host runs under Wine.

server.protocolVersion

Zig
pub fn protocolVersion(allocator: Allocator) core.Error!u32

The network protocol version of the server, derived from the running build's game version.

  • Parameters:
    • allocator : Allocator
  • Return type: core.Error!u32

server.levelProtocolVersion

Zig
pub fn levelProtocolVersion(allocator: Allocator) core.Error!u32

The protocol the level was last written by. It says how old the save is, not what the server speaks.

  • Parameters:
    • allocator : Allocator
  • Return type: core.Error!u32

server.processId

Zig
pub fn processId(allocator: Allocator) core.Error!u32

The id of the server process.

  • Parameters:
    • allocator : Allocator
  • Return type: core.Error!u32

server.worldStartCount

Zig
pub fn worldStartCount(allocator: Allocator) core.Error!u32

How many times the world has been opened.

  • Parameters:
    • allocator : Allocator
  • Return type: core.Error!u32

server.isHardcore

Zig
pub fn isHardcore(allocator: Allocator) core.Error!bool
  • Parameters:
    • allocator : Allocator
  • Return type: core.Error!bool

server.educationFeaturesEnabled

Zig
pub fn educationFeaturesEnabled(allocator: Allocator) core.Error!bool
  • Parameters:
    • allocator : Allocator
  • Return type: core.Error!bool

server.localTime

Zig
pub fn localTime(allocator: Allocator) core.Error!types.LocalTime

The local time of the server.

  • Parameters:
    • allocator : Allocator
  • Return type: core.Error!types.LocalTime

server.listEvents

Zig
pub fn listEvents(allocator: Allocator) core.Error![][]u8

Every event id the host can currently resolve, each owned by the caller with the slice holding them; free them with core.freeList.

  • Parameters:
    • allocator : Allocator
  • Return type: core.Error![][]u8
  • Slots: list_events

server.listPlayers

Zig
pub fn listPlayers(allocator: Allocator) core.Error!types.Owned(PlayerInfo)

Every online player.

  • Parameters:
    • allocator : Allocator
  • Return type: core.Error!types.Owned(PlayerInfo)
  • Slots: list_players

server.listActors

Zig
pub fn listActors(allocator: Allocator, dim: i32) core.Error!types.Owned(ActorEntry)

The live actors of a dimension; -1 lists every dimension.

  • Parameters:
    • allocator : Allocator
    • dim : i32
  • Return type: core.Error!types.Owned(ActorEntry)
  • Slots: list_actors

server.broadcast

Zig
pub fn broadcast(message: []const u8) core.Error!void

Sends a message to every online player.

  • Parameters:
    • message : []const u8
  • Return type: core.Error!void
  • Slots: broadcast_message

server.GamingStatus

Zig
1
2
3
4
5
6
7
pub const GamingStatus = enum(i32) {
    default = 0,
    starting = 1,
    running = 2,
    stopping = 3,
    _,
};

The run stage of the server, mirroring ll::GamingStatus.

server.PlayerInfo

Zig
pub const PlayerInfo = struct {
    name: []const u8,
    xuid: []const u8,
    uuid: []const u8,
    dim: i32,
    x: f64,
    y: f64,
    z: f64,
    // ...
};

One online player.

server.ActorEntry

Zig
1
2
3
4
5
pub const ActorEntry = struct {
    id: i64,
    type_name: []const u8,
    // ...
};

One live actor of a listing.