Vitaly
Vitaly

Reputation: 2662

How to run "gradlew runClient" in debug mode?

I am writing a mod for Minecraft.

I use neoforged/NeoGradle. I can run Minecraft client with my mod by

gradlew runClient

I know that the mod works, because I can see it in the game. I use IntellijIdea as IDE. And my break points in it don't work.

How to run "gradlew runClient" in debug mode?

Upvotes: 1

Views: 54

Answers (1)

Diego Maza
Diego Maza

Reputation: 1

You can run gradlew runClient in debug mode by following these steps:

Method 1: Using IntelliJ IDEA’s Built-in Gradle Debugging

  1. Open IntelliJ IDEA and load the mod project.
  2. Open the Gradle Tool Window
    • View → Tool Windows → Gradle (or press Alt + 9).
  3. Find runClient Task
    • Expand Tasks → forgegradle (or Tasks → neoforge depending on the setup).
    • Locate runClient.
  4. Run in Debug Mode
    • Right-click runClient and select Debug.

Method 2: Running from Terminal with Debug Flag

  1. Open a terminal inside IntelliJ (or any external terminal).

  2. Run the following command:

    gradlew runClient --debug-jvm
    
  3. IntelliJ will stop and wait for a debugger to attach.

  4. Go to Run → Attach Debugger to Process, and select the Minecraft process.

Now breakpoints should work properly.


If breakpoints still don't work, make sure:

  • The mod is compiled with debugging symbols (-g flag enabled in build.gradle).
  • The breakpoint is in code that is actually executed.
  • The mod is running in the same environment as the debugger.

Let me know if you need more help!

Upvotes: 0

Related Questions