FabricMC / fabric-loom

Gradle build system plugin used to automate the setup of a minecraft mod development environment.
MIT License
225 stars 194 forks source link

Intellij Run configurations don't include resourceProcessing #1010

Closed nightpool closed 6 months ago

nightpool commented 7 months ago

Hi all! A bit confused about where to begin with this report, but I'm trying to use the "Minecraft Client" run configurations generated by loom, but they fail because my fabric.mod.json file requires some template processing from Gradle before it can be used:

image

which gives me an error:

 net.fabricmc.loader.impl.FormattedException: Some of your mods are incompatible with the game or each other!
A potential solution has been determined, this may resolve your problem:
     - Replace mod 'Foo' (foo) ${version} with any version that is compatible with:
         - fabricloader 0.15.2
         - minecraft 1.20.2
More details:
     - Mod 'Foo' (foo) ${version} requires version ${loader_version} of mod 'Fabric Loader' (fabricloader), but only the wrong version is present: 0.15.2!
     - Mod 'Foo' (foo) ${version} requires version ${minecraft_version} of 'Minecraft' (minecraft), but only the wrong version is present: 1.20.2!

the gradle :runClient tasks work fine, but that seems to make it harder to debug & slower to compile. Plus, I don't think it works with hot reloading?

This seems like a bug in that the "Minecraft Client" should have a Before Build task to pre-process the resources and put them in the right place (wherever that may be).

Presumably this would also break for anybody with generated data?

Technici4n commented 7 months ago

On Fabric, people generally don't use variable expansion in their resources like that. If you don't then you can even set "Build with" to IDEA instead of Gradle for hopefully faster compile times.

nightpool commented 7 months ago

@Technici4n The official fabric gradle template uses it: https://github.com/FabricMC/fabric-example-mod/blob/1.20/build.gradle#L52

nightpool commented 7 months ago

And the default MinecraftDev IDEA plugin templates extend this to fill in the loader_version and minecraft_version: https://github.com/minecraft-dev/MinecraftDev/blob/dev/src/main/resources/fileTemplates/j2ee/fabric/fabric_build.gradle.ft#L41-L42

So I don't think it's correct to say this isn't commonly done. A quick github search shows that 15k mods have this property defined:

image

For example, this snippet from Create:

https://github.com/Fabricators-of-Create/Create/blob/49cc17e/build.gradle#L188-L213

image

modmuss50 commented 6 months ago

This is an intelij limitation, sadly nothing we can do to fix it (loom has nothing to do with processResources anyway).

I would reccomend not using the MC dev template, the official template (https://fabricmc.net/develop/template/) does not do this, and works great when building+running via idea.

nightpool commented 6 months ago

@modmuss50 there's no way to run a single short gradle script to process the resources during the intellij Before Launch phase? That doesn't seem correct to me, Intellij definitely provides the tools to do so

The official template you provided still has the same conceptual issue, in that it uses the ${version} build variable which is not interpolated when launched through the IDE. Fabric just happens not to crash when a mod's version is malformed, by pure luck. (this would almost certainly break if you were testing with a mod that depended on the mod you're currently developing)

The fact that all fabric developers are prevented from using build variables in their fabric.mod.json file if they want resource reloading is a major issue and I think as a project we could do a better job leveraging the capabilities of the IDE to solve this

modmuss50 commented 6 months ago

@modmuss50 there's no way to run a single short gradle script to process the resources during the intellij Before Launch phase? That doesn't seem correct to me, Intellij definitely provides the tools to do so

Not really no, as doing so would then remove the main benefit (the major peformance improvement) of building without gradle.

Fabric just happens not to crash

This was done on purpose, loom does provide the tools to read the mod version from the fabric.mod.json and set it as the Gradle version, maybe we should do that in the example mod and remove process resources 🤔

nightpool commented 6 months ago

I just want to be able to type /reload and get updated versions of my datapacks when i edit them. I haven't really ever seen a performance difference between running my mod through IntelliJ or through Gradle (starting up the instance and doing mixins is always much longer than compiling the code anyway)

On Sun, Jan 7, 2024 at 10:39 AM modmuss @.***> wrote:

@modmuss50 https://github.com/modmuss50 there's no way to run a single short gradle script to process the resources during the intellij Before Launch phase? That doesn't seem correct to me, Intellij definitely provides the tools to do so

Not really no, as doing so would then remove the main benefit (the major peformance improvement) of building without gradle.

Fabric just happens not to crash

This was done on purpose, loom does provide the tools to read the mod version from the fabric.mod.json and set it as the Gradle version, maybe we should do that in the example mod and remove process resources 🤔

— Reply to this email directly, view it on GitHub https://github.com/FabricMC/fabric-loom/issues/1010#issuecomment-1880108033, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABZCV6VN6HWOK5H6N3GX6LYNLFUZAVCNFSM6AAAAABA5MBRAKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQOBQGEYDQMBTGM . You are receiving this because you authored the thread.Message ID: @.***>