Hey guys,
after some weeks of getting experienced with Minecraft modding, I want to submit an issue here that occurs when you use the IDE IntelliJ for your mods.
I started with a very basic mod to implement my own items. Therefor, I had to learn about modding and first of all, gradle.
Since I am no Java newbie, I know how projects were structured and how to handle with IDEs. I've always used IntelliJ. Eclipse is good and has a ton of
features but I am still preferring IntelliJ. So here is the problem.
There are several articles and forum topics mentioning the setup of workspaces for your mods in IntelliJ. This is also one of the topics in the official
Minecraft Forge documentation. The steps to setup such a workspace aren't hard and were done very fast. But when I tried to test my mod, I ran into the
first issues.
The textures simply didn't load and I couldn't explain why this happens. I checked every file I wrote at least 10 times, I checked the textures, I
copied whole repositories from people that offered Minecraft modding tutorials, I even forked famous mods just to see how they handle their item
implementation and why my textures weren't working. Nothing worked. I always got the famous purple-black texture ingame and several errors about
missing textures and models. Since I realized that not even my localization file was being loaded, my assumption was that the assets folder wasn't loaded
at all and when I tested it with some log messages, my assumption was quickly confirmed.
Nothing what I did seemed to fix this issue and I was about to give up but after some hours of searching through all the internet pages I've found about
that issue or even about little keywords, I finally found a little post about IntelliJ messing around with the assets folder.
There is a simple solution. You can put the following code at the end of your build.gradle and everything will work perfectly fine:
sourceSets { main { output.resourcesDir = output.classesDir } }
No errors, no warnings, all textures instantly loaded, all models loaded, everything was localized.
So... why do I post this?
There is still something wrong. Why does not a single post mention this code? Why is it marked as deprecated? Why do no popular mods use this code
in their build.gradle?
Well, most mod creators use Eclipse, that's for sure and Eclipse doesn't have this issue. Lucky for them but what about modders that actually use
IntelliJ and don't have this issue?
I quickly realized that this code might help with the local testing environment but you can't build your mod with it. It will give you an error.
You can only build your mod when you remove it again but the local client instance doesn't work then. Interestingly when I build the mod, the assets
are copied just fine and everything works in the real game when you load the mod. However, you can't get working textures in the IDE when
you don't put this code in your build.gradle.
So what is the solution of this? How do you get IntelliJ to run without problems if you want to test AND build within the same project.
The only thing that comes to my mind would be a work around to load an artifact whenever you start your client which copies the assets
manually but that sounds too difficult for making a Minecraft mod. I am open for suggestions, thanks for reading.
Greetz,
Relentless
Solution for this problem: