Skip to content

Commit

Permalink
Merge remote-tracking branch 'refs/remotes/original/dev' into mixinex…
Browse files Browse the repository at this point in the history
…tras-expression

# Conflicts:
#	src/main/kotlin/platform/mixin/handlers/mixinextras/WrapOperationHandler.kt
  • Loading branch information
LlamaLad7 committed Jul 2, 2024
2 parents 5c1cd92 + 9da3841 commit 7b07722
Show file tree
Hide file tree
Showing 60 changed files with 1,921 additions and 138 deletions.
2 changes: 2 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ repositories {
maven("https://maven.fabricmc.net/") {
content {
includeModule("net.fabricmc", "mapping-io")
includeModule("net.fabricmc", "fabric-loader")
}
}
mavenCentral()
Expand Down Expand Up @@ -132,6 +133,7 @@ dependencies {
classifier = "shaded"
}
}
testLibs(libs.test.fabricloader)
testLibs(libs.test.nbt) {
artifact {
extension = "nbt"
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ kotlin.code.style=official
ideaVersion = 2023.2.2
ideaVersionName = 2023.2.2

coreVersion = 1.7.4
coreVersion = 1.7.6
downloadIdeaSources = true

pluginTomlVersion = 232.8660.88
Expand Down
1 change: 1 addition & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ fuel-coroutines = { module = "com.github.kittinunf.fuel:fuel-coroutines", versio
test-mockJdk = "org.jetbrains.idea:mock-jdk:1.7-4d76c50"
test-mixin = "org.spongepowered:mixin:0.8.5"
test-spongeapi = "org.spongepowered:spongeapi:7.4.0"
test-fabricloader = "net.fabricmc:fabric-loader:0.15.11"
test-nbt = "com.demonwav.mcdev:all-types-nbt:1.0"

junit-api = { module = "org.junit.jupiter:junit-jupiter-api", version.ref = "junit" }
Expand Down
6 changes: 5 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ Minecraft Development for IntelliJ
<td align="left">2024.1</td>
<td align="left"><a href="https://ci.mcdev.io/viewType.html?buildTypeId=MinecraftDev_Nightly_20241"><img src="https://ci.mcdev.io/app/rest/builds/buildType:(id:MinecraftDev_Nightly_20241)/statusIcon.svg" alt="2024.1 Nightly Status" /></a></td>
</tr>
<tr>
<td align="left">2024.2</td>
<td align="left"><a href="https://ci.mcdev.io/viewType.html?buildTypeId=MinecraftDev_Nightly_20242"><img src="https://ci.mcdev.io/app/rest/builds/buildType:(id:MinecraftDev_Nightly_20242)/statusIcon.svg" alt="2024.2 Nightly Status" /></a></td>
</tr>
<tr>
<td align="right"><b>OS Tests</b></td>
<td align="left" colspan="2">
Expand All @@ -31,7 +35,7 @@ Minecraft Development for IntelliJ
</tr>
</table>

Info and Documentation [![Current Release](https://img.shields.io/badge/release-1.7.4-orange.svg?style=flat-square)](https://plugins.jetbrains.com/plugin/8327)
Info and Documentation [![Current Release](https://img.shields.io/badge/release-1.7.6-orange.svg?style=flat-square)](https://plugins.jetbrains.com/plugin/8327)
----------------------

<a href="https://discord.gg/j6UNcfr"><img src="https://i.imgur.com/JXu9C1G.png" height="48px"></img></a>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
/*
* Minecraft Development for IntelliJ
*
* https://mcdev.io/
*
* Copyright (C) 2024 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 <https://www.gnu.org/licenses/>.
*/

package com.demonwav.mcdev.platform.mcp.gradle.tooling.neomoddev

import com.demonwav.mcdev.platform.mcp.gradle.tooling.McpModelNMD
import org.gradle.api.Project
import org.jetbrains.annotations.NotNull
import org.jetbrains.plugins.gradle.tooling.ErrorMessageBuilder
import org.jetbrains.plugins.gradle.tooling.ModelBuilderService

import java.nio.file.Files

final class NeoModDevGradleModelBuilderImpl implements ModelBuilderService {

@Override
boolean canBuild(String modelName) {
return McpModelNMD.name == modelName
}

@Override
Object buildAll(String modelName, Project project) {
def extension = project.extensions.findByName('neoForge')
if (extension == null) {
return null
}

if (!project.plugins.findPlugin("net.neoforged.moddev")) {
return null
}

def neoforgeVersion = extension.version.get()
if (neoforgeVersion == null) {
return null
}

def accessTransformers = extension.accessTransformers.get().collect { project.file(it) }

// Hacky way to guess where the mappings file is, but I could not find a proper way to find it
def neoformDir = project.buildDir.toPath().resolve("neoForm")
def mappingsFile = Files.list(neoformDir)
.map { it.resolve("config/joined.tsrg") }
.filter { Files.exists(it) }
.findFirst()
.orElse(null)
?.toFile()

//noinspection GroovyAssignabilityCheck
return new NeoModDevGradleModelImpl(neoforgeVersion, mappingsFile, accessTransformers)
}

@Override
ErrorMessageBuilder getErrorMessageBuilder(@NotNull Project project, @NotNull Exception e) {
return ErrorMessageBuilder.create(
project, e, "MinecraftDev import errors"
).withDescription("Unable to build MinecraftDev MCP project configuration")
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* Minecraft Development for IntelliJ
*
* https://mcdev.io/
*
* Copyright (C) 2024 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 <https://www.gnu.org/licenses/>.
*/

package com.demonwav.mcdev.platform.mcp.gradle.tooling.neomoddev


import com.demonwav.mcdev.platform.mcp.gradle.tooling.McpModelNMD
import groovy.transform.CompileStatic

@CompileStatic
final class NeoModDevGradleModelImpl implements McpModelNMD, Serializable {

final String neoForgeVersion
final File mappingsFile
final List<File> accessTransformers

NeoModDevGradleModelImpl(
final String neoForgeVersion,
final File mappingsFile,
final List<File> accessTransformers
) {
this.neoForgeVersion = neoForgeVersion
this.mappingsFile = mappingsFile
this.accessTransformers = accessTransformers
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* Minecraft Development for IntelliJ
*
* https://mcdev.io/
*
* Copyright (C) 2024 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 <https://www.gnu.org/licenses/>.
*/

package com.demonwav.mcdev.platform.mcp.gradle.tooling;

import java.io.File;
import java.util.List;

public interface McpModelNMD {
String getNeoForgeVersion();
File getMappingsFile();
List<File> getAccessTransformers();
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
com.demonwav.mcdev.platform.mcp.gradle.tooling.archloom.ArchitecturyModelBuilderImpl
com.demonwav.mcdev.platform.mcp.gradle.tooling.fabricloom.FabricLoomModelBuilderImpl
com.demonwav.mcdev.platform.mcp.gradle.tooling.neogradle.NeoGradle7ModelBuilderImpl
com.demonwav.mcdev.platform.mcp.gradle.tooling.neomoddev.NeoModDevGradleModelBuilderImpl
com.demonwav.mcdev.platform.mcp.gradle.tooling.vanillagradle.VanillaGradleModelBuilderImpl
com.demonwav.mcdev.platform.mcp.gradle.tooling.McpModelFG2BuilderImpl
com.demonwav.mcdev.platform.mcp.gradle.tooling.McpModelFG3BuilderImpl
2 changes: 1 addition & 1 deletion src/main/kotlin/creator/buildsystem/gradle-steps.kt
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ import org.jetbrains.plugins.gradle.service.execution.GradleRunConfiguration
import org.jetbrains.plugins.gradle.service.project.open.canLinkAndRefreshGradleProject
import org.jetbrains.plugins.gradle.service.project.open.linkAndRefreshGradleProject

val DEFAULT_GRADLE_VERSION = SemanticVersion.release(8, 5)
val DEFAULT_GRADLE_VERSION = SemanticVersion.release(8, 7)
val GRADLE_VERSION_KEY = Key.create<SemanticVersion>("mcdev.gradleVersion")

fun FixedAssetsNewProjectWizardStep.addGradleWrapperProperties(project: Project) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ import com.demonwav.mcdev.util.SemanticVersion
class BungeeMainPlatformStep(parent: BungeePlatformStep) : AbstractBungeePlatformStep(parent, PlatformType.BUNGEECORD) {
override fun getRepositories(mcVersion: SemanticVersion) = listOf(
BuildRepository("sonatype", "https://oss.sonatype.org/content/groups/public/"),
// Seems to be required since 1.21
BuildRepository("Minecraft Libraries", "https://libraries.minecraft.net/"),
)

override fun getDependencies(mcVersion: SemanticVersion) = listOf(
Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/platform/fabric/creator/gradle-steps.kt
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class FabricGradleFilesStep(parent: NewProjectWizardStep) : AbstractLongRunningA
val mcVersion = data.getUserData(FabricVersionChainStep.MC_VERSION_KEY) ?: return
val yarnVersion = data.getUserData(FabricVersionChainStep.YARN_VERSION_KEY) ?: return
val loaderVersion = data.getUserData(FabricVersionChainStep.LOADER_VERSION_KEY) ?: return
val loomVersion = "1.5-SNAPSHOT"
val loomVersion = "1.6-SNAPSHOT"
val javaVersion = findStep<JdkProjectSetupFinalizer>().preferredJdk.ordinal
val apiVersion = data.getUserData(FabricVersionChainStep.API_VERSION_KEY)
val officialMappings = data.getUserData(FabricVersionChainStep.OFFICIAL_MAPPINGS_KEY) ?: false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,15 @@ package com.demonwav.mcdev.platform.fabric.inspection

import com.demonwav.mcdev.platform.fabric.reference.EntryPointReference
import com.demonwav.mcdev.platform.fabric.util.FabricConstants
import com.demonwav.mcdev.util.equivalentTo
import com.intellij.codeInspection.InspectionManager
import com.intellij.codeInspection.LocalInspectionTool
import com.intellij.codeInspection.ProblemDescriptor
import com.intellij.codeInspection.ProblemHighlightType
import com.intellij.codeInspection.ProblemsHolder
import com.intellij.json.psi.JsonArray
import com.intellij.json.psi.JsonElementVisitor
import com.intellij.json.psi.JsonLiteral
import com.intellij.json.psi.JsonProperty
import com.intellij.json.psi.JsonStringLiteral
import com.intellij.psi.JavaPsiFacade
Expand Down Expand Up @@ -79,8 +82,7 @@ class FabricEntrypointsInspection : LocalInspectionTool() {
val element = resolved.singleOrNull()?.element
when {
element is PsiClass && !literal.text.contains("::") -> {
val propertyKey = literal.parentOfType<JsonProperty>()?.name
val expectedType = propertyKey?.let { FabricConstants.ENTRYPOINT_BY_TYPE[it] }
val (propertyKey, expectedType) = findEntrypointKeyAndType(literal)
if (propertyKey != null && expectedType != null &&
!isEntrypointOfCorrectType(element, propertyKey)
) {
Expand Down Expand Up @@ -111,21 +113,43 @@ class FabricEntrypointsInspection : LocalInspectionTool() {
reference.rangeInElement,
)
}

if (!element.hasModifierProperty(PsiModifier.PUBLIC)) {
holder.registerProblem(
literal,
"Entrypoint method must be public",
ProblemHighlightType.GENERIC_ERROR_OR_WARNING,
reference.rangeInElement,
)
}

if (!element.hasModifierProperty(PsiModifier.STATIC)) {
val clazz = element.containingClass
if (clazz != null && clazz.constructors.isNotEmpty() &&
clazz.constructors.find { !it.hasParameters() } == null
) {
holder.registerProblem(
literal,
"Entrypoint instance method class must have an empty constructor",
ProblemHighlightType.GENERIC_ERROR_OR_WARNING,
reference.rangeInElement,
)
}
}
}

element is PsiField -> {
if (!element.hasModifierProperty(PsiModifier.STATIC)) {
if (!element.hasModifierProperty(PsiModifier.PUBLIC)) {
holder.registerProblem(
literal,
"Entrypoint field must be static",
"Entrypoint field must be public",
ProblemHighlightType.GENERIC_ERROR_OR_WARNING,
reference.rangeInElement,
)
}

val propertyKey = literal.parentOfType<JsonProperty>()?.name
val (propertyKey, expectedType) = findEntrypointKeyAndType(literal)
val fieldTypeClass = (element.type as? PsiClassType)?.resolve()
val expectedType = propertyKey?.let { FabricConstants.ENTRYPOINT_BY_TYPE[it] }
if (propertyKey != null && fieldTypeClass != null && expectedType != null &&
!isEntrypointOfCorrectType(fieldTypeClass, propertyKey)
) {
Expand All @@ -141,11 +165,21 @@ class FabricEntrypointsInspection : LocalInspectionTool() {
}
}

private fun findEntrypointKeyAndType(literal: JsonLiteral): Pair<String?, String?> {
val propertyKey = when (val parent = literal.parent) {
is JsonArray -> (parent.parent as? JsonProperty)?.name
is JsonProperty -> parent.parentOfType<JsonProperty>()?.name
else -> null
}
val expectedType = propertyKey?.let { FabricConstants.ENTRYPOINT_BY_TYPE[it] }
return propertyKey to expectedType
}

private fun isEntrypointOfCorrectType(element: PsiClass, type: String): Boolean {
val entrypointClass = FabricConstants.ENTRYPOINT_BY_TYPE[type]
?: return false
val clazz = JavaPsiFacade.getInstance(element.project).findClass(entrypointClass, element.resolveScope)
return clazz != null && element.isInheritor(clazz, true)
return clazz != null && (element.equivalentTo(clazz) || element.isInheritor(clazz, true))
}
}
}
Loading

0 comments on commit 7b07722

Please sign in to comment.