bedrock-kit
    Preparing search index...

    Class AddOn

    The main entry point for bedrockKit. Represents a Minecraft Bedrock addon consisting of a behavior pack and an optional resource pack.

    Create instances using the static async factory methods:

    // Node.js
    const addon = await AddOn.fromDisk("./behavior_pack", "./resource_pack");

    // Browser
    const addon = await AddOn.fromFiles(bpFiles, rpFiles);

    // Navigate
    const zombie = addon.entities.get("minecraft:zombie");
    console.log(zombie?.displayName); // "Zombie"
    console.log(zombie?.spawnRule?.biomeTags); // ["monster", "overworld"]

    const spear = addon.items.get("minecraft:copper_spear");
    console.log(spear?.texture?.id); // "textures/items/copper_spear"
    console.log(spear?.recipes.length); // 1
    Index

    Accessors

    • get behaviorPackPath(): string

      Resolved absolute path to the behavior pack directory.

      Returns string

    • get languages(): { get(lang?: string): LangFile }

      Access to localization files. Call .get(langCode) to retrieve a LangFile for the given language code.

      Returns { get(lang?: string): LangFile }

      const en = addon.languages.get("en_US");
      console.log(en?.get("item.minecraft.stick.name")); // "Stick"
    • get resourcePackPath(): string

      Resolved absolute path to the resource pack directory.

      Returns string

    Methods

    • Returns the asset whose file path matches (or ends with) filePath. Searches across all loaded asset types.

      Pass a class constructor as the second argument to narrow the return type. Returns undefined if the asset is found but is not an instance of the requested class.

      Parameters

      • filePath: string

      Returns Asset

      const asset  = addon.getAssetByPath("entities/zombie.json");
      const entity = addon.getAssetByPath("entities/zombie.json", BehaviorEntity);
      const recipe = addon.getAssetByPath("recipes/acacia_chest_boat.json", Recipe);
    • Returns the asset whose file path matches (or ends with) filePath. Searches across all loaded asset types.

      Pass a class constructor as the second argument to narrow the return type. Returns undefined if the asset is found but is not an instance of the requested class.

      Type Parameters

      Parameters

      • filePath: string
      • type: new (...args: any[]) => T

      Returns T

      const asset  = addon.getAssetByPath("entities/zombie.json");
      const entity = addon.getAssetByPath("entities/zombie.json", BehaviorEntity);
      const recipe = addon.getAssetByPath("recipes/acacia_chest_boat.json", Recipe);
    • Creates an AddOn by reading pack directories from disk (Node.js only).

      Parameters

      • bpPath: string

        Absolute or relative path to the behavior pack directory.

      • OptionalrpPath: string

        Absolute or relative path to the resource pack directory. Optional — omit if the addon has no resource pack.

      Returns Promise<AddOn>

      const addon = await AddOn.fromDisk("./behavior_pack", "./resource_pack");
      
    • Creates an AddOn from browser File[] arrays (browser only).

      Parameters

      • bpFiles: File[]

        Files from the behavior pack folder selection.

      • rpFiles: File[]

        Files from the resource pack folder selection.

      Returns Promise<AddOn>

      const addon = await AddOn.fromFiles(bpFileList, rpFileList);