Type of item to create. See the @minecraft/vanilla-data.MinecraftItemTypes enumeration for a list of standard item types in Minecraft experiences.
Optional
amount: 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.
Readonly
isReadonly
maxOptional
nameReadonly
typeReadonly
typeReturns a copy of this item stack.
The identifier of the component (e.g., 'minecraft:food'). If no namespace prefix is specified, 'minecraft:' is assumed. Available component IDs can be found as part of the ItemComponentTypes enum.
Returns the component if it exists on the item stack, otherwise undefined.
Beta
The property identifier.
Returns the value for the property, or undefined if the property has not been set.
Beta
Returns the total size, in bytes, of all the dynamic properties that are currently stored for this entity. This includes the size of both the key and the value. This can be useful for diagnosing performance warning signs - if, for example, an entity has many megabytes of associated dynamic properties, it may be slow to load on various devices.
ItemStack to check stacking compatability with.
True if the Item Stack is stackable with the itemStack passed in.
Optional
blockIdentifiers: string[]String list of block types that the item can destroy.
Optional
blockIdentifiers: string[]String list of block types that the item can be placed on.
Beta
The property identifier.
Optional
value: string | number | boolean | Vector3Data value of the property to set.
Optional
loreList: 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);
}
Beta
Name of the item type event to trigger. If a namespace is not specified, minecraft: is assumed.
Defines a collection of items.