pumpkin-plugin-wit/v0.1/item-stack.wit
Alexander Medvedev f481f5677d add more stuff
2026-08-29 20:31:24 +02:00

105 lines
4.5 KiB
Plaintext

interface item-stack {
use attributes.{attribute, attribute-modifier};
use data-components.{data-component};
use enchantments.{attribute-modifier-slot, enchantment};
use text.{text-component};
/// Represents an enchantment and its level.
record enchantment-value {
enchantment: enchantment,
level: u32,
}
/// Represents a custom enchantment and its level on an item stack.
record custom-enchantment-value {
enchantment-id: string,
level: u32,
}
/// Represents an attribute modifier applied to an item stack for a specific slot.
record item-attribute-modifier {
attribute: attribute,
modifier: attribute-modifier,
slot: attribute-modifier-slot,
}
/// Represents a data component and its serialized value.
record data-component-value {
component: data-component,
/// The serialized value of the component.
value: list<u8>,
}
use common.{nbt-entry, nbt-tree, nbt-tag};
resource item-stack {
constructor(registry-key: string, count: u8);
/// Returns the unique registry key of the item (e.g., "minecraft:diamond").
get-registry-key: func() -> string;
/// Returns the number of items in the stack.
get-count: func() -> u8;
/// Sets the number of items in the stack.
set-count: func(count: u8);
/// Returns the maximum number of items that can be in this stack.
get-max-count: func() -> u8;
/// Returns all enchantments on this item stack.
get-enchantments: func() -> list<enchantment-value>;
/// Adds an enchantment to this item stack.
add-enchantment: func(enchantment: enchantment, level: u32);
/// Removes an enchantment from this item stack.
remove-enchantment: func(enchantment: enchantment);
/// Returns all custom enchantments on this item stack.
get-custom-enchantments: func() -> list<custom-enchantment-value>;
/// Adds a custom enchantment to this item stack.
add-custom-enchantment: func(enchantment-id: string, level: u32);
/// Removes a custom enchantment from this item stack.
remove-custom-enchantment: func(enchantment-id: string);
/// Returns the level of a custom enchantment on this item stack, if present.
get-custom-enchantment-level: func(enchantment-id: string) -> option<u32>;
/// Returns whether this item stack has a specific custom enchantment.
has-custom-enchantment: func(enchantment-id: string) -> bool;
/// Returns all attribute modifiers on this item stack.
get-attribute-modifiers: func() -> list<item-attribute-modifier>;
/// Adds an attribute modifier to this item stack.
add-attribute-modifier: func(modifier: item-attribute-modifier);
/// Removes all attribute modifiers for a specific attribute from this item stack.
remove-attribute-modifiers: func(attribute: attribute);
/// Clears all custom attribute modifiers from this item stack.
clear-attribute-modifiers: func();
/// Returns the lore of this item stack.
get-lore: func() -> list<text-component>;
/// Sets the lore of this item stack.
set-lore: func(lore: list<text-component>);
/// Adds a line to the lore of this item stack.
add-lore: func(line: text-component);
/// Returns the custom name of this item stack, if set.
get-custom-name: func() -> option<text-component>;
/// Sets the custom name of this item stack.
set-custom-name: func(name: option<text-component>);
/// Sets a namespaced custom data value on this item stack.
set-custom-data: func(namespace: string, key: string, value: nbt-tree);
/// Returns a namespaced custom data value from this item stack, if set.
get-custom-data: func(namespace: string, key: string) -> option<nbt-tree>;
/// Removes a namespaced custom data value from this item stack.
remove-custom-data: func(namespace: string, key: string);
/// Returns whether this item stack has a namespaced custom data value.
has-custom-data: func(namespace: string, key: string) -> bool;
/// Returns all data components on this item stack.
get-components: func() -> list<data-component-value>;
/// Sets a data component on this item stack.
set-component: func(component: data-component, value: list<u8>);
/// Removes a data component from this item stack.
remove-component: func(component: data-component);
}
}