// priority: 12
// Visit the wiki for more info - https://kubejs.com/
// This script can be reloaded with the reload command.

ServerEvents.loaded((event) => {
  if (Platform.mods.worldedit) {
    console.log("WorldEdit is installed!");
  } else {
    console.log("WorldEdit is not installed.");
  }
  global.isWorldEditInstalled = Platform.mods.worldedit ? true : false;
});

const flintBlockID = 'supplementaries:flint_block';
const createDG = 'createdieselgenerators:';
const eureka = 'vs_eureka:';
const clockwork = 'vs_clockwork:'
const mowziesmobs = 'mowziesmobs:';

/**
 * 
 * 
 * 
 * 
 *
 * 
 * 
 * 
 * 
 * Custom item and block recipes
 * 
 */
ServerEvents.recipes((event) => {



    /**
     * 
     * 
     * Kubejs Wanderlite ingot
     */
    event.recipes.create.crushing([
        "kubejs:wanderlite_dust",
        // Item.of("kubejs:wanderlite_dust").withChance(0.1)
    ], "vs_clockwork:wanderlite_matrix").processingTime(500);

    event.recipes.create.crushing([
        Item.of("kubejs:wanderlite_dust").withChance(0.5)
    ], "vs_clockwork:wanderlite_crystal").processingTime(300);

    event.recipes.create.crushing([
        Item.of("kubejs:wanderlite_dust")
    ], "kubejs:wanderlite_ingot").processingTime(700);


    event.recipes.create.mixing(
        ['kubejs:wanderlite_ingot', 'kubejs:wanderlite_ingot'],
        [
            "kubejs:wanderlite_dust",

            //1 enderium ingot requires 0.5 diamonds, 1 ender pearls, 1.5 lead
            "thermal:enderium_ingot", "thermal:enderium_ingot",
            "thermal:enderium_ingot", "thermal:enderium_ingot",
            "thermal:enderium_ingot", "thermal:enderium_ingot",
            "thermal:enderium_ingot", "thermal:enderium_ingot",
            "thermal:enderium_ingot", "thermal:enderium_ingot",

            "create:powdered_obsidian", "create:powdered_obsidian",
            "create:powdered_obsidian", "create:powdered_obsidian",
            "create:powdered_obsidian", "create:powdered_obsidian",
            "create:powdered_obsidian", "create:powdered_obsidian",

            "create:rose_quartz", "create:rose_quartz",
            "create:rose_quartz", "create:rose_quartz",
            "create:rose_quartz", "create:rose_quartz",
            "create:rose_quartz", "create:rose_quartz",
        ]).superheated();


    /**
     * 
     * 
     * Create components
     */
    event.shaped(Item.of("kubejs:brass_piston", 1), [
        "  G",
        " I ",
        "P  "
    ], {
        //top
        G: "kubejs:brass_gear",
        // G: "create:brass_ingot",
        //end
        P: "create:brass_nugget",
        //rod
        // I: "createaddition:iron_rod",
        I: "createaddition:brass_rod",
    });

    event.shaped(Item.of("kubejs:brass_gear", 1), [
        " P ",
        "PIP",
        " P "
    ], {
        P: "create:brass_ingot",
        I: "minecraft:iron_nugget",
    });

    event.shaped(Item.of("kubejs:precision_component", 1),
        ["PPP", "PPP", "PPP"], {
        P: "create:precision_mechanism",
    });

    event.shaped(Item.of("kubejs:precision_machine", 1),
        ["PPP", "PPP", "PPP"], {
        P: "kubejs:precision_component",
    });


    event.shaped(Item.of("create:precision_mechanism", 9), ["kubejs:precision_component"]);
    event.shaped(Item.of("kubejs:precision_component", 9), ["kubejs:precision_machine"]);


    //Dirt
    event.shaped(Item.of("kubejs:phantom_dirt", 12), ["BSB", "BFB", "BSB"], {
        B: "minecraft:dirt",
        F: "minecraft:phantom_membrane",
        S: "minecraft:string",
    });

    //Stone
    event.shaped(Item.of("kubejs:phantom_stone", 12), ["BSB", "BFB", "BSB"], {
        B: "minecraft:stone",
        F: "minecraft:phantom_membrane",
        S: "minecraft:string",
    });

    //netherrack
    event.shaped(Item.of("kubejs:phantom_netherrack", 12), ["BSB", "BFB", "BSB"], {
        B: "minecraft:netherrack",
        F: "minecraft:phantom_membrane",
        S: "minecraft:string",
    });

    //snow
    event.shaped(Item.of("kubejs:phantom_snow", 12), ["BSB", "BFB", "BSB"], {
        B: "minecraft:snow_block",
        F: "minecraft:phantom_membrane",
        S: "minecraft:string",
    });

    //sandstone
    event.shaped(Item.of("kubejs:phantom_sandstone", 12), ["BSB", "BFB", "BSB"], {
        B: "minecraft:sandstone",
        F: "minecraft:phantom_membrane",
        S: "minecraft:string",
    });

    //red sandstone
    event.shaped(Item.of("kubejs:phantom_red_sandstone", 12), ["BSB", "BFB", "BSB"], {
        B: "minecraft:red_sandstone",
        F: "minecraft:phantom_membrane",
        S: "minecraft:string",
    });

    //cobblestone
    event.shaped(Item.of("kubejs:phantom_cobblestone", 12), ["BSB", "BFB", "BSB"], {
        B: "minecraft:cobblestone",
        F: "minecraft:phantom_membrane",
        S: "minecraft:string",
    });

    //stone bricks
    event.shaped(Item.of("kubejs:phantom_stone_bricks", 12), ["BSB", "BFB", "BSB"], {
        B: "minecraft:stone_bricks",
        F: "minecraft:phantom_membrane",
        S: "minecraft:string",
    });

    //end stone
    event.shaped(Item.of("kubejs:phantom_end_stone", 12), ["BSB", "BFB", "BSB"], {
        B: "minecraft:end_stone",
        F: "minecraft:phantom_membrane",
        S: "minecraft:string",
    });


    //Steering mechanism
    let incomplete = 'kubejs:incomplete_steering_mechanism';
    // let incomplete = 'create:incomplete_precision_mechanism';

    event.recipes.create.sequenced_assembly([
        Item.of('kubejs:steering_mechanism').withChance(125.0), // this is the item that will appear in JEI as the result
        Item.of('create:brass_sheet').withChance(8.0), // the rest of these items will be part of the scrap
        Item.of('create:andesite_alloy').withChance(15.0),
        Item.of('create:cogwheel').withChance(5.0),
        Item.of('create:shaft').withChance(2.0),
        Item.of('create:crushed_gold_ore').withChance(2.0),
        Item.of('2x minecraft:gold_nugget').withChance(2.0),
        'minecraft:iron_ingot',

        //create:brass_sheet
    ], 'northstar:circuit', [ // the input #forge:plates/iron
        // the transitional item set by `transitionalItem('create:incomplete_large_cogwheel')` is the item used during the intermediate stages of the assembly
        // like a normal recipe function, is used as a sequence step in this array. Input and output have the transitional item
        event.recipes.createDeploying(incomplete, [incomplete, 'create:golden_sheet']),
        event.recipes.createPressing(incomplete, incomplete),
        event.recipes.createDeploying(incomplete, [incomplete, 'create:large_cogwheel']),
        event.recipes.createDeploying(incomplete, [incomplete, 'create:cogwheel']),
        // event.recipes.createDeploying(incomplete, [incomplete, 'minecraft:iron_nugget']),
        // event.recipes.createCutting(incomplete, incomplete), 
        event.recipes.createDeploying(incomplete, [incomplete, 'create:precision_mechanism'])

    ]).transitionalItem(incomplete).loops(20) // set the transitional item and the number of loops



});