From 394b37f4bebcd5dd697f6bfe1e1746bdf7270faf Mon Sep 17 00:00:00 2001 From: Dominic Date: Mon, 31 May 2021 17:38:57 -0500 Subject: [PATCH] Schematic expansion stuff --- CalamityLists.cs | 13 ++++ CustomRecipes/ArsenalTierGatedRecipe.cs | 28 ++++++++ CustomRecipes/RecipeUnlockHandler.cs | 55 +++++++++++++++ Items/DraedonMisc/EncryptedSchematicHell.cs | 23 ++++++ ...hematic.png => EncryptedSchematicHell.png} | Bin Items/DraedonMisc/EncryptedSchematicIce.cs | 23 ++++++ Items/DraedonMisc/EncryptedSchematicIce.png | Bin 0 -> 611 bytes Items/DraedonMisc/EncryptedSchematicJungle.cs | 23 ++++++ .../DraedonMisc/EncryptedSchematicJungle.png | Bin 0 -> 611 bytes ...atic.cs => EncryptedSchematicPlanetoid.cs} | 6 +- .../EncryptedSchematicPlanetoid.png | Bin 0 -> 611 bytes .../EncryptedSchematicSunkenSea.cs | 24 +++++++ .../EncryptedSchematicSunkenSea.png | Bin 0 -> 611 bytes TileEntities/TECodebreaker.cs | 66 ++++++++++++++++-- UI/DraedonDecryptUI.cs | 38 +++++++--- World/CalamityWorld.cs | 10 +++ World/DraedonStructures.cs | 10 +-- 17 files changed, 295 insertions(+), 24 deletions(-) create mode 100644 CustomRecipes/ArsenalTierGatedRecipe.cs create mode 100644 CustomRecipes/RecipeUnlockHandler.cs create mode 100644 Items/DraedonMisc/EncryptedSchematicHell.cs rename Items/DraedonMisc/{EncryptedSchematic.png => EncryptedSchematicHell.png} (100%) create mode 100644 Items/DraedonMisc/EncryptedSchematicIce.cs create mode 100644 Items/DraedonMisc/EncryptedSchematicIce.png create mode 100644 Items/DraedonMisc/EncryptedSchematicJungle.cs create mode 100644 Items/DraedonMisc/EncryptedSchematicJungle.png rename Items/DraedonMisc/{EncryptedSchematic.cs => EncryptedSchematicPlanetoid.cs} (72%) create mode 100644 Items/DraedonMisc/EncryptedSchematicPlanetoid.png create mode 100644 Items/DraedonMisc/EncryptedSchematicSunkenSea.cs create mode 100644 Items/DraedonMisc/EncryptedSchematicSunkenSea.png diff --git a/CalamityLists.cs b/CalamityLists.cs index 3daa47a5bb..d787cb5500 100644 --- a/CalamityLists.cs +++ b/CalamityLists.cs @@ -5,6 +5,7 @@ using CalamityMod.Items.Accessories; using CalamityMod.Items.Accessories.Wings; using CalamityMod.Items.Ammo.FiniteUse; using CalamityMod.Items.Armor.Vanity; +using CalamityMod.Items.DraedonMisc; using CalamityMod.Items.Fishing.AstralCatches; using CalamityMod.Items.Fishing.BrimstoneCragCatches; using CalamityMod.Items.Fishing.FishingRods; @@ -155,6 +156,8 @@ namespace CalamityMod public static List ZeroMinionSlotExceptionList; public static List DontCopyOriginalMinionAIList; + public static Dictionary EncryptedSchematicIDRelationship; + public static void LoadLists() { donatorList = new List() @@ -2506,6 +2509,14 @@ namespace CalamityMod { ProjectileType() }; + + EncryptedSchematicIDRelationship = new Dictionary() + { + [1] = ItemType(), + [2] = ItemType(), + [3] = ItemType(), + [4] = ItemType(), + }; } public static void UnloadLists() @@ -2594,6 +2605,8 @@ namespace CalamityMod MinionsToNotResurrectList = null; ZeroMinionSlotExceptionList = null; DontCopyOriginalMinionAIList = null; + + EncryptedSchematicIDRelationship = null; } } } diff --git a/CustomRecipes/ArsenalTierGatedRecipe.cs b/CustomRecipes/ArsenalTierGatedRecipe.cs new file mode 100644 index 0000000000..9830216ac3 --- /dev/null +++ b/CustomRecipes/ArsenalTierGatedRecipe.cs @@ -0,0 +1,28 @@ +using Terraria.ModLoader; + +namespace CalamityMod.CustomRecipes +{ + public class ArsenalTierGatedRecipe : ModRecipe + { + public int Tier; + public ArsenalTierGatedRecipe(Mod mod, int tier) : base(mod) => Tier = tier; + + public override bool RecipeAvailable() + { + switch (Tier) + { + case 1: + return RecipeUnlockHandler.HasUnlockedT1ArsenalRecipes; + case 2: + return RecipeUnlockHandler.HasUnlockedT2ArsenalRecipes; + case 3: + return RecipeUnlockHandler.HasUnlockedT3ArsenalRecipes; + case 4: + return RecipeUnlockHandler.HasUnlockedT4ArsenalRecipes; + case 5: + return RecipeUnlockHandler.HasUnlockedT5ArsenalRecipes; + } + return false; + } + } +} \ No newline at end of file diff --git a/CustomRecipes/RecipeUnlockHandler.cs b/CustomRecipes/RecipeUnlockHandler.cs new file mode 100644 index 0000000000..b768573f22 --- /dev/null +++ b/CustomRecipes/RecipeUnlockHandler.cs @@ -0,0 +1,55 @@ +using System.Collections.Generic; +using System.IO; +using Terraria; + +namespace CalamityMod.CustomRecipes +{ + public static class RecipeUnlockHandler + { + public static bool HasUnlockedT1ArsenalRecipes = false; + public static bool HasUnlockedT2ArsenalRecipes = false; + public static bool HasUnlockedT3ArsenalRecipes = false; + public static bool HasUnlockedT4ArsenalRecipes = false; + public static bool HasUnlockedT5ArsenalRecipes = false; + + public static void Save(List boolTagContainer) + { + boolTagContainer.AddWithCondition("HasUnlockedT1ArsenalRecipes", HasUnlockedT1ArsenalRecipes); + boolTagContainer.AddWithCondition("HasUnlockedT2ArsenalRecipes", HasUnlockedT2ArsenalRecipes); + boolTagContainer.AddWithCondition("HasUnlockedT3ArsenalRecipes", HasUnlockedT3ArsenalRecipes); + boolTagContainer.AddWithCondition("HasUnlockedT4ArsenalRecipes", HasUnlockedT4ArsenalRecipes); + boolTagContainer.AddWithCondition("HasUnlockedT5ArsenalRecipes", HasUnlockedT5ArsenalRecipes); + } + + public static void Load(IList boolTagContainer) + { + HasUnlockedT1ArsenalRecipes = boolTagContainer.Contains("HasUnlockedT1ArsenalRecipes"); + HasUnlockedT2ArsenalRecipes = boolTagContainer.Contains("HasUnlockedT2ArsenalRecipes"); + HasUnlockedT3ArsenalRecipes = boolTagContainer.Contains("HasUnlockedT3ArsenalRecipes"); + HasUnlockedT4ArsenalRecipes = boolTagContainer.Contains("HasUnlockedT4ArsenalRecipes"); + HasUnlockedT5ArsenalRecipes = boolTagContainer.Contains("HasUnlockedT5ArsenalRecipes"); + } + + public static void SendData(BinaryWriter writer) + { + BitsByte flags = new BitsByte(); + flags[0] = HasUnlockedT1ArsenalRecipes; + flags[1] = HasUnlockedT2ArsenalRecipes; + flags[2] = HasUnlockedT3ArsenalRecipes; + flags[3] = HasUnlockedT4ArsenalRecipes; + flags[4] = HasUnlockedT5ArsenalRecipes; + + writer.Write(flags); + } + + public static void ReceiveData(BinaryReader reader) + { + BitsByte flags = reader.ReadByte(); + HasUnlockedT1ArsenalRecipes = flags[0]; + HasUnlockedT2ArsenalRecipes = flags[1]; + HasUnlockedT3ArsenalRecipes = flags[2]; + HasUnlockedT4ArsenalRecipes = flags[3]; + HasUnlockedT5ArsenalRecipes = flags[4]; + } + } +} \ No newline at end of file diff --git a/Items/DraedonMisc/EncryptedSchematicHell.cs b/Items/DraedonMisc/EncryptedSchematicHell.cs new file mode 100644 index 0000000000..0113e3f8f5 --- /dev/null +++ b/Items/DraedonMisc/EncryptedSchematicHell.cs @@ -0,0 +1,23 @@ +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.DraedonMisc +{ + public class EncryptedSchematicHell : ModItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Encrypted Schematic"); + Tooltip.SetDefault("Requires a Codebreaker with a sophisticated display to decrypt"); + } + + public override void SetDefaults() + { + item.width = 42; + item.height = 42; + item.rare = ItemRarityID.Red; + item.Calamity().customRarity = CalamityRarity.DraedonRust; + item.maxStack = 1; + } + } +} diff --git a/Items/DraedonMisc/EncryptedSchematic.png b/Items/DraedonMisc/EncryptedSchematicHell.png similarity index 100% rename from Items/DraedonMisc/EncryptedSchematic.png rename to Items/DraedonMisc/EncryptedSchematicHell.png diff --git a/Items/DraedonMisc/EncryptedSchematicIce.cs b/Items/DraedonMisc/EncryptedSchematicIce.cs new file mode 100644 index 0000000000..c1797e3e2d --- /dev/null +++ b/Items/DraedonMisc/EncryptedSchematicIce.cs @@ -0,0 +1,23 @@ +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.DraedonMisc +{ + public class EncryptedSchematicIce : ModItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Encrypted Schematic"); + Tooltip.SetDefault("Requires a Codebreaker with a complex voltage regulation system to decrypt"); + } + + public override void SetDefaults() + { + item.width = 42; + item.height = 42; + item.rare = ItemRarityID.Red; + item.Calamity().customRarity = CalamityRarity.DraedonRust; + item.maxStack = 1; + } + } +} diff --git a/Items/DraedonMisc/EncryptedSchematicIce.png b/Items/DraedonMisc/EncryptedSchematicIce.png new file mode 100644 index 0000000000000000000000000000000000000000..6cd561cb05192d8654317ef3a0d325e7d9512761 GIT binary patch literal 611 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 x=`XZ$ech6q@Mu){=l 1800; @@ -24,6 +24,51 @@ namespace CalamityMod.TileEntities public bool ContainsAdvancedDisplay; public bool ContainsVoltageRegulationSystem; public bool ContainsCoolingCell; + + public bool CanDecryptHeldSchematic + { + get + { + // You can't decrypt nothing. + if (HeldSchematicID == 0) + return false; + + int schematicType = CalamityLists.EncryptedSchematicIDRelationship[HeldSchematicID]; + if (schematicType == ModContent.ItemType()) + return ContainsDecryptionComputer; + if (schematicType == ModContent.ItemType()) + return ContainsDecryptionComputer && ContainsSensorArray; + if (schematicType == ModContent.ItemType()) + return ContainsDecryptionComputer && ContainsSensorArray && ContainsAdvancedDisplay; + if (schematicType == ModContent.ItemType()) + return ContainsDecryptionComputer && ContainsSensorArray && ContainsAdvancedDisplay && ContainsVoltageRegulationSystem; + + return false; + } + } + + public string UnderlyingSchematicText + { + get + { + // You can't decrypt nothing. + if (HeldSchematicID == 0) + return string.Empty; + + int schematicType = CalamityLists.EncryptedSchematicIDRelationship[HeldSchematicID]; + if (schematicType == ModContent.ItemType()) + return "test1"; + if (schematicType == ModContent.ItemType()) + return "test2"; + if (schematicType == ModContent.ItemType()) + return "test3"; + if (schematicType == ModContent.ItemType()) + return "test4"; + + return string.Empty; + } + } + public Vector2 Center => Position.ToWorldCoordinates(8f * CodebreakerTile.Width, 8f * CodebreakerTile.Height); // This guarantees that this tile entity will not persist if not placed directly on the top left corner of a Charging Station tile. @@ -56,7 +101,7 @@ namespace CalamityMod.TileEntities public override void Update() => UpdateTime(); - public void DropConstituents(int x, int y) + public void DropConstituents(int x, int y) { if (ContainsDecryptionComputer) Item.NewItem(x * 16, y * 16, 32, 32, ModContent.ItemType()); @@ -68,7 +113,10 @@ namespace CalamityMod.TileEntities Item.NewItem(x * 16, y * 16, 32, 32, ModContent.ItemType()); if (ContainsCoolingCell) Item.NewItem(x * 16, y * 16, 32, 32, ModContent.ItemType()); - } + + if (HeldSchematicID != 0) + Item.NewItem(x * 16, y * 16, 32, 32, CalamityLists.EncryptedSchematicIDRelationship[HeldSchematicID]); + } public void SyncConstituents() { @@ -125,7 +173,7 @@ namespace CalamityMod.TileEntities packet.Write((byte)CalamityModMessageType.UpdateCodebreakerContainedStuff); packet.Write(ID); packet.Write(InputtedCellCount); - packet.Write(HasSchematic); + packet.Write(HeldSchematicID); } public static void ReadContainmentSync(Mod mod, BinaryReader reader) @@ -136,7 +184,7 @@ namespace CalamityMod.TileEntities // Continue reading to the end even if a tile entity with the given ID does not exist. // Not doing this will cause errors/bugs. int cellCount = reader.ReadInt32(); - bool hasSchematic = reader.ReadBoolean(); + int schematicID = reader.ReadInt32(); // After doing reading, check again to see if the tile entity is actually there. // If it isn't don't bother doing anything else. @@ -148,7 +196,7 @@ namespace CalamityMod.TileEntities return; codebreakerTileEntity.InputtedCellCount = cellCount; - codebreakerTileEntity.HasSchematic = hasSchematic; + codebreakerTileEntity.HeldSchematicID = schematicID; } public void UpdateTime() @@ -165,7 +213,8 @@ namespace CalamityMod.TileEntities ["ContainsSensorArray"] = ContainsSensorArray, ["ContainsAdvancedDisplay"] = ContainsAdvancedDisplay, ["ContainsVoltageRegulationSystem"] = ContainsVoltageRegulationSystem, - ["ContainsCoolingCell"] = ContainsCoolingCell + ["ContainsCoolingCell"] = ContainsCoolingCell, + ["HeldSchematicID"] = HeldSchematicID }; } @@ -176,6 +225,7 @@ namespace CalamityMod.TileEntities ContainsAdvancedDisplay = tag.GetBool("ContainsAdvancedDisplay"); ContainsVoltageRegulationSystem = tag.GetBool("ContainsVoltageRegulationSystem"); ContainsCoolingCell = tag.GetBool("ContainsCoolingCell"); + HeldSchematicID = tag.GetInt("HeldSchematicID"); } public override void NetSend(BinaryWriter writer, bool lightSend) @@ -185,6 +235,7 @@ namespace CalamityMod.TileEntities writer.Write(ContainsAdvancedDisplay); writer.Write(ContainsVoltageRegulationSystem); writer.Write(ContainsCoolingCell); + writer.Write(HeldSchematicID); } public override void NetReceive(BinaryReader reader, bool lightReceive) @@ -194,6 +245,7 @@ namespace CalamityMod.TileEntities ContainsAdvancedDisplay = reader.ReadBoolean(); ContainsVoltageRegulationSystem = reader.ReadBoolean(); ContainsCoolingCell = reader.ReadBoolean(); + HeldSchematicID = reader.ReadInt32(); } } } diff --git a/UI/DraedonDecryptUI.cs b/UI/DraedonDecryptUI.cs index c908be04ad..428a9d6139 100644 --- a/UI/DraedonDecryptUI.cs +++ b/UI/DraedonDecryptUI.cs @@ -3,6 +3,7 @@ using CalamityMod.TileEntities; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using System; +using System.Linq; using System.Text; using Terraria; using Terraria.DataStructures; @@ -69,12 +70,19 @@ namespace CalamityMod.UI Texture2D emptySchematicIconTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/UI/EncryptedSchematicSlot_Empty"); Texture2D occupiedSchematicIconTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/UI/EncryptedSchematicSlot_Full"); - Texture2D schematicTexture = codebreakerTileEntity.HasSchematic ? occupiedSchematicIconTexture : emptySchematicIconTexture; + Texture2D schematicTexture = codebreakerTileEntity.HeldSchematicID != 0 ? occupiedSchematicIconTexture : emptySchematicIconTexture; spriteBatch.Draw(schematicTexture, schematicSlotDrawCenter, null, Color.White, 0f, schematicTexture.Size() * 0.5f, 1f, SpriteEffects.None, 0f); HandleSchematicSlotInteractions(codebreakerTileEntity, schematicSlotDrawCenter, cellTexture.Size()); + // Display some error text if the codebreaker isn't strong enough to decrypt the text. + if (codebreakerTileEntity.HeldSchematicID != 0 && !codebreakerTileEntity.CanDecryptHeldSchematic) + { + Vector2 errorDisplayLocation = schematicSlotDrawCenter + Vector2.UnitY * 20f; + DisplayNotStrongEnoughErrorText(errorDisplayLocation); + } + // Handle decryption costs. - if (codebreakerTileEntity.HasSchematic && codebreakerTileEntity.DecryptionCountdown == 0) + else if (codebreakerTileEntity.HeldSchematicID != 0 && codebreakerTileEntity.DecryptionCountdown == 0) { int cost = 30; Vector2 costDisplayLocation = schematicSlotDrawCenter + Vector2.UnitY * 20f; @@ -91,17 +99,20 @@ namespace CalamityMod.UI Vector2 textPanelCenter = backgroundTopLeft + Vector2.UnitX * backgroundTexture.Width + textPanelTexture.Size() * new Vector2(-0.5f, 0.5f); spriteBatch.Draw(textPanelTexture, textPanelCenter, null, Color.White, 0f, textPanelTexture.Size() * 0.5f, 1f, SpriteEffects.None, 0f); - // Generate gibberish and use slowly insert the real text at the beginning. + // Generate gibberish and use slowly insert the real text. // When decryption is done the gibberish will go away and only the underlying text will remain. int textPadding = 6; - string trueMessage = "The FitnessGram Pacer Test is a multistage aerobic capacity test that progressively gets more difficult as it continues. The 20 meter pacer test will begin in 30 seconds. Line up at the start. The running speed starts slowly, but gets faster each minute after you hear this signal."; + string trueMessage = codebreakerTileEntity.UnderlyingSchematicText; StringBuilder text = new StringBuilder(codebreakerTileEntity.DecryptionCountdown == 0 ? trueMessage : CalamityUtils.GenerateRandomAlphanumericString(500)); + // Don't mess with whitespace characters. Doing so can cause the word-wrap to "jump" around. for (int i = 0; i < trueMessage.Length; i++) { if (char.IsWhiteSpace(trueMessage[i])) text[i] = trueMessage[i]; } + + // Insert the necessary amount of true text. for (int i = 0; i < (int)(trueMessage.Length * codebreakerTileEntity.DecryptionCompletion); i++) text[i] = trueMessage[i]; @@ -204,21 +215,23 @@ namespace CalamityMod.UI if (Main.mouseLeft && Main.mouseLeftRelease) { - if (playerHandItem.IsAir && codebreakerTileEntity.HasSchematic) + if (playerHandItem.IsAir && codebreakerTileEntity.HeldSchematicID != 0) { - playerHandItem.SetDefaults(ModContent.ItemType()); - codebreakerTileEntity.HasSchematic = false; + playerHandItem.SetDefaults(CalamityLists.EncryptedSchematicIDRelationship[codebreakerTileEntity.HeldSchematicID]); + codebreakerTileEntity.HeldSchematicID = 0; codebreakerTileEntity.DecryptionCountdown = 0; codebreakerTileEntity.SyncContainedStuff(); Main.PlaySound(SoundID.Grab); + AwaitingDecryptionTextClose = false; } - else if (playerHandItem.type == ModContent.ItemType()) + else if (CalamityLists.EncryptedSchematicIDRelationship.ContainsValue(playerHandItem.type)) { + codebreakerTileEntity.HeldSchematicID = CalamityLists.EncryptedSchematicIDRelationship.First(i => i.Value == Main.mouseItem.type).Key; playerHandItem.TurnToAir(); - codebreakerTileEntity.HasSchematic = true; codebreakerTileEntity.SyncContainedStuff(); Main.PlaySound(SoundID.Grab); + AwaitingDecryptionTextClose = false; } } @@ -257,5 +270,12 @@ namespace CalamityMod.UI Main.spriteBatch.Draw(confirmationTexture, drawPosition, null, Color.White, 0f, confirmationTexture.Size() * 0.5f, VerificationButtonScale, SpriteEffects.None, 0f); } + + public static void DisplayNotStrongEnoughErrorText(Vector2 drawPosition) + { + string text = "Encryption unsolveable: Upgrades required."; + drawPosition.X -= 30f; + Utils.DrawBorderStringFourWay(Main.spriteBatch, Main.fontMouseText, text, drawPosition.X, drawPosition.Y + 20f, Color.IndianRed * (Main.mouseTextColor / 255f), Color.Black, Vector2.Zero, 1f); + } } } diff --git a/World/CalamityWorld.cs b/World/CalamityWorld.cs index 445f06248d..377a9dbcc3 100644 --- a/World/CalamityWorld.cs +++ b/World/CalamityWorld.cs @@ -1,4 +1,5 @@ using CalamityMod.CalPlayer; +using CalamityMod.CustomRecipes; using CalamityMod.DataStructures; using CalamityMod.Events; using CalamityMod.NPCs; @@ -456,6 +457,8 @@ namespace CalamityMod.World if (HasGeneratedLuminitePlanetoids) downed.Add("HasGeneratedLuminitePlanetoids"); + RecipeUnlockHandler.Save(downed); + return new TagCompound { { @@ -560,6 +563,8 @@ namespace CalamityMod.World encounteredOldDuke = downed.Contains("encounteredOldDuke"); HasGeneratedLuminitePlanetoids = downed.Contains("HasGeneratedLuminitePlanetoids"); + RecipeUnlockHandler.Load(downed); + abyssChasmBottom = tag.GetInt("abyssChasmBottom"); acidRainPoints = tag.GetInt("acidRainPoints"); Reforges = tag.GetInt("Reforges"); @@ -803,6 +808,9 @@ namespace CalamityMod.World writer.Write(flags8); writer.Write(flags9); writer.Write(flags10); + + RecipeUnlockHandler.SendData(writer); + writer.Write(abyssChasmBottom); writer.Write(acidRainPoints); writer.Write(Reforges); @@ -914,6 +922,8 @@ namespace CalamityMod.World _ = flags10[6]; _ = flags10[7]; + RecipeUnlockHandler.ReceiveData(reader); + abyssChasmBottom = reader.ReadInt32(); acidRainPoints = reader.ReadInt32(); Reforges = reader.ReadInt32(); diff --git a/World/DraedonStructures.cs b/World/DraedonStructures.cs index f10e8a59d7..00ecb4d969 100644 --- a/World/DraedonStructures.cs +++ b/World/DraedonStructures.cs @@ -227,7 +227,7 @@ namespace CalamityMod.World { contents.Insert(0, new ChestItem(ModContent.ItemType(), 1)); contents.Insert(1, new ChestItem(ModContent.ItemType(), 1)); - contents.Insert(2, new ChestItem(ModContent.ItemType(), 1)); + contents.Insert(2, new ChestItem(ModContent.ItemType(), 1)); } for (int i = 0; i < contents.Count; i++) { @@ -298,7 +298,7 @@ namespace CalamityMod.World if (!hasPlacedLogAndSchematic) { contents.Insert(0, new ChestItem(ModContent.ItemType(), 1)); - contents.Insert(1, new ChestItem(ModContent.ItemType(), 1)); + contents.Insert(1, new ChestItem(ModContent.ItemType(), 1)); } for (int i = 0; i < contents.Count; i++) { @@ -365,7 +365,7 @@ namespace CalamityMod.World if (!hasPlacedLogAndSchematic) { contents.Insert(0, new ChestItem(ModContent.ItemType(), 1)); - contents.Insert(1, new ChestItem(ModContent.ItemType(), 1)); + contents.Insert(1, new ChestItem(ModContent.ItemType(), 1)); } // If it's a frozen chest. if (type == TileID.Containers) @@ -448,7 +448,7 @@ namespace CalamityMod.World if (!hasPlacedLogAndSchematic) { contents.Insert(0, new ChestItem(ModContent.ItemType(), 1)); - contents.Insert(1, new ChestItem(ModContent.ItemType(), 1)); + contents.Insert(1, new ChestItem(ModContent.ItemType(), 1)); } for (int i = 0; i < contents.Count; i++) { @@ -541,7 +541,7 @@ namespace CalamityMod.World if (!hasPlacedLogAndSchematic) { contents.Insert(0, new ChestItem(ModContent.ItemType(), 1)); - contents.Insert(1, new ChestItem(ModContent.ItemType(), 1)); + contents.Insert(1, new ChestItem(ModContent.ItemType(), 1)); } for (int i = 0; i < contents.Count; i++) {