#Why isnt this enchanting the item?
1 messages · Page 1 of 1 (latest)
seems like a bug with gametest addEnchantment not doing anything
const itemStack = new Minecraft.ItemStack("minecraft:bow", 1)
const enchantment = new Minecraft.Enchantment("infinity", 1);
const component = (itemStack.getComponent("enchantments") as Minecraft.ItemEnchantsComponent);
Minecraft.world.sendMessage(`Can add enchantment?: ${component.enchantments.canAddEnchantment(enchantment)}`);
const result = component.enchantments.addEnchantment(enchantment);
Minecraft.world.sendMessage(`Enchantment added?: ${result}`);
Minecraft.world.sendMessage(`Enchantment is on item?: ${component.enchantments.getEnchantment(enchantment.type.id) !== undefined}`);
inventory.setItem(1, itemStack);
i found a way
to get it working
but my get enchantment function
isnt saying anything
it doesnt report an error its just addEnchantment isnt actually adding the enchantment for some reason
no
console.log(getEnchantments(item20, "power"))```
const getEnchantments = (item, type) => {
const enchants = item.getComponent('enchantments');
return enchants.enchantments.getEnchantment(type).level
};```
just use my wrapper
u don’t even know js lol
const ench = item.getComponent("enchantments")
const enchList = ench.enchantments
enchList.addEnchantment(new Enchantment("infinity",1))
ench.enchantments = enchList
``` @manic hemlock
wheres your enchantments wrapper? im trying to addEnchantments myself and if feels broke :/