File size: 1,515 Bytes
8524bea
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
//Demo mod showing how to use lib.customitems.js
ModAPI.addEventListener("lib:libcustomitems:loaded", () => {
    console.log("Registered my cool custom item.");
    LibCustomItems.registerItem({
        tag: "mymod:test_item_1",
        base: "magma_cream",
        name: "Custom Item",
        qty: 32,
        useRecipe: true,
        recipe: [
            "###",
            "# #",
            "###"
        ],
        recipeLegend: {
            "#": {
                "type": "block",
                "id": "dirt"
            }
        },
        //Optional: onRightClickGround
        onRightClickGround: `/*/user, world, itemstack, blockpos/*/
        itemstack.stackSize -= 1;
        if (itemstack.stackSize < 1) {
            user.inventory.mainInventory[user.inventory.currentItem] = null;
        }
        user.setHealth(2);
        return true; //PreventDefault
        `,
        //Optional: onLeftClickGround
        onLeftClickGround: `/*/user, world, itemstack, blockpos/*/
        itemstack.stackSize -= 1;
        if (itemstack.stackSize < 1) {
            user.inventory.mainInventory[user.inventory.currentItem] = null;
        }
        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);
        `,
    });
});