From 27cf89c736432c6fc693a59e2992e8b3ce20839f Mon Sep 17 00:00:00 2001 From: RebeccaNod1 Date: Fri, 8 May 2026 18:00:15 -0600 Subject: [PATCH] Fix type casting in ReplaceOutfit --- SecondBotEvents/Services/CurrentOutfitFolder.cs | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/SecondBotEvents/Services/CurrentOutfitFolder.cs b/SecondBotEvents/Services/CurrentOutfitFolder.cs index 89d1630..3b1d952 100644 --- a/SecondBotEvents/Services/CurrentOutfitFolder.cs +++ b/SecondBotEvents/Services/CurrentOutfitFolder.cs @@ -522,14 +522,16 @@ namespace SecondBotEvents.Services AddLink(item); } - // Detach all current non-body-part items first to avoid toggling - var currentWorn = ContentLinks().Select(RealInventoryItem).Where(i => !IsBodyPart(i)).ToList(); - if (currentWorn.Count > 0) - { - GetClient().Appearance.RemoveFromOutfit(currentWorn); - } + // Re-implementing ReplaceOutfit logic manually to ensure a clean swap without toggling. + var wearables = outfit.OfType().ToList(); + var attachments = outfit.Where(item => item is InventoryAttachment || item is InventoryObject).ToList(); + + // 1. Replace wearables (this is usually safe and doesn't toggle) + GetClient().Appearance.ReplaceOutfit(wearables.Cast().ToList()); + + // 2. Replace attachments with FirstDetachAll=true and replace=true to prevent toggling + GetClient().Appearance.AddAttachments(attachments, true, true); - GetClient().Appearance.ReplaceOutfit(outfit, false); ThreadPool.QueueUserWorkItem(sync => { Thread.Sleep(2000);