bedrock-kit
    Preparing search index...

    Class Texture

    Represents a texture file (.png or .tga) from the resource pack's textures/ directory.

    Keyed by relative path without extension, matching how atlas files reference textures (e.g. "textures/tsu/nat/blocks/maple_log").

    Note: getPixelData() is only available in Node.js (disk) mode. In browser mode the collection will be empty, and properties on other assets that return Texture will return undefined.

    Access via addon.textures.get(id).

    const tex = addon.textures.get("textures/tsu/nat/blocks/maple_log");
    console.log(tex?.getPixelData()?.length); // byte length of the PNG
    console.log(tex?.textureSet); // raw texture_set.json data
    console.log(tex?.mer?.id); // "textures/.../maple_log_mer"
    console.log(tex?.usedByBlocks.map(b => b.id));
    Index

    Constructors

    • Parameters

      • id: string
      • filePath: string
      • textureSetData: Record<string, unknown>
      • addon: AddOn

      Returns Texture

    Properties

    filePath: string

    Absolute path to the texture file on disk. Empty string in browser mode.

    id: string

    The relative path from the resource pack root, without file extension. e.g. "textures/tsu/nat/blocks/maple_log"

    Accessors

    • get heightmap(): Texture

      The heightmap companion texture, resolved from texture_set.heightmap. Heightmaps are an alternative to normal maps in Bedrock PBR. undefined if this texture has no texture set or no heightmap entry.

      Returns Texture

    • get mer(): Texture

      The metalness/emissive/roughness (MER) companion texture, resolved from texture_set.metalness_emissive_roughness. undefined if this texture has no texture set or no MER entry.

      Returns Texture

    • get normal(): Texture

      The normal map companion texture, resolved from texture_set.normal. undefined if this texture has no texture set or no normal map entry.

      Returns Texture

    • get textureSet(): Record<string, unknown>

      The raw data from the companion <name>.texture_set.json file, if present. Contains PBR layer definitions — use normal, heightmap, and mer for resolved Texture objects instead of parsing this manually.

      Returns Record<string, unknown>

    • get usedByEntities(): Entity[]

      All entities whose resource pack texture definitions include this texture.

      Returns Entity[]

    Methods

    • Reads the raw bytes of this texture file from disk. Returns undefined in browser mode or if the file cannot be read.

      Returns Buffer<ArrayBufferLike>