Repository navigation
Home
Welcome to the wiki!
PatchLib is a library for enabling the modification of Starsector code at runtime.
It uses an annotation-driven API, as in the following example:
@Patch(target = @ClassMatch(subtype = CampaignClockAPI.class))
public class TestPatch {
@After(target = @MethodMatch(methodName = "getCycle"))
public static void afterGetCycle(AfterContext context) {
context.setReturnValue((int) context.getReturnValue() + 1000);
}
}This is a simple patch that adds code after the original code of the getCycle method in Starsector's CampaignClock class. It increases the return value by 1000, changing the in-game display value.

This wiki assumes that you have a basic understanding of both Java programming and Starsector modding. If you lack either, it is recommended that you do not use this library, as it is otherwise easy to break things unknowingly.
On the right side, you can find the navbar with links to all pages. When first getting started, you should begin with the Introduction to PatchLib section and go through each page one by one.
If you make use of LLMs, either to explain the library to you, or to write the patches on its own, it is recommended to download the skill below. A "skill" is just a zip that contains documentation and instructions for LLMs, you can google how to install skills for what provider you are using.
It contains both guidance on how to use the library, but also many steps describing how to keep things compatible. If you make heavy use of LLMs, you should use something like it to prevent your mod from becoming a compatibility nightmare for other mods. Even with it though, you should apply common sense and verify that the patches make sense.
- Home
- Introduction to Patchlib
- Patch Types
- Working with obfuscated code
- Example Patches
- Other utilities
- Patching with Kotlin
- Developer Documentation