// 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;
});


/*
Add Recipes
 */

const flintBlockID = 'supplementaries:flint_block';

ServerEvents.recipes((event) => {
  event.shaped(
    //Add nametag recipe.
    Item.of("minecraft:name_tag", 1), [
    "BCC",
    " BC",
    "A B"
  ],
    {
      A: "minecraft:writable_book",
      B: "minecraft:paper",
      C: "minecraft:string",
    }
  );


  event.shaped(
    //I think create northstar is missing this recipe
    Item.of("northstar:lunar_sapphire_crystal", 1), [
    " C ",
    "RCR",
    "ICI"
  ],
    {
      I: "minecraft:iron_ingot",
      R: "minecraft:redstone",
      C: "northstar:polished_lunar_sapphire",
    }
  );

  //Replace recipes
  event.remove([
    { output: "waystones:warp_plate" },
  ]);

  //This should be hard to make for 2 reasons
  // A) you should use other means of travel
  // B) warp plate is free (no XP cost) (Warp plate)
  event.recipes.create.mechanical_crafting('waystones:warp_plate', [
    'FFCFF',
    'DPEPD',
    'DPOPD',
    'DOOOD',
    'SSWSS',
  ],
    {
      D: 'waystones:warp_dust',
      // B: 'minecraft:stone_bricks',
      S: 'minecraft:obsidian',
      O: 'create:powdered_obsidian',
      P: 'minecraft:ender_pearl',
      E: 'minecraft:ender_eye',
      C: 'thermal:rf_coil',
      W: 'waystones:warp_stone',
      F: flintBlockID,
    });

});

/**
 * Add phantom block recipes
 */
ServerEvents.recipes((event) => {
  //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",
  });

});