Type of item to create. See the @minecraft/vanilla-data.MinecraftItemTypes enumeration for a list of standard item types in Minecraft experiences.
Optionalamount: numberNumber of items to place in the stack, between 1-255. The provided value will be clamped to the item's maximum stack size. Note that certain items can only have one item in the stack.
BetaamountNumber of the items in the stack. Valid values range between 1-255. The provided value will be clamped to the item's maximum stack size.
This property can't be edited in read-only mode.
ReadonlyisBetakeepGets or sets whether the item is kept on death.
This property can't be edited in read-only mode.
BetalockGets or sets the item's lock mode. The default value is
ItemLockMode.none.
This property can't be edited in read-only mode.
ReadonlymaxOptional BetanameGiven name of this stack of items. The name tag is displayed
when hovering over the item. Setting the name tag to an
empty string or undefined will remove the name tag.
This property can't be edited in read-only mode.
ReadonlytypeReadonlytypeBetaGet the list of block types this item can break in Adventure mode.
This function can't be called in read-only mode.
BetaGet the list of block types this item can be placed on in Adventure mode.
This function can't be called in read-only mode.
The identifier of the component (e.g., 'minecraft:food') to retrieve. If no namespace prefix is specified, 'minecraft:' is assumed. If the component is not present on the item stack or doesn't exist, undefined is returned.
ItemStack to check stacking compatability with.
True if the Item Stack is stackable with the itemStack passed in.
BetaOptionalblockIdentifiers: string[]String list of block types that the item can destroy.
The list of block types this item can break in Adventure mode. The block names are displayed in the item's tooltip. Setting the value to undefined will clear the list.
This function can't be called in read-only mode.
BetaOptionalblockIdentifiers: string[]String list of block types that the item can be placed on.
The list of block types this item can be placed on in Adventure mode. This is only applicable to block items. The block names are displayed in the item's tooltip. Setting the value to undefined will clear the list.
This function can't be called in read-only mode.
OptionalloreList: string[]List of lore lines. Each element in the list represents a new line. The maximum lore line count is 20. The maximum lore line length is 50 characters.
Sets the lore value - a secondary display string - for an ItemStack. The lore list is cleared if set to an empty string or undefined.
This function can't be called in read-only mode.
const diamondAwesomeSword = new mc.ItemStack(mc.MinecraftItemTypes.diamondSword, 1);
let players = mc.world.getAllPlayers();
diamondAwesomeSword.setLore(["§c§lDiamond Sword of Awesome§r", "+10 coolness", "§p+4 shiny§r"]);
// hover over/select the item in your inventory to see the lore.
const inventory = players[0].getComponent("inventory") as mc.EntityInventoryComponent;
inventory.container.setItem(0, diamondAwesomeSword);
let item = inventory.container.getItem(0);
if (item) {
let enchants = item.getComponent("minecraft:enchantments") as mc.ItemEnchantsComponent;
let knockbackEnchant = new mc.Enchantment("knockback", 3);
enchants.enchantments.addEnchantment(knockbackEnchant);
}
BetaName of the item type event to trigger. If a namespace is not specified, minecraft: is assumed.
Triggers an item type event. For custom items, a number of events are defined in an items' definition for key item behaviors.
This function can't be called in read-only mode.
Defines a collection of items.