Well at this point your mod should work.
IntelliJ is as simple to use for Forge modding as Eclipse.
If you still have the same problem, we might have to review all your module settings one by one. Including run configurations, compile path...
Assuming you didn't simply have a mistake in your code for the textures path.
Run
gradlew build
Then test the mod in Minecraft. If it works, we'll be sure the fault is within IntelliJ.
Well at this point your mod should work.
IntelliJ is as simple to use for Forge modding as Eclipse.
If you still have the same problem, we might have to review all your module settings one by one. Including run configurations, compile path...
Assuming you didn't simply have a mistake in your code for the textures path.
Run
gradlew build
Then test the mod in Minecraft. If it works, we'll be sure the fault is within IntelliJ.
Textures works perfectly outside of Intellij .. I guess something is wrong with my setup of Intellij then?
I've set it all up for a former project, was simple enough based on diesieben07's quick guide (with the exception of Importing build.gradle instead of Opening it) - not sure why you had so much trouble Xuluf.
EDIT: Well even though everything went smoothly as per that short guide, I see what you mean - resources are borked. Hmm.
What I want to do though is have all my mods in the one project, where each mod is a module. I've done this in a basic sense, but is that the right idea if, say, one of my mods is a library, and another mod depends on it? Can IDEA be told that one module is dependent on another...? And if so, how? Custom Run configuration perhaps?
Note that by "library", I mean a "Forge mod" library - not a standard Java library (which IntelliJ docs would cover I'm sure).
Summary of what I've done:
1) Made an empty IDEA Project
2) Added two mods via "Import Module" on the build.gradle
3) Manually setup the Run Configurations for each module (GradleStart, etc.)
Running the mods works all good and well, but... yeah, was hoping one of you guys knew how to go about the dependency thing.
Note you don't have to manually setup the run configurations.
As explained before
gradlew genIntellijRuns
will do all that is necessary.
You can make module dependency in Idea. Just go into the module settings (F4) and add the other module under the dependencies tab. Don't make circular dependency, and load the correct module from the run configuration. You are done.
Note you don't have to manually setup the run configurations.
As explained before
gradlew genIntellijRuns
will do all that is necessary.
You can make module dependency in Idea. Just go into the module settings (F4) and add the other module under the dependencies tab. Don't make circular dependency, and load the correct module from the run configuration. You are done.
This seems to be a Forge bug (or lack of implementation) - running genIntellijRuns via commandline or the Gradle run configs in IDEA just crashed out with "You must load the project in IDEA before running!" - it checks for the IDEA project directory/file before proceeding, but this doesn't exist because I added the mod as a module (the project files are in the parent folder instead).
But that's no matter, the Run configurations are working fine now. Well apart from resources (see below) - but the resources don't work even when I do it all standard and by-the-book (a single-mod project import).
I'll look into that re: depedencies, thanks.
I'm mostly trying to get the resources working now. As Xuluf said, he solved it - but manually copying the files to the artifact directory is more of a work-around than a solution. I'm sure the problem exists in dependencies - in Eclipse, I can see that "Minecraft/src/main/resources" are in the build path as a "source" type, but it's nowhere to be found in IDEA - apart from being marked as "resources". If I could figure out where IDEA makes the jar file when you chose "run", I could inspect the jar file to see if it's adding the path right (there's a lot of stuff in the IDEA module settings that make no sense to me). EDIT: Oh right, java doesn't actually need to "compile to a jar" to run But I found the classpath in log, it has the build/classes/main there and right after it, build/classes/resources too - which is all good, so this makes no sense.
Also, I didn't manually copy them to an artifact foldeR??
It's fully automatic? You said "putting it in before launch", I dunno what you mean by that.
Well then maybe it's useless, but I hacked up a script to do it for me - dirty, but works. I just add this .cmd file to the top of Run Configurations > Before Launch (above Make). Automatic; good enough. cmd file goes in the mod(ule) root folder.
IDEA doesn't want to copy resources to the same classpath entry as the compiled
sources when running, but insists on them going in their own classpath entry.
Forge does not like this. Dodgy script to copy missing resources (and lang assets)
to the same classpath entry as the compiled source.
equivalent of linux 'cd dirname'
CD %~dp0
copy resources
xcopy src\main\resources build\classes\main /E /I /Y
copy lang assets
xcopy src\main\java\assets build\classes\main /E /I /Y
Re: TE resetting stuff, what do you mean by "doesn't update after restart"? I had massive stress with getting that campfire TE saving/loading properly lol.
What I meant with "putting it in before launch" was : Run Configurations > Before Launch.
TE: So I have a TileEntity which prints out the "x" variable. It does print it out but once I reload the world save (not the game) the nbt is still there, but it isn't printing anything anymore? And when I restart the game, the nbt is gone and it works(it updates)?..
What I meant with "putting it in before launch" was : Run Configurations > Before Launch.
Oh right, so basically the same thing as I did. I checked the artifacts screen, it was far more scary for me than a batch script xD
Re: TE, you should .markDirty on the TE when you modify it's NBT. I dunno if that'll fix it, though you should be marking it dirty anyway. About integrated server; I think I remember that the world doesn't actually "fully unload" (or at least, WorldUnload Forge event is not fired).
Also, I can't really remember this junk well lol but the packet handlers might help too (can't hurt). Probably not the reason because you're doing nothing client side...
@Override
public Packet getDescriptionPacket() {
NBTTagCompound tagCompound = new NBTTagCompound();
writeToNBT(tagCompound);
return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, 1, tagCompound);
}
@Override
public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) {
NBTTagCompound tag = pkt.func_148857_g();
readFromNBT(tag);
}
Dunno, compared to my TE that's all that was missing. Whack some logging in your NBT read/write methods to see they're being called when they should maybe?
The worldObj is probably be null, makes sense if so (TE's along with their NBT are being loaded *as* the world loads, not after). If so, you'll have to get that TE later.
Maybe the Intellij version is the one causing the resource stuff.. As I've only seen Intellij IDEA 14 users have this problem? Might be wrong though
Could be. I use version 13 and never had a resource problem, nor the "You must load the project in IDEA before running!" message from ForgeGradle.
Hence why i am stumped at your "artifact" solution.
Granted i have all my mods under the same project, so never had to rebuilt it entirely. I usually make a new module from a freshly extracted "forge-src", then check the compile path, and everything works. Maybe Gradle force idea to load stuff right ?
Isn't the resources root selected as 'src/main/resources' under the module setting "Sources" tab ?
Could be. I use version 13 and never had a resource problem, nor the "You must load the project in IDEA before running!" message from ForgeGradle.
Hence why i am stumped at your "artifact" solution.
Granted i have all my mods under the same project, so never had to rebuilt it entirely. I usually make a new module from a freshly extracted "forge-src", then check the compile path, and everything works. Maybe Gradle force idea to load stuff right ?
Isn't the resources root selected as 'src/main/resources' under the module setting "Sources" tab ?
Yeah the module settings seem sane to me, I think Forge Gradle just needs to be updated for the IDEA 14. I even specifically said to exclude the
"resources" folder from build path, but it still whacks them into build/resources/. No idea where that's defined, but I'd guess ForgeGradle.
Did you check if the worldObj is null first? If it is, I'd just do it in the ticker. worldObj will never be null when updateEntity is called, I know that much.
EDIT: Yes, it is null in first nbt load I remember now, this is the reason I first used that "needUpdate" boolean in my Campfire.
@Override
public void updateEntity() {
//if (worldObj.isRemote) return; <--- not sure if you want this or even if it's needed?
if (listener == null)
listener = (ISignalListener)worldObj.getTileEntity(nbt2.getInteger("x"), nbt2.getInteger("y"), nbt2.getInteger("z"));
else return; // we're not loaded, so abort this tick (do you want this too? whatever lol)
[...]
}
Probably obvious, but if you needed to do more than a one-liner it'd be better to use an "isLoaded" class field boolean instead.
I know I'm being paranoid here but that sucks that you have to add an extra operation to every single tick for only a first-load case! Maybe there's a better way... assuming of course, that this worldObj thing is the problem.
IntelliJ is as simple to use for Forge modding as Eclipse.
If you still have the same problem, we might have to review all your module settings one by one. Including run configurations, compile path...
Assuming you didn't simply have a mistake in your code for the textures path.
Run
gradlew build
Then test the mod in Minecraft. If it works, we'll be sure the fault is within IntelliJ.
Textures works perfectly outside of Intellij .. I guess something is wrong with my setup of Intellij then?
EDIT: Were these the ones you wanted to see?
http://imgur.com/lPnvgbk,cJdnR05
Art by me: MrPancakeWolfie@DeviantArt
What about your run setting ?
Did you use 'gradlew genIntellijRuns', or did you set it manually ?
Yep, I used that
Art by me: MrPancakeWolfie@DeviantArt
Output directory: "projectName\build\classes\main"
Directory content: pointing to the resource folder where the sub folder is "src\main\resources"
Then basically just putting it in before launch.
Art by me: MrPancakeWolfie@DeviantArt
I've set it all up for a former project, was simple enough based on diesieben07's quick guide (with the exception of Importing build.gradle instead of Opening it) - not sure why you had so much trouble Xuluf.
EDIT: Well even though everything went smoothly as per that short guide, I see what you mean - resources are borked. Hmm.
What I want to do though is have all my mods in the one project, where each mod is a module. I've done this in a basic sense, but is that the right idea if, say, one of my mods is a library, and another mod depends on it? Can IDEA be told that one module is dependent on another...? And if so, how? Custom Run configuration perhaps?
Note that by "library", I mean a "Forge mod" library - not a standard Java library (which IntelliJ docs would cover I'm sure).
Summary of what I've done:
1) Made an empty IDEA Project
2) Added two mods via "Import Module" on the build.gradle
3) Manually setup the Run Configurations for each module (GradleStart, etc.)
Running the mods works all good and well, but... yeah, was hoping one of you guys knew how to go about the dependency thing.
As explained before
gradlew genIntellijRuns
will do all that is necessary.
You can make module dependency in Idea. Just go into the module settings (F4) and add the other module under the dependencies tab. Don't make circular dependency, and load the correct module from the run configuration. You are done.
For automated build through gradle, it requires a bit more manipulation:
http://www.minecraftforge.net/forum/index.php/topic,14791.0.html
This seems to be a Forge bug (or lack of implementation) - running genIntellijRuns via commandline or the Gradle run configs in IDEA just crashed out with "You must load the project in IDEA before running!" - it checks for the IDEA project directory/file before proceeding, but this doesn't exist because I added the mod as a module (the project files are in the parent folder instead).
But that's no matter, the Run configurations are working fine now. Well apart from resources (see below) - but the resources don't work even when I do it all standard and by-the-book (a single-mod project import).
I'll look into that re: depedencies, thanks.
I'm mostly trying to get the resources working now. As Xuluf said, he solved it - but manually copying the files to the artifact directory is more of a work-around than a solution. I'm sure the problem exists in dependencies - in Eclipse, I can see that "Minecraft/src/main/resources" are in the build path as a "source" type, but it's nowhere to be found in IDEA - apart from being marked as "resources". If I could figure out where IDEA makes the jar file when you chose "run", I could inspect the jar file to see if it's adding the path right (there's a lot of stuff in the IDEA module settings that make no sense to me). EDIT: Oh right, java doesn't actually need to "compile to a jar" to run But I found the classpath in log, it has the build/classes/main there and right after it, build/classes/resources too - which is all good, so this makes no sense.
Also, I didn't manually copy them to an artifact foldeR??
EDIT: ALSO: My tileEntity doesn't seems to update after I restart the world? And it resets once I restart the game.. D: Does anybody know why :/ ?
Art by me: MrPancakeWolfie@DeviantArt
It's fully automatic? You said "putting it in before launch", I dunno what you mean by that.
Well then maybe it's useless, but I hacked up a script to do it for me - dirty, but works. I just add this .cmd file to the top of Run Configurations > Before Launch (above Make). Automatic; good enough. cmd file goes in the mod(ule) root folder.
Re: TE resetting stuff, what do you mean by "doesn't update after restart"? I had massive stress with getting that campfire TE saving/loading properly lol.
TE: So I have a TileEntity which prints out the "x" variable. It does print it out but once I reload the world save (not the game) the nbt is still there, but it isn't printing anything anymore? And when I restart the game, the nbt is gone and it works(it updates)?..
Art by me: MrPancakeWolfie@DeviantArt
Oh right, so basically the same thing as I did. I checked the artifacts screen, it was far more scary for me than a batch script xD
Re: TE, you should .markDirty on the TE when you modify it's NBT. I dunno if that'll fix it, though you should be marking it dirty anyway. About integrated server; I think I remember that the world doesn't actually "fully unload" (or at least, WorldUnload Forge event is not fired).
Also, I can't really remember this junk well lol but the packet handlers might help too (can't hurt). Probably not the reason because you're doing nothing client side...
Art by me: MrPancakeWolfie@DeviantArt
but those coordinates aren't an incompatible block?
Art by me: MrPancakeWolfie@DeviantArt
The worldObj is probably be null, makes sense if so (TE's along with their NBT are being loaded *as* the world loads, not after). If so, you'll have to get that TE later.
Could be. I use version 13 and never had a resource problem, nor the "You must load the project in IDEA before running!" message from ForgeGradle.
Hence why i am stumped at your "artifact" solution.
Granted i have all my mods under the same project, so never had to rebuilt it entirely. I usually make a new module from a freshly extracted "forge-src", then check the compile path, and everything works. Maybe Gradle force idea to load stuff right ?
Isn't the resources root selected as 'src/main/resources' under the module setting "Sources" tab ?
Any idea how?
Art by me: MrPancakeWolfie@DeviantArt
Yeah the module settings seem sane to me, I think Forge Gradle just needs to be updated for the IDEA 14. I even specifically said to exclude the
"resources" folder from build path, but it still whacks them into build/resources/. No idea where that's defined, but I'd guess ForgeGradle.
Did you check if the worldObj is null first? If it is, I'd just do it in the ticker. worldObj will never be null when updateEntity is called, I know that much.
EDIT: Yes, it is null in first nbt load I remember now, this is the reason I first used that "needUpdate" boolean in my Campfire.
Probably obvious, but if you needed to do more than a one-liner it'd be better to use an "isLoaded" class field boolean instead.
I know I'm being paranoid here but that sucks that you have to add an extra operation to every single tick for only a first-load case! Maybe there's a better way... assuming of course, that this worldObj thing is the problem.