For AI agents: the complete documentation index is available at /llms.txt, the full documentation bundle is available at /llms-full.txt, and this page is available as Markdown at /server/classes/ItemComponentRegistry.md.

Class: ItemComponentRegistry

component

Beta

提供为物品注册自定义组件的功能。

Provides the functionality for registering custom components for items.

Methods

registerCustomComponent()

registerCustomComponent(name, itemCustomComponent): void

Early Execution Beta

Parameters

name

string

表示该自定义组件的 ID,必须包含命名空间。该 ID 可在物品 JSON 配置的 'minecraft:custom_components' 物品组件下指定。

itemCustomComponent

ItemCustomComponent

当使用此自定义组件 ID 的物品上发生对应事件时,将被调用的事件函数集合。

Returns

void

Remarks

注册一个可在物品 JSON 配置中使用的物品自定义组件。

Registers an item custom component that can be used in item JSON configuration.

Throws

This function can throw errors.

CustomComponentInvalidRegistryError

EngineError

ItemCustomComponentAlreadyRegisteredError

ItemCustomComponentReloadNewComponentError

ItemCustomComponentReloadNewEventError

ItemCustomComponentReloadVersionError

NamespaceNameError

同领域相关