Skip to content

Server

Represents the Minecraft server that is running the game. Provides access to server-wide operations such as loading and saving structures.

Fields

dedicated: boolean — Read-Only

Indicates whether the server is running as a dedicated (standalone) server. false if it is an integrated server running inside a client (e.g. singleplayer or LAN).

difficulty: Difficulty — Read-Only

The difficulty of the game, which all worlds of this server share. Change it with the command /difficulty. See Difficulty.

filesystem: Filesystem — Read-Only

A reference to the server's filesystem.

players: Player[ ] — Read-Only

A list of references to all currently online players.

version: string — Read-Only

The Minecraft version of this server.

worlds: World[ ] — Read-Only

A list of references to all worlds of this server, one per dimension, starting with the overworld.

Methods

getWorld(dimension: DimensionName) → world: World?

Returns a reference to the world for the given dimension name, or nil if the server has no such dimension.

Example

local nether = spell.server:getWorld("the_nether") --[[@as World]]
player:teleport(nether, Vec3(0,64,0))

Parameters

  • dimension: DimensionName — The name of the dimension, e.g. "the_nether" or "overworld".

Returns

  • world: World? — A reference to the world that represents the given dimension, or nil if there is none.

loadStructure(name: string) → structure: Structure

Loads a Structure from the server's filesystem or internal repository by its name.

Returns a Structure object that can be pasted into the world or inspected.

Example: Load and paste a structure

local struct = spell.server:loadStructure("arena")
spell:pasteStructure(struct)

Parameters

  • name: string — The name of the structure to load.

Returns

  • structure: Structure — The loaded structure object.

saveStructure(name: string, structure: Structure) → path: string

Saves a Structure to the server's filesystem with the given name.

Returns the file path where the structure was saved.

Example: Copy and save a structure

local struct = spell:copyStructure(spell.pos + Vec3(10, 10, 10))
local path = spell.server:saveStructure("arena", struct)
print("Saved at " .. path)

Parameters

  • name: string — The name to use for saving the structure.
  • structure: Structure — The structure to save.

Returns

  • path: string — The file path where the structure is saved.