Skip to content

Commit

Permalink
Merge pull request #83 from sakura-ryoko/multiversion
Browse files Browse the repository at this point in the history
upgrade from Fallen Breath's Mod Template; add 1.21.3 and 1.21.4 branches
  • Loading branch information
aria1th authored Dec 4, 2024
2 parents ee37d27 + 1865f2c commit f9e19e8
Show file tree
Hide file tree
Showing 31 changed files with 377 additions and 119 deletions.
35 changes: 24 additions & 11 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
plugins {
id 'com.replaymod.preprocess' version '6989e16efc'
id 'fabric-loom' version '1.7-SNAPSHOT' apply false
id 'fabric-loom' version '1.9-SNAPSHOT' apply false
// https://github.com/ReplayMod/preprocessor
// https://github.com/Fallen-Breath/preprocessor
id 'com.replaymod.preprocess' version '9d21b334a7'
}

preprocess {
strictExtraMappings = false

//def mc1165 = createNode('1.16.5', 1_16_05, 'yarn')
//def mc1171 = createNode('1.17.1', 1_17_01, 'yarn')
//def mc1182 = createNode('1.18.2', 1_18_02, 'yarn')
Expand All @@ -17,6 +21,8 @@ preprocess {
def mc1206 = createNode('1.20.6', 1_20_06, 'yarn')
def mc1210 = createNode('1.21.0', 1_21_00, 'yarn')
def mc1211 = createNode('1.21.1', 1_21_01, 'yarn')
def mc1213 = createNode('1.21.3', 1_21_03, 'yarn')
def mc1214 = createNode('1.21.4', 1_21_04, 'yarn')

// mapping difference map
// base 1194 -> 1193 -> 1192 ->1190-> 118 -> 117 -> 116
Expand All @@ -26,6 +32,8 @@ preprocess {
mc1206.link(mc1204, file('versions/mapping-1.20.6-1.20.4.txt'))
mc1210.link(mc1206, file('versions/mapping-1.21.0-1.20.6.txt'))
mc1211.link(mc1210, file('versions/mapping-1.21.1-1.21.0.txt'))
mc1213.link(mc1211, file('versions/mapping-1.21.3-1.21.1.txt'))
mc1214.link(mc1213, file('versions/mapping-1.21.4-1.21.3.txt'))
//mc1194.link(mc1193, file('versions/mapping-1.19.4-1.19.3.txt'))
//mc1193.link(mc1192, file('versions/mapping-1.19.3-1.19.2.txt'))
//mc1192.link(mc1190, file('versions/mapping-1.19.2-1.19.0.txt'))
Expand All @@ -42,19 +50,24 @@ preprocess {
// gradlew :1.16.5:setCoreVersion -> set coremod version to 1.16.5
tasks.register('buildAndGather') {
subprojects {
dependsOn project.name + ':build'
dependsOn project.tasks.named('build').get()
}
doFirst {
println 'Building and gathering all subprojects'
copy {
subprojects {
def libDir = project.projectDir.toPath().resolve('build/libs')
from(libDir) {
println 'Gathering builds'
def buildLibs = {
p -> p.buildDir.toPath().resolve('libs')
}
delete fileTree(buildLibs(rootProject)) {
include '*'
}
subprojects {
copy {
from(buildLibs(project)) {
include '*.jar'
exclude '*-sources.jar', '*-dev.jar'
exclude '*-dev.jar', '*-sources.jar', '*-shadow.jar'
}
into 'build/libs/'
duplicatesStrategy = DuplicatesStrategy.INCLUDE
into buildLibs(rootProject)
duplicatesStrategy DuplicatesStrategy.INCLUDE
}
}
}
Expand Down
171 changes: 106 additions & 65 deletions common.gradle
Original file line number Diff line number Diff line change
@@ -1,37 +1,11 @@
// common.gradle is a file that called separately by each module.
plugins {
id 'fabric-loom' version '1.7-SNAPSHOT'
id 'com.replaymod.preprocess' version '6989e16efc'
}

int mcVersion = 1

preprocess {
mcVersion = vars.get()["MC"] as Integer
tabIndentation = true
}

if (mcVersion >= 12005) {
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
}
else if (mcVersion >= 11800) {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
else if (mcVersion >= 11700) {
sourceCompatibility = JavaVersion.VERSION_16
targetCompatibility = JavaVersion.VERSION_16
}
else {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
apply plugin: 'fabric-loom'
apply plugin: 'com.replaymod.preprocess'

int mcVersion = project.mcVersion

archivesBaseName = "${project.archives_base_name}-mc${project.minecraft_version}"
version = project.mod_version
group = project.maven_group
//preprocess {
//mcVersion = vars.get()["MC"] as Integer
//}

repositories {
mavenCentral()
Expand All @@ -44,6 +18,12 @@ repositories {
maven {
url "https://pkgs.dev.azure.com/djtheredstoner/DevAuth/_packaging/public/maven/v1"
}
//maven { url 'https://maven.fallenbreath.me/releases' }
}

// https://github.com/FabricMC/fabric-loader/issues/783
configurations {
modRuntimeOnly.exclude group: 'net.fabricmc', module: 'fabric-loader'
}

dependencies {
Expand Down Expand Up @@ -84,51 +64,112 @@ dependencies {
}
//modImplementation "fi.dy.masa.litematica:litematica-fabric-${project.minecraft_version_out}:${project.litematica_version}"
}
annotationProcessor "com.github.LlamaLad7:MixinExtras:0.1.1"

// [FEATURE] MIXIN_AUDITOR
//modRuntimeOnly 'me.fallenbreath:mixin-auditor:0.1.0'
//include(modImplementation("me.fallenbreath:conditional-mixin-fabric:${project.conditionalmixin_version}"))
//include(annotationProcessor(implementation("io.github.llamalad7:mixinextras-fabric:${project.mixinextras_version}")))
}

processResources {
inputs.property "version", project.mod_version
// {$argument} exists in src/main/resources/fabric.mod.json, then it will be replaced with the value of the argument.
filesMatching("fabric.mod.json") {
def map = [
"version": version,
"minecraft_dependency": project.minecraft_version_out
]
expand map
}
String MIXIN_CONFIG_PATH = 'litematica-printer.mixins.json'
JavaVersion JAVA_COMPATIBILITY
if (mcVersion >= 12005) {
JAVA_COMPATIBILITY = JavaVersion.VERSION_21
} else if (mcVersion >= 11800) {
JAVA_COMPATIBILITY = JavaVersion.VERSION_17
} else if (mcVersion >= 11700) {
JAVA_COMPATIBILITY = JavaVersion.VERSION_16
} else {
JAVA_COMPATIBILITY = JavaVersion.VERSION_1_8
}
JavaVersion MIXIN_COMPATIBILITY_LEVEL = JAVA_COMPATIBILITY

tasks.withType(JavaCompile).configureEach {
// ensure that the encoding is set to UTF-8, no matter what the system default is
// this fixes some edge cases with special characters not displaying correctly
// see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html
// If Javadoc is generated, this must be specified in that task too.
it.options.encoding = "UTF-8"

if (mcVersion >= 12005) {
it.options.release = 21
loom {
def commonVmArgs = ['-Dmixin.debug.export=true', '-Dmixin.debug.countInjections=true']
runConfigs.configureEach {
// to make sure it generates all "Minecraft Client (:subproject_name)" applications
ideConfigGenerated = true
runDir '../../run'
vmArgs commonVmArgs
}
else if (mcVersion >= 11800) {
it.options.release = 17
// [FEATURE] MIXIN_AUDITOR
//runs {
//def auditVmArgs = [*commonVmArgs, '-DmixinAuditor.audit=true']
//serverMixinAudit {
//server()
//vmArgs auditVmArgs
//ideConfigGenerated false
//}
//}
}

String modVersionSuffix = ''
String artifactVersion = project.mod_version
String artifactVersionSuffix = ''
// detect github action environment variables
// https://docs.github.com/en/actions/learn-github-actions/environment-variables#default-environment-variables
if (System.getenv("BUILD_RELEASE") != "true") {
String buildNumber = System.getenv("BUILD_ID")
modVersionSuffix += buildNumber != null ? ('+build.' + buildNumber) : '-SNAPSHOT'
artifactVersionSuffix = '-SNAPSHOT' // A non-release artifact is always a SNAPSHOT artifact
}
String fullModVersion = project.mod_version + modVersionSuffix
String fullProjectVersion, fullArtifactVersion

group = project.maven_group
if (System.getenv("JITPACK") == "true") {
// move mc version into archivesBaseName, so jitpack will be able to organize archives from multiple subprojects correctly
base.archivesName = project.archives_base_name + '-mc' + project.minecraft_version
fullProjectVersion = 'v' + project.mod_version + modVersionSuffix
fullArtifactVersion = artifactVersion + artifactVersionSuffix
} else {
base.archivesName = project.archives_base_name
fullProjectVersion = 'v' + project.mod_version + '-mc' + project.minecraft_version + modVersionSuffix
fullArtifactVersion = artifactVersion + '-mc' + project.minecraft_version + artifactVersionSuffix
}
version = fullProjectVersion

processResources {
inputs.property "id", project.mod_id
inputs.property "name", project.mod_name
inputs.property "version", fullModVersion
inputs.property "minecraft_dependency", project.minecraft_dependency

filesMatching("fabric.mod.json") {
def valueMap = [
"id": project.mod_id,
"name": project.mod_name,
"version": fullModVersion,
"minecraft_dependency": project.minecraft_dependency,
]
expand valueMap
}
else if (mcVersion >= 11700) {
it.options.release = 16

filesMatching(MIXIN_CONFIG_PATH) {
filter { s -> s.replace('{{COMPATIBILITY_LEVEL}}', "JAVA_${MIXIN_COMPATIBILITY_LEVEL.ordinal() + 1}") }
}
else {
it.options.release = 8
}

// ensure that the encoding is set to UTF-8, no matter what the system default is
// this fixes some edge cases with special characters not displaying correctly
// see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html
tasks.withType(JavaCompile).configureEach {
options.encoding = "UTF-8"
options.compilerArgs << "-Xlint:deprecation" << "-Xlint:unchecked"
if (JAVA_COMPATIBILITY <= JavaVersion.VERSION_1_8) {
// suppressed "source/target value 8 is obsolete and will be removed in a future release"
options.compilerArgs << '-Xlint:-options'
}
}

java {
// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task
// if it is present.
// If you remove this line, sources will not be generated.
withSourcesJar()
sourceCompatibility = JAVA_COMPATIBILITY
targetCompatibility = JAVA_COMPATIBILITY
//withSourcesJar()
}

jar {
from("LICENSE") {
rename { "${it}_${project.archivesBaseName}"}
}
from(rootProject.file('LICENSE')) {
rename { "${it}_${project.archives_base_name}" }
}
}
21 changes: 15 additions & 6 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
org.gradle.jvmargs=-Xmx6G
# This is base gradle.properties file for all projects in the workspace.
# This must not contain specific configuration for any project, such as minecraft version, etc.
# Fabric Properties
loader_version=0.15.11
# Gradle Properties
org.gradle.jvmargs=-Xmx6G

# Fabric Basic Properties
loader_version=0.16.9

# Mod Properties
mod_version = 7.2.1
mod_id = litematica-printer
mod_name = Litematica Printer
mod_version = 7.2.2
maven_group = aria1th.extensions
archives_base_name = litematica-printer

# Global Dependencies
# https://github.com/Fallen-Breath/conditional-mixin
#conditionalmixin_version=0.6.3

# https://github.com/LlamaLad7/MixinExtras
mixinextras_version=0.3.6
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
3 changes: 3 additions & 0 deletions jitpack.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
before_install:
- sdk install java 21.0.5-tem
- sdk use java 21.0.5-tem
26 changes: 8 additions & 18 deletions settings.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import groovy.json.JsonSlurper

pluginManagement {
repositories {
maven {
Expand All @@ -9,7 +11,8 @@ pluginManagement {
url = "https://jitpack.io"
}
maven {
url "https://masa.dy.fi/maven"
name = 'Masa'
url = "https://masa.dy.fi/maven"
}
mavenCentral()
gradlePluginPortal()
Expand All @@ -19,31 +22,18 @@ pluginManagement {
switch (requested.id.id) {
case "com.replaymod.preprocess": {
useModule("com.github.Fallen-Breath:preprocessor:${requested.version}")
break
}
}
}
}
}
def versions = Arrays.asList(
//"1.16.5",
//"1.17.1",
//"1.18.2",
//"1.19.0",
//"1.19.2",
//"1.19.3",
"1.19.4",
"1.20.1",
"1.20.2",
"1.20.4",
"1.20.6",
"1.21.0",
"1.21.1"
)

for (String version : versions) {
def settings = new JsonSlurper().parseText(file('settings.json').text)
for (String version : settings.versions) {
include(":$version")

def proj = project(":$version")
proj.projectDir = file("versions/$version")
proj.buildFileName = "../../common.gradle"
}
}
13 changes: 13 additions & 0 deletions settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"versions": [
"1.19.4",
"1.20.1",
"1.20.2",
"1.20.4",
"1.20.6",
"1.21.0",
"1.21.1",
"1.21.3",
"1.21.4"
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ private static void onDoEasyPlaceAction(MinecraftClient mc, CallbackInfoReturnab
//in case of NPE, print log instead
MessageHolder.sendMessageUncheckedUnique(mc.player, e.getMessage());
if (!hasSent && mc.player != null) {
//#if MC>=11900
//#if MC>=12102
//$$ mc.player.sendMessage(Text.of("Null pointer exception has occured, please upload log at https://github.com/aria1th/litematica-printer/issues"), false);
//#elseif MC>=11900
mc.player.sendMessage(Text.of("Null pointer exception has occured, please upload log at https://github.com/aria1th/litematica-printer/issues"));
//#else
//$$mc.player.sendMessage(new LiteralText("Null pointer exception has occured, please upload log at https://github.com/aria1th/litematica-printer/issues"), false);
Expand Down
Loading

0 comments on commit f9e19e8

Please sign in to comment.