Skip to content

A library mod containing common code, mainly used by most of my Minecraft mods as a dependency.

License

Notifications You must be signed in to change notification settings

SanAndreaP/SanLib

Repository files navigation

SanLib

License Version Game API CurseForge project page

Twitter Mastodon Reddit Sponsor

Get the mod on CurseForge: Project Page


What this is

This is a library mod containing common code, mainly used by most of my Minecraft mods as a dependency. For players, it is only an additional mod to download alongside other mods requiring this. For developers, feel free to use and/or depend on any part of this codebase/library.

If you are a player and have issues with this library, please skip to the Contributions section below.

Features

  • JSON-based entity models, complete with resource pack support and hot-reload via command or on reloading resource packs.
  • JSON-based GUI components, with resource pack support
  • Easy to use networking implementation
  • Easy emissive block texture definitions
  • Class for easier color manipulations like converting RGB to HSL and vice versa
  • An XOR-Shift random implementation that aims to be faster than the regular Java-Random class
  • Several utility classes, like for example a cached reflection helper
  • A custom ingredient class for better NBT handling in recipes
  • A helper class for capability-based energy transfer
  • A couple of functional interfaces, e.g. ones that can throw exceptions
  • Command for orthogonal rendering of entities
  • Tuples
  • an easter egg
  • this ain't a coremod!

Why you might need it

Players: a mod you use depends on this.

Developers: A library makes it easier to maintain multiple mods, as they don't need to duplicate common things, like e.g. networking or converting ticks into readable time. Even when maintaining only one mod, it may be beneficial to use a library, depending on the scope of the mod.

If depending on a whole library seems too much, or you already have your own library mod, feel free to use any part of this codebase, as long as you respect the license.

How to use

Players: put the latest .jar file from CurseForge for your Minecraft version into the mods folder.

Developers: If you want to have this mod as a dependency, I strongly recommend using a gradle dependency within your build.gradle as follows:

repositories {
    // ...
    
    maven { // SanLib
        name 'SanLib'
        url 'https://repo.repsy.io/mvn/sanandreap/sanlib'
    }
}

// ...

dependencies {
    // ...
    
    implementation fg.deobf('de.sanandrew.mods:sanlib:${mc_version}-${sanlib_version}')
}

${mc_version} gets replaced by the current Minecraft version. (i.e. 1.16.5)

${sanlib_version} gets replaced by the version of SanLib you want to use (i.e 2.0.0-SNAPSHOT)

You can either write those in manually (implementation fg.deobf('de.sanandrew.mods:sanlib:1.16.5-2.0.0-SNAPSHOT'))
or define those variables within a gradle.properties file next to your build.gradle like

mc_version=1.16.5
sanlib_version=2.0.0-SNAPSHOT

Contributions

Note: make sure you read the CONTRIBUTING.md document before you proceed.

You have any problems regarding this library? Do you have a suggestion? Open a new issue within the Issues tab above. It will provide you with multiple templates.

You have some code that could benefit this library? Make sure you fork1 this repository, make your changes and create a pull request2. Please note that you should know about modding Minecraft in general3.

Footnotes

  1. How to fork a repo: https://docs.github.com/en/desktop/contributing-and-collaborating-using-github-desktop/adding-and-cloning-repositories/cloning-and-forking-repositories-from-github-desktop

  2. How to create a pull request: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request-from-a-fork

  3. a beginners guide can be found here: https://moddingtutorials.org/