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

    Properties

    export_action?: Action

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

    export_options: { [key: string]: FormElement }

    List of export option inputs

    extension: string

    The default file extension that the codec uses

    format: ModelFormat
    name: string

    The display name of the codec

    plugin?: string

    The ID of the plugin that created the object

    remember: boolean

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

    support_partial_export: boolean

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

    Methods

    • Compiles the file content

      Parameters

      • Optionaloptions: any

      Returns any

    • Parameters

      • event_name: string
      • data: any

      Returns void

    • Return the stored export option values of the current project

      Returns { [key: string]: any }

    • Adds an event listener to the codec

      Parameters

      • event_name: string

        The event type to listen for

      • callback: (data: any) => void

      Returns void

    • Adds a single-use event listener to the codec

      Parameters

      • event_name: string

        The event type to listen for

      • callback: (data: any) => void

      Returns 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

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

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

    • Removes an event listener from the codec

      Parameters

      • event_name: string
      • callback: (data: any) => void

      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