RetroFuturaGradle
RetroFuturaGradle copied to clipboard
Error when calling vanilla or Forge classes from dependency library in kotlin environment
Example:
val stack: ItemStack = ItemStack(Items.IRON_INGOT)
crafttweaker.api.minecraft.CraftTweakerMC.getItemStack(stack) <-
Error Message: Cannot access class 'net.minecraft.item.ItemStack'. Check your module classpath for missing or conflicting dependencies
I'm facing the same problem. I fixed it temporarily by putting the dependency source code in the build/rfg/minecraft-src folder. However, this is a bad way, because the decompiled dependency source contains errors.
Maybe you managed to solve this problem in a better way during these 2 months?
Same problem. Wasn't happening before to me IIRC, I've been using RFG earlier with Kotlin without problems :I
@slava110 oh really? i didn’t know that solution
Have a look at https://github.com/GTNewHorizons/MX-Random/blob/master/addon.gradle - it builds with latest RFG using the GTNH buildscript without issues and is a kotlin mod.
And if that doesn't help, please send a code sample or repository I can actually test to see what's going on
Have a look at https://github.com/GTNewHorizons/MX-Random/blob/master/addon.gradle - it builds with latest RFG using the GTNH buildscript without issues and is a kotlin mod.
well… is that project using RFG? i couldn’t find any reference in *.gradle files
Yes, almost all GTNH projects use RFG. We now switched to GTNHGradle which uses RFG as a dependency, but you can look at the old buildscript here https://github.com/GTNewHorizons/MX-Random/blob/8a6903997e9c34e991f607554d179367c3d8d3b6/build.gradle
Can i use GTNHGradle for MC1.12.2?
@eigenraven I've created minimal reproducible example here:
https://github.com/slava110/RFGKotlinProblem
I'm depending on CreativeCore mod with rfg.deobf on it here
After initial setup you will (probably) be able to see error in ExampleMod.kt file like this one:
Any updates on this, found any workarounds?
Yes, almost all GTNH projects use RFG. We now switched to GTNHGradle which uses RFG as a dependency, but you can look at the old buildscript here https://github.com/GTNewHorizons/MX-Random/blob/8a6903997e9c34e991f607554d179367c3d8d3b6/build.gradle
That project has same problem
Try run gradlew setupDecompWorkspace. I got the same issue on your test repo before running that command. The issue gies away afterwards.
Try run
gradlew setupDecompWorkspace. I got the same issue on your test repo before running that command. The issue gies away afterwards.
I did run it, does not help
If anything,
- I bumped gradle version in gradlew setting to 8.6
- I'm running gradle with java 17
- I'm using intellij 2023.3.x, with RFG enabled version of minecraftdev plugin
I don't think any of these would practically matter, but that's probably the only outstanding points
also can you build the project by running gradlew build?
If anything,
I bumped gradle version in gradlew setting to 8.6
I'm running gradle with java 17
I'm using intellij 2023.3.x, with RFG enabled version of minecraftdev plugin
I don't think any of these would practically matter, but that's probably the only outstanding points
also can you build the project by running gradlew build?
Yes, the project builds just fine, also if I access the library from java, it works just fine (without no warnings/errors), so it is related to how IDEA handles Kotlin I think. Will check the other stuff and let you know if that helps
If anything,
- I bumped gradle version in gradlew setting to 8.6
- I'm running gradle with java 17
- I'm using intellij 2023.3.x, with RFG enabled version of minecraftdev plugin
I don't think any of these would practically matter, but that's probably the only outstanding points
also can you build the project by running gradlew build?
Did not help, rolled back to 2023.3.6, java 17, gradle 8.6. Only thing I did not understand fully, what do you mean by "RFG enabled"?
https://github.com/eigenraven/MinecraftDev as opposed to the one you would find on plugin marketplace
How about gradlew clean and delete .idea folder (while IDE is closed of course)?
How about gradlew clean and delete .idea folder (while IDE is closed of course)?
Yeah, same setup, same problem (tried different projects, recloning, invalidating cache, etc):
Still have the same problem. I tried different Kotlin (1.8.22 — 1.9.23) + Gradle (8.2 — 8.7) + system-wide JDK (1.8 — 21), and nothing helped.
The problem can be solved in bad way, to decompile the .jar dependency and to put its classes into rfg/minecraft-src. But you know, the quality of decompiled dependencies is low.
@Hummel009 @Glease So I figured out an interesting fix for that. After turning on the Kotlin K2 Mode in Kotlin language settings the issue is gone.
I also filled out an issue on the JetBrains YouTrack as it might be an issue on their end: https://youtrack.jetbrains.com/issue/IDEA-352220/Cannot-access-class-net.minecraftforge.fml.common.event.FMLServerStartingEvent.-Check-your-module-classpath-for-missing-or
Yes, compiler K2 works perfect with retrofuturagradle. Thanks!
With the release of Kotlin 2.0, the error did not disappear on its own (although the developers report that the compiler is now used by default). Apparently, the “K2 Mode” checkbox does something different. So we'll have to wait a while longer before everything works as it should. Because at the moment, unfortunately, enabling this checkbox breaks a lot of other plugins.