Please disclose if your mod was created primarily using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of ReturnToSender v1.3.0
ReturnToSender.dll
Decompiled a year agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using HarmonyLib; using Microsoft.CodeAnalysis; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("ReturnToSender")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("ReturnToSender")] [assembly: AssemblyCopyright("Copyright © 2022")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("444a0c22-9b14-4246-8053-930ea36381f0")] [assembly: AssemblyFileVersion("1.3.0")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.3.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace ReturnToSender { [HarmonyPatch(typeof(ZDOMan))] internal static class ZDOManPatch { [HarmonyTranspiler] [HarmonyPatch("Update")] private static IEnumerable<CodeInstruction> UpdateTranspiler(IEnumerable<CodeInstruction> instructions) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Expected O, but got Unknown return new CodeMatcher(instructions, (ILGenerator)null).Start().MatchStartForward((CodeMatch[])(object)new CodeMatch[1] { new CodeMatch((OpCode?)OpCodes.Call, (object)AccessTools.Method(typeof(ZDOMan), "SendZDOToPeers2", (Type[])null, (Type[])null), (string)null) }).ThrowIfInvalid("Could not patch ZDOMan.Update()! (send-zdo-to-peers)") .SetOperandAndAdvance((object)AccessTools.Method(typeof(ZDOManPatch), "SendZDOToPeers", (Type[])null, (Type[])null)) .InstructionEnumeration(); } private static void SendZDOToPeers(ZDOMan zdoManager, float dt) { zdoManager.m_sendTimer += dt; if (zdoManager.m_sendTimer > 0.05f) { zdoManager.m_sendTimer = 0f; List<ZDOPeer> peers = zdoManager.m_peers; int i = 0; for (int count = peers.Count; i < count; i++) { zdoManager.SendZDOs(peers[i], false); } } } } public static class PluginConfig { public static ConfigEntry<bool> IsModEnabled { get; private set; } public static void BindConfig(ConfigFile config) { IsModEnabled = config.Bind<bool>("_Global", "isModEnabled", true, "Globally enable or disable this mod (restart required)."); } } [BepInPlugin("redseiko.valheim.returntosender", "ReturnToSender", "1.3.0")] public sealed class ReturnToSender : BaseUnityPlugin { public const string PluginGuid = "redseiko.valheim.returntosender"; public const string PluginName = "ReturnToSender"; public const string PluginVersion = "1.3.0"; private void Awake() { PluginConfig.BindConfig(((BaseUnityPlugin)this).Config); if (PluginConfig.IsModEnabled.Value) { Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "redseiko.valheim.returntosender"); } } } }