Jump to content

[1.12.1] Implementation of an API (Baubles)


Recommended Posts

Posted (edited)

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
Posted

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

Posted (edited)

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
Posted

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.

Posted

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.

Posted

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?

Posted (edited)
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
Posted
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.

Posted (edited)

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
Posted
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.

Posted

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/?

Posted
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.

Posted (edited)

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
  • 2 years later...
Posted

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"

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

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • that happens every time I enter a new dimension.
    • This is the last line before the crash: [ebwizardry]: Synchronising spell emitters for PixelTraveler But I have no idea what this means
    • What in particular? I barely used that mod this time around, and it's never been a problem in the past.
    • Im trying to build my mod using shade since i use the luaj library however i keep getting this error Reason: Task ':reobfJar' uses this output of task ':shadowJar' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed. So i try adding reobfJar.dependsOn shadowJar  Could not get unknown property 'reobfJar' for object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler. my gradle file plugins { id 'eclipse' id 'idea' id 'maven-publish' id 'net.minecraftforge.gradle' version '[6.0,6.2)' id 'com.github.johnrengelman.shadow' version '7.1.2' id 'org.spongepowered.mixin' version '0.7.+' } apply plugin: 'net.minecraftforge.gradle' apply plugin: 'org.spongepowered.mixin' apply plugin: 'com.github.johnrengelman.shadow' version = mod_version group = mod_group_id base { archivesName = mod_id } // Mojang ships Java 17 to end users in 1.18+, so your mod should target Java 17. java.toolchain.languageVersion = JavaLanguageVersion.of(17) //jarJar.enable() println "Java: ${System.getProperty 'java.version'}, JVM: ${System.getProperty 'java.vm.version'} (${System.getProperty 'java.vendor'}), Arch: ${System.getProperty 'os.arch'}" minecraft { mappings channel: mapping_channel, version: mapping_version copyIdeResources = true runs { configureEach { workingDirectory project.file('run') property 'forge.logging.markers', 'REGISTRIES' property 'forge.logging.console.level', 'debug' arg "-mixin.config=derp.mixin.json" mods { "${mod_id}" { source sourceSets.main } } } client { // Comma-separated list of namespaces to load gametests from. Empty = all namespaces. property 'forge.enabledGameTestNamespaces', mod_id } server { property 'forge.enabledGameTestNamespaces', mod_id args '--nogui' } gameTestServer { property 'forge.enabledGameTestNamespaces', mod_id } data { workingDirectory project.file('run-data') args '--mod', mod_id, '--all', '--output', file('src/generated/resources/'), '--existing', file('src/main/resources/') } } } sourceSets.main.resources { srcDir 'src/generated/resources' } repositories { flatDir { dirs './libs' } maven { url = "https://jitpack.io" } } configurations { shade implementation.extendsFrom shade } dependencies { minecraft "net.minecraftforge:forge:${minecraft_version}-${forge_version}" implementation 'org.luaj:luaj-jse-3.0.2' implementation fg.deobf("com.github.Virtuoel:Pehkui:${pehkui_version}") annotationProcessor 'org.spongepowered:mixin:0.8.5:processor' minecraftLibrary 'luaj:luaj-jse:3.0.2' shade 'luaj:luaj-jse:3.0.2' } // Example for how to get properties into the manifest for reading at runtime. tasks.named('jar', Jar).configure { manifest { attributes([ 'Specification-Title' : mod_id, 'Specification-Vendor' : mod_authors, 'Specification-Version' : '1', // We are version 1 of ourselves 'Implementation-Title' : project.name, 'Implementation-Version' : project.jar.archiveVersion, 'Implementation-Vendor' : mod_authors, 'Implementation-Timestamp': new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"), "TweakClass" : "org.spongepowered.asm.launch.MixinTweaker", "TweakOrder" : 0, "MixinConfigs" : "derp.mixin.json" ]) } rename 'mixin.refmap.json', 'derp.mixin-refmap.json' } shadowJar { archiveClassifier = '' configurations = [project.configurations.shade] finalizedBy 'reobfShadowJar' } assemble.dependsOn shadowJar reobf { re shadowJar {} } publishing { publications { mavenJava(MavenPublication) { artifact jar } } repositories { maven { url "file://${project.projectDir}/mcmodsrepo" } } } my entire project:https://github.com/kevin051606/DERP-Mod/tree/Derp-1.0-1.20
  • Topics

×
×
  • Create New...

Important Information

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