From ceecec34786deaf9cf46208961138b5984842aa1 Mon Sep 17 00:00:00 2001 From: Scratch-hv | Oeil-de-Lynx <104771596+OeildeLynx31@users.noreply.github.com> Date: Thu, 12 Sep 2024 20:47:47 +0200 Subject: [PATCH] Add enchant effect to the wooden axe of the worldedit mod --- examplemods/Worldedit.js | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/examplemods/Worldedit.js b/examplemods/Worldedit.js index 3ba9a19..e74f000 100644 --- a/examplemods/Worldedit.js +++ b/examplemods/Worldedit.js @@ -144,3 +144,30 @@ ModAPI.addEventListener("lib:libcustomitems:loaded", () => { }); }); })(); + +ModAPI.addEventListener("update", () => { + let inventoryItems = ModAPI.mcinstance.$thePlayer.$inventory.$mainInventory.data; + inventoryItems.forEach((item) => { + if (item != null) { + if (item.$getDisplayName() == 'Wand' && item.$isItemEnchanted() === 0) { + craftResult.$addEnchantment(); // add effect to item in inventory + } + } + }) + if (String(ModAPI.mcinstance.$currentScreen).indexOf('inventory.GuiCrafting') > -1) { + let craftMatrixItems = ModAPI.mcinstance.$currentScreen.$inventorySlots0.$craftMatrix1.$stackList.data; + craftMatrixItems.forEach((item) => { + if (item != null) { + if (item.$getDisplayName() == 'Wand' && item.$isItemEnchanted() === 0) { + craftResult.$addEnchantment(); // add effect to item in crafing grid + } + } + }) + let craftResult = ModAPI.mcinstance.$currentScreen.$inventorySlots0.$craftResult0.$stackResult.data[0]; + if (craftResult != null) { + if (craftResult.$getDisplayName() == 'Wand' && craftResult.$isItemEnchanted() === 0) { + craftResult.$addEnchantment(); // add effect to item in crafing result + } + } + } +})