From df75615ea7504a37a53e2e24adc0ec5774993f6a Mon Sep 17 00:00:00 2001 From: ZXMushroom63 Date: Wed, 18 Sep 2024 15:51:19 +0800 Subject: [PATCH] Increase LCI featureset --- examplemods/CustomItemsDemo.js | 10 +++++++++- examplemods/lib.customitems.js | 4 +++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/examplemods/CustomItemsDemo.js b/examplemods/CustomItemsDemo.js index f81bffc..e062cc7 100644 --- a/examplemods/CustomItemsDemo.js +++ b/examplemods/CustomItemsDemo.js @@ -6,6 +6,7 @@ ModAPI.addEventListener("lib:libcustomitems:loaded", () => { base: "magma_cream", name: "Custom Item", qty: 32, + useRecipe: true, recipe: [ "###", "# #", @@ -17,6 +18,7 @@ ModAPI.addEventListener("lib:libcustomitems:loaded", () => { "id": "dirt" } }, + //Optional: onRightClickGround onRightClickGround: `/*/user, world, itemstack, blockpos/*/ itemstack.stackSize -= 1; if (itemstack.stackSize < 1) { @@ -25,6 +27,7 @@ ModAPI.addEventListener("lib:libcustomitems:loaded", () => { user.setHealth(2); return true; //PreventDefault `, + //Optional: onLeftClickGround onLeftClickGround: `/*/user, world, itemstack, blockpos/*/ itemstack.stackSize -= 1; if (itemstack.stackSize < 1) { @@ -32,6 +35,11 @@ ModAPI.addEventListener("lib:libcustomitems:loaded", () => { } user.setHealth(20); return true; //PreventDefault - ` + `, + //Optional: craftingExtra + craftingExtra: `/*/itemstack/*/ + let enchant = ModAPI.reflect.getClassByName("Enchantment").staticMethods.getEnchantmentById.method(5); //ENCHANTMENT_OXYGEN (respiration) + itemstack.addEnchantment(enchant); + `, }); }); \ No newline at end of file diff --git a/examplemods/lib.customitems.js b/examplemods/lib.customitems.js index 40a0280..8afbb3a 100644 --- a/examplemods/lib.customitems.js +++ b/examplemods/lib.customitems.js @@ -142,7 +142,9 @@ } var craftingManager = ModAPI.reflect.getClassById("net.minecraft.item.crafting.CraftingManager").staticMethods.getInstance.method(); - ModAPI.hooks.methods.nmic_CraftingManager_addRecipe(craftingManager, testItem, recipe); + if((data.useRecipe !== false) || (data.useRecipe !== "false")) { + ModAPI.hooks.methods.nmic_CraftingManager_addRecipe(craftingManager, testItem, recipe); + } } ModAPI.dedicatedServer.appendCode(libServerside); ModAPI.dedicatedServer.appendCode("globalThis.LCI_registerItem = " + LCI_registerItem.toString());