From 504da98bcb9fa2f2a5b6365075caab11de84a8ea Mon Sep 17 00:00:00 2001 From: Doze-Zoze Date: Mon, 14 Jul 2025 15:25:03 -0500 Subject: [PATCH] Reworked Cosmolight & re-added Moonlight, now named Bakidon --- Items/Tools/ClimateChange/Bakidon.cs | 58 +++++++++++++ Items/Tools/ClimateChange/Bakidon.png | Bin 0 -> 607 bytes Items/Tools/ClimateChange/Cosmolight.cs | 78 +++++++++++------- .../en-US/Mods.CalamityMod.Items.Tools.hjson | 16 +++- 4 files changed, 119 insertions(+), 33 deletions(-) create mode 100644 Items/Tools/ClimateChange/Bakidon.cs create mode 100644 Items/Tools/ClimateChange/Bakidon.png diff --git a/Items/Tools/ClimateChange/Bakidon.cs b/Items/Tools/ClimateChange/Bakidon.cs new file mode 100644 index 0000000000..a552dfe6e9 --- /dev/null +++ b/Items/Tools/ClimateChange/Bakidon.cs @@ -0,0 +1,58 @@ +using CalamityMod.CalPlayer; +using CalamityMod.Items.Materials; +using Terraria; +using Terraria.GameContent.Creative; +using Terraria.GameContent.NetModules; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.Net; + +namespace CalamityMod.Items.Tools.ClimateChange +{ + [LegacyName("Moonlight")] + public class Bakidon : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Tools"; + + public override void SetDefaults() + { + Item.width = 20; + Item.height = 20; + Item.rare = ItemRarityID.LightRed; + Item.useAnimation = 9; + Item.useTime = 9; + Item.autoReuse = false; // Explicitly not autofire, since it can be used quickly now + Item.useStyle = ItemUseStyleID.HoldUp; + Item.UseSound = SoundID.Item60; + Item.consumable = false; + } + + public override void ModifyResearchSorting(ref ContentSamples.CreativeHelper.ItemGroup itemGroup) + { + itemGroup = (ContentSamples.CreativeHelper.ItemGroup)CalamityResearchSorting.ToolsOther; + } + + public override bool? UseItem(Player player) + { + if (Main.netMode != NetmodeID.Server && player == Main.LocalPlayer) + { + var power = CreativePowerManager.Instance.GetPower(); + NetPacket packet = NetCreativePowersModule.PreparePacket(power.PowerId, 1); + packet.Writer.Write(!power.Enabled); + NetManager.Instance.SendToServerOrLoopback(packet); + } + return true; + } + + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(ItemID.FallenStar, 10). + AddIngredient(ItemID.SoulofLight, 7). + AddIngredient(ItemID.SoulofNight, 7). + AddIngredient(5). + AddTile(TileID.DemonAltar). + Register(); + } + } +} diff --git a/Items/Tools/ClimateChange/Bakidon.png b/Items/Tools/ClimateChange/Bakidon.png new file mode 100644 index 0000000000000000000000000000000000000000..e48b63f74417805804136a2f04a6979cce557576 GIT binary patch literal 607 zcmeAS@N?(olHy`uVBq!ia0vp^YCtT*!3-p=m~6v=6k~CayA#8@b22Z19F}xPUq=Rp zjs4tz5?O(Kl>na**JydQDotY^8M~!!=4z3ddTrAVR{1*bTXF9|@&E5zuYS1-RQPT7 zw|_v2rzFTP_&)+L2;Dz-4k*r9;1OBOz`%D9gc)~C%zg_LlqhkHC<)F_D=AMbN@WO0 z%*-p%^K%VRFx4~EvyjewwF0PSTWW-7ny0500|$`9${@wa%D@O@c>%FBlnwHg1|u_A zoC(M_WMpCx0Mb!FoY~F-7S95*LEvT?Bf|@z=V3IOr3^r+3G56kK$QkY#s-WFAf|$B zWL*F;X$p`H0!%=2nZPQ8EG>X6s4hbT1CZ>~+RWCZz^VIy%wwJ|jv*HQM<*TRJ8Zz= z%qih<`Tzg>CsQMLdrqDedu%D={u3-(zg1nLge~`rKh^!&w{n%=i8DSdGnTKKyrY}( z-El`Hjh*Sc{3mo-7l=P@Z;E75beJ0cIx5pWfBS~4jaxhJMKiC;ZJ63|?N#UZjg~$4 zs?Ar=(Y-Qx-Y=nT?@ex+HSuh7IK6UR(yA?Y`xe;hK9>qNyn4paDAP@6(WmSA8yl`3 zvhc7|oc!%fR^V$1@pF?U4cG#b?Oto&FwH3COFFh*;^6sH^Ea@kHOZDbL}+{l`OeeT K&t;ucLK6UxWxwD6 literal 0 HcmV?d00001 diff --git a/Items/Tools/ClimateChange/Cosmolight.cs b/Items/Tools/ClimateChange/Cosmolight.cs index b380c4f384..0a210124c4 100644 --- a/Items/Tools/ClimateChange/Cosmolight.cs +++ b/Items/Tools/ClimateChange/Cosmolight.cs @@ -1,18 +1,19 @@ -using CalamityMod.CalPlayer; +using System.Linq; +using CalamityMod.CalPlayer; using CalamityMod.Items.Materials; +using CalamityMod.World; using Terraria; +using Terraria.GameContent.Creative; +using Terraria.GameContent.NetModules; using Terraria.ID; using Terraria.ModLoader; +using Terraria.Net; namespace CalamityMod.Items.Tools.ClimateChange { public class Cosmolight : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Tools"; - // Hardcoded times set by the vanilla Journey Mode buttons. - // These are "halfway through day" and "halfway through night" respectively. - private const int NoonCutoff = 27000; - private const int MidnightCutoff = 16200; public override void SetDefaults() { @@ -21,10 +22,11 @@ namespace CalamityMod.Items.Tools.ClimateChange Item.rare = ItemRarityID.LightRed; Item.useAnimation = 9; Item.useTime = 9; - Item.autoReuse = false; // Explicitly not autofire, since it can be used quickly now + Item.autoReuse = false; Item.useStyle = ItemUseStyleID.HoldUp; Item.UseSound = SoundID.Item60; Item.consumable = false; + Item.channel = true; } public override void ModifyResearchSorting(ref ContentSamples.CreativeHelper.ItemGroup itemGroup) @@ -34,40 +36,54 @@ namespace CalamityMod.Items.Tools.ClimateChange public override bool CanUseItem(Player player) => !CalamityPlayer.areThereAnyDamnBosses; + public override bool AltFunctionUse(Player player) + { + return true; + } public override bool? UseItem(Player player) { - //Only SinglePlayer or DedServ should change time to prevent unwanted race condition - if (Main.netMode == NetmodeID.MultiplayerClient) - return true; - - // Early Morning -> Noon - if (Main.dayTime && Main.time < NoonCutoff) - Main.SkipToTime(NoonCutoff, true); - - // Afternoon -> Dusk - else if (Main.dayTime) - Main.SkipToTime(0, false); - - // Early Night -> Midnight - else if (!Main.dayTime && Main.time < MidnightCutoff) - Main.SkipToTime(MidnightCutoff, false); - - // Late Night -> Dawn - else if (!Main.dayTime) - Main.SkipToTime(0, true); - + if (Main.netMode != NetmodeID.Server && player == Main.LocalPlayer && (player.altFunctionUse == 2 || (CreativePowerManager.Instance.GetPower().Enabled))) + { + var power = CreativePowerManager.Instance.GetPower(); + NetPacket packet = NetCreativePowersModule.PreparePacket(power.PowerId, 1); + packet.Writer.Write(!power.Enabled); + NetManager.Instance.SendToServerOrLoopback(packet); + } return true; } public override void AddRecipes() { CreateRecipe(). - AddIngredient(ItemID.FallenStar, 10). - AddIngredient(ItemID.SoulofLight, 7). - AddIngredient(ItemID.SoulofNight, 7). - AddIngredient(5). - AddTile(TileID.Anvils). + AddIngredient(). + AddIngredient(ItemID.Sundial). + AddIngredient(5). + AddTile(TileID.DemonAltar). Register(); } } + + public class CosmolightTimeRateChange : ModSystem + { + public override void ModifyTimeRate(ref double timeRate, ref double tileUpdateRate, ref double eventUpdateRate) + { + if (Main.player.Any(x => x.active && x.channel && x.altFunctionUse != 2 && x.HeldItem.type == ModContent.ItemType())) + { + timeRate *= 120; + } + } + + public override void PostUpdateEverything() + { + //When outside of Journey Mode, time freeze disables during bosses + if (CalamityUtils.AnyBossNPCS() && !Main.GameModeInfo.IsJourneyMode) + if (Main.netMode != NetmodeID.MultiplayerClient && (CreativePowerManager.Instance.GetPower().Enabled)) + { + var power = CreativePowerManager.Instance.GetPower(); + NetPacket packet = NetCreativePowersModule.PreparePacket(power.PowerId, 1); + packet.Writer.Write(!power.Enabled); + NetManager.Instance.SendToServerOrLoopback(packet); + } + } + } } diff --git a/Localization/en-US/Mods.CalamityMod.Items.Tools.hjson b/Localization/en-US/Mods.CalamityMod.Items.Tools.hjson index 1083e38f93..cc7e40ad49 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.Tools.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.Tools.hjson @@ -80,8 +80,10 @@ Cosmolight: { DisplayName: Cosmolight Tooltip: ''' - Advances time immediately to the next dawn, noon, dusk or midnight - Does not work while a boss is alive + A magical artifact, rekindled by the touch of godly fire + to fast forward time + to freeze time + This does not work while a boss is alive ''' } @@ -252,3 +254,13 @@ WulfrumTreasurePinger: { This contraption seems incredibly shoddy. [c/FC4903:It'll break sooner than later for sure] ''' } + +Bakidon: { + DisplayName: Bakidon + Tooltip: + ''' + A magical artifact, whose flame died out long ago + Using it freezes the passage of time + This does not work while a boss is alive + ''' +}