From 0d44230ae0ee709740ab2c33c6338531d0c8e380 Mon Sep 17 00:00:00 2001 From: Apehum <36326454+Apehum@users.noreply.github.com> Date: Wed, 9 Oct 2024 19:20:20 +0800 Subject: [PATCH] feat(mod): 1.21.2-pre1 fabric --- .../src/main/kotlin/su/plo/slib/api/event/GlobalEvent.kt | 2 +- versions/1.21.2-fabric/gradle.properties | 1 + versions/build.gradle.kts | 1 + versions/root.gradle.kts | 4 ++++ .../src/main/kotlin/su/plo/slib/mod/world/ModServerWorld.kt | 5 +++++ 5 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 versions/1.21.2-fabric/gradle.properties diff --git a/api/common/src/main/kotlin/su/plo/slib/api/event/GlobalEvent.kt b/api/common/src/main/kotlin/su/plo/slib/api/event/GlobalEvent.kt index 8e3a87b..7909401 100644 --- a/api/common/src/main/kotlin/su/plo/slib/api/event/GlobalEvent.kt +++ b/api/common/src/main/kotlin/su/plo/slib/api/event/GlobalEvent.kt @@ -8,7 +8,7 @@ abstract class GlobalEvent ( ) { private val listeners: MutableSet = CopyOnWriteArraySet() - var invoker = invokerSupplier.apply(listeners) + val invoker = invokerSupplier.apply(listeners) fun registerListener(listener: T) { if (listeners.add(listener)) invokerSupplier.apply(listeners) diff --git a/versions/1.21.2-fabric/gradle.properties b/versions/1.21.2-fabric/gradle.properties new file mode 100644 index 0000000..2b00f5d --- /dev/null +++ b/versions/1.21.2-fabric/gradle.properties @@ -0,0 +1 @@ +essential.defaults.loom.minecraft=com.mojang:minecraft:1.21.2-pre1 diff --git a/versions/build.gradle.kts b/versions/build.gradle.kts index 442ae5f..856d117 100644 --- a/versions/build.gradle.kts +++ b/versions/build.gradle.kts @@ -39,6 +39,7 @@ dependencies { 12004 -> "0.95.4+1.20.4" 12006 -> "0.97.7+1.20.6" 12100 -> "0.100.4+1.21" + 12102 -> "0.105.3+1.21.2" else -> throw GradleException("Unsupported platform $platform") } diff --git a/versions/root.gradle.kts b/versions/root.gradle.kts index da0d707..545be9c 100644 --- a/versions/root.gradle.kts +++ b/versions/root.gradle.kts @@ -6,6 +6,8 @@ group = "$group.versions-root" preprocess { + val fabric12102 = createNode("1.21.2-fabric", 12102, "official") + val fabric12100 = createNode("1.21-fabric", 12100, "official") val neoForge12100 = createNode("1.21-neoforge", 12100, "official") val forge12100 = createNode("1.21-forge", 12100, "official") @@ -36,6 +38,8 @@ preprocess { val fabric11605 = createNode("1.16.5-fabric", 11605, "official") val forge11605 = createNode("1.16.5-forge", 11605, "official") + fabric12102.link(fabric12100) + neoForge12100.link(fabric12006) fabric12100.link(fabric12006) forge12100.link(forge12004) diff --git a/versions/src/main/kotlin/su/plo/slib/mod/world/ModServerWorld.kt b/versions/src/main/kotlin/su/plo/slib/mod/world/ModServerWorld.kt index 19634d6..b38a997 100644 --- a/versions/src/main/kotlin/su/plo/slib/mod/world/ModServerWorld.kt +++ b/versions/src/main/kotlin/su/plo/slib/mod/world/ModServerWorld.kt @@ -59,8 +59,13 @@ class ModServerWorld( //#if MC>=12005 //$$ private fun parseGameEvent(gameEventName: String): Holder.Reference = + //#if MC>=12102 + //$$ BuiltInRegistries.GAME_EVENT.get(ResourceLocation.tryParse(gameEventName)!!) + //$$ .orElseThrow { IllegalArgumentException("Invalid game event") } + //#else //$$ BuiltInRegistries.GAME_EVENT.getHolder(ResourceLocation.tryParse(gameEventName)) //$$ .orElseThrow { IllegalArgumentException("Invalid game event") } + //#endif //#elseif MC>=11900 private fun parseGameEvent(gameEventName: String): GameEvent { //#if MC>=11903