Skip to content
BasaltSoftware
Bedrock 1.26.60

Site colour

Discord
Esc

    ↑↓ moveEnter openEsc close

    Keyboard shortcuts
    Ctrl K
    Search the whole site, from any page
    /
    Jump to the sidebar search, or search the whole site where there isn't one
    Enter
    Open the top search result
    Esc
    Clear the search, or close this panel
    ?
    Show these shortcuts

    Class in @minecraft/server

    Extends ItemComponent

    The enchantments on an item that takes them. Changes go on the stack at once.

    import { ItemEnchantableComponent } from '@minecraft/server';
    import { ItemStack, type ItemEnchantableComponent } from '@minecraft/server';
    const item = new ItemStack('minecraft:diamond_sword');
    const component: ItemEnchantableComponent | undefined = item.getComponent('minecraft:enchantable');
    if (component) {
    console.log(item.typeId, component.typeId);
    }
    import { ItemStack } from '@minecraft/server';
    const item = new ItemStack('minecraft:diamond_sword');
    const component = item.getComponent('minecraft:enchantable');
    if (component) {
    console.log(item.typeId, component.typeId);
    }

    static read-only

    static readonly componentId = "minecraft:enchantable";

    read-only

    readonly slots: string[];

    Always empty in Basalt.

    addEnchantment(enchantment: Enchantment): void;

    Puts an enchantment on, replacing the same one at another level.

    Parameters
    enchantment
    Enchantment
    Throws
    • Error if the item doesn’t take it, the level is out of range, or another enchantment on it excludes this one.
    addEnchantments(enchantments: Enchantment[]): void;
    Parameters
    enchantments
    Enchantment[]
    canAddEnchantment(enchantment: Enchantment): boolean;

    Whether addEnchantment would succeed.

    Parameters
    enchantment
    Enchantment
    Returns
    boolean
    getEnchantment(enchantmentType: EnchantmentType | string): { type: EnchantmentType; level: number } | undefined;
    Parameters
    enchantmentType
    EnchantmentType | string
    Returns
    { type: EnchantmentType; level: number } | undefined
    getEnchantments(): { type: EnchantmentType; level: number }[];
    Returns
    { type: EnchantmentType; level: number }[]
    hasEnchantment(enchantmentType: EnchantmentType | string): boolean;
    Parameters
    enchantmentType
    EnchantmentType | string
    Returns
    boolean
    removeAllEnchantments(): void;
    removeEnchantment(enchantmentType: EnchantmentType | string): void;
    Parameters
    enchantmentType
    EnchantmentType | string

    ItemComponentTypeMap.enchantable, ItemComponentTypeMap.minecraft:enchantable

    From ItemComponent: typeId, isValid