Blockbench Reference Docs
    Preparing search index...

    A codec represents a specific file format that can be imported into and exported from Blockbench. The codec handles the compilation and parsing, as well as the loading and exporting logic

    Hierarchy (View Summary)

    Indexable

    • [key: string]: any

      Additional properties

    Index

    Constructors

    • Creates a new codec

      Parameters

      Returns Codec

    Methods

    • Parameters

      • path: string

      Returns void

    • Parameters

      • path: string

      Returns void

    • Compiles the file content

      Parameters

      • Optionaloptions: { [key: string]: any }

      Returns any

    • Returns void

    • Parameters

      • event_name: string
      • data: any

      Returns any

    • Opens the file browser to export a file of this type

      Parameters

      • Optionaloptions: Record<string, any>

      Returns Promise<void>

    • Parameters

      Returns Promise<void>

    • Generate a file name to suggest when exporting

      Returns string

    • Return the stored export option values of the current project

      Returns { [key: string]: any }

    • Load a file into the program

      Parameters

      • model: any
      • Optionalfile: FileResult
      • Optionalargs: LoadOptions

        Load options

      Returns boolean | void

    • Parameters

      • content: any
      • path: string
      • callback: (path: string) => void

      Returns void

    • Takes the content of a file, and loads the model into the current Blockbench project

      Parameters

      • data: any

        File content

      • path: string

        File path

      • Optionalargs: LoadOptions

      Returns void

    • Parameters

      Returns Promise<void>

    • Prompt the user to enter their preferred export settings into the dialog

      Returns Promise<{ [key: string]: any }>

    • Parameters

      Returns void

    • Generates the suggested file path. This is the path that the explorer opens in when exporting this type

      Returns string

    • Write the content of this file to the selected location. The default method can be overwritten to achieve custom behavior

      Parameters

      • content: any

        File content, as generated by compile()

      • path: string

        The file export path

      Returns void

    • Parameters

      Returns Promise<void>

    • Get a list of all possible extensions of all codecs

      Returns string[]

    Properties

    events: Record<string, EventListener[]>
    export_action?: Action

    If available, the action that is used to export files using this codec

    export_options: Record<string, FormElementOptions>

    List of export option inputs

    extension: string

    The default file extension that the codec uses

    format?: ModelFormat

    Default/main format of this codec

    name: string

    The display name of the codec

    plugin?: string
    remember: boolean

    Whether to remember files that use this codec in the recent models list

    support_offset: boolean
    support_partial_export: boolean

    Whether the codec can be used to export a part of the model via a collection