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", base: "magma_cream",
name: "Custom Item", name: "Custom Item",
qty: 32, qty: 32,
useRecipe: true,
recipe: [ recipe: [
"###", "###",
"# #", "# #",
@ -17,6 +18,7 @@ ModAPI.addEventListener("lib:libcustomitems:loaded", () => {
"id": "dirt" "id": "dirt"
} }
}, },
//Optional: onRightClickGround
onRightClickGround: `/*/user, world, itemstack, blockpos/*/ onRightClickGround: `/*/user, world, itemstack, blockpos/*/
itemstack.stackSize -= 1; itemstack.stackSize -= 1;
if (itemstack.stackSize < 1) { if (itemstack.stackSize < 1) {
@ -25,6 +27,7 @@ ModAPI.addEventListener("lib:libcustomitems:loaded", () => {
user.setHealth(2); user.setHealth(2);
return true; //PreventDefault return true; //PreventDefault
`, `,
//Optional: onLeftClickGround
onLeftClickGround: `/*/user, world, itemstack, blockpos/*/ onLeftClickGround: `/*/user, world, itemstack, blockpos/*/
itemstack.stackSize -= 1; itemstack.stackSize -= 1;
if (itemstack.stackSize < 1) { if (itemstack.stackSize < 1) {
@ -32,6 +35,11 @@ ModAPI.addEventListener("lib:libcustomitems:loaded", () => {
} }
user.setHealth(20); user.setHealth(20);
return true; //PreventDefault 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,8 +142,10 @@
} }
var craftingManager = ModAPI.reflect.getClassById("net.minecraft.item.crafting.CraftingManager").staticMethods.getInstance.method(); var craftingManager = ModAPI.reflect.getClassById("net.minecraft.item.crafting.CraftingManager").staticMethods.getInstance.method();
if((data.useRecipe !== false) || (data.useRecipe !== "false")) {
ModAPI.hooks.methods.nmic_CraftingManager_addRecipe(craftingManager, testItem, recipe); ModAPI.hooks.methods.nmic_CraftingManager_addRecipe(craftingManager, testItem, recipe);
} }
}
ModAPI.dedicatedServer.appendCode(libServerside); ModAPI.dedicatedServer.appendCode(libServerside);
ModAPI.dedicatedServer.appendCode("globalThis.LCI_registerItem = " + LCI_registerItem.toString()); ModAPI.dedicatedServer.appendCode("globalThis.LCI_registerItem = " + LCI_registerItem.toString());
window.LibCustomItems = {}; window.LibCustomItems = {};