Skip to content

dexman545/Outlet

Repository files navigation

Outlet

A Gradle plugin for lazy Minecraft mod developement.

Provides the following features:

  • Getting the latest Minecraft version available, optionally within a given range
  • Getting the latest or earliest Yarn version for a Minecraft version
  • Getting the latest available version of Fabric loader
  • Getting the latest available version of Fabric API for a Minecraft version
  • Getting the latest available version of Neoforge for a Minecraft version
  • Getting the latest available version of Parchment for a Minecraft version
    • Will try to find the closest matching Minecraft version that has parchment mappings
  • Getting the required Java version for a Minecraft version
  • Getting the Java compatibility level for a range of Miencraft versions
  • Generating the list of acceptable Minecraft versions based on a given range, useful for instance with publishing on Modrinth via Minotaur
  • Generating the list of acceptable Minecraft versions based on a given range for use on Curseforge via CurseGradle
  • Optional nondestructive automatic updating of gradle.properties versions with the new values Outlet has produced

Usage

There are three parts to using Outlet: applying the plugin, feeding it options, then calling the methods. The latter two occur anywhere after application.

Application

Add Outlet as you would using any other gradle plugin.

Telling it what you want

Dummy values in use!

Add any of the following (mcVersionRange is required):

// The Minecraft version range from the fabric.mod.json.
// Use '*' to match any MC version
// Default: null - set it!
outlet.mcVersionRange = '*'
// Whether outlet.mcVersions() should return snapshots
// Default: true
outlet.allowSnapshotsForProject = true
// Whether outlet.yarnVersion() should return the latest yarn version or 
// the earliest yarn version for a given Minecraft version
// Default: true
outlet.useLatestYarn = true
// Whether outlet.latestMc() respects the provided range
// Default: true
outlet.latestMcRespectsRange = true

// Whether the properties file versions should be updated.
// This also doubles as an environment check, eg. update them in dev 
// but not on a build server
// Default: false
outlet.maintainPropertiesFile = true

// The map of entries to update in the properties file and their new version
// Any key/value pair in the properties file can be updated in this way, not just those Outlet manages!
// Default: empty
outlet.propertiesData = ['fabric_version': outlet.fapiVersion()]

// The amount of time to keep the cache before attempting to update
// Default 12 hrs, set to null to disable
outlet.cacheTime = new TimeDuration(0, 12, 0, 0, 0)

Note: these can also be set using the outlet block!

Getting stuff out of it

You can set the outputs of these methods to settings or use them directly.

// Get the set of Minecraft version strings
// Can be used for automated Modrinth upload
outlet.mcVersions() // Returns Set<String>

// Get the set of Minecraft version strings for automated curseforge upload
outlet.curseforgeMcVersions() // Returns Set<String>

// Get the latest Minecraft version
outlet.latestMc() // Returns String

// Get the latest Fabric Loader version
outlet.loaderVersion() // Returns String

// Get the Yarn version for the latest MC version (output of latestMc())
outlet.yarnVersion() // Returns String

// Get the Yarn version for the given MC version
// mcVer - the Minecraft version, such as '21w10a'
outlet.yarnVersion(mcVer) // Returns String

// Get the latest Fabric API version for the latest MC version (output of latestMc())
outlet.fapiVersion() // Returns String

// Get the latest Fabric API version for the given MC version
// mcVer - the Minecraft version, such as '21w10a'
outlet.fapiVersion(mcVer) // Returns String

// Get the Java version for the latest MC version
// For use in setting the compiler level
// Defaults to 8 if it cannot be found
outlet.javaVersion() // Returns int

// Get the Java version for the given MC version
// For use in setting the compiler level
// Defaults to 8 if it cannot be found
// mcVer - the Minecraft version, such as '21w10a'
outlet.javaVersion(mcVer) // Returns int

// Get the Java language compatibility level that all versions in mcVersions() can support
// For use in setting compatibility level
// Defaults to 8 if it cannot be found
// Examples:
//      Range: 1.16 - 1.18; Returns: 8
//      Range: 1.17 - 1.18; Returns: 16
//      Range: 1.18.x;      Returns: 17
outlet.javaLanguageCompatibility() // Returns int

Example

// In this project, range is in gradle.properties, could also read it from fabric.mod.json
outlet.mcVersionRange = project.range

// Use fabric example mod's variables to keep template mostly unchanged
project.minecraft_version = outlet.latestMc()
project.loader_version = outlet.loaderVersion()
project.yarn_mappings =  outlet.yarnVersion()
project.fabric_version = outlet.fapiVersion()