ServerEvents.recipes(event => {
  event.recipes.summoningrituals
    .altar('minecraft:diamond')
    .id('kubejs:summoning/eldorath')

    .input('4x minecraft:lapis_lazuli')
    .input('16x minecraft:stone')
    .input('minecraft:redstone')

    .recipeTime(100)
    .dayTime('day')
})

SummoningRituals.complete(event => {
  const id = String(event.recipe.getId())

  if (id !== 'kubejs:summoning/eldorath') return

  let cmd = 'summon armageddon_mod:eldoraththe_ancient_builder ~ ~ ~'

  if (event.pos) {
    cmd = `summon armageddon_mod:eldoraththe_ancient_builder ${event.pos.x} ${event.pos.y + 1} ${event.pos.z}`
  } else if (event.block) {
    cmd = `summon armageddon_mod:eldoraththe_ancient_builder ${event.block.x} ${event.block.y + 1} ${event.block.z}`
  }

  event.server.runCommandSilent(cmd)
})
