JSM Developer API Documentation
    Preparing search index...

    Interface ModDefinition

    The main mod definition that is read by the game.

    interface ModDefinition {
        eventOnBlockDestroy?: (event: BlockEvent) => boolean;
        eventOnBlockPlace?: (event: BlockEvent) => boolean;
        eventOnPlayerMove?: (event: PlayerMoveEvent) => boolean;
        getModDetails: () => ModDetails;
        getModNamespace: () => string;
        hud?: (ctx: HUDContext) => void;
        start?: () => void;
        tick?: () => void;
    }
    Index

    Properties

    eventOnBlockDestroy?: (event: BlockEvent) => boolean

    This function will be called every time the player attempts to break a block in the world.

    Type Declaration

      • (event: BlockEvent): boolean
      • Parameters

        • event: BlockEvent

          The block event that contains information about the event.

        Returns boolean

        The function should return true if the event should be cancelled.

    eventOnBlockPlace?: (event: BlockEvent) => boolean

    This function will be called every time the player attempts to place a block in the world.

    Type Declaration

      • (event: BlockEvent): boolean
      • Parameters

        • event: BlockEvent

          The block event that contains information about the event.

        Returns boolean

        The function should return true if the event should be cancelled.

    eventOnPlayerMove?: (event: PlayerMoveEvent) => boolean

    This function will be called every time the player attempts to use the W, A, S, D or arrow keys to move. This function does not get called for gravity.

    Type Declaration

      • (event: PlayerMoveEvent): boolean
      • Parameters

        • event: PlayerMoveEvent

          The block event that contains information about the event.

        Returns boolean

        The function should return true if the event should be cancelled. The player will snap back to their original position.

    getModDetails: () => ModDetails

    This function is called by the game to retrieve information about the mod.

    Type Declaration

    This function should return the same ModDetails every time it is called.

    getModNamespace: () => string

    This function is called by the game to get the namespace for the mod.

    Type Declaration

      • (): string
      • Returns string

        The mod's namespace

    This function should return the same string every time it is called. It should also be unique to other mods, however, the game will allow duplicate namespaces and the two mods will act as one. The namespace should only consist of lowercase letters.

    hud?: (ctx: HUDContext) => void

    This function is called every HUD refresh. Do not use the HUDContext anywhere outside of this function.

    Type Declaration

      • (ctx: HUDContext): void
      • Parameters

        Returns void

        The HUD context which contains all the functions for drawing to the HUD.

    start?: () => void

    This function is called when the game is starting. You should register all Blocks here.

    Type Declaration

      • (): void
      • Returns void

    tick?: () => void

    This function is called every game tick.

    Type Declaration

      • (): void
      • Returns void