let item = new ItemStack('minecraft:diamond_sword');
let ecomp = item?.getComponent('minecraft:enchantable');
if(ecomp) {
ecomp.addEnchantment({type: new EnchantmentType('sharpness'), level: 1});
}
player.getComponent('minecraft:inventory').container.addItem(item);
When i try to add enchantments on ItemStack using code above always unable and no error message.
(Version: 1.9.0-beta)
note: Sorry, my english is bad.
Document Details
⚠ Do not edit this section. It is required for learn.microsoft.com ➟ GitHub issue linking.
ID: 4f22a783-9919-f384-da3f-38dd70c82150
Version Independent ID: 4f22a783-9919-f384-da3f-38dd70c82150
When i try to add enchantments on ItemStack using code above always unable and no error message. (Version: 1.9.0-beta) note: Sorry, my english is bad.
Document Details
⚠ Do not edit this section. It is required for learn.microsoft.com ➟ GitHub issue linking.