Modding:Monkey patching: Difference between revisions

From Vintage Story Wiki
→‎Basic Patching: prevent the patches from getting double applied
(Made heading level more consistent with other pages)
(→‎Basic Patching: prevent the patches from getting double applied)
Line 26: Line 26:
     public void Start(ICoreAPI api) {
     public void Start(ICoreAPI api) {
         this.api = api;
         this.api = api;
         harmony = new Harmony("MyModId");
         // The mod is started once for the server and once for the client.
        harmony.PatchAll(); // Applies all harmony patches
        // Prevent the patches from being applied by both in the same process.
        if (!Harmony.HasAnyPatches(Mod.Info.ModID)) {
            harmony = new Harmony(Mod.Info.ModID);
            harmony.PatchAll(); // Applies all harmony patches
        }
     }
     }
     // ... Harmony patch functions here
     // ... Harmony patch functions here
Confirmedusers
261

edits