Breakpoint Debugging TFGCore in a Modpack Instance
Sometimes during development of TFGCore you may end up in a situation where the behaviour is different between the Mod development environment, and the Modpack environment. This guide covers how to attach a Debugger instance to a Modpack-Modern instance, which will give you the tools necessary for debugging complex issues.
Information taken from: https://www.jetbrains.com/help/idea/attach-to-process.html
Setup
- Have a working instance of Core-Modern
- A launcher that lets you modify JVM Arguments
Steps
- Ensure your instance of the Modpack is on the same branch as the Core-Modern branch
- If you're debugging a modpack instance in branch dev, the Core-Modern branch needs to be in dev as well.
- Build TFGCore so that the .jar file ends up in your modpack instance. You will need to setup a
gradle-local.propertiesfile, guide on how to do this can be found here - Assign the following Java Arguments to the JVM on your modpack instance.
-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=127.0.0.1:5005suspend=yhalts the execution of the modpack until a debugger is attached. set this tonif you do not wish for this behaviour- You can find the Java Arguments in the Prism Launcher by right clicking your modpack instance, selecting
Edit, then clicking theSettingssidebar.
Boot up your modpack instance.
On IntelliJ, go to
Run/Attach to ProcessSelect the option that contains the port number 5005
This will attach the debugger to the modpack instance, and the modpack will boot up as normal
Setting up breakpoints within TFGCore will break the execution once that point is reached, allowing you to inspect the internals.