-
-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support code mods #37
Conversation
Please wait for a bit. I will be reviewing this in the upcoming days and hopefully merging and testing for a later release. |
Currently Do we need to split |
What is the proposed code mod structure? It needs to be generalized and kept relatively simple to make creating such mods easier. |
…when loading mods
Making code mods requires proficiency in Java, developers need to read the client code, and then try to modify the code. So I think the hardest thing is reading the code. I don't have a best standard project layout, I am waiting for @lucasluqui to design one. See also mods I made: The core provides tools for creating classes, modifying classes, modifying methods, and adding fields, and also provides APIs for quickly adding commands, example: |
Code mods might be required for running the latest JVM as well, depending on how you launch projectx. Trying to use default getdown, you'll need to block "jvmarg = -XX:+AggressiveOpts" from being set, this can be done with a simple code mod. Of course, you could also just ship your own getdown build and do it there. You'll also need to swap out native libs for LWJGL with their latest 2.9.X variant, for compatibility purposes. You'll also need to specify "--add-opens=java.*****=ALL-UNNAMED" type arguments for every single internal JDK API used for Java 16+. That said, Java 20 is possible and runs SK perfectly fine: |
I understand where the enthusiasm of getting the game running on bleeding edge, much more modern Java versions comes from but the gains of going through all the hoops is less than 1%, at most. Given all the issues that'd rise from supporting everything above Java 8 -on top of the ones we already have- Knight Launcher does not aim to support anything higher than so. Of course this would not hinder the possibility of tackling it on your own and getting all set up manually, it's just not going to be supported by default nor given assistance by us. |
That said, there should still be modifications put in place to allow the option of running the latest Java, even if you don't install or provide such. Additionally, there are quite a few Garbage Collection changes that may interest people, that aren't available for older Java variants. |
Code mods are not a requirement for Java 8+ VMs to function. I won't merge or implement any VM compatibility specific modifications into KL or the proposed code mods functionality by leego for the reason I detailed above. Users that really want to go the extra mile are free to do so just not through KL. |
...and with that said, that's why it was brought up in this thread, as it would be a use case for code modding. |
Getdown code modification found to be unnecessary for running bleeding edge Java. As per The-File/SK-Fixed#2 |
ProjectXBootstrap.java is dependent on the version of spiral knights being utilized. Specifically because the game client uses ProGuard obfuscation for method/class/field/etc obfuscation. The smallest change to an irrelevant part of the client will cause the obfuscator in the build script to be run again and thus create class files that are mutable even with no functional changes. |
You'd need to resolve for fields/methods/class names dynamically rather than in source code. |
In other words, if Spiral Knights ever updates in the future due to a one line change in the client to a part knight launcher nor code mods touch, nor should care about, ProjectXBootstrap.java would likely fail to work. |
1. ProjectXBootstrap.java (New)
Add
ProjectXBootstrap
to replaceProjectXApp
, which is used to boot and load jar mods, such as replacingdeployment.properties
at runtime.2. LauncherDigester.java (New)
Add
LauncherDigester
to modifygetdown.txt
anddigest.txt
before SK starts.getdown.txt
:digest.txt
3. ModLoader.java (Modified)
It now reads the jar mods correctly
4. GameSettings.java (Modified)
GameSettings.loadConnectionSettings() is no longer used, it is replaced by ProjectXBootstrap.loadConnectionSettings().
KnightLauncher/src/main/java/com/lucasallegri/bootstrap/ProjectXBootstrap.java
Lines 86 to 117 in c8f89ad
5. LauncherGlobals.java (Modified)
Modify
LauncherGlobals
to detect the jvm path and usecom.lucasallegri.bootstrap.ProjectXBootstrap
instead ofcom.threerings.projectx.client.ProjectXApp
.I tested it on Mac and Windows 10 (except Linux), both zip mods and jar mods work: