Update for newer IDEA+MC versions

This commit is contained in:
Ben 2024-06-22 18:53:14 +02:00
parent 6be2d28e4f
commit 5c347786ad
Signed by: ben
GPG key ID: 0F54A7ED232D3319
2 changed files with 38 additions and 7 deletions

View file

@ -1,11 +1,11 @@
plugins { plugins {
id("java") id("java")
id("org.jetbrains.kotlin.jvm") version "1.9.0" id("org.jetbrains.kotlin.jvm") version "2.0.0"
id("org.jetbrains.intellij") version "1.16.0" id("org.jetbrains.intellij") version "1.16.0"
} }
group = "rs485.network" group = "rs485.network"
version = "1.0-SNAPSHOT" version = "1.1-SNAPSHOT"
repositories { repositories {
mavenCentral() mavenCentral()
@ -14,25 +14,29 @@ repositories {
// Configure Gradle IntelliJ Plugin // Configure Gradle IntelliJ Plugin
// Read more: https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html // Read more: https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html
intellij { intellij {
version.set("2023.3.3") version.set("2024.1.3")
type.set("IC") // Target IDE Platform type.set("IC") // Target IDE Platform
plugins.set(listOf("com.intellij.java")) plugins.set(listOf("com.intellij.java"))
} }
kotlin {
compilerOptions {
jvmTarget.set(org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_17)
apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_0)
}
}
tasks { tasks {
// Set the JVM compatibility versions // Set the JVM compatibility versions
withType<JavaCompile> { withType<JavaCompile> {
sourceCompatibility = "17" sourceCompatibility = "17"
targetCompatibility = "17" targetCompatibility = "17"
} }
withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
kotlinOptions.jvmTarget = "17"
}
patchPluginXml { patchPluginXml {
sinceBuild.set("233") sinceBuild.set("233")
untilBuild.set("233.*") //untilBuild.set("241.*")
} }
signPlugin { signPlugin {

View file

@ -15,6 +15,8 @@ class LWJGLExitMouseGrabDebuggerManagerListener : XDebuggerManagerListener {
debugProcess.session.addSessionListener(object : XDebugSessionListener { debugProcess.session.addSessionListener(object : XDebugSessionListener {
override fun sessionPaused() { override fun sessionPaused() {
val evaluator = debugProcess.evaluator ?: return val evaluator = debugProcess.evaluator ?: return
// older MC versions (lwjgl 2)
ApplicationManager.getApplication().invokeLater { ApplicationManager.getApplication().invokeLater {
val expression = XExpressionImpl( val expression = XExpressionImpl(
/* expression = */ "Mouse.setGrabbed(false);", /* expression = */ "Mouse.setGrabbed(false);",
@ -37,6 +39,31 @@ class LWJGLExitMouseGrabDebuggerManagerListener : XDebuggerManagerListener {
/* expressionPosition = */ null, /* expressionPosition = */ null,
) )
} }
// newer MC versions (lwjgl 3?)
ApplicationManager.getApplication().invokeLater {
val expression = XExpressionImpl(
/* expression = */ "MinecraftClient.getInstance().mouse.unlockCursor();\n" +
"MinecraftClient.getInstance().setScreenAndRender(MinecraftClient.getInstance().currentScreen);",
/* language = */ JavaLanguage.INSTANCE,
/* customInfo = */ "net.minecraft.client.MinecraftClient",
/* mode = */ EvaluationMode.CODE_FRAGMENT,
)
evaluator.evaluate(
/* expression = */ expression,
/* callback = */
object : XEvaluationCallbackBase() {
override fun errorOccurred(errorMessage: String) {
// ignore
}
override fun evaluated(result: XValue) {
// ignore
}
},
/* expressionPosition = */ null,
)
}
} }
}) })
} }