Script API - v1.21.100
    Preparing search index...

    Contains information on a type of enchantment.

    import { EnchantmentType } from "@minecraft/server";

    // EnchantmentType represents a specific type of enchantment
    // This is typically used to identify enchantments on items

    // Example of working with enchantment types
    function demonstrateEnchantmentType() {
    // EnchantmentType is usually obtained from the EnchantmentTypes registry
    // but for demonstration, we show how it would be used

    // Example properties that an EnchantmentType would have:
    const enchantmentExample = {
    id: "minecraft:sharpness",
    maxLevel: 5,
    };

    console.log(`Enchantment ID: ${enchantmentExample.id}`);
    console.log(`Maximum level: ${enchantmentExample.maxLevel}`);

    // EnchantmentType would be used in contexts like:
    // - Checking what enchantments are on an item
    // - Adding enchantments to items
    // - Comparing enchantment types

    return enchantmentExample;
    }

    // Usage example
    const enchantmentInfo = demonstrateEnchantmentType();
    Index

    Constructors

    Properties

    Constructors

    • Parameters

      • enchantmentType: string

      Returns EnchantmentType

      This function can throw errors.

    Properties

    id: string

    The name of the enchantment type.

    This property can't be read in early-execution mode.

    maxLevel: number

    The maximum level this type of enchantment can have.

    This property can't be read in early-execution mode.