BaseMod icon indicating copy to clipboard operation
BaseMod copied to clipboard

Modded Achievements Framework V2

Open Cany0udance opened this issue 1 year ago • 0 comments

A better version of the other PR that I closed.

This would allow mod authors to easily add achievements to their mods. Below the base game achievement grid, a new achievement grid will be added for each mod that adds achievements. It will look like this:

image

All mods need to do to add achievements is the following:

  • Add a .png with locked/unlocked pictures of the achievement(s)
  • An atlas to go with the above .png
  • Subscribe to EditAchievementsSubscriber in the main mod class and filling out receiveEditAchievements using registerAchievementGrid and registerAchievement
  • Add achievement unlock logic for their achievements where necessary
  • Achievement title/description strings in their UIStrings class

Here is a quick example of how a mod would add achievements in the main class:

    @Override
    public void receiveEditAchievements() {
        TextureAtlas atlas = AtlasLoader.getAtlas("theconstrictorpackagemod/achievements/ConstrictorAchievements.atlas");

        BaseMod.registerAchievementGrid(theconstrictormod.modID, atlas, "#yConstrictor #yAchievements");
        BaseMod.registerAchievement("CHOKED_OUT");
        BaseMod.registerAchievement("I_AM_THE_TIDE");
        BaseMod.registerAchievement("CONSTRICTOR_MASTERY");
    }

Notes:

  • I get that atlases aren't too popular in the modding community. My case is that atlases are how the base game handles achievements, and was a lot easier for me to code than figuring out how to add individual achievements. If this merges I will gladly write a wiki page with an easy guide on how to implement achievements, including how to do a copy/paste/edit of a basic atlas. If atlases are truly a deal breaker, I can attempt to refactor the code. Emphasis on attempt. Getting this to work with atlases was easier for me because...
  • All the code here was written by AI. I don't know how to do the whole coding thing myself. No hard feelings if that is also a deal breaker.
  • Achievement unlocks can be edited via the STSAchievements file. They will automatically show up there once unlocked (e.g. "fishing:ADVENTURER_MASTERY": "true") and can be edited down to "false" again

Cany0udance avatar Jun 21 '24 04:06 Cany0udance