Posted January 26, 20169 yr So, I understand that an API is just some classes for other mods to interact with mine. But, do I simply create a package for my API classes, compile my mod with it, and have people use the source of my mod for the API? Do I have to compile an API separately? Do I have to define a class or package as an API? I just want to make sure people won't have errors when attempting to interact with my mod. I am not a cat. I know my profile picture is sexy and amazing beyond anything you could imagine but my cat like features only persist in my fierce eyes. I might be a cat.
January 26, 20169 yr Yes, you should create a specific package for your API classes, if any, so that you can declare it as an API by including a package-info.java file: @API(owner = "yourmodid", provides = "UniqueNameForAPI", apiVersion = "1.8-1.0") package yourmod.api; import net.minecraftforge.fml.common.API; This lets FML / Forge know that this is an API package so that it prioritizes making the classes in it available sooner rather than later when loading mods (at least that's how I understand it - may not be 100% correct). Whether you release that API package separately or include it in your mod is up to you; personally I tend to just include them with my mods, but if you plan on having lots of your own mods using the same API, it may be better to release it separately as a dependency, or you could shade it. http://i.imgur.com/NdrFdld.png[/img]
January 26, 20169 yr Author Are you sure it's a .info file? Wouldn't you need to do a .java to use the @API annotation? I am not a cat. I know my profile picture is sexy and amazing beyond anything you could imagine but my cat like features only persist in my fierce eyes. I might be a cat.
January 26, 20169 yr Are you sure it's a .info file? Wouldn't you need to do a .java to use the @API annotation? Sorry, it's named "package-info.java" http://i.imgur.com/NdrFdld.png[/img]
January 26, 20169 yr Author I tried creating that, but it says you can't use a dash in your class name. I am not a cat. I know my profile picture is sexy and amazing beyond anything you could imagine but my cat like features only persist in my fierce eyes. I might be a cat.
January 26, 20169 yr Author Silly me, just had to create the file outside of eclipse. Thanks! I am not a cat. I know my profile picture is sexy and amazing beyond anything you could imagine but my cat like features only persist in my fierce eyes. I might be a cat.
January 26, 20169 yr Author One more question though, what if someone implements my API classes, and someone using that mod does not have my mod loaded? Wouldn't that crash the game? I am not a cat. I know my profile picture is sexy and amazing beyond anything you could imagine but my cat like features only persist in my fierce eyes. I might be a cat.
January 26, 20169 yr If people want to use your API as an optional option, they can use the @Optional annotation so forge knows not to crash when your API is missing. So no need to worry about that. Projects: Discontinued: - N2ConfigAPI - Meachanical Crafting Table Latest: - CollectionUtils Coöperations: - InGameConfigManager
January 26, 20169 yr Author Alright, would they put that annotation over their Item or Block class? (I created the weight limit mod , so they have to implement my interface in order to provide items with weight). I am not a cat. I know my profile picture is sexy and amazing beyond anything you could imagine but my cat like features only persist in my fierce eyes. I might be a cat.
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.