//Disable Enchanting Table:
BlockEvents.rightClicked('minecraft:enchanting_table', event => {
  event.cancel()
})

//Altar Enchanting Recipes:
//Efficiency:
BlockEvents.rightClicked(event => {
  if (event.level.isClientSide()) return
  if (event.hand !== 'main_hand') return

  const { block, player } = event
  if (block.id !== 'rediscovered:dragon_altar') return

  const main = player.mainHandItem
  const off  = player.offHandItem
  if (main.id !== 'minecraft:book' || off.id !== 'minecraft:diamond') return

  //Consume Exactly 1 of Each:
  main.shrink(1)
  off.shrink(1)

  //Give Efficiency I Book with a ShortTag (1s) instead of a DoubleTag (1.0d)
  const nbtString = '{StoredEnchantments:[{id:"minecraft:efficiency",lvl:1s}]}'
  const enchantedBook = Item.of('minecraft:enchanted_book', nbtString)
  player.give(enchantedBook)

  player.level.playSound(
    null,
    player.x, player.y, player.z,
    'block.enchantment_table.use',
    'blocks',
    1.0,
    1.0
  )
})

//Stasis:
BlockEvents.rightClicked(event => {
  if (event.level.isClientSide()) return
  if (event.hand !== 'main_hand') return

  const { block, player } = event
  if (block.id !== 'rediscovered:dragon_altar') return

  const main = player.mainHandItem
  const off  = player.offHandItem
  if (main.id !== 'minecraft:book' || off.id !== 'phantasm:crystal_shard') return

  main.shrink(1)
  off.shrink(1)

  const nbtString = '{StoredEnchantments:[{id:"supplementaries:stasis",lvl:1s}]}'
  const enchantedBook = Item.of('minecraft:enchanted_book', nbtString)
  player.give(enchantedBook)

  player.level.playSound(
    null,
    player.x, player.y, player.z,
    'block.enchantment_table.use',
    'blocks',
    1.0,
    1.0
  )
})

//Feather Falling:
BlockEvents.rightClicked(event => {
  if (event.level.isClientSide()) return
  if (event.hand !== 'main_hand') return

  const { block, player } = event
  if (block.id !== 'rediscovered:dragon_altar') return

  const main = player.mainHandItem
  const off  = player.offHandItem
  if (main.id !== 'minecraft:book' || off.id !== 'outer_end:halite_crystal') return

  main.shrink(1)
  off.shrink(1)

  const nbtString = '{StoredEnchantments:[{id:"minecraft:feather_falling",lvl:1s}]}'
  const enchantedBook = Item.of('minecraft:enchanted_book', nbtString)
  player.give(enchantedBook)

  player.level.playSound(
    null,
    player.x, player.y, player.z,
    'block.enchantment_table.use',
    'blocks',
    1.0,
    1.0
  )
})

//Sharpness:
BlockEvents.rightClicked(event => {
  if (event.level.isClientSide()) return
  if (event.hand !== 'main_hand') return

  const { block, player } = event
  if (block.id !== 'rediscovered:dragon_altar') return

  const main = player.mainHandItem
  const off  = player.offHandItem
  if (main.id !== 'minecraft:book' || off.id !== 'alexsmobs:cachalot_whale_tooth') return

  main.shrink(1)
  off.shrink(1)

  const nbtString = '{StoredEnchantments:[{id:"minecraft:sharpness",lvl:1s}]}'
  const enchantedBook = Item.of('minecraft:enchanted_book', nbtString)
  player.give(enchantedBook)

  player.level.playSound(
    null,
    player.x, player.y, player.z,
    'block.enchantment_table.use',
    'blocks',
    1.0,
    1.0
  )
})

//Alleviating:
//BlockEvents.rightClicked(event => {
  //if (event.level.isClientSide()) return
  //if (event.hand !== 'main_hand') return
//
  //const { block, player } = event
  //if (block.id !== 'rediscovered:dragon_altar') return
//
  //const main = player.mainHandItem
  //const off  = player.offHandItem
  //if (main.id !== 'minecraft:book' || off.id !== 'minecraft:ghast_tear') return
//
  //main.shrink(1)
  //off.shrink(1)
//
  //const nbtString = '{StoredEnchantments:[{id:"allurement:alleviating",lvl:1s}]}'
  //const enchantedBook = Item.of('minecraft:enchanted_book', nbtString)
  //player.give(enchantedBook)
//
  //player.level.playSound(
    //null,
    //player.x, player.y, player.z,
    //'block.enchantment_table.use',
    //'blocks',
    //1.0,
    //1.0
  //)
//})

//Thorns:
BlockEvents.rightClicked(event => {
  if (event.level.isClientSide()) return
  if (event.hand !== 'main_hand') return

  const { block, player } = event
  if (block.id !== 'rediscovered:dragon_altar') return

  const main = player.mainHandItem
  const off  = player.offHandItem
  if (main.id !== 'minecraft:book' || off.id !== 'rediscovered:rose') return //Don't Forget to Add Tag Here!

  main.shrink(1)
  off.shrink(1)

  const nbtString = '{StoredEnchantments:[{id:"minecraft:thorns",lvl:1s}]}'
  const enchantedBook = Item.of('minecraft:enchanted_book', nbtString)
  player.give(enchantedBook)

  player.level.playSound(
    null,
    player.x, player.y, player.z,
    'block.enchantment_table.use',
    'blocks',
    1.0,
    1.0
  )
})

//Looting:
BlockEvents.rightClicked(event => {
  if (event.level.isClientSide()) return
  if (event.hand !== 'main_hand') return

  const { block, player } = event
  if (block.id !== 'rediscovered:dragon_altar') return

  const main = player.mainHandItem
  const off  = player.offHandItem
  if (main.id !== 'minecraft:book' || off.id !== 'minecraft:pitcher_pod') return

  main.shrink(1)
  off.shrink(1)

  const nbtString = '{StoredEnchantments:[{id:"minecraft:looting",lvl:1s}]}'
  const enchantedBook = Item.of('minecraft:enchanted_book', nbtString)
  player.give(enchantedBook)

  player.level.playSound(
    null,
    player.x, player.y, player.z,
    'block.enchantment_table.use',
    'blocks',
    1.0,
    1.0
  )
})

//Air Hop:
//BlockEvents.rightClicked(event => {
  //if (event.level.isClientSide()) return
  //if (event.hand !== 'main_hand') return
//
  //const { block, player } = event
  //if (block.id !== 'rediscovered:dragon_altar') return
//
  //const main = player.mainHandItem
  //const off  = player.offHandItem
  //if (main.id !== 'minecraft:book' || off.id !== 'quark:bottled_cloud') return
//
  //main.shrink(1)
  //off.shrink(1)
//
  //const nbtString = '{StoredEnchantments:[{id:"airhop:air_hop",lvl:1s}]}'
  //const enchantedBook = Item.of('minecraft:enchanted_book', nbtString)
  //player.give(enchantedBook)
//
  //player.level.playSound(
    //null,
    //player.x, player.y, player.z,
    //'block.enchantment_table.use',
    //'blocks',
    //1.0,
    //1.0
  //)
//})

// Air Hop:
BlockEvents.rightClicked(event => {
  if (event.level.isClientSide()) return
  if (event.hand !== 'main_hand') return

  const { block, player } = event
  if (block.id !== 'rediscovered:dragon_altar') return

  const main = player.mainHandItem
  const off  = player.offHandItem
  if (main.id !== 'minecraft:book' || off.id !== 'quark:bottled_cloud') return

  // consume inputs
  main.shrink(1)
  off.shrink(1)

  // give back empty bottle into off‑hand
  // Note: this **overwrites** whatever was in off‑hand,  
  // but we know it's already empty now that we've shrunk it.
  player.offHandItem = Item.of('minecraft:glass_bottle')

  // give the enchanted book to the main inventory
  const nbtString = '{StoredEnchantments:[{id:"airhop:air_hop",lvl:1s}]}'
  player.give(Item.of('minecraft:enchanted_book', nbtString))

  player.level.playSound(
    null,
    player.x, player.y, player.z,
    'block.enchantment_table.use',
    'blocks',
    1.0,
    1.0
  )
})


//Silk Touch:
BlockEvents.rightClicked(event => {
  if (event.level.isClientSide()) return
  if (event.hand !== 'main_hand') return

  const { block, player } = event
  if (block.id !== 'rediscovered:dragon_altar') return

  const main = player.mainHandItem
  const off  = player.offHandItem
  if (main.id !== 'minecraft:book' || off.id !== 'phantasm:starflower') return

  main.shrink(1)
  off.shrink(1)

  const nbtString = '{StoredEnchantments:[{id:"minecraft:silk_touch",lvl:1s}]}'
  const enchantedBook = Item.of('minecraft:enchanted_book', nbtString)
  player.give(enchantedBook)

  player.level.playSound(
    null,
    player.x, player.y, player.z,
    'block.enchantment_table.use',
    'blocks',
    1.0,
    1.0
  )
})

//Fire Aspect:
BlockEvents.rightClicked(event => {
  if (event.level.isClientSide()) return
  if (event.hand !== 'main_hand') return

  const { block, player } = event
  if (block.id !== 'rediscovered:dragon_altar') return

  const main = player.mainHandItem
  const off  = player.offHandItem
  if (main.id !== 'minecraft:book' || off.id !== 'minecraft:torchflower') return

  main.shrink(1)
  off.shrink(1)

  const nbtString = '{StoredEnchantments:[{id:"minecraft:fire_aspect",lvl:1s}]}'
  const enchantedBook = Item.of('minecraft:enchanted_book', nbtString)
  player.give(enchantedBook)

  player.level.playSound(
    null,
    player.x, player.y, player.z,
    'block.enchantment_table.use',
    'blocks',
    1.0,
    1.0
  )
})

//Power:
BlockEvents.rightClicked(event => {
  if (event.level.isClientSide()) return
  if (event.hand !== 'main_hand') return

  const { block, player } = event
  if (block.id !== 'rediscovered:dragon_altar') return

  const main = player.mainHandItem
  const off  = player.offHandItem
  if (main.id !== 'minecraft:book' || off.id !== 'galosphere:raw_silver') return

  main.shrink(1)
  off.shrink(1)

  const nbtString = '{StoredEnchantments:[{id:"minecraft:power",lvl:1s}]}'
  const enchantedBook = Item.of('minecraft:enchanted_book', nbtString)
  player.give(enchantedBook)

  player.level.playSound(
    null,
    player.x, player.y, player.z,
    'block.enchantment_table.use',
    'blocks',
    1.0,
    1.0
  )
})

//Punch:
BlockEvents.rightClicked(event => {
  if (event.level.isClientSide()) return
  if (event.hand !== 'main_hand') return

  const { block, player } = event
  if (block.id !== 'rediscovered:dragon_altar') return

  const main = player.mainHandItem
  const off  = player.offHandItem
  if (main.id !== 'minecraft:book' || off.id !== 'alexsmobs:bear_fur') return

  main.shrink(1)
  off.shrink(1)

  const nbtString = '{StoredEnchantments:[{id:"minecraft:punch",lvl:1s}]}'
  const enchantedBook = Item.of('minecraft:enchanted_book', nbtString)
  player.give(enchantedBook)

  player.level.playSound(
    null,
    player.x, player.y, player.z,
    'block.enchantment_table.use',
    'blocks',
    1.0,
    1.0
  )
})
