Skip to content
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

Running Forge while building with intellij on 1.18 & 1.18-mixin branch fails 1.18.1/1.18.2 due to missing Common module resources & classes #12

Closed
CorgiTaco opened this issue Apr 23, 2022 · 10 comments

Comments

@CorgiTaco
Copy link

CorgiTaco commented Apr 23, 2022

This issue also occurs on 1.18.2.

Here's a video of what happens: https://youtu.be/g-ZUYu0mIWw

Video starts w/ building w/ gradle, then I switch to Intellij building.

Fabric building w/ intellij works just fine

@jaredlll08
Copy link
Owner

Can you reproduce on a default forge MDK?

@CorgiTaco
Copy link
Author

CorgiTaco commented Apr 28, 2022

@jaredlll08 No, i cannot reproduce: https://www.youtube.com/watch?v=PlzwcKwnPqQ

@CorgiTaco
Copy link
Author

CorgiTaco commented Apr 28, 2022

1.18-mixin Branch

Fixing the initial error

Ok so to fix the error in: #12 (comment)

I had to change: https://github.com/jaredlll08/MultiLoader-Template/blob/1.18-with-mixin/Forge/build.gradle#L85

to:

    annotationProcessor 'org.spongepowered:mixin:0.8.5:processor'

this presents another issue in regards to the common resources not being used by forge: https://youtu.be/f3RHH1YQktk

Here is the error from the console: https://gist.github.com/CorgiTaco/cb2da7002b83773720542cf2207c8937

I did do a fresh genIntellijRuns before the video starts also

Forge Behavior

In the forge client configuration MOD_CLASSES environment variable:

modClientRun%%D:/coding/MultiLoader-Template-Test\Forge\out\production\resources;modClientRun%%D:/coding/MultiLoader-Template-Test\Forge\out\production\classes;modClientRun%%D:/coding/MultiLoader-Template-Test\Forge\out\main\resources;modClientRun%%D:/coding/MultiLoader-Template-Test\Forge\out\main\classes

You can see it makes an compiler output directory(out/) in forge's module as opposed to the Intellij's project setting's compiler output directory i specified:

D:\coding\MultiLoader-Template-Test\out

After running the forge client configuration, here are the output targets:
image

Fabric Behavior

When running Fabric's client configuration on the other hand, it does NOT produce an out directory in the fabric module, but rather in Intellij's project setting's compiler output directory:
image

@CorgiTaco
Copy link
Author

CorgiTaco commented Apr 28, 2022

1.18 branch

So I decided to also run the Forge Client Configuration main 1.18 branch with Intellij and it seems the issue persists on that branch. But this time the Common Module classes cannot be found: https://youtu.be/noaZOmqxuRY

Yes, i did rebuild gradle & genIntellijRuns prior to running the game.

Console output: https://gist.github.com/CorgiTaco/bf4c0578e1984ec2b5f5c3d3b9ab2405

Fabric building with intellij works fine

@CorgiTaco CorgiTaco changed the title Running Forge while building with intellij on 1.18-mixin branch fails 1.18.1/1.18.2 Running Forge while building with intellij on 1.18 & 1.18-mixin branch fails 1.18.1/1.18.2 Apr 28, 2022
@CorgiTaco CorgiTaco changed the title Running Forge while building with intellij on 1.18 & 1.18-mixin branch fails 1.18.1/1.18.2 Running Forge while building with intellij on 1.18 & 1.18-mixin branch fails 1.18.1/1.18.2 due to missing Common module resources & classes Apr 28, 2022
@jaredlll08
Copy link
Owner

jaredlll08 commented Apr 28, 2022

This is an issue with ForgeGradle.

Over here: https://github.com/SizableShrimp/ForgeGradle/blob/fc3dfcea2110a48011efb6e661b5f9c88bd738d5/src/common/java/net/minecraftforge/gradle/common/util/runs/IntellijRunGenerator.java#L246

FG assumes that all sources listed will be under the Forge project instead of in other projects (not sure if we are actually using it incorrectly, but it works fine when running under gradle).

What you could do if you absolutely need to run it under idea (I assume for hotswapping code), is manually change your run config to read like so:

modClientRun%%$PROJECT_DIR$\Forge\out\production\resources
modClientRun%%$PROJECT_DIR$\Forge\out\production\classes
modClientRun%%$PROJECT_DIR$\Common\out\main\resources
modClientRun%%$PROJECT_DIR$\Common\out\main\classes

(although on a single line with ; between).

@jaredlll08
Copy link
Owner

What you can actually do, is change your run config to look like this:

        client {
            workingDirectory project.file('run')
            ideaModule "${rootProject.name}.${project.name}.main"
            taskName 'Client'
            property 'mixin.env.remapRefMap', 'true'
            property 'mixin.env.refMapRemappingFile', "${projectDir}/build/createSrgToMcp/output.srg"

            def output = sourceSets.main.output;
            def commonOutput = project(":Common").sourceSets.main.output;
            environment("MOD_CLASSES", [output.classesDirs.asPath, output.resourcesDir.path, commonOutput.classesDirs.asPath, commonOutput.resourcesDir.path].join(";"))
            mods {
                modClientRun {
                    source sourceSets.main
                    source project(":Common").sourceSets.main
                }
            }
        }

Which appears to be working fine with loading and hotswapping, although be warned, this does set your MOD_CLASSES to:

$PROJECT_DIR$\Forge\build\classes\java\main
$PROJECT_DIR$\Forge\build\resources\main
$PROJECT_DIR$\Common\build\classes\java\main
$PROJECT_DIR$\Common\build\resources\main

which are the paths used when running under gradle, not the paths used when running under IDEA, I don't know the implications it may have though.

@CorgiTaco
Copy link
Author

Doing these instructions: #12 (comment) works for both forge loading + hotswapping!!!

https://youtu.be/G3HTBZOE3N8

Thank you so much :D

@CorgiTaco
Copy link
Author

I'd also say that you should probably add #12 (comment) to this git repo's forge build.gradle when you get the chance.

@jaredlll08
Copy link
Owner

After talking with someone and doing a few more tests, this shouldn't actually work, the format isn't 1:1 with what Forge expects (may not be applicable for new Forge versions) and it is using the gradle build folders, not the IntelliJ ones.

Also in doing more testing, while it seems to work fully for normal idea, trying to use the Single Hotswap plugin for a single class always fails, not sure why exactly.

Im also unsure how it would work for dcevm, if that even works on Forge, the Jetbrains jdk was giving issues a while ago.

I think we could hardcode a path to the idea output for common though, but when I tested that in the few minutes I had, it wasn't working, so I'm going to re-open this until a concrete fix is found.

@jaredlll08 jaredlll08 reopened this Apr 28, 2022
@jaredlll08
Copy link
Owner

This should have been fixed by MinecraftForge/ForgeGradle#851 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants