// Priority: 10
/**
  
  █▀▄▀█ █▀█ █▄░█ █░█ █▀▄▀█ █▀▀ █▄░█ ▀█▀ ▄▀█ █░░   █▀▀ ▀▄▀ █▀█ █▀▀ █▀█ █ █▀▀ █▄░█ █▀▀ █▀▀
  █░▀░█ █▄█ █░▀█ █▄█ █░▀░█ ██▄ █░▀█ ░█░ █▀█ █▄▄   ██▄ █░█ █▀▀ ██▄ █▀▄ █ ██▄ █░▀█ █▄▄ ██▄

  ☻/  * @file The Twilightforest script to clear weather
  /▌  * @copyright KnightDexx's Modded Minecraft World & ModernGamingWorld
  /\

*/
BlockEvents.rightClicked((event) => {

  const { entity, block, level, server } = event

  if (!entity.isPlayer() || entity.isFake()) {
    return
  }

  const dimension = String(level.getDimension())

  if (
    (level.isRaining || level.isThundering) &&
    dimension == 'twilightforest:twilight_forest' &&
    block.id.match(/(minecraft:|comforts:).*(_bed|sleeping_bag|hammock_)/)  // PORTED: getId() → .id
  ) {
    // Clear weather after 100 ticks
    server.scheduleInTicks(100, (schedule) => {
      let interval = randomInt(3, 7) * 24000
      console.log(`Halting Rain for ${interval} ticks!`)
      // PORTED: removed leading '/' from command string
      let command = `execute in minecraft:overworld run weather clear ${interval}`
      schedule.server.runCommandSilent(command)
    })
  }

})
