From d2e25b28b2dca7a59de4f93b61dc7874ee747aaa Mon Sep 17 00:00:00 2001 From: Scratch-hv | Oeil-de-Lynx <104771596+OeildeLynx31@users.noreply.github.com> Date: Thu, 12 Sep 2024 19:10:45 +0200 Subject: [PATCH 1/4] Add metadatas to the example mod Worldedit.js --- examplemods/Worldedit.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/examplemods/Worldedit.js b/examplemods/Worldedit.js index 8f764aa..3ba9a19 100644 --- a/examplemods/Worldedit.js +++ b/examplemods/Worldedit.js @@ -1,5 +1,7 @@ -//WIP worldedit by radmanplays - +ModAPI.meta.title("Worldedit"); +ModAPI.meta.credits("By radmanplays"); +ModAPI.meta.icon("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAcUlEQVR42mNgoAcw1xT4D8Jka25LVQNjkg2Bac4OlP9fGqFImgHImmHY00z0f4af3H+SDADZDNIc6SwJpjXkuP+THHggm5ENIckrMGeDbIZ5hWgDQJo709XhziYpOpFtJjnuKdaM7OwhYjMIkG0zpQAAtFpjWIvu2dwAAAAASUVORK5CYII="); +ModAPI.meta.description("World eaglercraft mod."); ModAPI.addEventListener("lib:libcustomitems:loaded", () => { console.log("Registered worldedit custom items."); LibCustomItems.registerItem({ 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 2/4] 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 + } + } + } +}) From 002a7d2afcd132b1cd62d11f82cf7ee553d2e72d Mon Sep 17 00:00:00 2001 From: ZXMushroom63 <116805577+ZXMushroom63@users.noreply.github.com> Date: Sun, 15 Sep 2024 11:51:21 +0800 Subject: [PATCH 3/4] Update Worldedit.js --- examplemods/Worldedit.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examplemods/Worldedit.js b/examplemods/Worldedit.js index e74f000..52937a8 100644 --- a/examplemods/Worldedit.js +++ b/examplemods/Worldedit.js @@ -1,7 +1,7 @@ -ModAPI.meta.title("Worldedit"); +ModAPI.meta.title("WorldEdit"); ModAPI.meta.credits("By radmanplays"); ModAPI.meta.icon("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAcUlEQVR42mNgoAcw1xT4D8Jka25LVQNjkg2Bac4OlP9fGqFImgHImmHY00z0f4af3H+SDADZDNIc6SwJpjXkuP+THHggm5ENIckrMGeDbIZ5hWgDQJo709XhziYpOpFtJjnuKdaM7OwhYjMIkG0zpQAAtFpjWIvu2dwAAAAASUVORK5CYII="); -ModAPI.meta.description("World eaglercraft mod."); +ModAPI.meta.description("Use //wand, //set and //walls in singleplayer worlds."); ModAPI.addEventListener("lib:libcustomitems:loaded", () => { console.log("Registered worldedit custom items."); LibCustomItems.registerItem({ From 7c584b641f6f789674f3447a0cafad0ae7984335 Mon Sep 17 00:00:00 2001 From: Scratch-hv | Oeil-de-Lynx <104771596+OeildeLynx31@users.noreply.github.com> Date: Tue, 17 Sep 2024 20:34:00 +0200 Subject: [PATCH 4/4] Rewrote the enchant system on Worldedit.js Now it's permanent, but I don't have found a solution for the crafted items for now. --- examplemods/Worldedit.js | 32 +++++--------------------------- 1 file changed, 5 insertions(+), 27 deletions(-) diff --git a/examplemods/Worldedit.js b/examplemods/Worldedit.js index 52937a8..73a41ea 100644 --- a/examplemods/Worldedit.js +++ b/examplemods/Worldedit.js @@ -69,6 +69,11 @@ ModAPI.addEventListener("lib:libcustomitems:loaded", () => { const displayTag = NBTTagCompoundClass.constructors[0](); itemStack.$stackTagCompound.$setTag(ModAPI.util.str("display"), displayTag); + // Add the enchant effect to the item + let enchant = ModAPI.hooks._classMap.nme_Enchantment.staticMethods.getEnchantmentById.method(0); + enchant.$effectId = -1; + itemStack.$addEnchantment(enchant); + // Set item name displayTag.$setString(ModAPI.util.str("Name"), ModAPI.util.str("Wand")); @@ -144,30 +149,3 @@ 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 - } - } - } -})