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/Potions.md.

Class: Potions

Beta

用于访问所有药水效果类型、传递类型以及创建药水。

Used for accessing all potion effect types, delivery types, and creating potions.

Methods

getAllDeliveryTypes()

static getAllDeliveryTypes(): PotionDeliveryType[]

Beta

Returns

PotionDeliveryType[]

所有已注册传递类型句柄的数组。

Array of all registered delivery type handles.

Remarks

获取所有已注册的药水传递类型的句柄。

Retrieves handles for all registered potion delivery types.


getAllEffectTypes()

static getAllEffectTypes(): PotionEffectType[]

Beta

Returns

PotionEffectType[]

所有已注册效果类型句柄的数组。

Array of all registered effect type handles.

Remarks

获取所有已注册的药水效果的类型句柄。

Retrieves all type handle for all registered potion effects.


getDeliveryType()

static getDeliveryType(potionDeliveryId): PotionDeliveryType | undefined

Beta

Parameters

potionDeliveryId

string

Returns

PotionDeliveryType | undefined

包装有效传递 ID 的类型句柄,如果传递 ID 无效则返回 undefined

A type handle wrapping the valid delivery id, or undefined for an invalid delivery id.

Remarks

获取指定药水传递 ID 的类型句柄。

Retrieves a type handle for a specified potion delivery id.


getEffectType()

static getEffectType(potionEffectId): PotionEffectType | undefined

Beta

Parameters

potionEffectId

string

有效的药水效果 ID。请参见 @minecraft/vanilla-data.MinecraftPotionEffectTypes。

A valid potion effect id. See @minecraft/vanilla-data.MinecraftPotionEffectTypes

Returns

PotionEffectType | undefined

包装有效效果 ID 的类型句柄,如果效果 ID 无效则返回 undefined

A type handle wrapping the valid effect id, or undefined for an invalid effect id.

Remarks

获取指定药水效果 ID 的类型句柄。

Retrieves a type handle for a specified potion effect id.


resolve()

static resolve<T, U>(potionEffectType, potionDeliveryType): ItemStack

Beta

Type Parameters

T

T extends string = MinecraftPotionEffectTypes

U

U extends string = MinecraftPotionDeliveryTypes

Parameters

potionEffectType

PotionEffectType | T

potionDeliveryType

PotionDeliveryType | U

Returns

ItemStack

Remarks

根据效果和传递类型创建药水。

Creates a potion given an effect and delivery type.

Throws

This function can throw errors.

EngineError

InvalidPotionDeliveryTypeError

InvalidPotionEffectTypeError