Interface ServerMod

This is the interface that mods can implement to get notification of events in games. Note that mods only run on the server at the current time.

Hierarchy

  • ServerMod

Properties

apiVersion: number

API version this mod uses - not present = 0

chatName: string

The name of the mod to be displayed when the mod produces chat messages

dependencies?: ModDependency[]

Optional dependencies on other mods

id: string

The ID of the mod, used as a namespace - this is mandatory, without it a mod won't load

name: string

The name of the mod to be displayed in the config dialog - this is mandatory, without it a mod won't load

version: number

The version of the mod

Methods

  • Implement this function if the mod wants to be the world generator. The first mod found with this method implemented will be used to regenerate the map when its reset. If no mod is found with this function then default world generation is used.

    Parameters

    • game: GameContext

      The context on which the mod can callback to modify the game.

    • width: number

      The width of the map being generated

    • height: number

      The height of the map being generated

    • seed: number

      The seed being used

    Returns void

  • Notification that a mob is blocked by a particular location

    Parameters

    • game: GameContext

      The context on which the mod can callback to modify the game.

    • mob: MobContext

      The mob blocked by the location

    • x: number

      The x coordinate in tiles of the location blocking

    • y: number

      The y coordinate in tiles of the location blocking

    Returns void

    See

    MobContext

  • Notification of when the game starts altogether. This is a good place to add/change assets, tools and blocks since it happens first in the lifecycle.

    Parameters

    • game: GameContext

      The context on which the mod can callback to modify the game.

    Returns void

  • Notification that a mob is hitting their head on a particular location

    Parameters

    • game: GameContext

      The context on which the mod can callback to modify the game.

    • mob: MobContext

      The mob hitting their head on the location

    • x: number

      The x coordinate in tiles of the location being hit

    • y: number

      The y coordinate in tiles of the location being hit

    Returns void

    See

    MobContext

  • Notification when the mod has been loaded/installed. Be careful what you call here since most of the system may not be available

    Parameters

    • game: GameContext

      The context on which the mod can callback to modify the game.

    Returns void

  • Notification that a mob joined the world

    Parameters

    Returns void

  • Notification that a mob used a tool in is progress at a given location

    Parameters

    • game: GameContext

      The context on which the mod can callback to modify the game.

    • mob: undefined | MobContext

      The mob using the tool on the location

    • x: number

      The x coordinate in tiles of the target

    • y: number

      The y coordinate in tiles of the target

    • layer: Layer

      The layer being targeted (0=foreground, 1=background)

    • toolId: string

      The id of the tool being used (as defined when doing an

    Returns void

    See

    • MobContext
    • GameContext.addTool )
  • Notification that a player has selected a tool

    Parameters

    • game: GameContext

      The game in which the player existing

    • mob: MobContext

      The player in the world

    • toolId: string

      The ID of the tool selected

    Returns void

  • Notification that a tile has been changed in the game. Every time any player updates the world the notification will callback into the mod.

    Parameters

    • game: GameContext

      The context on which the mod can callback to modify the game.

    • mob: undefined | MobContext

      The mob making the change if any (when mod make changes they don't have a mob)

    • x: number

      The x coordinate in tiles of the change

    • y: number

      The y coordinate in tiles of the change

    • layer: Layer

      The layer the change is taking place on (0=foreground, 1=background)

    • block: number

      The block that has been placed on the map (or 0 for removal)

    • oldBlock: number

      The block that was in this location previously

    Returns void

    See

    MobContext

  • Notification that a mob is standing on a particular location

    Parameters

    • game: GameContext

      The context on which the mod can callback to modify the game.

    • mob: MobContext

      The mob standing on the location

    • x: number

      The x coordinate in tiles of the location being stood on

    • y: number

      The y coordinate in tiles of the location being stood on

    Returns void

    See

    MobContext

  • When implemented in a mod this will be called every frame (or tick). This can be used to do dynamic updates based on time.

    Parameters

    • game: GameContext

      The context on which the mod can callback to modify the game.

    Returns void

  • Notification that a previously scheduled timer fired

    Parameters

    • game: GameContext

      The game to callback on to to make changes

    • callbackName: string

      The name of the callback that was registered with the timer

    • Optional tileX: number

      The x coordinate of the optional tile location this time was associated with

    • Optional tileY: number

      The y coordinate of the optional tile location this time was associated with

    • Optional layer: number

      The layer of optional tile location this time was associated with

    Returns void

  • Notification that a mob pressed the trigger button on a particular location.

    Parameters

    • game: GameContext

      The context on which the mod can callback to modify the game.

    • mob: MobContext

      The mob pressing the trigger on the location

    • x: number

      The x coordinate in tiles of the target

    • y: number

      The y coordinate in tiles of the target

    Returns void

    See

    MobContext

  • Notification that a mob used a tool on a given location

    Parameters

    • game: GameContext

      The context on which the mod can callback to modify the game.

    • mob: undefined | MobContext

      The mob using the tool on the location

    • x: number

      The x coordinate in tiles of the target

    • y: number

      The y coordinate in tiles of the target

    • layer: Layer

      The layer being targeted (0=foreground, 1=background)

    • toolId: string

      The id of the tool being used (as defined when doing an

    Returns void

    See

    • MobContext
    • GameContext.addTool )
  • Notification that a new world has been generated

    Parameters

    • game: GameContext

      The context on which the mod can callback to modify the game.

    • width: number

      The width of the map being generated

    • height: number

      The height of the map being generated

    • seed: number

      The seed being used

    Returns void

  • Notification that the player(s) are being added to the world. This is useful to show messages and do setup that is dependent on there being a network and players (e.g. sending chat messages)

    Parameters

    • game: GameContext

      The context on which the mod can callback to modify the game.

    Returns void

Generated using TypeDoc