From 4429598658d08605f405438947fd2f3e00aeff91 Mon Sep 17 00:00:00 2001 From: Chev Date: Thu, 22 May 2025 01:47:49 -0700 Subject: [PATCH 1/8] Update config localization to use newer tModLoader standards --- LifeSourcesLight/LifeSourcesLightConfig.cs | 9 ++++----- .../en-US_Mods.LifeSourcesLight.hjson | 18 +++++++++--------- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/LifeSourcesLight/LifeSourcesLightConfig.cs b/LifeSourcesLight/LifeSourcesLightConfig.cs index 0363ce3..b8d9aa8 100644 --- a/LifeSourcesLight/LifeSourcesLightConfig.cs +++ b/LifeSourcesLight/LifeSourcesLightConfig.cs @@ -4,19 +4,18 @@ using Terraria.ModLoader.Config; namespace LifeSourcesLight { - [Label("Config")] public class LifeSourcesLightConfig : ModConfig { public override ConfigScope Mode => ConfigScope.ClientSide; + [LabelKey("$Mods.LifeSourcesLight.Configs.Common.EnableHeartCrystalLight.Label")] + [TooltipKey("$Mods.LifeSourcesLight.Configs.Common.EnableHeartCrystalLight.Tooltip")] [DefaultValue(true)] - [Label("Enable Lighting for Heart Crystal")] - [Tooltip("Whether or not to enable lighting for the Heart Crystal.")] public bool EnableHeartCrystalLight { get; set; } + [LabelKey("$Mods.LifeSourcesLight.Configs.Common.EnableLifeFruitLight.Label")] + [TooltipKey("$Mods.LifeSourcesLight.Configs.Common.EnableLifeFruitLight.Tooltip")] [DefaultValue(true)] - [Label("Enable Lighting for Life Fruit")] - [Tooltip("Whether or not to enable lighting for the Life Fruit.")] public bool EnableLifeFruitLight { get; set; } public override void OnChanged() diff --git a/LifeSourcesLight/Localization/en-US_Mods.LifeSourcesLight.hjson b/LifeSourcesLight/Localization/en-US_Mods.LifeSourcesLight.hjson index ab9bbee..b6260bd 100644 --- a/LifeSourcesLight/Localization/en-US_Mods.LifeSourcesLight.hjson +++ b/LifeSourcesLight/Localization/en-US_Mods.LifeSourcesLight.hjson @@ -1,15 +1,15 @@ Configs: { - LifeSourcesLightConfig: { - DisplayName: Config + Common: { + EnableLifeFruitLight: { + Tooltip: Whether or not to enable lighting for the Life Fruit. + Label: Enable Lighting for Life Fruit + } EnableHeartCrystalLight: { - Label: Enable Lighting for Heart Crystal Tooltip: Whether or not to enable lighting for the Heart Crystal. - } - - EnableLifeFruitLight: { - Label: Enable Lighting for Life Fruit - Tooltip: Whether or not to enable lighting for the Life Fruit. + Label: Enable Lighting for Heart Crystal } } -} \ No newline at end of file + + LifeSourcesLightConfig.DisplayName: Config +} From 1a43a6114ccc2973abd6b95d7248f11972294a9f Mon Sep 17 00:00:00 2001 From: Chev Date: Thu, 22 May 2025 01:49:00 -0700 Subject: [PATCH 2/8] Fix mixed indentation (simultaneous tabs & spaces) --- LifeSourcesLight/LifeSourcesLightConfig.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/LifeSourcesLight/LifeSourcesLightConfig.cs b/LifeSourcesLight/LifeSourcesLightConfig.cs index b8d9aa8..5185678 100644 --- a/LifeSourcesLight/LifeSourcesLightConfig.cs +++ b/LifeSourcesLight/LifeSourcesLightConfig.cs @@ -9,12 +9,12 @@ namespace LifeSourcesLight public override ConfigScope Mode => ConfigScope.ClientSide; [LabelKey("$Mods.LifeSourcesLight.Configs.Common.EnableHeartCrystalLight.Label")] - [TooltipKey("$Mods.LifeSourcesLight.Configs.Common.EnableHeartCrystalLight.Tooltip")] + [TooltipKey("$Mods.LifeSourcesLight.Configs.Common.EnableHeartCrystalLight.Tooltip")] [DefaultValue(true)] public bool EnableHeartCrystalLight { get; set; } [LabelKey("$Mods.LifeSourcesLight.Configs.Common.EnableLifeFruitLight.Label")] - [TooltipKey("$Mods.LifeSourcesLight.Configs.Common.EnableLifeFruitLight.Tooltip")] + [TooltipKey("$Mods.LifeSourcesLight.Configs.Common.EnableLifeFruitLight.Tooltip")] [DefaultValue(true)] public bool EnableLifeFruitLight { get; set; } From 9b083b8357416db4e2bc89debc18c472deb4757b Mon Sep 17 00:00:00 2001 From: Chev Date: Thu, 22 May 2025 01:50:12 -0700 Subject: [PATCH 3/8] Add Steam Workshop description --- LifeSourcesLight/description_workshop.txt | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 LifeSourcesLight/description_workshop.txt diff --git a/LifeSourcesLight/description_workshop.txt b/LifeSourcesLight/description_workshop.txt new file mode 100644 index 0000000..bb9f058 --- /dev/null +++ b/LifeSourcesLight/description_workshop.txt @@ -0,0 +1,3 @@ +Makes life crystals & life fruits emit light. + +Comes with a config, if you want only life crystals or life fruits to emit light, and not both. From 41a97f1ad5d2a21eef237f2a3665c918c34c919d Mon Sep 17 00:00:00 2001 From: Chev Date: Thu, 22 May 2025 02:06:18 -0700 Subject: [PATCH 4/8] LifeSourcesLight: Rework mod code - Update Main.tileLighted (attempt to fix bug where lights wouldn't work in multiplayer until the config was reloaded) - Organize and tidy code a bit --- LifeSourcesLight/LifeSourcesLight.cs | 17 +++------- LifeSourcesLight/LifeSourcesLightModSystem.cs | 33 ++++++++++++++----- LifeSourcesLight/LightOverrideHeartCrystal.cs | 2 +- LifeSourcesLight/LightOverrideLifeFruit.cs | 2 +- 4 files changed, 30 insertions(+), 24 deletions(-) diff --git a/LifeSourcesLight/LifeSourcesLight.cs b/LifeSourcesLight/LifeSourcesLight.cs index 531d3eb..aa9a90e 100644 --- a/LifeSourcesLight/LifeSourcesLight.cs +++ b/LifeSourcesLight/LifeSourcesLight.cs @@ -4,21 +4,12 @@ namespace LifeSourcesLight { public class LifeSourcesLight : Mod { - internal static bool _enableHeartCrystalLight; - public static bool EnableHeartCrystalLight + public override void PostSetupContent() { - get { return _enableHeartCrystalLight; } - } + base.PostSetupContent(); - internal static bool _enableLifeFruitLight; - public static bool EnableLifeFruitLight - { - get { return _enableLifeFruitLight; } - } - - public override void Load() - { - base.Load(); + // Update Main.tileLighted on post-load to ensure config is properly loaded + LifeSourcesLightModSystem.UpdateTileLighted(); } } } \ No newline at end of file diff --git a/LifeSourcesLight/LifeSourcesLightModSystem.cs b/LifeSourcesLight/LifeSourcesLightModSystem.cs index 44bd29f..cf9ee4b 100644 --- a/LifeSourcesLight/LifeSourcesLightModSystem.cs +++ b/LifeSourcesLight/LifeSourcesLightModSystem.cs @@ -6,20 +6,35 @@ namespace LifeSourcesLight { public class LifeSourcesLightModSystem : ModSystem { - private LifeSourcesLightConfig _configInstance; - - public LifeSourcesLightModSystem() : base() - { - _configInstance = ModContent.GetInstance(); + internal static bool _enableLightHeartCrystal = true; + public static bool EnableLightHeartCrystal { + get { return _enableLightHeartCrystal; } } + internal static bool _enableLightLifeFruit = true; + public static bool EnableLightLifeFruit { + get { return _enableLightLifeFruit; } + } + + // We use the booleans above later in an if-check, and to my knowledge, + // that if-check runs every tick or every frame. + // It's more efficient than calling ModContent.GetInstance() every tick + // (as far as I'm aware) public void ApplySettings() { - LifeSourcesLight._enableHeartCrystalLight = _configInstance.EnableHeartCrystalLight; - LifeSourcesLight._enableLifeFruitLight = _configInstance.EnableLifeFruitLight; + LifeSourcesLightConfig configInstance = ModContent.GetInstance(); - Main.tileLighted[TileID.Heart] = LifeSourcesLight._enableHeartCrystalLight; - Main.tileLighted[TileID.LifeFruit] = LifeSourcesLight._enableLifeFruitLight; + _enableLightHeartCrystal = configInstance.EnableHeartCrystalLight; + _enableLightLifeFruit = configInstance.EnableLifeFruitLight; + + UpdateTileLighted(); + } + + // Modified Main.tileLighted for the heart crystal & life fruit + // Necessary in order to enable lighting calculations for both + public static void UpdateTileLighted() { + Main.tileLighted[TileID.Heart] = EnableLightHeartCrystal; + Main.tileLighted[TileID.LifeFruit] = EnableLightLifeFruit; } } } diff --git a/LifeSourcesLight/LightOverrideHeartCrystal.cs b/LifeSourcesLight/LightOverrideHeartCrystal.cs index 3a420c7..4bd2799 100644 --- a/LifeSourcesLight/LightOverrideHeartCrystal.cs +++ b/LifeSourcesLight/LightOverrideHeartCrystal.cs @@ -10,7 +10,7 @@ namespace LifeSourcesLight public override void ModifyLight(int i, int j, int type, ref float r, ref float g, ref float b) { - if (type == TileID.Heart && LifeSourcesLight.EnableHeartCrystalLight) + if (type == TileID.Heart && LifeSourcesLightModSystem.EnableLightHeartCrystal) { r = (255f / 255f) * LifeCrystalBrightCoefficient; g = (38f / 255f) * LifeCrystalBrightCoefficient; diff --git a/LifeSourcesLight/LightOverrideLifeFruit.cs b/LifeSourcesLight/LightOverrideLifeFruit.cs index c706c3a..e85f757 100644 --- a/LifeSourcesLight/LightOverrideLifeFruit.cs +++ b/LifeSourcesLight/LightOverrideLifeFruit.cs @@ -10,7 +10,7 @@ namespace LifeSourcesLight public override void ModifyLight(int i, int j, int type, ref float r, ref float g, ref float b) { - if (type == TileID.LifeFruit && LifeSourcesLight.EnableLifeFruitLight) + if (type == TileID.LifeFruit && LifeSourcesLightModSystem.EnableLightLifeFruit) { r = (221f / 255f) * LifeFruitBrightCoefficient; g = (181f / 255f) * LifeFruitBrightCoefficient; From 4ecdc3ef40def5534085cbe57d3638e8216be75d Mon Sep 17 00:00:00 2001 From: Chev Date: Thu, 22 May 2025 02:06:37 -0700 Subject: [PATCH 5/8] Update localization to include item icons --- .../Localization/en-US_Mods.LifeSourcesLight.hjson | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/LifeSourcesLight/Localization/en-US_Mods.LifeSourcesLight.hjson b/LifeSourcesLight/Localization/en-US_Mods.LifeSourcesLight.hjson index b6260bd..a99dca7 100644 --- a/LifeSourcesLight/Localization/en-US_Mods.LifeSourcesLight.hjson +++ b/LifeSourcesLight/Localization/en-US_Mods.LifeSourcesLight.hjson @@ -2,12 +2,12 @@ Configs: { Common: { EnableLifeFruitLight: { Tooltip: Whether or not to enable lighting for the Life Fruit. - Label: Enable Lighting for Life Fruit + Label: "[i/s1:1291] Enable Lighting for Life Fruit" } EnableHeartCrystalLight: { Tooltip: Whether or not to enable lighting for the Heart Crystal. - Label: Enable Lighting for Heart Crystal + Label: "[i/s1:29] Enable Lighting for Heart Crystal" } } From 5c4e6dee2c8e44b817adfa7032e1eeaad643e094 Mon Sep 17 00:00:00 2001 From: Chev Date: Thu, 22 May 2025 02:06:56 -0700 Subject: [PATCH 6/8] Update Steam Workshop description to include a link to the mod's source code --- LifeSourcesLight/description_workshop.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/LifeSourcesLight/description_workshop.txt b/LifeSourcesLight/description_workshop.txt index bb9f058..b932c20 100644 --- a/LifeSourcesLight/description_workshop.txt +++ b/LifeSourcesLight/description_workshop.txt @@ -1,3 +1,5 @@ Makes life crystals & life fruits emit light. Comes with a config, if you want only life crystals or life fruits to emit light, and not both. + +This mod's source code is available on my Terraria mods GitHub repo: https://github.com/chev2/terraria-mods From b9bcd0e7496bda159606d9e6f5af927dd95ac05c Mon Sep 17 00:00:00 2001 From: Chev Date: Thu, 22 May 2025 02:07:39 -0700 Subject: [PATCH 7/8] LifeSourcesLight: Migrate mod to newer standards - Migrate from .NET 6.0 to .NET 8.0 - Update launchSettings.json --- LifeSourcesLight/LifeSourcesLight.csproj | 13 ++++++++----- LifeSourcesLight/Properties/launchSettings.json | 4 ++-- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/LifeSourcesLight/LifeSourcesLight.csproj b/LifeSourcesLight/LifeSourcesLight.csproj index d2b6580..b4d317c 100644 --- a/LifeSourcesLight/LifeSourcesLight.csproj +++ b/LifeSourcesLight/LifeSourcesLight.csproj @@ -1,13 +1,16 @@ - + + + LifeSourcesLight - net6.0 - AnyCPU latest + false + false + + - - \ No newline at end of file + diff --git a/LifeSourcesLight/Properties/launchSettings.json b/LifeSourcesLight/Properties/launchSettings.json index 8da89ff..1011447 100644 --- a/LifeSourcesLight/Properties/launchSettings.json +++ b/LifeSourcesLight/Properties/launchSettings.json @@ -2,13 +2,13 @@ "profiles": { "Terraria": { "commandName": "Executable", - "executablePath": "dotnet", + "executablePath": "$(DotNetName)", "commandLineArgs": "$(tMLPath)", "workingDirectory": "$(tMLSteamPath)" }, "TerrariaServer": { "commandName": "Executable", - "executablePath": "dotnet", + "executablePath": "$(DotNetName)", "commandLineArgs": "$(tMLServerPath)", "workingDirectory": "$(tMLSteamPath)" } From 8d7c4fa6cbec92f9ac84f7e016cad338567e3b3f Mon Sep 17 00:00:00 2001 From: Chev Date: Thu, 22 May 2025 02:14:12 -0700 Subject: [PATCH 8/8] LifeSourcesLight: Release v1.3.0 --- LifeSourcesLight/build.txt | 2 +- LifeSourcesLight/description.txt | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/LifeSourcesLight/build.txt b/LifeSourcesLight/build.txt index acfc89b..3f631b3 100644 --- a/LifeSourcesLight/build.txt +++ b/LifeSourcesLight/build.txt @@ -1,5 +1,5 @@ displayName = Heart Crystal & Life Fruit Glow author = Chev -version = 1.2.0 +version = 1.3.0 homepage = https://github.com/chev2/terraria-mods side = Client diff --git a/LifeSourcesLight/description.txt b/LifeSourcesLight/description.txt index 73e5553..2bfdd07 100644 --- a/LifeSourcesLight/description.txt +++ b/LifeSourcesLight/description.txt @@ -1,6 +1,13 @@ -Makes heart crystals [i/s1:29] & life fruits [i/s1:1291] emit light. +Makes life crystals [i/s1:29] & life fruits [i/s1:1291] emit light. [c/00FFFF:Changelog] +[v1.3.0] 2025-05-22 +- Attempt to fix bug where lights would sometimes not work in multiplayer until config was reloaded +- Added some nice item icons to the config menu +- Update mod internals to reflect newer tModLoader standards + - Migrate from .NET 6.0 to .NET 8.0 + - Use newer LabelKey and TooltipKey for mod configuration + [v1.2.0] 2023-08-06 - Update for tModLoader v1.4.4 - Life Fruits now glow yellow instead of green to better distinguish them from Jungle Spores