feat(minecraft): Support down to Minecraft 1.16.5 and related fixes
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import de.siphalor.jcyo.gradle.JcyoTask
|
||||
import de.siphalor.tweed5.gradle.plugin.minecraft.mod.MinecraftModded
|
||||
import java.nio.file.Files
|
||||
import java.nio.file.StandardCopyOption
|
||||
@@ -6,6 +7,7 @@ import java.util.Properties
|
||||
plugins {
|
||||
java
|
||||
id("fabric-loom")
|
||||
id("de.siphalor.tweed5.publishing")
|
||||
id("de.siphalor.tweed5.expanded-sources-jar")
|
||||
id("de.siphalor.jcyo")
|
||||
id("io.freefair.lombok")
|
||||
@@ -21,7 +23,7 @@ val mcProps = Properties().apply {
|
||||
|
||||
val mcCatalog = versionCatalogs.named("mcLibs")
|
||||
|
||||
group = "de.siphalor.tweed5.minecraft.${project.name}"
|
||||
group = "de.siphalor.tweed5.minecraft"
|
||||
val archivesBaseName = "${project.name}-mc$minecraftVersionDescriptor"
|
||||
base {
|
||||
archivesName.set(archivesBaseName)
|
||||
@@ -63,6 +65,7 @@ repositories {
|
||||
includeGroupAndSubgroups("de.siphalor")
|
||||
}
|
||||
}
|
||||
mavenLocal()
|
||||
}
|
||||
|
||||
configurations {
|
||||
@@ -86,9 +89,29 @@ dependencies {
|
||||
"testmodImplementation"(sourceSets.main.map { it.output })
|
||||
}
|
||||
|
||||
val jcyoVars = mcProps.stringPropertyNames()
|
||||
.filter { it.startsWith("preprocessor.") }
|
||||
.map { it to mcProps[it] }
|
||||
.associate { (key, value) -> key.substring("preprocessor.".length) to value.toString() }
|
||||
val jcyo = tasks.register<JcyoTask>("jcyo") {
|
||||
inputDirectory = file("src/main/java")
|
||||
variables = jcyoVars
|
||||
}
|
||||
val testmodJcyo = tasks.register<JcyoTask>("testmodJcyo") {
|
||||
inputDirectory = file("src/testmod/java")
|
||||
variables = jcyoVars
|
||||
}
|
||||
|
||||
tasks.compileJava {
|
||||
dependsOn(jcyo)
|
||||
}
|
||||
|
||||
tasks.named("compileTestmodJava") {
|
||||
dependsOn(testmodJcyo)
|
||||
}
|
||||
|
||||
java {
|
||||
sourceCompatibility = JavaVersion.VERSION_1_8
|
||||
targetCompatibility = JavaVersion.VERSION_1_8
|
||||
withSourcesJar()
|
||||
}
|
||||
|
||||
lombok {
|
||||
@@ -120,14 +143,23 @@ afterEvaluate {
|
||||
}
|
||||
}
|
||||
|
||||
tasks.jar {
|
||||
dependsOn(tasks.processMinecraftModResources)
|
||||
from(project.layout.buildDirectory.dir("minecraftModResources"))
|
||||
}
|
||||
tasks.named<Copy>("processResources") {
|
||||
inputs.property("id", project.name)
|
||||
inputs.property("version", project.version)
|
||||
inputs.property("name", properties["module.name"])
|
||||
inputs.property("description", properties["module.description"])
|
||||
inputs.property("repoUrl", properties["git.url"])
|
||||
|
||||
tasks.sourcesJar {
|
||||
dependsOn(tasks.processMinecraftModResources)
|
||||
from(project.layout.buildDirectory.dir("minecraftModResources"))
|
||||
from(project.layout.settingsDirectory.dir("../tweed5-minecraft/mod-template/resources")) {
|
||||
expand(mapOf(
|
||||
"id" to project.name.replace('-', '_'),
|
||||
"version" to project.version,
|
||||
"name" to properties["module.name"].toString(),
|
||||
"description" to properties["module.description"],
|
||||
"repoUrl" to properties["git.url"],
|
||||
))
|
||||
}
|
||||
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
|
||||
}
|
||||
|
||||
tasks.named<Copy>("processTestmodResources") {
|
||||
@@ -152,3 +184,15 @@ tasks.named<Copy>("processTestmodResources") {
|
||||
fun getMcCatalogVersion(name: String): String {
|
||||
return mcCatalog.findVersion(name).get().requiredVersion
|
||||
}
|
||||
|
||||
publishing {
|
||||
publications {
|
||||
create<MavenPublication>("minecraftMod") {
|
||||
groupId = "${project.group}.${project.name}"
|
||||
artifactId = "${project.name}-${minecraftVersionDescriptor}"
|
||||
version = shortVersion
|
||||
|
||||
from(components["java"])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,8 +14,8 @@ dependencies {
|
||||
modTestmodImplementation(fabricApi.module(it, mcLibs.versions.fabric.api.get()))
|
||||
}
|
||||
testmodImplementation(project(":tweed5-bundle", configuration = "minecraftModElements"))
|
||||
testmodImplementation(project(":tweed5-fabric-helper", configuration = "namedElements"))
|
||||
modTestmodImplementation(mcLibs.coat)
|
||||
modTestmodImplementation(mcLibs.amecs.api)
|
||||
testmodImplementation(project(":tweed5-fabric-helper"))
|
||||
testmodImplementation("de.siphalor.tweed5:tweed5-serde-hjson")
|
||||
}
|
||||
|
||||
@@ -2,21 +2,42 @@ package de.siphalor.tweed5.coat.bridge.api;
|
||||
|
||||
import lombok.AccessLevel;
|
||||
import lombok.NoArgsConstructor;
|
||||
//- import net.minecraft.client.resources.language.I18n;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.MutableComponent;
|
||||
//- import net.minecraft.network.chat.TextComponent;
|
||||
//- import net.minecraft.network.chat.TranslatableComponent;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
public class TweedCoatMappingUtils {
|
||||
public static MutableComponent translatableComponentWithFallback(String translationKey, @Nullable String fallback) {
|
||||
//# if MC_VERSION_NUMBER >= 11900
|
||||
return Component.translatableWithFallback(translationKey, fallback == null ? "" : fallback);
|
||||
// FIXME
|
||||
//if (I18n.exists(translationKey)) {
|
||||
// return Component.translatable(translationKey);
|
||||
//} else if (fallback != null) {
|
||||
// return Component.literal(fallback);
|
||||
//} else {
|
||||
// return Component.empty();
|
||||
//}
|
||||
//# else
|
||||
//- if (I18n.exists(translationKey)) {
|
||||
//- return new TranslatableComponent(translationKey);
|
||||
//- } else if (fallback != null) {
|
||||
//- return new TextComponent(fallback);
|
||||
//- } else {
|
||||
//- return new TextComponent("");
|
||||
//- }
|
||||
//# end
|
||||
}
|
||||
|
||||
public static MutableComponent translatableComponent(String translationKey, Object... args) {
|
||||
//# if MC_VERSION_NUMBER >= 11900
|
||||
return Component.translatable(translationKey, args);
|
||||
//# else
|
||||
//- return new TranslatableComponent(translationKey, args);
|
||||
//# end
|
||||
}
|
||||
|
||||
public static MutableComponent literalComponent(String literal) {
|
||||
//# if MC_VERSION_NUMBER >= 11900
|
||||
return Component.literal(literal);
|
||||
//# else
|
||||
//- return new TextComponent(literal);
|
||||
//# end
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,8 @@ import java.util.Objects;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static de.siphalor.tweed5.coat.bridge.api.TweedCoatMappingUtils.literalComponent;
|
||||
|
||||
@CommonsLog
|
||||
public class BasicTweedCoatEntryHandler<T extends @Nullable Object> implements ConfigEntryHandler<T> {
|
||||
protected final ConfigEntry<T> configEntry;
|
||||
@@ -43,7 +45,7 @@ public class BasicTweedCoatEntryHandler<T extends @Nullable Object> implements C
|
||||
.flatMap(entryIssues -> entryIssues.issues().stream())
|
||||
.map(issue -> new Message(
|
||||
mapLevel(issue.level()),
|
||||
Component.literal(issue.message())
|
||||
literalComponent(issue.message())
|
||||
))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
@@ -68,7 +70,7 @@ public class BasicTweedCoatEntryHandler<T extends @Nullable Object> implements C
|
||||
|
||||
@Override
|
||||
public Component asText(T value) {
|
||||
return Component.literal(Objects.toString(value));
|
||||
return literalComponent(Objects.toString(value));
|
||||
}
|
||||
|
||||
protected T processSaveValue(T value) {
|
||||
|
||||
@@ -12,6 +12,9 @@ import java.util.Collections;
|
||||
import java.util.Objects;
|
||||
import java.util.function.Function;
|
||||
|
||||
import static de.siphalor.tweed5.coat.bridge.api.TweedCoatMappingUtils.literalComponent;
|
||||
import static de.siphalor.tweed5.coat.bridge.api.TweedCoatMappingUtils.translatableComponent;
|
||||
|
||||
@RequiredArgsConstructor
|
||||
@CommonsLog
|
||||
public class ConvertingTweedCoatEntryHandler<T extends @Nullable Object, C> implements ConfigEntryHandler<C> {
|
||||
@@ -34,7 +37,7 @@ public class ConvertingTweedCoatEntryHandler<T extends @Nullable Object, C> impl
|
||||
} catch (Exception e) {
|
||||
return Collections.singletonList(new Message(
|
||||
Message.Level.ERROR,
|
||||
Component.translatable(CONVERSION_EXCEPTION_TEXT_KEY, e.getMessage())
|
||||
translatableComponent(CONVERSION_EXCEPTION_TEXT_KEY, e.getMessage())
|
||||
));
|
||||
}
|
||||
}
|
||||
@@ -60,6 +63,6 @@ public class ConvertingTweedCoatEntryHandler<T extends @Nullable Object, C> impl
|
||||
|
||||
@Override
|
||||
public Component asText(C value) {
|
||||
return Component.literal(Objects.toString(value));
|
||||
return literalComponent(Objects.toString(value));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,10 +16,12 @@ import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper;
|
||||
import net.minecraft.client.KeyMapping;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.screens.TitleScreen;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import static de.siphalor.tweed5.coat.bridge.api.TweedCoatMappingUtils.translatableComponent;
|
||||
|
||||
@CustomLog
|
||||
public class TweedCoatBridgeTestMod implements ClientModInitializer {
|
||||
public static final String MOD_ID = "tweed5_coat_bridge_testmod";
|
||||
@@ -52,13 +54,25 @@ public class TweedCoatBridgeTestMod implements ClientModInitializer {
|
||||
|
||||
config = configContainerHelper.loadAndUpdateInConfigDirectory(() -> DEFAULT_CONFIG_VALUE);
|
||||
|
||||
KeyBindingHelper.registerKeyBinding(new ScreenKeyBinding(MOD_ID + ".config", 84, KeyMapping.Category.MISC));
|
||||
KeyBindingHelper.registerKeyBinding(new ScreenKeyBinding(
|
||||
MOD_ID + ".config",
|
||||
GLFW.GLFW_KEY_T,
|
||||
//# if MC_VERSION_NUMBER >= 12109
|
||||
KeyMapping.Category.MISC
|
||||
//# else
|
||||
//- "key.categories.misc"
|
||||
//# end
|
||||
));
|
||||
|
||||
log.info("Current config: " + config);
|
||||
}
|
||||
|
||||
private class ScreenKeyBinding extends KeyMapping implements PriorityKeyBinding {
|
||||
//# if MC_VERSION_NUMBER >= 12109
|
||||
public ScreenKeyBinding(String name, int key, Category category) {
|
||||
//# else
|
||||
//- public ScreenKeyBinding(String name, int key, String category) {
|
||||
//# end
|
||||
super(name, key, category);
|
||||
}
|
||||
|
||||
@@ -71,7 +85,7 @@ public class TweedCoatBridgeTestMod implements ClientModInitializer {
|
||||
ConfigScreen configScreen = configCoatBridgeExtension.createConfigScreen(
|
||||
ConfigScreenCreateParams.<TweedCoatBridgeTestModConfig>builder()
|
||||
.translationKeyPrefix(MOD_ID + ".config")
|
||||
.title(Component.translatable(MOD_ID + ".title"))
|
||||
.title(translatableComponent(MOD_ID + ".title"))
|
||||
.rootEntry(configContainer.rootEntry())
|
||||
.currentValue(config)
|
||||
.defaultValue(DEFAULT_CONFIG_VALUE)
|
||||
|
||||
1
tweed5-minecraft/gradle/mc-1.16.5/gradle.properties
Normal file
1
tweed5-minecraft/gradle/mc-1.16.5/gradle.properties
Normal file
@@ -0,0 +1 @@
|
||||
preprocessor.mc_version_number = 11605
|
||||
12
tweed5-minecraft/gradle/mc-1.16.5/mcLibs.versions.toml
Normal file
12
tweed5-minecraft/gradle/mc-1.16.5/mcLibs.versions.toml
Normal file
@@ -0,0 +1,12 @@
|
||||
[versions]
|
||||
amecs-api = "1.6.2"
|
||||
coat = "1.0.0-beta.24"
|
||||
fabric-api = "0.42.0+1.16"
|
||||
minecraft = "1.16.5"
|
||||
parchment = "2022.03.06"
|
||||
|
||||
[libraries]
|
||||
amecs-api = { group = "de.siphalor.amecs-api", name = "amecs-api-mc1.16.5", version.ref = "amecs-api" }
|
||||
coat = { group = "de.siphalor.coat", name = "coat-mc1.16.5", version.ref = "coat" }
|
||||
fabric-api = { group = "net.fabricmc.fabric-api", name = "fabric-api", version.ref = "fabric-api" }
|
||||
minecraft = { group = "com.mojang", name = "minecraft", version.ref = "minecraft" }
|
||||
1
tweed5-minecraft/gradle/mc-1.17.1/gradle.properties
Normal file
1
tweed5-minecraft/gradle/mc-1.17.1/gradle.properties
Normal file
@@ -0,0 +1 @@
|
||||
preprocessor.mc_version_number = 11701
|
||||
12
tweed5-minecraft/gradle/mc-1.17.1/mcLibs.versions.toml
Normal file
12
tweed5-minecraft/gradle/mc-1.17.1/mcLibs.versions.toml
Normal file
@@ -0,0 +1,12 @@
|
||||
[versions]
|
||||
amecs-api = "1.6.2"
|
||||
coat = "1.0.0-beta.24"
|
||||
fabric-api = "0.46.1+1.17"
|
||||
minecraft = "1.17.1"
|
||||
parchment = "2021.12.12"
|
||||
|
||||
[libraries]
|
||||
amecs-api = { group = "de.siphalor.amecs-api", name = "amecs-api-mc1.17.1", version.ref = "amecs-api" }
|
||||
coat = { group = "de.siphalor.coat", name = "coat-mc1.17.1", version.ref = "coat" }
|
||||
fabric-api = { group = "net.fabricmc.fabric-api", name = "fabric-api", version.ref = "fabric-api" }
|
||||
minecraft = { group = "com.mojang", name = "minecraft", version.ref = "minecraft" }
|
||||
1
tweed5-minecraft/gradle/mc-1.18.2/gradle.properties
Normal file
1
tweed5-minecraft/gradle/mc-1.18.2/gradle.properties
Normal file
@@ -0,0 +1 @@
|
||||
preprocessor.mc_version_number = 11802
|
||||
12
tweed5-minecraft/gradle/mc-1.18.2/mcLibs.versions.toml
Normal file
12
tweed5-minecraft/gradle/mc-1.18.2/mcLibs.versions.toml
Normal file
@@ -0,0 +1,12 @@
|
||||
[versions]
|
||||
amecs-api = "1.6.2"
|
||||
coat = "1.0.0-beta.24"
|
||||
fabric-api = "0.77.0+1.18.2"
|
||||
minecraft = "1.18.2"
|
||||
parchment = "2022.11.06"
|
||||
|
||||
[libraries]
|
||||
amecs-api = { group = "de.siphalor.amecs-api", name = "amecs-api-mc1.18.2", version.ref = "amecs-api" }
|
||||
coat = { group = "de.siphalor.coat", name = "coat-mc1.18.2", version.ref = "coat" }
|
||||
fabric-api = { group = "net.fabricmc.fabric-api", name = "fabric-api", version.ref = "fabric-api" }
|
||||
minecraft = { group = "com.mojang", name = "minecraft", version.ref = "minecraft" }
|
||||
1
tweed5-minecraft/gradle/mc-1.19.4/gradle.properties
Normal file
1
tweed5-minecraft/gradle/mc-1.19.4/gradle.properties
Normal file
@@ -0,0 +1 @@
|
||||
preprocessor.mc_version_number = 11904
|
||||
12
tweed5-minecraft/gradle/mc-1.19.4/mcLibs.versions.toml
Normal file
12
tweed5-minecraft/gradle/mc-1.19.4/mcLibs.versions.toml
Normal file
@@ -0,0 +1,12 @@
|
||||
[versions]
|
||||
amecs-api = "1.6.2"
|
||||
coat = "1.0.0-beta.24"
|
||||
fabric-api = "0.87.2+1.19.4"
|
||||
minecraft = "1.19.4"
|
||||
parchment = "2023.06.26"
|
||||
|
||||
[libraries]
|
||||
amecs-api = { group = "de.siphalor.amecs-api", name = "amecs-api-mc1.19.4", version.ref = "amecs-api" }
|
||||
coat = { group = "de.siphalor.coat", name = "coat-mc1.19.4", version.ref = "coat" }
|
||||
fabric-api = { group = "net.fabricmc.fabric-api", name = "fabric-api", version.ref = "fabric-api" }
|
||||
minecraft = { group = "com.mojang", name = "minecraft", version.ref = "minecraft" }
|
||||
1
tweed5-minecraft/gradle/mc-1.20.6/gradle.properties
Normal file
1
tweed5-minecraft/gradle/mc-1.20.6/gradle.properties
Normal file
@@ -0,0 +1 @@
|
||||
preprocessor.mc_version_number = 12006
|
||||
12
tweed5-minecraft/gradle/mc-1.20.6/mcLibs.versions.toml
Normal file
12
tweed5-minecraft/gradle/mc-1.20.6/mcLibs.versions.toml
Normal file
@@ -0,0 +1,12 @@
|
||||
[versions]
|
||||
amecs-api = "1.6.2"
|
||||
coat = "1.0.0-beta.24"
|
||||
fabric-api = "0.100.8+1.20.6"
|
||||
minecraft = "1.20.6"
|
||||
parchment = "2024.06.16"
|
||||
|
||||
[libraries]
|
||||
amecs-api = { group = "de.siphalor.amecs-api", name = "amecs-api-mc1.20.2", version.ref = "amecs-api" }
|
||||
coat = { group = "de.siphalor.coat", name = "coat-mc1.20.5", version.ref = "coat" }
|
||||
fabric-api = { group = "net.fabricmc.fabric-api", name = "fabric-api", version.ref = "fabric-api" }
|
||||
minecraft = { group = "com.mojang", name = "minecraft", version.ref = "minecraft" }
|
||||
@@ -0,0 +1 @@
|
||||
preprocessor.mc_version_number = 12110
|
||||
|
||||
Reference in New Issue
Block a user