Перейти к основному содержимому

Class: ItemStack

A detached, mutable item stack value owned by QuestScript.

class ItemStack

Related API: DataValue, ItemStackData, ItemStackDataInput

Constructors

Constructor

def __init__(self, type_id: str, amount: Optional[int]=1) -> None:

Create a stack for a namespaced item type and initial amount.

Properties

amount

amount: int

Mutable item count.

name_tag

name_tag: str

Mutable custom display name; use an empty string to clear it.

type_id

@property
def type_id(self) -> str:

Namespaced item type identifier.

Methods

from_data

@staticmethod
def from_data(data: Union[ItemStackData, ItemStackDataInput]) -> ItemStack:

Restore every declared field from a typed ItemStackData snapshot.

Related API: ItemStack, ItemStackData, ItemStackDataInput

clone

def clone(self) -> ItemStack:

Return an independent copy of this stack.

Related API: ItemStack

get_lore

def get_lore(self) -> Sequence[str]:

Return a copy of the current lore lines.

set_lore

def set_lore(self, lore: Optional[Sequence[str]]=None) -> None:

Replace the lore; None clears it.

get_tags

def get_tags(self) -> Sequence[str]:

Return the immutable item tags provided by Minecraft.

has_tag

def has_tag(self, tag: str) -> bool:

Return whether the item has a particular Minecraft tag.

get_data

def get_data(self, key: str) -> DataValue:

Read data in the calling Script's automatic script-name namespace.

Known runtime defect: current storage is still shared by every Script.

Related API: DataValue

set_data

def set_data(self, key: str, value: Optional[DataValue]=None) -> None:

Write or remove data in the calling Script's automatic namespace.

Known runtime defect: current storage is still shared by every Script.

Related API: DataValue

get_data_keys

def get_data_keys(self) -> Sequence[str]:

Return the available QuestScript data keys on this stack.

to_data

def to_data(self) -> ItemStackData:

Return a detached, typed snapshot accepted by ItemStack.from_data.

Related API: ItemStackData