/// <summary>The mod entry point, called after the mod is first loaded.</summary>
        /// <param name="helper">Provides simplified APIs for writing mods.</param>
        public override void Entry(IModHelper helper)
        {
            RWeatherIcon = new Rectangle();
            WeatherOpt   = helper.ReadConfig <WeatherConfig>();
            Logger       = Monitor;
            Translator   = Helper.Translation;
            Reflection   = Helper.Reflection;
            MPHandler    = Helper.Multiplayer;
            Dice         = new Xoshiro.PRNG64.XoShiRo256starstar();
            OurIcons     = new Sprites.Icons(Helper.Content);
            WeatherProcessing.Init();
            Conditions         = new WeatherConditions();
            DescriptionEngine  = new Descriptions(WeatherOpt, Helper.Translation);
            queuedMsg          = null;
            SummitRebornLoaded = false;

            if (WeatherOpt.Verbose)
            {
                Monitor.Log($"Loading climate type: {WeatherOpt.ClimateType} from file", LogLevel.Trace);
            }

            var path = Path.Combine("assets", "climates", WeatherOpt.ClimateType + ".json");

            GameClimate = helper.Data.ReadJsonFile <FerngillClimate>(path);

            if (GameClimate is null)
            {
                this.Monitor.Log($"The required '{path}' file is missing. Try reinstalling the mod to fix that.", LogLevel.Error);
                this.Monitor.Log("This mod will now disable itself.", LogLevel.Error);
                this.Disabled = true;
            }

            if (Disabled)
            {
                return;
            }

            var harmony = new Harmony("koihimenakamura.climatesofferngill");

            harmony.Patch(
                original: AccessTools.Method(typeof(GameLocation), "drawAboveAlwaysFrontLayer"),
                transpiler: new HarmonyMethod(AccessTools.Method(typeof(GameLocationPatches), "DAAFLTranspiler")));
            Monitor.Log("Patching GameLocation::drawAboveAlwaysFrontLayer with a Transpiler.", LogLevel.Trace);

            harmony.Patch(
                original: AccessTools.Method(typeof(Game1), "drawWeather"),
                prefix: new HarmonyMethod(AccessTools.Method(typeof(Game1Patches), "DrawWeatherPrefix")));
            Monitor.Log("Patching Game1::drawWeather with a prefix method.", LogLevel.Trace);

            harmony.Patch(
                original: AccessTools.Method(typeof(Game1), "updateWeather"),
                prefix: new HarmonyMethod(AccessTools.Method(typeof(Game1Patches), "UpdateWeatherPrefix")));
            Monitor.Log("Patching Game1::updateWeather with a prefix method.", LogLevel.Trace);

            harmony.Patch(
                original: AccessTools.Method(AccessTools.TypeByName("StardewModdingAPI.Framework.SGame"), "DrawImpl"),
                transpiler: new HarmonyMethod(AccessTools.Method(typeof(SGamePatches), "DrawImplTranspiler")));
            Monitor.Log("Patching SMAPI (SGame::DrawImpl) with a transpiler.", LogLevel.Trace);

            harmony.Patch(
                original: AccessTools.Constructor(AccessTools.TypeByName("StardewValley.WeatherDebris"), new[] { typeof(Vector2), typeof(int), typeof(float), typeof(float), typeof(float) }),
                postfix: new HarmonyMethod(AccessTools.Method(typeof(WeatherDebrisPatches), "CtorPostfix")));
            Monitor.Log("Patching WeatherDebris's constructor method with a postfix method.", LogLevel.Trace);

            harmony.Patch(
                original: AccessTools.Method(typeof(WeatherDebris), "draw"),
                prefix: new HarmonyMethod(AccessTools.Method(typeof(WeatherDebrisPatches), "DrawPrefix")));
            Monitor.Log("Patching WeatherDebris::draw with a prefix method.", LogLevel.Trace);

            harmony.Patch(
                original: AccessTools.Method(typeof(WeatherDebris), "update", new[] { typeof(bool) }),
                prefix: new HarmonyMethod(AccessTools.Method(typeof(WeatherDebrisPatches), "UpdatePrefix")));
            Monitor.Log("Patching WeatherDebris::draw with a prefix method.", LogLevel.Trace);

            //INSERT DNT CHECKS HERE
            var modManifest = Helper.ModRegistry.Get("knakamura.dynamicnighttime");

            if (modManifest != null)
            {
                if (modManifest.Manifest.Version.IsOlderThan("1.2.11"))
                {
                    Monitor.Log("WARNING: Overcast weather may not work correctly unless you are running Dynamic Night Time 1.2.11 or later", LogLevel.Alert);
                }
            }
            else
            {
                harmony.Patch(
                    original: AccessTools.Method(typeof(Game1), "UpdateGameClock"),
                    postfix: new HarmonyMethod(AccessTools.Method(typeof(GameClockPatch), "Postfix")));
                Monitor.Log("Patching Game1::UpdateGameClock with a Postfix method. (Used only when Climates is installed and DNT is not.)", LogLevel.Trace);
            }

            ConsoleCommands.Init();
            SanityCheckConfigOptions();

            //subscribe to events
            var events = helper.Events;

            events.GameLoop.DayStarted            += OnDayStarted;
            events.GameLoop.Saving                += OnSaving;
            events.GameLoop.TimeChanged           += OnTimeChanged;
            events.Display.MenuChanged            += OnMenuChanged;
            events.GameLoop.UpdateTicked          += OnUpdateTicked;
            events.GameLoop.GameLaunched          += OnGameLaunched;
            events.GameLoop.OneSecondUpdateTicked += OnOneSecondUpdateTicked;
            events.GameLoop.ReturnedToTitle       += OnReturnedToTitle;
            events.GameLoop.SaveLoaded            += OnSaveLoaded;
            events.Display.RenderedWorld          += Display_RenderedWorld;
            //events.Display.RenderingHud += OnRenderingHud;
            events.Display.RenderedHud            += OnRenderedHud;
            events.Input.ButtonPressed            += OnButtonPressed;
            events.Multiplayer.ModMessageReceived += OnModMessageRecieved;

            //console commands
            helper.ConsoleCommands
            .Add("world_tmrwweather", helper.Translation.Get("console-text.desc_tmrweather"), ConsoleCommands.TomorrowWeatherChangeFromConsole)
            .Add("world_setweather", helper.Translation.Get("console-text.desc_setweather"), ConsoleCommands.WeatherChangeFromConsole)
            .Add("debug_clearspecial", "debug command to clear special weathers", ConsoleCommands.ClearSpecial)
            .Add("debug_weatherstatus", "!", ConsoleCommands.OutputWeather)
            .Add("debug_sswa", "Show Special Weather", ConsoleCommands.ShowSpecialWeather)
            .Add("debug_vrainc", "Set Rain Amt.", ConsoleCommands.SetRainAmt)
            .Add("debug_raindef", "Set Rain Deflection.", ConsoleCommands.SetRainDef)

            /*
             *  .Add("debug_setwindchance", "Set Wind Chance", ConsoleCommands.SetWindChance)
             *  .Add("debug_setwindtresh", "Set Wind Threshold", ConsoleCommands.SetWindThreshold)
             *  .Add("debug_setwindrange", "Set Wind Range", ConsoleCommands.SetWindRange)
             *  .Add("debug_raintotal", "Get Rain Total", ConsoleCommands.DisplayRainTotal)
             *  .Add("debug_getcurrentwind", "Show wind values", ConsoleCommands.ShowWind)
             *  .Add("debug_resetwind", "Reset Global Wind", ConsoleCommands.ResetGlobalWind)
             */
            .Add("debug_printClimate", "Print Climate Tracker Data", ConsoleCommands.DisplayClimateTrackerData);
        }
        /// <summary>The mod entry point, called after the mod is first loaded.</summary>
        /// <param name="helper">Provides simplified APIs for writing mods.</param>
        public override void Entry(IModHelper helper)
        {
            RWeatherIcon = new Rectangle();
            WeatherOpt   = helper.ReadConfig <WeatherConfig>();
            Logger       = Monitor;
            Translator   = Helper.Translation;
            Reflection   = Helper.Reflection;
            MPHandler    = Helper.Multiplayer;
            Dice         = new MersenneTwister();
            OurIcons     = new Sprites.Icons(Helper.Content);
            WeatherProcessing.Init();
            Conditions         = new WeatherConditions();
            DescriptionEngine  = new Descriptions(WeatherOpt, Helper.Translation);
            queuedMsg          = null;
            SummitRebornLoaded = false;

            if (WeatherOpt.Verbose)
            {
                Monitor.Log($"Loading climate type: {WeatherOpt.ClimateType} from file", LogLevel.Trace);
            }

            var path = Path.Combine("assets", "climates", WeatherOpt.ClimateType + ".json");

            GameClimate = helper.Data.ReadJsonFile <FerngillClimate>(path);

            if (GameClimate is null)
            {
                this.Monitor.Log($"The required '{path}' file is missing. Try reinstalling the mod to fix that.", LogLevel.Error);
                this.Monitor.Log("This mod will now disable itself.", LogLevel.Error);
                this.Disabled = true;
            }

            if (Disabled)
            {
                return;
            }

            var harmony = HarmonyInstance.Create("koihimenakamura.climatesofferngill");

            harmony.PatchAll(Assembly.GetExecutingAssembly());

            ConsoleCommands.Init();

            MethodInfo    GameLocationDAAFL = AccessTools.Method(typeof(GameLocation), "drawAboveAlwaysFrontLayer");
            HarmonyMethod DAAFLTranspiler   = new HarmonyMethod(AccessTools.Method(typeof(GameLocationPatches), "DAAFLTranspiler"));

            Monitor.Log($"Patching {GameLocationDAAFL} with Transpiler: {DAAFLTranspiler}", LogLevel.Trace);;
            harmony.Patch(GameLocationDAAFL, transpiler: DAAFLTranspiler);

            MethodInfo    GameDrawW         = AccessTools.Method(typeof(Game1), "drawWeather");
            HarmonyMethod DrawWeatherPrefix = new HarmonyMethod(AccessTools.Method(typeof(Game1Patches), "DrawWeatherPrefix"));

            Monitor.Log($"Patching {GameDrawW} with Prefix: {DrawWeatherPrefix}", LogLevel.Trace);;
            harmony.Patch(GameDrawW, prefix: DrawWeatherPrefix);

            Type          t             = AccessTools.TypeByName("StardewModdingAPI.Framework.SGame");
            MethodInfo    SGameDrawImpl = AccessTools.Method(t, "DrawImpl");
            HarmonyMethod DrawTrans     = new HarmonyMethod(AccessTools.Method(typeof(SGamePatches), "DrawImplTranspiler"));

            Monitor.Log($"Patching {SGameDrawImpl} with Transpiler: {DrawTrans}", LogLevel.Trace);
            harmony.Patch(SGameDrawImpl, transpiler: DrawTrans);

            t = AccessTools.TypeByName("StardewValley.WeatherDebris");
            var           DebrisConstructor = AccessTools.Constructor(t, new[] { typeof(Vector2), typeof(int), typeof(float), typeof(float), typeof(float) });
            HarmonyMethod CtorPatch         = new HarmonyMethod(AccessTools.Method(typeof(WeatherDebrisPatches), "CtorPostfix"));

            Monitor.Log($"Patching {DebrisConstructor} with Postfix: {CtorPatch}", LogLevel.Trace);
            harmony.Patch(DebrisConstructor, postfix: CtorPatch);

            MethodInfo    DebrisDraw  = AccessTools.Method(typeof(WeatherDebris), "draw");
            HarmonyMethod DebrisPatch = new HarmonyMethod(AccessTools.Method(typeof(WeatherDebrisPatches), "DrawPrefix"));

            Monitor.Log($"Patching {DebrisDraw} with Prefix: {DebrisDraw}", LogLevel.Trace);
            harmony.Patch(DebrisDraw, prefix: DebrisPatch);

            MethodInfo    DebrisUpdate      = AccessTools.Method(typeof(WeatherDebris), "update", new[] { typeof(bool) });
            HarmonyMethod DebrisUpdatePatch = new HarmonyMethod(AccessTools.Method(typeof(WeatherDebrisPatches), "UpdatePrefix"));

            Monitor.Log($"Patching {DebrisUpdate} with Prefix: {DebrisUpdatePatch}", LogLevel.Trace);
            harmony.Patch(DebrisUpdate, prefix: DebrisUpdatePatch);

            //INSERT DNT CHECKS HERE
            var modManifest = Helper.ModRegistry.Get("knakamura.dynamicnighttime");

            if (modManifest != null)
            {
                if (modManifest.Manifest.Version.IsOlderThan("1.2.11"))
                {
                    Monitor.Log("WARNING: Overcast weather may not work correctly unless you are running Dynamic Night Time 1.2.11 or later", LogLevel.Alert);
                }
            }
            else
            {
                //Normal Climates patch goes here.
                MethodInfo UpdateGameClock = helper.Reflection.GetMethod(SDVUtilities.GetSDVType("Game1"), "UpdateGameClock").MethodInfo;
                MethodInfo postfixClock    = helper.Reflection.GetMethod(typeof(Patches.GameClockPatch), "Postfix").MethodInfo;
                Monitor.Log($"Postfixing {UpdateGameClock} with {postfixClock}", LogLevel.Trace);
                harmony.Patch(UpdateGameClock, null, new HarmonyMethod(postfixClock));
            }

            SanityCheckConfigOptions();

            //subscribe to events
            var events = helper.Events;

            events.GameLoop.DayStarted            += OnDayStarted;
            events.GameLoop.Saving                += OnSaving;
            events.GameLoop.TimeChanged           += OnTimeChanged;
            events.Display.MenuChanged            += OnMenuChanged;
            events.GameLoop.UpdateTicked          += OnUpdateTicked;
            events.GameLoop.GameLaunched          += OnGameLaunched;
            events.GameLoop.OneSecondUpdateTicked += OnOneSecondUpdateTicked;
            events.GameLoop.ReturnedToTitle       += OnReturnedToTitle;
            events.GameLoop.SaveLoaded            += OnSaveLoaded;
            events.Display.RenderingHud           += OnRenderingHud;
            events.Display.RenderedHud            += OnRenderedHud;
            events.Input.ButtonPressed            += OnButtonPressed;
            events.Multiplayer.ModMessageReceived += OnModMessageRecieved;
            // events.GameLoop.UpdateTicking += GameLoop_UpdateTicking;

            //console commands
            helper.ConsoleCommands
            .Add("world_tmrwweather", helper.Translation.Get("console-text.desc_tmrweather"), ConsoleCommands.TomorrowWeatherChangeFromConsole)
            .Add("world_setweather", helper.Translation.Get("console-text.desc_setweather"), ConsoleCommands.WeatherChangeFromConsole)
            .Add("debug_clearspecial", "debug command to clear special weathers", ConsoleCommands.ClearSpecial)
            .Add("debug_weatherstatus", "!", ConsoleCommands.OutputWeather)
            .Add("debug_sswa", "Show Special Weather", ConsoleCommands.ShowSpecialWeather)
            .Add("debug_vrainc", "Set Rain Amt.", ConsoleCommands.SetRainAmt)
            .Add("debug_raintotal", "Get Rain Total", ConsoleCommands.DisplayRainTotal)
            .Add("debug_printClimate", "Print Climate Tracker Data", ConsoleCommands.DisplayClimateTrackerData);
        }