This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
wiggle1000's profile picture

Need help setting up the mod API

Started by wiggle1000, 20 March 2017 - 08:50 PM
wiggle1000 #1
Posted 20 March 2017 - 09:50 PM
I've been toiling for days over this problem: I have no idea how to use the CC API in my mod!
I'm using IntelliJ IDEA, and forge for 1.7.10. I can't get the mod to show up when I test the game..

Basically: What steps can I take to install the mod API (for use in making peripherals, etc.)?
Edited on 20 March 2017 - 09:15 PM
SquidDev #2
Posted 20 March 2017 - 11:49 PM
Firstly, I'd seriously consider developing for 1.8.9/1.10.2 instead of 1.7.10. Porting mods between versions is a bit of a pain, so if you're going in fresh I'd just start using as recent a version as possible. Anyway, in order to depend on ComputerCraft: you basically have two options:

Embedding the API
This is the "standard" way of including APIs. It makes it easier to work with the source, but does mean you have to keep the API up to date with the mod's version.

If you open the CC jar as a zip file (using something like 7zip, or your OS's built in archiver), you'll see an api/src folder. You want to extract that to the "src/api/java" directory, so you have something like this.

You should now be able to use the CC APIs. You may need to re-generate the project files if they don't show up immediately. Note, you'll also need to copy the CC jar into the run/mods folder for it to be loaded at runtime.

Adding as a dependency
This is the method I use in my mods. It makes it slightly easier to manage versions as you aren't bundling anything.

Open your build.gradle file and add the following code:

repositories {
  ivy {
	name = "ComputerCraft"
	artifactPattern "http://addons-origin.cursecdn.com/files/2269/339/[module][revision](.[ext])"
  }
}

dependencies {
  compile "ComputerCraft:ComputerCraft:1.75"
}
Please be aware that the version numbers and repository strings are different for different versions of the mods. There is a list of version strings here.



Note, in both cases you may need to install CodeChickenCore: this allows obfuscated mods to run in a deobfuscated environment. Be aware that this is only needed in 1.7.10, Forge for 1.8.9+ does this automatically.
Edited on 20 March 2017 - 10:51 PM
Kyahne #3
Posted 21 March 2017 - 12:47 AM
@SquidDev, as a sidenote (wiggle is a co-dev of mine), porting between 1.7.10 -> 1.9/1.10/1.11 is actually fairly easy, we made our 1.11 HxCCore and ported back within a few hours to all the versions we have on curse. Render code is the only pain.

Also, on topic, you make an amazingly complete post sir I commend your effort in making the forums requiring less replys to get the job done.
As a fellow developer I thank you as this has helped me out quite a bit (not directly as I know how to gradle etc.. but helping teach someone that helps me since I can't teach…)..
wiggle1000 #4
Posted 21 March 2017 - 01:33 AM
-SNIP-

Thank you, I'm trying the second method now. Works like a charm! Thank you, thank you! The process for setting these things up isn't well documented.. You're a life saver!
Edited on 21 March 2017 - 01:02 AM