TLA Api
TLA Api is an intermediate layer that simplifies working with recipe viewer APIs in Minecraft. This tool enables mod developers to create a unified integration system that will function with various popular recipe viewing programs.
Currently, support is provided for the following recipe viewers: EMI and REi.
Usage
Connection via Gradle
To access TLA Api through Jitpack, you need to add the following lines to the build.gradle file:
repositories {
maven {
url "https://jitpack.io"
}
}
dependencies {
modImplementation "com.github.mattidragon:TlaApi:${tla_api_version}"
include "com.github.mattidragon:TlaApi:${tla_api_version}"
}
Getting Started
To work with the API, you need to implement the TlaApiPlugin interface and add your implementation to the tla-api entry point. It is important to note that the entire API functions exclusively on the client side. When using separated source sets, you need to implement the API in the client part.
public class MyTlaPlugin implements TlaApiPlugin {
@Override
public void register(PluginContext context) {
// API registration is done here
}
}
{
"entrypoints": {
"tla-api": [
"my.package.MyTlaPlugin"
]
}
}
Content Registration
After setting up the entry point, you can proceed with content registration. All API documentation is available through javadocs, allowing you to use your IDE's capabilities to explore the functionality. The API structure is primarily based on EMIs, but certain changes have been made to ensure compatibility with REI.
Important Aspects
Although TLA Api provides a universal abstraction, developers are advised to independently verify the correct operation of their code with both recipe viewers. For example, for EMI, you still need to convert all tags. There may also be slight differences in the display of some interface elements.
For convenient work with the API, it is recommended to pay attention to the following annotations:
- @ApiStatus.Internal - Code elements not intended for use by mod developers;
- @ImplementationOnly - Code parts focused on implementing API for recipe viewers;
- @PluginOnly - Components intended exclusively for plugins;
- @ImplementationsExtend - Indicates that the interface is implemented by API implementations;
- @PluginsExtend - Means that the interface is implemented by plugins.
Frequently Asked Questions
Question: Does this API allow mods that only support one viewer to work with two? Answer: No. This API only makes it easier for developers to support both viewers.
Question: Why does the API only work on the client side? Answer: The entire EMI API functions exclusively on the client side, and REI's server-side API does not contain the functions used by TLA.
Question: Are there any usage examples? Answer: Yes, you can familiarize yourself with the test mod here Git: https://github.com/mattidragon/TlaApi/tree/1.20.4/src/testmod. It contains some non-standard implementations but demonstrates the API's capabilities well.