Skip to content

Instantly share code, notes, and snippets.

@matshou
Created May 2, 2020 15:23
Show Gist options
  • Save matshou/247e0792a853cd03234191f009f31ea1 to your computer and use it in GitHub Desktop.
Save matshou/247e0792a853cd03234191f009f31ea1 to your computer and use it in GitHub Desktop.
Providing files for inspection on #mixin
buildscript {
repositories {
maven { url = 'https://files.minecraftforge.net/maven' }
maven { url = 'https://repo.spongepowered.org/maven' }
jcenter()
mavenCentral()
}
dependencies {
classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '3.+', changing: true
classpath 'org.spongepowered:mixingradle:0.7-SNAPSHOT'
}
}
apply plugin: 'net.minecraftforge.gradle'
apply plugin: 'org.spongepowered.mixin'
apply plugin: 'eclipse'
apply plugin: 'maven-publish'
version = "${minecraftVersion}-${modVersion}"
group = "io.${groupName}.${modId}"
archivesBaseName = project.modId
// Need this here so eclipse task generates correctly.
compileJava.sourceCompatibility = compileJava.targetCompatibility = '1.8'
sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility
repositories {
mavenCentral()
maven { url 'https://repo.spongepowered.org/maven' }
maven { url 'https://jitpack.io' }
}
mixin {
add sourceSets.main, "mixins.${modId}.refmap.json"
}
minecraft {
// The mappings can be changed at any time, and must be in the following format.
// snapshot_YYYYMMDD Snapshot are built nightly.
// stable_# Stables are built at the discretion of the MCP team.
// 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: 'snapshot', version: "${mappingBuild}-${mappingMCVersion}"
// makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable.
runs {
client {
workingDirectory project.file('run')
arg "-mixin.config=" + archivesBaseName + ".mixins.json"
// Recommended logging data for a userdev environment
property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP'
// Recommended logging level for the console
property 'forge.logging.console.level', 'info'
mods { timelib { source sourceSets.main } }
}
server {
workingDirectory project.file('run')
// Recommended logging data for a userdev environment
property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP'
// Recommended logging level for the console
property 'forge.logging.console.level', 'info'
mods { timelib { source sourceSets.main } }
}
}
}
dependencies {
minecraft "net.minecraftforge:forge:${minecraftVersion}-${forgeVersion}"
compile "org.spongepowered:mixin:0.8.1-SNAPSHOT"
}
// Get properties into the manifest for reading by the runtime..
jar {
manifest {
attributes([
"Specification-Title": project.modId,
"Specification-Vendor": "${groupName}",
"Specification-Version": "1", // We are version 1 of ourselves
"Implementation-Title": project.name,
"Implementation-Version": "${version}",
"Implementation-Vendor": "${groupName}",
"Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"),
"MixinConfigs": "${modId}.mixins.json"
])
}
}
// Example configuration to allow publishing using the maven-publish task
// This is the preferred method to reobfuscate your jar file
jar.finalizedBy('reobfJar')
publishing {
publications {
mavenJava(MavenPublication) {
artifact jar
}
}
repositories {
maven {
url "file:///${project.projectDir}/mcmodsrepo"
}
}
}
// Generate sources when building mod
task sourcesJar(type: Jar, dependsOn: classes) {
classifier = 'sources'
from sourceSets.main.allSource
}
build.dependsOn sourcesJar
artifacts {
archives sourcesJar
}
// Process resources on build and make sure that variables are
// correctly inserted into mods.toml when the mod is built or run
processResources {
// This will ensure that this task is redone when the versions change.
inputs.property 'version', project.version
// Replace stuff in mods.toml, nothing else
from(sourceSets.main.resources.srcDirs) {
include 'META-INF/mods.toml'
// Replace version
expand 'version': project.version
}
// Copy everything else except the mods.toml
from(sourceSets.main.resources.srcDirs) {
exclude 'META-INF/mods.toml'
}
}
# Sets default memory used for gradle commands. Can be overridden by user or command line properties.
# This is required to provide enough memory for the Minecraft decompilation process.
org.gradle.jvmargs=-Xmx3G
org.gradle.daemon=false
modId=timelib
modVersion=0.1.1
groupName=yooksi
minecraftVersion=1.15.2
forgeVersion=31.1.63
mappingMCVersion=1.15.1
mappingBuild=20200501
mixinBootstrapVer=1.0.2
{
"required": true,
"package": "io.yooksi.timelib.mixin",
"compatibilityLevel": "JAVA_8",
"refmap": "mixins.timelib.refmap.json",
"mixins": [
"World_advanceTimeMixin",
"MinecraftServer_runMixin",
"CommandsMixin"
],
"client": [
"ClientPlayNetworkHandler_onChunkDataMixin",
"Timer_updateTimerMixin"
],
"injectors": {
"defaultRequire": 1
},
"minVersion": "0.8"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment