This is a library that can be shaded into Minecraft mods.
When multiple mods with MCLib embedded are present, calls to shared modules from all mods are redirected to whichever mod has the newest version of the given module.
UpdateCheck
: checks for updates and displays the results in a HTML file, with a notification button in the main menu.
MCLibModules.updateCheckAPI
AssetDirector
: downloader for Mojang's assets and Minecraft jars directly off their servers, allowing use and redistribution of things like sounds without EULA worries.
AssetDirectorAPI
SloppyDepLoader
: a dependency loader for optional dependencies, which won't fail if the dependency fails to be located. It makes no guarantee it will locate the requested dependencies, hence its name.
SloppyDepLoaderAPI
.InventoryUtils2
: helper for CodeChickenLib's InventoryUtils
classReleases are published on JitPack. To use this library in your mod, add this to your buildscript:
repositories {
maven { url 'https://jitpack.io' }
}
minecraft {
srgExtra "PK: makamys/mclib <YOUR/MOD/PACKAGE>/repackage/makamys/mclib"
}
dependencies {
shade('com.github.makamys:MCLib:<VERSION>'){
exclude group: "codechicken"
}
}
In place of <VERSION>
, use a release number (e.g. 0.3.4
).
A commit hash can also be used, but doing this in production is discouraged as it may make MCLib unable to correctly select the highest version of the library.
The above snippet assumes there is a shade
configuration in your build script. If there isn't, you can use the below one as an example (the configurations
block has to go before the dependencies
block). For additional explanation on what this does, see ForgeGradle's shading tutorial.
configurations {
shade
compile.extendsFrom shade
}
jar {
configurations.shade.each { dep ->
from(project.zipTree(dep)){
exclude 'META-INF', 'META-INF/**'
}
}
}
The library first has to be initialized by calling MCLib.init()
in the mod construction phase. You can do this like this in your mod class:
@EventHandler
public void onConstruction(FMLConstructionEvent event) {
MCLib.init();
}
Static helper classes like SloppyDepLoader
can be used by simply calling their static methods.
Shared modules like UpdateCheck
require special setup via their respective *API
classes (e.g. UpdateCheckAPI
). See the example test files above to see how to use them.
Check the wiki for more documentation.
If you want to see some examples of the library in action, see Satchels and Et Futurum Requiem.
The library has some test packages containing test mods that test its features. These packages are excluded from builds normally. To enable them, add -Ptest_<library name>
to your Gradle command. See project.gradle for the available flags.
See LICENSE.md.