Skip to content

Instantly share code, notes, and snippets.

@ChampionAsh5357
Last active May 19, 2021 18:09
Show Gist options
  • Save ChampionAsh5357/c5ea3878782e63881f89b537c407ace8 to your computer and use it in GitHub Desktop.
Save ChampionAsh5357/c5ea3878782e63881f89b537c407ace8 to your computer and use it in GitHub Desktop.
Multilingual Mod Examples Buildscript
// Attach plugins
plugins {
// The ForgeGradle Plugin, necessary to create the userdev environment and build mods
id 'net.minecraftforge.gradle' version '4.1.+'
// Language Specific Plugins go here
// Language: Plugin:
// Java 'java-library'
// Kotlin 'org.jetbrains.kotlin.jvm' (needs version identifier)
// Scala 'scala'
// Groovy 'groovy'
id 'java-library'
}
// Standard Project Information
version = "${project.minecraft_version}-${project.mod_specver}.${project.mod_implver}"
group = project.user_group
archivesBaseName = project.mod_id
// Sets the toolchain to compile against OpenJDK 8
java.toolchain {
languageVersion = JavaLanguageVersion.of(8)
vendor = JvmVendorSpec.ADOPTOPENJDK
}
minecraft {
// The mappings can be changed at any time, and must be in the following format:
// Channel: Version:
// snapshot YYYYMMDD Snapshot are built nightly
// stable # Stables are built at the discretion of the MCP team
// official MCVersion Official field/method names from Mojang mapping files
//
// You must be aware of the Mojang license when using the 'official' mappings
// See more information here: https://github.com/MinecraftForge/MCPConfig/blob/master/Mojang.md
//
// Use non-default mappings at your own risk. they may not always work
// Simply re-run your setup task after changing the mappings to update your workspace
mappings channel: project.mappings_type, version: project.mappings_version
// Exposes fields, methods, constructors, and classes for use within the mod
// Set mod_transformer to 'true' within gradle.properties to enable
if (project.hasProperty('mod_transformer') && project.getProperty('mod_transformer').toBoolean())
accessTransformer file('src/main/resources/META-INF/accesstransformer.cfg')
// Default run configurations
// These can be tweaked, removed, or duplicated as needed
runs {
// Client run configuration
client {
// Directory for the project to run in
workingDirectory project.file('run/client')
// Set the console logging level
property 'forge.logging.console.level', 'debug'
// Attach the sources to the run
mods.create(project.mod_id).source(sourceSets.main)
}
// Server run configuration
server {
workingDirectory project.file('run/server')
property 'forge.logging.console.level', 'debug'
mods.create(project.mod_id).source(sourceSets.main)
}
// Data run configuration
data {
workingDirectory project.file('run/data')
property 'forge.logging.console.level', 'debug'
// Specify the modid for data generation, where to output the resulting resource, and where to look for existing resources
args '--mod', project.mod_id,
'--all',
'--output', file('src/generated/resources/'),
'--existing', sourceSets.main.resources.srcDirs[0].toString()
mods.create(project.mod_id).source(sourceSets.main)
}
}
}
// Include resources generated by data generators
sourceSets.main.resources {
srcDir 'src/generated/resources'
exclude '.cache/'
}
dependencies {
// Include MinecraftForge as a dependency
minecraft group: 'net.minecraftforge', name: 'forge', version: "${project.minecraft_version}-${project.forge_version}"
// Include any language specific libraries here
// These could either be a mod that has the necessary language libraries and/or the libraries themselves for you to compile against/shade in
// It is recommended to use either an existing or separate mod to handle language libraries
}
// Set attributes of the jar
jar {
// Set manifest information
manifest.attributes([
"Specification-Title": project.mod_name,
"Specification-Vendor": project.user_name,
"Specification-Version": project.mod_specver,
"Implementation-Title": project.mod_name,
"Implementation-Version": project.version,
"Implementation-Vendor": project.user_name,
"Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
])
// Reobfuscate the jar file to be used in production
finalizedBy 'reobfJar'
}
# Gradle Properties
org.gradle.jvmargs=-Xmx3G
org.gradle.daemon=false
# User Information
user_name = Forge Community Wiki
user_group = uk.gemwire
# Minecraft Information
minecraft_version = 1.16.5
# Forge Information
forge_version = 36.1.16
# Mappings Information
mappings_type = official
mappings_version = 1.16.5
# Mod Information
mod_id = multilingualmodexamples
mod_name = Multilingual Mod Examples
mod_desc = Different Loaders, Different Languages
mod_transformer = false
mod_specver = 1.0.0
mod_implver = 0-beta
// Add External Plugins
pluginManagement {
// Add MinecraftForge maven to plugin management
repositories {
maven { url 'https://maven.minecraftforge.net' }
mavenCentral()
}
// Resolve ForgeGradle within plugin block
resolutionStrategy.eachPlugin {
if (requested.id.id == 'net.minecraftforge.gradle')
useModule group: requested.id.id, name: 'ForgeGradle', version: requested.version
}
}
// Project Name
rootProject.name = 'MultilingualModExamples-Forge-Java'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment