BaseMod icon indicating copy to clipboard operation
BaseMod copied to clipboard

`ModHelper.isModEnabled(String mod)` doesn't work with Custom Mods added in `publishAddCustomModeMods`

Open alexdriedger opened this issue 5 years ago • 1 comments

@Override
public void receiveCustomModeMods(List<CustomMod> list) {
        CustomMod cm = new CustomMod("MyCoolCustomModID", "p", true); // also if last param is false
        list.add(cm);
}

Expected Behavior

// any patch
ModHelper.isModEnabled("MyCoolCustomModID"); // True

Actual Behavior

// any patch
ModHelper.isModEnabled("MyCoolCustomModID"); // False

Current Workaround

CardCrawlGame.trial != null && CardCrawlGame.trial.dailyModIDs().contains("MyCoolCustomModID");

alexdriedger avatar Mar 18 '19 16:03 alexdriedger

The problem seems to be in getMod which is called from setMods.

getMod checks a mod id against lists of mods populated in initialize. Mods added from receiveCustomModeMods are not added to any lists of mods in initialize. Patching initialize and getMod should fix the problem.

alexdriedger avatar Mar 18 '19 16:03 alexdriedger