Skip to content

Commit

Permalink
RFG Compat patches
Browse files Browse the repository at this point in the history
  • Loading branch information
eigenraven committed Sep 12, 2024
1 parent 4c3f5ee commit 44c44ed
Show file tree
Hide file tree
Showing 22 changed files with 515 additions and 43 deletions.
1 change: 1 addition & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
[*.{kt,kts}]
max_line_length=120
indent_size = 4
ij_kotlin_imports_layout=*
7 changes: 2 additions & 5 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,12 @@ jobs:
restore-keys: |
${{ runner.os }}-gradle-
- name: Setup publish token
env:
JETBRAINS_TOKEN: ${{ secrets.JETBRAINS_TOKEN }}
shell: bash
run: |
mkdir -p ~/.gradle/
echo "GRADLE_USER_HOME=$HOME/.gradle" >> "$GITHUB_ENV"
echo "mcdev.deploy.token=${JETBRAINS_TOKEN}" > ~/.gradle/gradle.properties
- name: Publish plugin
run: ./gradlew clean publishPlugin --no-daemon --stacktrace
run: ./gradlew clean assemble buildPlugin --no-daemon --stacktrace
- name: Get tag name
id: get_tag
shell: bash
Expand All @@ -55,7 +52,7 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.get_tag.outputs.tag }}
name: 'Release ${{ steps.get_tag.outputs.release }}'
name: 'Release ${{ github.ref_name }}'
body: '## [View all plugin releases here.](https://plugins.jetbrains.com/plugin/8327-minecraft-development/versions/stable/)'
prerelease: false
draft: false
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 = 2024.2
ideaVersionName = 2024.2

coreVersion = 1.8.1
coreVersion = 1.8.1-rfg

# Silences a build-time warning because we are bundling our own kotlin library
kotlin.stdlib.default.dependency = false
24 changes: 20 additions & 4 deletions readme.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,24 @@
<p align="center"><a href="https://minecraftdev.org/"><img src="https://minecraftdev.org/assets/icon.svg" height="120" alt="logo"/></a></p>
1.7-1.12 support fork of Minecraft Development for IntelliJ
==================================

Fork-specific features
----------------------

- Release mouse capture on debug breakpoints for LWJGL2 and Lwjgl3ify projects
- Proper detection of old ForgeGradle and RetroFuturaGradle minecraft project types, including mapping paths
- Allows the mixin plugin to work correctly on 1.7 and 1.12 projects, potentially more versions (untested)

RFG-Enabled Fork Installation
------------

1. Go into the plugins menu in IntelliJ (Settings -> Plugins)
1. Click the gear icon on the top, and click "Manage Plugin Repositories"
1. Add a raw GitHub link to the update file in the [updates directory](https://github.com/eigenraven/MinecraftDev/tree/rfg/updates), corresponding to the version of IntelliJ you have. For example, if you have 2024.1, use https://raw.githubusercontent.com/eigenraven/MinecraftDev/rfg/updates/updatePlugins-241.xml
1. MinecraftDev should now show an update if you have the official version installed, which corresponds to Earth's edition of MinecraftDev. If you didn't have the official version installed, installing MinecraftDev will also install the RFG edition.


Minecraft Development for IntelliJ
==================================
----------------------------------

<table>
<tr>
Expand Down Expand Up @@ -43,8 +60,7 @@ Info and Documentation [![Current Release](https://img.shields.io/badge/release-
Visit [https://minecraftdev.org](https://minecraftdev.org) for some information about the project.


Installation
------------
### Installation instructions for the official project:

This plugin is available on the [JetBrains IntelliJ plugin repository](https://plugins.jetbrains.com/plugin/8327).

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/*
* 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 org.gradle.api.Project
import org.jetbrains.annotations.NotNull
import org.jetbrains.plugins.gradle.tooling.ErrorMessageBuilder
import org.jetbrains.plugins.gradle.tooling.ModelBuilderService

final class McpModelRFGBuilderImpl implements ModelBuilderService {

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

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

def mcpTasksObj = project.extensions.findByName('mcpTasks')
if (mcpTasksObj == null) {
return null
}

if (project.tasks.findByName("generateForgeSrgMappings") == null) {
return null
}

def mappingFiles = project.tasks.generateForgeSrgMappings.outputs.files.files.collect { it.absolutePath }
def atFiles = mcpTasksObj.deobfuscationATs.files.collect {it}
try {
def implObj = new McpModelRFGImpl(extension.mcVersion.get(), extension.mcpMappingChannel.get() + "-" + extension.mcpMappingVersion.get(), mappingFiles.toSet(), atFiles)
return implObj
} catch (Throwable t) {
System.err.println(t.message)
t.printStackTrace()
throw t
}
}

@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,49 @@
/*
* 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 groovy.transform.CompileStatic

@CompileStatic
final class McpModelRFGImpl implements McpModelRFG, Serializable {

final String minecraftVersion
final String mcpVersion
final Set<String> mappingFiles
final List<File> accessTransformers

McpModelRFGImpl(String minecraftVersion, String mcpVersion, Set<String> mappingFiles, List<File> accessTransformers) {
this.minecraftVersion = minecraftVersion
this.mcpVersion = mcpVersion
this.mappingFiles = mappingFiles
this.accessTransformers = accessTransformers
}

@Override
public String toString() {
return "McpModelRFGImpl{" +
"minecraftVersion='" + minecraftVersion + '\'' +
", mcpVersion='" + mcpVersion + '\'' +
", mappingFiles=" + mappingFiles +
", accessTransformers=" + accessTransformers +
'}';
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* 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;
import java.util.Set;

public interface McpModelRFG extends McpModel {
String getMinecraftVersion();
Set<String> getMappingFiles();
List<File> getAccessTransformers();
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ com.demonwav.mcdev.platform.mcp.gradle.tooling.neomoddev.NeoModDevGradleModelBui
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
com.demonwav.mcdev.platform.mcp.gradle.tooling.McpModelRFGBuilderImpl
10 changes: 10 additions & 0 deletions src/main/kotlin/facet/MinecraftFacetDetector.kt
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ import com.demonwav.mcdev.platform.PlatformType
import com.demonwav.mcdev.platform.architectury.framework.ARCHITECTURY_LIBRARY_KIND
import com.demonwav.mcdev.platform.architectury.framework.ArchitecturyGradleData
import com.demonwav.mcdev.platform.fabric.framework.FABRIC_LIBRARY_KIND
import com.demonwav.mcdev.platform.forge.framework.FORGE_LIBRARY_KIND
import com.demonwav.mcdev.platform.mcp.framework.MCP_LIBRARY_KIND
import com.demonwav.mcdev.platform.mcp.gradle.tooling.archloom.ArchitecturyModel
import com.demonwav.mcdev.platform.sponge.framework.SPONGE_LIBRARY_KIND
import com.demonwav.mcdev.util.ifEmpty
Expand Down Expand Up @@ -221,6 +223,14 @@ class MinecraftFacetDetector : ProjectActivity {

platformKinds.add(SPONGE_LIBRARY_KIND)
}
// RFG Patch: fix auto-detection of the Forge/MCP facets on RFG projects
if (m.name.endsWith(".patchedMc", ignoreCase = false)) {
// RetroFuturaGradle decompiled MC sources
platformKinds.add(FORGE_LIBRARY_KIND)
platformKinds.add(MCP_LIBRARY_KIND)
libraryVersions[FORGE_LIBRARY_KIND] = "1.0"
libraryVersions[MCP_LIBRARY_KIND] = "1.0"
}
return@forEach true
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ class UngrabMouseDebugSessionListener(private val process: DebugProcessImpl) : X
val virtualMachine = debugProcess.virtualMachineProxy as? VirtualMachineProxyImpl ?: return
val evaluationContext = EvaluationContextImpl(suspendContextImpl, frameProxy)

// RFG Patch: Fix mouse ungrabbing with lwjgl3ify
val mouseClass = virtualMachine.classesByName("org.lwjgl.input.Mouse")?.singleOrNull() as? ClassType
?: virtualMachine.classesByName("org.lwjglx.input.Mouse")?.singleOrNull() as? ClassType
// LWJGL 3 does not have the Mouse class, Minecraft uses its own MouseHelper instead
if (mouseClass != null) {
ungrab2(mouseClass, virtualMachine, debugProcess, evaluationContext)
Expand Down
19 changes: 14 additions & 5 deletions src/main/kotlin/platform/mcp/gradle/McpProjectResolverExtension.kt
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,12 @@ import com.demonwav.mcdev.platform.mcp.gradle.datahandler.McpModelFG2Handler
import com.demonwav.mcdev.platform.mcp.gradle.datahandler.McpModelFG3Handler
import com.demonwav.mcdev.platform.mcp.gradle.datahandler.McpModelNG7Handler
import com.demonwav.mcdev.platform.mcp.gradle.datahandler.McpModelNMDHandler
import com.demonwav.mcdev.platform.mcp.gradle.datahandler.McpModelRFGHandler
import com.demonwav.mcdev.platform.mcp.gradle.tooling.McpModelFG2
import com.demonwav.mcdev.platform.mcp.gradle.tooling.McpModelFG3
import com.demonwav.mcdev.platform.mcp.gradle.tooling.McpModelNG7
import com.demonwav.mcdev.platform.mcp.gradle.tooling.McpModelNMD
import com.demonwav.mcdev.platform.mcp.gradle.tooling.McpModelRFG
import com.demonwav.mcdev.util.runGradleTask
import com.intellij.openapi.externalSystem.model.DataNode
import com.intellij.openapi.externalSystem.model.project.ModuleData
Expand All @@ -40,7 +42,13 @@ class McpProjectResolverExtension : AbstractProjectResolverExtension() {

// Register our custom Gradle tooling API model in IntelliJ's project resolver
override fun getExtraProjectModelClasses(): Set<Class<out Any>> =
setOf(McpModelFG2::class.java, McpModelFG3::class.java, McpModelNG7::class.java, McpModelNMD::class.java)
setOf(
McpModelFG2::class.java,
McpModelFG3::class.java,
McpModelNG7::class.java,
McpModelNMD::class.java,
McpModelRFG::class.java
)

override fun getToolingExtensionsClasses() = extraProjectModelClasses

Expand All @@ -66,7 +74,7 @@ class McpProjectResolverExtension : AbstractProjectResolverExtension() {
}

private fun findAllTaskNames(node: DataNode<*>): List<String> {
fun findAllTaskNames(node: DataNode<*>, taskNames: MutableList<String>) {
fun findAllTaskNames(node: DataNode<*>, taskNames: MutableSet<String>) {
val data = node.data
if (data is McpModelData) {
data.taskName?.let { taskName ->
Expand All @@ -78,9 +86,9 @@ class McpProjectResolverExtension : AbstractProjectResolverExtension() {
}
}

val res = arrayListOf<String>()
val res = hashSetOf<String>()
findAllTaskNames(node, res)
return res
return res.toList()
}

override fun populateModuleExtraModels(gradleModule: IdeaModule, ideModule: DataNode<ModuleData>) {
Expand All @@ -93,6 +101,7 @@ class McpProjectResolverExtension : AbstractProjectResolverExtension() {
}

companion object {
private val handlers = listOf(McpModelFG2Handler, McpModelFG3Handler, McpModelNG7Handler, McpModelNMDHandler)
private val handlers =
listOf(McpModelFG2Handler, McpModelFG3Handler, McpModelNG7Handler, McpModelNMDHandler, McpModelRFGHandler)
}
}
Loading

0 comments on commit 44c44ed

Please sign in to comment.