diff --git a/src/main/kotlin/creator/custom/TemplateDescriptor.kt b/src/main/kotlin/creator/custom/TemplateDescriptor.kt index ffca3e3ac..8f40dcbb3 100644 --- a/src/main/kotlin/creator/custom/TemplateDescriptor.kt +++ b/src/main/kotlin/creator/custom/TemplateDescriptor.kt @@ -40,7 +40,7 @@ data class TemplateDescriptor( companion object { - const val FORMAT_VERSION = 2 + const val FORMAT_VERSION = 3 } } diff --git a/src/main/kotlin/creator/custom/derivation/FetchPaperDependencyVersionForMcVersion.kt b/src/main/kotlin/creator/custom/derivation/FetchPaperDependencyVersionForMcVersion.kt new file mode 100644 index 000000000..3bcc56159 --- /dev/null +++ b/src/main/kotlin/creator/custom/derivation/FetchPaperDependencyVersionForMcVersion.kt @@ -0,0 +1,70 @@ +/* + * Minecraft Development for IntelliJ + * + * https://mcdev.io/ + * + * Copyright (C) 2026 minecraft-dev + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, version 3.0 only. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ + +package com.demonwav.mcdev.creator.custom.derivation + +import com.demonwav.mcdev.creator.custom.PropertyDerivation +import com.demonwav.mcdev.creator.custom.TemplateValidationReporter +import com.demonwav.mcdev.creator.custom.types.CreatorProperty +import com.demonwav.mcdev.util.MinecraftVersions +import com.demonwav.mcdev.util.SemanticVersion + +class FetchPaperDependencyVersionForMcVersion : PreparedDerivation { + + override fun derive(parentValues: List): Any { + val version = parentValues[0] as SemanticVersion + if (version < MinecraftVersions.MC_26_1) { + return "${version}-R0.1-SNAPSHOT"; + } + + val isMaven = (parentValues[1] as String) == "Maven" + return if (isMaven) { + "[${version}.build,)" + } else { + "${version}.build.+" + } + } + + companion object : PropertyDerivationFactory { + + override fun create( + reporter: TemplateValidationReporter, + parents: List?>?, + derivation: PropertyDerivation + ): PreparedDerivation? { + if (parents.isNullOrEmpty()) { + reporter.error("Expected a parent") + return null + } + + if (!parents[0]!!.acceptsType(SemanticVersion::class.java)) { + reporter.error("First parent must produce a semantic version") + return null + } + + if (!parents[1]!!.acceptsType(String::class.java)) { + reporter.error("Second parent must produce a string") + return null + } + + return FetchPaperDependencyVersionForMcVersion() + } + } +} diff --git a/src/main/kotlin/creator/custom/types/StringCreatorProperty.kt b/src/main/kotlin/creator/custom/types/StringCreatorProperty.kt index dd834220a..0ec37a3ce 100644 --- a/src/main/kotlin/creator/custom/types/StringCreatorProperty.kt +++ b/src/main/kotlin/creator/custom/types/StringCreatorProperty.kt @@ -25,6 +25,7 @@ import com.demonwav.mcdev.creator.custom.CreatorContext import com.demonwav.mcdev.creator.custom.PropertyDerivation import com.demonwav.mcdev.creator.custom.TemplatePropertyDescriptor import com.demonwav.mcdev.creator.custom.TemplateValidationReporter +import com.demonwav.mcdev.creator.custom.derivation.FetchPaperDependencyVersionForMcVersion import com.demonwav.mcdev.creator.custom.derivation.PreparedDerivation import com.demonwav.mcdev.creator.custom.derivation.ReplacePropertyDerivation import com.demonwav.mcdev.creator.custom.derivation.SelectPropertyDerivation @@ -73,6 +74,11 @@ class StringCreatorProperty( ReplacePropertyDerivation.create(reporter, parents, derives) } + "fetchPaperDependencyVersionForMcVersion" -> { + val parents = collectDerivationParents(reporter) + FetchPaperDependencyVersionForMcVersion.create(reporter, parents, derives) + } + null -> { // No need to collect parent values for this one because it is not used SelectPropertyDerivation.create(reporter, emptyList(), derives) diff --git a/src/main/kotlin/platform/mixin/util/MinecraftMissingLVTChecker.kt b/src/main/kotlin/platform/mixin/util/MinecraftMissingLVTChecker.kt index 2c539324b..e751c13f2 100644 --- a/src/main/kotlin/platform/mixin/util/MinecraftMissingLVTChecker.kt +++ b/src/main/kotlin/platform/mixin/util/MinecraftMissingLVTChecker.kt @@ -32,7 +32,7 @@ class MinecraftMissingLVTChecker : MissingLVTChecker { !className.startsWith("net.minecraft.") && !className.startsWith("com.mojang.blaze3d.") -> false else -> { val mcVersion = context.mcVersion - mcVersion != null && mcVersion <= MinecraftVersions.MC25_4 + mcVersion != null && mcVersion <= MinecraftVersions.MC_1_21_11 } } } diff --git a/src/main/kotlin/util/MinecraftVersions.kt b/src/main/kotlin/util/MinecraftVersions.kt index 6da2ace28..2387c6775 100644 --- a/src/main/kotlin/util/MinecraftVersions.kt +++ b/src/main/kotlin/util/MinecraftVersions.kt @@ -46,13 +46,14 @@ object MinecraftVersions { val MC1_20_6 = SemanticVersion.release(1, 20, 6) val MC1_21 = SemanticVersion.release(1, 21) val MC1_21_1 = SemanticVersion.release(1, 21, 1) - val MC25_4 = SemanticVersion.release(25, 4) // placeholder till we know what the last 2025 winter drop version is + val MC_1_21_11 = SemanticVersion.release(1, 21, 11) + val MC_26_1 = SemanticVersion.release(26, 1) fun requiredJavaVersion(minecraftVersion: SemanticVersion) = when { minecraftVersion <= MC1_16_5 -> JavaSdkVersion.JDK_1_8 minecraftVersion <= MC1_17_1 -> JavaSdkVersion.JDK_16 minecraftVersion <= MC1_20_4 -> JavaSdkVersion.JDK_17 - minecraftVersion<= MC25_4 -> JavaSdkVersion.JDK_21 + minecraftVersion <= MC_1_21_11 -> JavaSdkVersion.JDK_21 else -> JavaSdkVersion.JDK_25 } }