Increase LCI featureset

This commit is contained in:
ZXMushroom63 2024-09-18 15:51:19 +08:00
parent 8d4a8152be
commit df75615ea7
2 changed files with 12 additions and 2 deletions

View File

@ -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);
`,
});
});

View File

@ -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());