Jump to content

[1.12.1] Implementation of an API (Baubles)


Fijal

Recommended Posts

I kinda hate to ask you peoples yet another thing after you helped me so recently, but that's what you're here for, right?

 

I'd like to use Baubles so my existing items can be equipped in the slots created by baubles. Unfortunately, the only guide I can find for using APIs is this, and it was published in early 2014, and last edited in early 2015. So yeah, I'm not sure how reliable that is, and whether or not it'll break my existing code if I try to follow it.

 

So this post basically just comes down to "hey, hey someone more experienced than me please help me figure out how to use the Baubles API"

Again, all my code can be found here.

 

Thanks in advance!

(This post assumes the 1.12 baubles version will work in 1.12.1)

Edited by Fijal
Link to comment
Share on other sites

How will you use the API? Will it have to be downloaded separately or do you want it integrated into your mod?

If it is integrated into the mod, you can download the de-obf.jar and use winrar to copy the packages and assets in.

If it is downloaded separately, in IntelliJ you can add dependencies in Project > Modules > Dependencies. You add the .jar there

Link to comment
Share on other sites

Few notes, I don't own Winrar so I'm using 7Zip and I'm using Eclipse instead of IntelliJ which I could never setup properly.

 

I'd be making it integrated into the mod I because I assume that makes for easier downloading.

So, I downloaded the file called Baubles-1.12-1.5.1-deobf, extract the files using 7Zip, and based on something I read, I put the extracted files in /src/api/.

All the files I extracted are .Class, not .Java, so Eclipse can't read them. Is that supposed to happen, or if I'm integrating it should I have downloaded the source version of Baubles?

 

Edit: If I were going to make it so Baubles must be downloaded separately (and it works if I do this so maybe I will), how do I make an item equipable in a Baubles-added slot? Is there an example item somewhere?

 

 

Edited by Fijal
Link to comment
Share on other sites

There is your problem.
Thats not how that should be done. Baubles in an independend mod and its api is just something you can access.
 

Since there does not seem to be a maven repository for baubles just put the jar in a new libs/ folder in your project root.

And run: gradle --refresh-dependencies

It should become available as a library in your working environment.

PM's regarding modding questions should belong in the Modder Support sub-forum and won't be answered.

Link to comment
Share on other sites

You can use any Git repository (like Baubles) as a Maven dependency through JitPack. I do this in my mod here.

 

You can also use CurseForge as a Maven repository through its API (see the Maven section).

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Link to comment
Share on other sites

I put Baubles-1.12-1.5.1-debof.jar in */libs/, ran ./gradlew setupDecompWorkspace --refresh-dependencies,(because I'm using powershell, the new default win10 1703, and I did setupDecomp thing because you have to run something before the --refresh thing.) opened up Eclipse, typed "IBauble" to get quick access to a Baubles file, and it said something like class file error and asked for a source.

 

Then thinking maybe I should try the API version of Baubles I downloaded Baubles-1.12-1.5.1-debof.jar, and did the same thing. This time it worked. Is it supposed to be like that?

Link to comment
Share on other sites

8 minutes ago, Choonster said:

You can use any Git repository (like Baubles) as a Maven dependency through JitPack. I do this in my mod here.

 

You can also use CurseForge as a Maven repository through its API (see the Maven section).

So, I just put

deobfCompile "com.github.azanor:Baubles:${baubles_version}"

in the dependencies section of my build.gradle

and

maven { url 'https://jitpack.io' }

to the repositories sections build.gradle and I won't need a baubles.jar?

 

Or would you suggest the CurseForge API?

 

 

Edited by Fijal
Link to comment
Share on other sites

Just now, Fijal said:

So, I just put


deobfCompile "com.github.azanor:Baubles:${baubles_version}"

in the dependencies section of my build.gradle

and


maven { url 'https://jitpack.io' }

to the repositories sections build.gradle and I won't need a baubles.jar?

 

Yes, once you've done that you don't need to manually download the Baubles JAR.

 

Make sure you actually define the baubles_version variable somewhere (e.g. in gradle.properties). This is the tag or commit ID that you want to depend on.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Link to comment
Share on other sites

So, gathering this all into one post, I put deobfCompile "com.github.azanor:Baubles:${baubles_version}" and maven { url 'https://jitpack.io' } in their respective sections of my build.gradle, make a gradle.properties file, and place baubles_version=7035b13 (which is still the latest commit) in it.

 

Do I need to place my versions of the following in gradle.properties as well?

mod_name=TestMod3
package_group=choonster.testmod3

mc_version=1.12.1
forge_version=14.22.0.2462

 

Also, will I be able to view BaublesApi.class as if I had the .jar?

Edited by Fijal
Link to comment
Share on other sites

2 minutes ago, Fijal said:

So, gathering this all into one post, I put deobfCompile "com.github.azanor:Baubles:${baubles_version}" and maven { url 'https://jitpack.io' } in their respective sections of my build.gradle, make a gradle.properties file, and place baubles_version=7035b13 (which is still the latest commit) in it.

 

Yes.

 

2 minutes ago, Fijal said:

Do I need to place my versions of the following in gradle.properties as well?

 

You don't have to, I only have them there because my buildscript uses those variables. I do recommend doing something similar in your own buildscript.

 

3 minutes ago, Fijal said:

Also, will I be able to view BaublesApi.class as if I had the .jar?

 

Yes, the source code from the repository will be linked to the JAR in your IDE.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Link to comment
Share on other sites

So I deleted all .jar files from */libs/ so it's completely empty now, and did all the stuff we talked about up above, ran ./gradlew setupDecompWorkspace --refresh-dependencies, launched eclipse and I can no longer find any classes named BaublesAPI.class or anything similar. Should I have kept a .jar file in */libs/?

Link to comment
Share on other sites

13 minutes ago, Fijal said:

So I deleted all .jar files from */libs/ so it's completely empty now, and did all the stuff we talked about up above, ran ./gradlew setupDecompWorkspace --refresh-dependencies, launched eclipse and I can no longer find any classes named BaublesAPI.class or anything similar. Should I have kept a .jar file in */libs/?


You probably need to refresh your IDE project. I think the way to do this for Eclipse is by re-running the eclipse Gradle task. If you were using IDEA, you'd just click the Refresh all Gradle Projects button in its Gradle window.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Link to comment
Share on other sites

oooh it works now. Thanks! I thought I wouldn't need to re-run that bit.

 

Does Baubles still have that example ring? Or was that removed? I ask  because I'm not seeing it, and I imagine that would be helpful for making my own custom items.

 

Edit: nvm, I found it just as I asked...

Edited by Fijal
Link to comment
Share on other sites

  • 2 years later...

I'm using eclipse IDE I've followed this thread and tried everything and can't figure out how to get this to work properly. The version you have is out of date now it is 1.5.2, but every time i try to refresh dependencies it says

  startup failed:
  build file 'C:\MinecraftModing\ElementalBaubles\build.gradle': 43: unexpected token: com.github.azanor:Baubles:1.5.2 @ line 43, column 12.
        Compile "com.github.azanor:Baubles:1.5.2"

Link to comment
Share on other sites

  • Guest locked this topic
Guest
This topic is now closed to further replies.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.