Skip to content

Commit 4b37a8b

Browse files
committed
Merge branch '2022.1' into 2022.2
2 parents 82ae46f + dcb7973 commit 4b37a8b

File tree

15 files changed

+92
-9
lines changed

15 files changed

+92
-9
lines changed

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ kotlin.code.style=official
1414
ideaVersion = 222-EAP-SNAPSHOT
1515
ideaVersionName = 2022.2
1616

17-
coreVersion = 1.5.19
17+
coreVersion = 1.5.20
1818
downloadIdeaSources = true
1919

2020
pluginTomlVersion = 222.2964.16

src/main/kotlin/insight/generation/MinecraftClassCreateAction.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,11 @@ class MinecraftClassCreateAction :
9191
override fun isAvailable(dataContext: DataContext): Boolean {
9292
val psi = dataContext.getData(CommonDataKeys.PSI_ELEMENT)
9393
val module = psi?.findModule() ?: return false
94-
val isModModule = MinecraftFacet.getInstance(module, FabricModuleType, ForgeModuleType) != null
94+
val isFabricMod = MinecraftFacet.getInstance(module, FabricModuleType) != null
95+
val isForgeMod = MinecraftFacet.getInstance(module, ForgeModuleType) != null
9596
val hasMcVersion = MinecraftFacet.getInstance(module, McpModuleType)?.getSettings()?.minecraftVersion != null
9697

97-
return isModModule && hasMcVersion && super.isAvailable(dataContext)
98+
return (isFabricMod || isForgeMod && hasMcVersion) && super.isAvailable(dataContext)
9899
}
99100

100101
override fun checkPackageExists(directory: PsiDirectory): Boolean {

src/main/kotlin/platform/architectury/creator/ArchitecturyTemplate.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ package com.demonwav.mcdev.platform.architectury.creator
1212

1313
import com.demonwav.mcdev.creator.buildsystem.BuildSystem
1414
import com.demonwav.mcdev.platform.BaseTemplate
15+
import com.demonwav.mcdev.platform.forge.util.ForgeConstants
1516
import com.demonwav.mcdev.platform.forge.util.ForgePackAdditionalData
1617
import com.demonwav.mcdev.platform.forge.util.ForgePackDescriptor
1718
import com.demonwav.mcdev.util.License
@@ -178,6 +179,7 @@ object ArchitecturyTemplate : BaseTemplate() {
178179
}
179180

180181
fun applyModsToml(project: Project, buildSystem: BuildSystem, config: ArchitecturyProjectConfig): String {
182+
val hasDisplayTestInManifest = config.forgeVersion >= ForgeConstants.DISPLAY_TEST_MANIFEST_VERSION
181183
val nextMcVersion = when (val part = config.mcVersion.parts.getOrNull(1)) {
182184
// Mimics the code used to get the next Minecraft version in Forge's MDK
183185
// https://github.com/MinecraftForge/MinecraftForge/blob/0ff8a596fc1ef33d4070be89dd5cb4851f93f731/build.gradle#L884
@@ -188,6 +190,7 @@ object ArchitecturyTemplate : BaseTemplate() {
188190
val props = mutableMapOf(
189191
"ARTIFACT_ID" to buildSystem.artifactId,
190192
"MOD_NAME" to config.pluginName,
193+
"DISPLAY_TEST" to hasDisplayTestInManifest,
191194
"FORGE_SPEC_VERSION" to config.forgeVersion.parts[0].versionString,
192195
"ARCHITECTURY_API_VERSION" to config.architecturyApiVersion.toString(),
193196
"MC_VERSION" to config.mcVersion.toString(),

src/main/kotlin/platform/forge/creator/Fg3Template.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ package com.demonwav.mcdev.platform.forge.creator
1212

1313
import com.demonwav.mcdev.creator.buildsystem.BuildSystem
1414
import com.demonwav.mcdev.platform.BaseTemplate
15+
import com.demonwav.mcdev.platform.forge.util.ForgeConstants
1516
import com.demonwav.mcdev.platform.forge.util.ForgePackAdditionalData
1617
import com.demonwav.mcdev.platform.forge.util.ForgePackDescriptor
1718
import com.demonwav.mcdev.util.MinecraftTemplates.Companion.FG3_1_17_MAIN_CLASS_TEMPLATE
@@ -183,6 +184,7 @@ object Fg3Template : BaseTemplate() {
183184
}
184185

185186
fun applyModsToml(project: Project, buildSystem: BuildSystem, config: ForgeProjectConfig): String {
187+
val hasDisplayTestInManifest = config.forgeVersion >= ForgeConstants.DISPLAY_TEST_MANIFEST_VERSION
186188
val nextMcVersion = when (val part = config.mcVersion.parts.getOrNull(1)) {
187189
// Mimics the code used to get the next Minecraft version in Forge's MDK
188190
// https://github.com/MinecraftForge/MinecraftForge/blob/0ff8a596fc1ef33d4070be89dd5cb4851f93f731/build.gradle#L884
@@ -193,6 +195,7 @@ object Fg3Template : BaseTemplate() {
193195
val props = mutableMapOf(
194196
"ARTIFACT_ID" to buildSystem.artifactId,
195197
"MOD_NAME" to config.pluginName,
198+
"DISPLAY_TEST" to hasDisplayTestInManifest,
196199
"FORGE_SPEC_VERSION" to config.forgeVersion.parts[0].versionString,
197200
"MC_VERSION" to config.mcVersion.toString(),
198201
"MC_NEXT_VERSION" to "1.$nextMcVersion",

src/main/kotlin/platform/forge/util/ForgeConstants.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010

1111
package com.demonwav.mcdev.platform.forge.util
1212

13+
import com.demonwav.mcdev.util.SemanticVersion
14+
1315
object ForgeConstants {
1416

1517
const val SIDED_PROXY_ANNOTATION = "net.minecraftforge.fml.common.SidedProxy"
@@ -32,9 +34,12 @@ object ForgeConstants {
3234
// From https://github.com/MinecraftForge/MinecraftForge/blob/0ff8a596fc1ef33d4070be89dd5cb4851f93f731/src/fmllauncher/java/net/minecraftforge/fml/loading/StringSubstitutor.java
3335
val KNOWN_SUBSTITUTIONS = setOf(JAR_VERSION_VAR, "\${global.mcVersion}", "\${global.forgeVersion}")
3436

37+
val DISPLAY_TESTS = setOf("MATCH_VERSION", "IGNORE_SERVER_VERSION", "IGNORE_ALL_VERSION", "NONE")
3538
val DEPENDENCY_SIDES = setOf("BOTH", "CLIENT", "SERVER")
3639
val DEPENDENCY_ORDER = setOf("NONE", "BEFORE", "AFTER")
3740

3841
// From https://github.com/MinecraftForge/MinecraftForge/blob/38a5400a8c878fe39cd389e6d4f68619d2738b88/src/fmllauncher/java/net/minecraftforge/fml/loading/moddiscovery/ModInfo.java#L45
3942
val MOD_ID_REGEX = "^[a-z][a-z0-9_-]{1,63}$".toRegex()
43+
44+
val DISPLAY_TEST_MANIFEST_VERSION = SemanticVersion.release(41, 0, 15)
4045
}

src/main/kotlin/platform/mcp/McpModuleSettings.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ class McpModuleSettings : PersistentStateComponent<McpModuleSettings.State> {
2525
var minecraftVersion: String? = null,
2626
var mcpVersion: String? = null,
2727
var mappingFile: String? = null,
28-
var srgType: SrgType? = null
28+
var srgType: SrgType? = null,
29+
var platformVersion: String? = null
2930
)
3031

3132
private var state: State = State(srgType = SrgType.SRG)

src/main/kotlin/platform/mcp/gradle/datahandler/McpModelFG3Handler.kt

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,21 +34,28 @@ object McpModelFG3Handler : McpModelDataHandler {
3434
) {
3535
val data = resolverCtx.getExtraProject(gradleModule, McpModelFG3::class.java) ?: return
3636

37-
var version: String? = null
37+
var mcVersion: String? = null
38+
var forgeVersion: String? = null
3839
for (minecraftDepVersion in data.minecraftDepVersions) {
3940
val index = minecraftDepVersion.indexOf('-')
4041
if (index == -1) {
4142
continue
4243
}
43-
version = minecraftDepVersion.substring(0, minecraftDepVersion.indexOf('-'))
44+
mcVersion = minecraftDepVersion.substring(0, index)
45+
46+
val forgeVersionEnd = minecraftDepVersion.indexOf('_')
47+
if (forgeVersionEnd != -1) {
48+
forgeVersion = minecraftDepVersion.substring(index + 1, forgeVersionEnd)
49+
}
4450
break
4551
}
4652

4753
val state = McpModuleSettings.State(
48-
version,
54+
mcVersion,
4955
data.mcpVersion,
5056
data.taskOutputLocation.absolutePath,
51-
SrgType.TSRG
57+
SrgType.TSRG,
58+
forgeVersion
5259
)
5360

5461
val gradleProjectPath = gradleModule.gradleProject.projectIdentifier.projectPath

src/main/kotlin/toml/platform/forge/ModsTomlSchema.kt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,14 @@ logoBlur=false
5858
credits="Thanks for this example mod goes to Java"
5959
# A text field displayed in the mod UI.
6060
authors="Love, Cheese and small house plants"
61+
# Display Test controls the display for your mod in the server connection screen
62+
# MATCH_VERSION means that your mod will cause a red X if the versions on client and server differ. This is the default behaviour and should be what you choose if you have server and client elements to your mod.
63+
# IGNORE_SERVER_VERSION means that your mod will not cause a red X if it's present on the server but not on the client. This is what you should use if you're a server only mod.
64+
# IGNORE_ALL_VERSION means that your mod will not cause a red X if it's present on the client or the server. This is a special case and should only be used if your mod has no server component.
65+
# NONE means that no display test is set on your mod. You need to do this yourself, see IExtensionPoint.DisplayTest for more information. You can define any scheme you wish with this value.
66+
# IMPORTANT NOTE: this is NOT an instruction as to which environments (CLIENT or DEDICATED SERVER) your mod loads on. Your mod should load (and maybe do nothing!) whereever it finds itself.
67+
displayTest="MATCH_VERSION" # MATCH_VERSION is the default if nothing is specified (#optional)
68+
6169
# The description text for the mod (multi line!)
6270
description='''
6371
This is a long form description of the mod. You can write whatever you want here

src/main/kotlin/toml/platform/forge/completion/ModsTomlCompletionContributor.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ class ModsTomlCompletionContributor : CompletionContributor() {
4242
extend(CompletionType.BASIC, inModsTomlKey(), ModsTomlKeyCompletionProvider)
4343
extendKnownValues("modLoader", "javafml")
4444
extendKnownValues("version", ForgeConstants.KNOWN_SUBSTITUTIONS)
45+
extendKnownValues("displayTest", ForgeConstants.DISPLAY_TESTS)
4546
extendKnownValues("ordering", ForgeConstants.DEPENDENCY_ORDER)
4647
extendKnownValues("side", ForgeConstants.DEPENDENCY_SIDES)
4748
extendBooleanValues("showAsResourcePack")

src/main/kotlin/toml/platform/forge/inspections/ModsTomlValidationInspection.kt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ import com.demonwav.mcdev.toml.TomlElementVisitor
1515
import com.demonwav.mcdev.toml.platform.forge.ModsTomlSchema
1616
import com.demonwav.mcdev.toml.stringValue
1717
import com.demonwav.mcdev.toml.tomlType
18+
import com.demonwav.mcdev.util.SemanticVersion
19+
import com.demonwav.mcdev.util.findMcpModule
1820
import com.intellij.codeInspection.InspectionManager
1921
import com.intellij.codeInspection.LocalInspectionTool
2022
import com.intellij.codeInspection.ProblemDescriptor
@@ -65,6 +67,22 @@ class ModsTomlValidationInspection : LocalInspectionTool() {
6567
holder.registerProblem(value, TextRange(1, endOffset), "Mod ID is invalid")
6668
}
6769
}
70+
"displayTest" -> {
71+
val value = keyValue.value ?: return
72+
val test = value.stringValue() ?: return
73+
if (test !in ForgeConstants.DISPLAY_TESTS) {
74+
val endOffset = if (value.text.endsWith('"')) test.length + 1 else test.length
75+
holder.registerProblem(value, TextRange(1, endOffset), "DisplayTest $test does not exist")
76+
}
77+
78+
val forgeVersion = runCatching {
79+
keyValue.findMcpModule()?.getSettings()?.platformVersion?.let(SemanticVersion::parse)
80+
}.getOrNull()
81+
val minVersion = ForgeConstants.DISPLAY_TEST_MANIFEST_VERSION
82+
if (forgeVersion != null && forgeVersion < minVersion) {
83+
holder.registerProblem(keyValue.key, "DisplayTest is only available since $minVersion")
84+
}
85+
}
6886
"side" -> {
6987
val value = keyValue.value ?: return
7088
val side = value.stringValue() ?: return

0 commit comments

Comments
 (0)