Skip to content

Zig: Client

Declarations

client.KeyHandler

Zig
pub const KeyHandler = fn (user: ?*anyopaque, action: KeyAction, impact: i32) void;

Called on the client thread for each press and release of a registered key: the user pointer given at registration, the action, and the focus impact the engine reports.

Functions

client.property

Zig
pub fn property(prop: i32) core.Error!f64

One numeric client property by its PIER_CPROP_* key. NoAnswer for a key this host does not know, or a key about the local player while the client is not in a world.

  • Parameters:
    • prop : i32
  • Return type: core.Error!f64
  • Slots: client_get_num

client.localPosition

Zig
pub fn localPosition() core.Error![3]f64

The local player's feet position: x, y and z.

client.localRotation

Zig
pub fn localRotation() core.Error![2]f64

The local player's pitch and yaw in degrees; a negative pitch looks up.

client.localDimension

Zig
pub fn localDimension() core.Error!i32

The id of the dimension the local player is in.

client.guiScale

Zig
pub fn guiScale() core.Error!f64

The GUI scale this client draws with.

client.serverPingMs

Zig
pub fn serverPingMs() core.Error!f64

The round trip to the server in milliseconds, as this client measures it.

client.isShowingMenu

Zig
pub fn isShowingMenu() core.Error!bool

Whether a menu screen is showing.

client.isShowingPauseScreen

Zig
pub fn isShowingPauseScreen() core.Error!bool

Whether the pause screen is showing.

client.isPlaying

Zig
pub fn isPlaying() core.Error!bool

Whether the client is playing a world.

client.isInRealm

Zig
pub fn isInRealm() core.Error!bool

Whether the world is a Realm.

client.isGameInputEnabled

Zig
pub fn isGameInputEnabled() core.Error!bool

Whether game input reaches the world, which a screen on top takes away.

client.topScreenName

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

The topmost screen of the client's screen stack, owned by the caller.

  • Parameters:
    • allocator : std.mem.Allocator
  • Return type: (core.Error || std.mem.Allocator.Error)![]u8
  • Slots: client_get_str

client.registeredKeys

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

Every key binding name the key registry holds, whichever mod registered it. The caller frees each name and the slice.

  • Parameters:
    • allocator : std.mem.Allocator
  • Return type: (core.Error || std.mem.Allocator.Error)![][]u8
  • Slots: client_list_keys

client.showMessage

Zig
pub fn showMessage(text: []const u8) core.Error!void

Shows text in this client's chat. Nothing is sent to a server.

  • Parameters:
    • text : []const u8
  • Return type: core.Error!void
  • Slots: client_action

client.setTitle

Zig
pub fn setTitle(text: []const u8) core.Error!void

Shows text as the title on this client.

  • Parameters:
    • text : []const u8
  • Return type: core.Error!void
  • Slots: client_action

client.setSubtitle

Zig
pub fn setSubtitle(text: []const u8) core.Error!void

Shows text as the subtitle on this client.

  • Parameters:
    • text : []const u8
  • Return type: core.Error!void
  • Slots: client_action

client.setActionBar

Zig
pub fn setActionBar(text: []const u8) core.Error!void

Shows text above the hotbar on this client.

  • Parameters:
    • text : []const u8
  • Return type: core.Error!void
  • Slots: client_action

client.showTip

Zig
pub fn showTip(text: []const u8) core.Error!void

Shows text as a tip on this client.

  • Parameters:
    • text : []const u8
  • Return type: core.Error!void
  • Slots: client_action

client.playUiSound

Zig
pub fn playUiSound(name: []const u8, volume: f64, pitch: f64) core.Error!void

Plays a UI sound by name on this client, such as "random.click".

  • Parameters:
    • name : []const u8
    • volume : f64
    • pitch : f64
  • Return type: core.Error!void
  • Slots: client_action

client.grabMouse

Zig
pub fn grabMouse() core.Error!void

Captures the mouse for the game, as a click into the world does.

client.releaseMouse

Zig
pub fn releaseMouse() core.Error!void

Releases the mouse to the screen.

client.setInputDisabled

Zig
pub fn setInputDisabled(disabled: bool) core.Error!void

Disables or enables game input.

  • Parameters:
    • disabled : bool
  • Return type: core.Error!void
  • Slots: client_action

client.leaveLevel

Zig
pub fn leaveLevel() core.Error!void

Leaves the current world for the menus. The engine does it asynchronously.

client.health

Zig
pub fn health() core.Error!f64

Actor::getHealth of the local player

client.maxHealth

Zig
pub fn maxHealth() core.Error!f64

Actor::getMaxHealth of the local player

client.isOnGround

Zig
pub fn isOnGround() core.Error!bool

Actor::isOnGround of the local player

client.isInWater

Zig
pub fn isInWater() core.Error!bool

Actor::isInWater of the local player

client.isSneaking

Zig
pub fn isSneaking() core.Error!bool

Actor::isSneaking of the local player

client.isSprinting

Zig
pub fn isSprinting() core.Error!bool

Actor::isSprinting of the local player

client.isSwimming

Zig
pub fn isSwimming() core.Error!bool

Actor::isSwimming of the local player

client.isOnFire

Zig
pub fn isOnFire() core.Error!bool

Actor::isOnFire of the local player

client.isFlying

Zig
pub fn isFlying() core.Error!bool

Player::isFlying of the local player

client.gameType

Zig
pub fn gameType() core.Error!f64

Player::getPlayerGameType of the local player

client.selectedSlot

Zig
pub fn selectedSlot() core.Error!f64

Player::getSelectedItemSlot of the local player

client.velX

Zig
pub fn velX() core.Error!f64

Actor::getPosDelta of the local player, blocks per tick

client.velY

Zig
pub fn velY() core.Error!f64

Actor::getPosDelta, the vertical part

client.velZ

Zig
pub fn velZ() core.Error!f64

Actor::getPosDelta, the z part

client.xpNeededNextLevel

Zig
pub fn xpNeededNextLevel() core.Error!f64

Player::getXpNeededForNextLevel of the local player

client.isLeavingGame

Zig
pub fn isLeavingGame() core.Error!bool

IClientInstance::isLeavingGame

client.isExitingLevel

Zig
pub fn isExitingLevel() core.Error!bool

IClientInstance::isExitingLevel

client.isInBedScreen

Zig
pub fn isInBedScreen() core.Error!bool

IClientInstance::isInBedScreen

client.isInDeathScreen

Zig
pub fn isInDeathScreen() core.Error!bool

IClientInstance::isInDeathScreen

client.isShowingLoadingScreen

Zig
pub fn isShowingLoadingScreen() core.Error!bool

IClientInstance::isShowingLoadingScreen

client.isShowingProgressScreen

Zig
pub fn isShowingProgressScreen() core.Error!bool

IClientInstance::isShowingProgressScreen

client.isShowingWorldProgressScreen

Zig
pub fn isShowingWorldProgressScreen() core.Error!bool

IClientInstance::isShowingWorldProgressScreen

client.isShowingDeathScreen

Zig
pub fn isShowingDeathScreen() core.Error!bool

IClientInstance::isShowingDeathScreen

client.isShowingServerForm

Zig
pub fn isShowingServerForm() core.Error!bool

IClientInstance::isShowingServerForm

client.isInWorldWithoutMenu

Zig
pub fn isInWorldWithoutMenu() core.Error!bool

IClientInstance::isInWorldAndNotShowingAnyMenuScreens

client.isWorldActive

Zig
pub fn isWorldActive() core.Error!bool

IClientInstance::isWorldActive

client.hasLevel

Zig
pub fn hasLevel() core.Error!bool

IClientInstance::hasLevel

client.isPreGame

Zig
pub fn isPreGame() core.Error!bool

IClientInstance::isPreGame

client.isInMultiplayerGame

Zig
pub fn isInMultiplayerGame() core.Error!bool

IClientInstance::isInMultiplayerGame

client.isMultiplayerClient

Zig
pub fn isMultiplayerClient() core.Error!bool

IClientInstance::isMultiPlayerClient

client.isPrimaryLevelMultiplayer

Zig
pub fn isPrimaryLevelMultiplayer() core.Error!bool

IClientInstance::isPrimaryLevelMultiplayer

client.isPrimaryLevelCrossPlatform

Zig
pub fn isPrimaryLevelCrossPlatform() core.Error!bool

IClientInstance::isPrimaryLevelCrossPlatformMultiplayer

client.isKeyboardEnabled

Zig
pub fn isKeyboardEnabled() core.Error!bool

IClientInstance::isKeyboardEnabled

client.isUsingController

Zig
pub fn isUsingController() core.Error!bool

IClientInstance::useController

client.isUsingTouchscreen

Zig
pub fn isUsingTouchscreen() core.Error!bool

IClientInstance::useTouchscreen

client.isMouseGrabbed

Zig
pub fn isMouseGrabbed() core.Error!bool

IClientInstance::getMouseGrabbed

client.isMouseAndKeyboard

Zig
pub fn isMouseAndKeyboard() core.Error!bool

IClientInstance::currentInputModeIsMouseAndKeyboard

client.hasConnectedController

Zig
pub fn hasConnectedController() core.Error!bool

IClientInstance::hasConnectedController

client.controllerId

Zig
pub fn controllerId() core.Error!f64

IClientInstance::getControllerId

client.isTouchGameplayAllowed

Zig
pub fn isTouchGameplayAllowed() core.Error!bool

IClientInstance::isTouchGameplayAllowed

client.isSplitScreenActive

Zig
pub fn isSplitScreenActive() core.Error!bool

IClientInstance::isSplitScreenActive

client.splitScreenCount

Zig
pub fn splitScreenCount() core.Error!f64

IClientInstance::getSplitScreenCount

client.guiScaleOffset

Zig
pub fn guiScaleOffset() core.Error!f64

IClientInstance::getGuiScaleOffset

client.isEduMode

Zig
pub fn isEduMode() core.Error!bool

IClientInstance::isEduMode

client.isInEditor

Zig
pub fn isInEditor() core.Error!bool

IClientInstance::isPlayerInEditor

client.isReadyToRender

Zig
pub fn isReadyToRender() core.Error!bool

IClientInstance::isReadyToRender

client.isFullVanillaPackOnStack

Zig
pub fn isFullVanillaPackOnStack() core.Error!bool

IClientInstance::isFullVanillaPackOnStack

client.serverConnectionTime

Zig
pub fn serverConnectionTime() core.Error!f64

IClientInstance::getServerConnectionTime

client.remoteServerTimeMs

Zig
pub fn remoteServerTimeMs() core.Error!f64

IClientInstance::getRemoteServerTimeMs

client.remoteServerNetworkTimeMs

Zig
pub fn remoteServerNetworkTimeMs() core.Error!f64

IClientInstance::getRemoteServerNetworkTimeMs

client.frameAlpha

Zig
pub fn frameAlpha() core.Error!f64

IClientInstance::getFrameAlpha, how far the frame is between two ticks

client.gameUpdateSeconds

Zig
pub fn gameUpdateSeconds() core.Error!f64

IClientInstance::getGameUpdateDurationInSeconds

client.isPrimaryClient

Zig
pub fn isPrimaryClient() core.Error!bool

IClientInstance::isPrimaryClient

client.userId

Zig
pub fn userId() core.Error!f64

IClientInstance::getUserId

client.isGameplayTipsEnabled

Zig
pub fn isGameplayTipsEnabled() core.Error!bool

IClientInstance::isGamePlayTipsEnabled

client.hasCommands

Zig
pub fn hasCommands() core.Error!bool

IClientInstance::hasCommands

client.platformId

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

IClientInstance::getPlatformId

  • Parameters:
    • allocator : std.mem.Allocator
  • Return type: (core.Error || std.mem.Allocator.Error)![]u8
  • Slots: client_get_str

client.platformOnlineId

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

IClientInstance::getPlatformOnlineId

  • Parameters:
    • allocator : std.mem.Allocator
  • Return type: (core.Error || std.mem.Allocator.Error)![]u8
  • Slots: client_get_str

client.localXuid

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

Player::getXuid of the local player; fails outside a world

  • Parameters:
    • allocator : std.mem.Allocator
  • Return type: (core.Error || std.mem.Allocator.Error)![]u8
  • Slots: client_get_str

client.localUuid

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

Player::getUuid of the local player in its canonical form

  • Parameters:
    • allocator : std.mem.Allocator
  • Return type: (core.Error || std.mem.Allocator.Error)![]u8
  • Slots: client_get_str

client.localNameTag

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

Actor::getNameTag of the local player

  • Parameters:
    • allocator : std.mem.Allocator
  • Return type: (core.Error || std.mem.Allocator.Error)![]u8
  • Slots: client_get_str

client.clipboard

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

AppPlatform::getClipboardText, the system clipboard

  • Parameters:
    • allocator : std.mem.Allocator
  • Return type: (core.Error || std.mem.Allocator.Error)![]u8
  • Slots: client_get_str

client.showPopup

Zig
pub fn showPopup(text: []const u8) core.Error!void

Shows a popup; a newline in text separates the message from a subtitle.

  • Parameters:
    • text : []const u8
  • Return type: core.Error!void
  • Slots: client_action

client.showDevConsoleMessage

Zig
pub fn showDevConsoleMessage(text: []const u8) core.Error!void

Writes text to the developer console.

  • Parameters:
    • text : []const u8
  • Return type: core.Error!void
  • Slots: client_action

client.setSuspendInput

Zig
pub fn setSuspendInput(suspended: bool) core.Error!void

Suspends or resumes all input.

  • Parameters:
    • suspended : bool
  • Return type: core.Error!void
  • Slots: client_action

client.setSuspendDirectionalInput

Zig
pub fn setSuspendDirectionalInput(suspended: bool) core.Error!void

Suspends or resumes movement input.

  • Parameters:
    • suspended : bool
  • Return type: core.Error!void
  • Slots: client_action

client.setGameInputEnabled

Zig
pub fn setGameInputEnabled(enabled: bool) core.Error!void

Enables or disables game input.

  • Parameters:
    • enabled : bool
  • Return type: core.Error!void
  • Slots: client_action

client.refocusMouse

Zig
pub fn refocusMouse(lost: bool) core.Error!void

Gives the mouse back to the game.

  • Parameters:
    • lost : bool
  • Return type: core.Error!void
  • Slots: client_action

client.muteAudio

Zig
pub fn muteAudio() core.Error!void

Mutes the client audio.

client.unmuteAudio

Zig
pub fn unmuteAudio() core.Error!void

Unmutes the client audio.

client.fadeOutMusic

Zig
pub fn fadeOutMusic() core.Error!void

Fades out the music that is playing.

client.setGuiScaleOffset

Zig
pub fn setGuiScaleOffset(offset: i32) core.Error!void

Sets the GUI scale offset.

  • Parameters:
    • offset : i32
  • Return type: core.Error!void
  • Slots: client_action

client.resetPlayerMovement

Zig
pub fn resetPlayerMovement() core.Error!void

Resets the movement input of the local player.

client.pushLeaveGameScreen

Zig
pub fn pushLeaveGameScreen() core.Error!void

Opens the screen that asks whether to leave the world.

client.openContentLogHistory

Zig
pub fn openContentLogHistory() core.Error!void

Opens the content log history.

client.setClipboard

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

Writes value to the system clipboard.

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

client.navigateHowToPlay

Zig
pub fn navigateHowToPlay(topic: []const u8) core.Error!void

Opens How to Play at topic, or at its start for an empty topic.

  • Parameters:
    • topic : []const u8
  • Return type: core.Error!void
  • Slots: client_action

client.options

Zig
pub fn options(allocator: std.mem.Allocator) (core.Error || std.mem.Allocator.Error)![]OptionPair

Every client option. The caller frees each key, each value and the slice.

  • Parameters:
    • allocator : std.mem.Allocator
  • Return type: (core.Error || std.mem.Allocator.Error)![]OptionPair
  • Slots: client_option_list

client.option

Zig
pub fn option(key: []const u8, allocator: std.mem.Allocator) (core.Error || std.mem.Allocator.Error)![]u8

One client option by its options.txt key, owned by the caller.

  • Parameters:
    • key : []const u8
    • allocator : std.mem.Allocator
  • Return type: (core.Error || std.mem.Allocator.Error)![]u8
  • Slots: client_option_get

client.setOption

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

Writes one client option from its options.txt text form; read it back to see what the engine kept.

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

client.registerKey

Zig
pub fn registerKey(name: []const u8, key_codes: []const i32, allow_remap: bool, user: ?*anyopaque, comptime handler: KeyHandler) core.Error!KeyBinding

Registers a key binding under name with its default key_codes. allow_remap lets the player rebind it. A name that is taken, or an empty code list, is Refused.

  • Parameters:
    • name : []const u8
    • key_codes : []const i32
    • allow_remap : bool
    • user : ?*anyopaque
    • handler : comptime KeyHandler
  • Return type: core.Error!KeyBinding
  • Slots: client_register_key

client.isInLevel

Zig
pub fn isInLevel() core.Error!bool

Whether the client is inside a level, which means a world is loaded.

client.localPlayerName

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

The name of the local player, owned by the caller. NoAnswer outside a level.

  • Parameters:
    • allocator : std.mem.Allocator
  • Return type: (core.Error || std.mem.Allocator.Error)![]u8
  • Slots: client_get_local_player

client.KeyBinding

Zig
1
2
3
4
pub const KeyBinding = struct {
    handle: c.PierKeyHandle,
    // ...
};

One registered key binding, kept to drop it.

client.KeyBinding.keyCodes

Zig
pub fn keyCodes(self: KeyBinding, allocator: std.mem.Allocator) (core.Error || std.mem.Allocator.Error)![]i32

The key codes currently assigned, which differ from the defaults when the player remapped the key. Owned by the caller.

  • Parameters:
    • allocator : std.mem.Allocator
  • Return type: (core.Error || std.mem.Allocator.Error)![]i32
  • Slots: client_get_key_codes

client.KeyBinding.unregister

Zig
pub fn unregister(self: *KeyBinding) core.Error!void

Drops the binding: this mod's handler stops firing. The engine keeps one key per name and offers no removal, so registering the same name again reuses it. Calling it twice is harmless.

client.KeyAction

Zig
1
2
3
4
5
pub const KeyAction = enum(i32) {
    up = 0,
    down = 1,
    _,
};

What a key binding reports.

client.KeyAction.isDown

Zig
pub fn isDown(self: KeyAction) bool
  • Return type: bool

client.OptionPair

Zig
1
2
3
4
5
pub const OptionPair = struct {
    key: []u8,
    value: []u8,
    // ...
};

One client option: its options.txt key and its value in that text form.