From d61bad46c58f74167eedfb5d3a25aeab2907589a Mon Sep 17 00:00:00 2001 From: Lassebq Date: Sat, 5 Oct 2024 16:29:43 +0300 Subject: [PATCH] Update build script. Merge micromixin into main branch --- build.gradle | 48 +++++++++++-------- launchwrapper-fabric/build.gradle | 6 --- launchwrapper-micromixin/build.gradle | 7 --- .../protocol/LegacyURLStreamHandler.java | 1 + .../injection/legacy/ClassicCrashScreen.java | 4 -- .../tweak/injection/legacy/LWJGLPatch.java | 11 +++-- .../launchwrapper/test/BTATest.java | 1 - 7 files changed, 36 insertions(+), 42 deletions(-) diff --git a/build.gradle b/build.gradle index aefdc04..73ca2d7 100644 --- a/build.gradle +++ b/build.gradle @@ -3,20 +3,24 @@ plugins { id 'maven-publish' } -archivesBaseName = 'launchwrapper' +def ENV = System.getenv() -project.ext.asm_version = 9.7 +group = 'org.mcphackers' +version = 1.0 +if(!ENV.RELEASE.equals('1')) { + project.version += '-SNAPSHOT' +} -def ENV = System.getenv() +def asm_version = 9.7 +def depends = [ + "org.mcphackers.rdi:rdi:1.0", + "org.ow2.asm:asm:${asm_version}", + "org.ow2.asm:asm-util:${asm_version}", + "org.ow2.asm:asm-tree:${asm_version}", + "org.json:json:20240303" +] dependencies { - implementation "org.mcphackers.rdi:rdi:1.0" - implementation "org.ow2.asm:asm:${project.asm_version}" - implementation "org.ow2.asm:asm-util:${project.asm_version}" - implementation "org.ow2.asm:asm-tree:${project.asm_version}" - implementation "org.json:json:20240303" - // I'll bring discord RPC support later, when I have an environment to compile natives - testRuntimeOnly('org.junit.platform:junit-platform-launcher:1.5.2') testImplementation 'org.junit.jupiter:junit-jupiter-engine:5.0.0' } @@ -30,15 +34,20 @@ test { } } -allprojects { +subprojects { apply plugin: 'java' - apply plugin: 'maven-publish' - group = 'org.mcphackers' - project.version = '1.0' - if(!ENV.RELEASE.equals('1')) { - project.version += '-SNAPSHOT' - } + project.group = rootProject.group + project.version = rootProject.version + + dependencies { + implementation rootProject + } +} + +allprojects { + apply plugin: 'java' + apply plugin: 'maven-publish' repositories { maven { @@ -49,6 +58,9 @@ allprojects { } mavenCentral() } + dependencies { + depends.each { depend -> implementation depend } + } task sourcesJar(type: Jar) { archiveClassifier = 'sources' @@ -94,8 +106,6 @@ allprojects { publishing { publications { mavenJava(MavenPublication) { - artifactId = project.archivesBaseName - artifact jar artifact sourcesJar } diff --git a/launchwrapper-fabric/build.gradle b/launchwrapper-fabric/build.gradle index b1f6c44..95f636a 100644 --- a/launchwrapper-fabric/build.gradle +++ b/launchwrapper-fabric/build.gradle @@ -6,17 +6,11 @@ repositories { } } -archivesBaseName = 'launchwrapper-fabric' compileJava { sourceCompatibility = JavaVersion.VERSION_1_8 targetCompatibility = JavaVersion.VERSION_1_8 } dependencies { - implementation rootProject - implementation "org.mcphackers.rdi:rdi:1.0" implementation "net.fabricmc:fabric-loader:0.16.4" - implementation "org.ow2.asm:asm:${project.asm_version}" - implementation "org.ow2.asm:asm-tree:${project.asm_version}" - implementation "org.ow2.asm:asm-util:${project.asm_version}" } \ No newline at end of file diff --git a/launchwrapper-micromixin/build.gradle b/launchwrapper-micromixin/build.gradle index b791aac..11333ba 100644 --- a/launchwrapper-micromixin/build.gradle +++ b/launchwrapper-micromixin/build.gradle @@ -9,16 +9,12 @@ repositories { } } -archivesBaseName = 'launchwrapper-micromixin' compileJava { sourceCompatibility = JavaVersion.VERSION_1_8 targetCompatibility = JavaVersion.VERSION_1_8 } dependencies { - implementation rootProject - implementation "org.mcphackers.rdi:rdi:1.0" - implementation 'org.json:json:20230311' implementation 'org.jetbrains:annotations-java5:24.1.0' implementation "org.stianloader:micromixin-transformer:0.6.5-a20240922" implementation "org.stianloader:micromixin-runtime:0.6.5-a20240922" @@ -27,7 +23,4 @@ dependencies { implementation "org.stianloader:stianloader-remapper:0.1.0-a20240601" // For remapping classes and references implementation "net.fabricmc:mapping-io:0.3.0" implementation "net.fabricmc:access-widener:2.1.0" - implementation "org.ow2.asm:asm:${project.asm_version}" - implementation "org.ow2.asm:asm-tree:${project.asm_version}" - implementation "org.ow2.asm:asm-util:${project.asm_version}" } \ No newline at end of file diff --git a/src/main/java/org/mcphackers/launchwrapper/protocol/LegacyURLStreamHandler.java b/src/main/java/org/mcphackers/launchwrapper/protocol/LegacyURLStreamHandler.java index 75da370..14e18d7 100644 --- a/src/main/java/org/mcphackers/launchwrapper/protocol/LegacyURLStreamHandler.java +++ b/src/main/java/org/mcphackers/launchwrapper/protocol/LegacyURLStreamHandler.java @@ -84,6 +84,7 @@ protected URLConnection openConnection(URL url) throws IOException { // if(path.equals("/worlds/test/$LOCATION_ID")) // return new BasicResponseURLConnection(url, "1"); } + //FIXME server sends their own skin as packet if(host.equals("textures.minecraft.net")) { if(path.startsWith("/texture/")) { return new TextureURLConnection(url, skins); diff --git a/src/main/java/org/mcphackers/launchwrapper/tweak/injection/legacy/ClassicCrashScreen.java b/src/main/java/org/mcphackers/launchwrapper/tweak/injection/legacy/ClassicCrashScreen.java index f7e2a03..39b9696 100644 --- a/src/main/java/org/mcphackers/launchwrapper/tweak/injection/legacy/ClassicCrashScreen.java +++ b/src/main/java/org/mcphackers/launchwrapper/tweak/injection/legacy/ClassicCrashScreen.java @@ -3,9 +3,6 @@ import static org.mcphackers.rdi.util.InsnHelper.*; import static org.objectweb.asm.Opcodes.*; -import java.util.ArrayList; -import java.util.List; - import org.mcphackers.launchwrapper.LaunchConfig; import org.mcphackers.launchwrapper.tweak.injection.InjectionWithContext; import org.mcphackers.launchwrapper.tweak.injection.MinecraftGetter; @@ -498,7 +495,6 @@ public boolean patchErrorScreen(ClassNodeSource source, ClassNode errScreen, Met } } // Cancel button patch - // TODO don't patch button if it's already present ClassNode screen = source.getClass(errScreen.superName); cancelButton: if(screen != null) { diff --git a/src/main/java/org/mcphackers/launchwrapper/tweak/injection/legacy/LWJGLPatch.java b/src/main/java/org/mcphackers/launchwrapper/tweak/injection/legacy/LWJGLPatch.java index 34fbb51..7ff8932 100644 --- a/src/main/java/org/mcphackers/launchwrapper/tweak/injection/legacy/LWJGLPatch.java +++ b/src/main/java/org/mcphackers/launchwrapper/tweak/injection/legacy/LWJGLPatch.java @@ -389,12 +389,13 @@ && compareInsn(insns3[6], INVOKESPECIAL, "org/lwjgl/opengl/DisplayMode", " while(insn2 != null) { AbstractInsnNode[] insns2 = fill(insn2, 4); if(compareInsn(insns2[0], INVOKESTATIC, "org/lwjgl/opengl/Display", "setFullscreen", "(Z)V") - && compareInsn(insns2[1], INVOKESTATIC, "org/lwjgl/opengl/Display", "update", "()V") - && compareInsn(insns2[2], LDC, 1000L) - && compareInsn(insns2[3], INVOKESTATIC, "java/lang/Thread", "sleep", "(J)V")) { + && compareInsn(insns2[1], INVOKESTATIC, "org/lwjgl/opengl/Display", "update", "()V")) { // Removes fullscreen delay - m.instructions.remove(insns2[2]); - m.instructions.remove(insns2[3]); + if(compareInsn(insns2[2], LDC, 1000L) + && compareInsn(insns2[3], INVOKESTATIC, "java/lang/Thread", "sleep", "(J)V")) { + m.instructions.remove(insns2[2]); + m.instructions.remove(insns2[3]); + } toggleFullscreen = m; } diff --git a/src/test/java/org/mcphackers/launchwrapper/test/BTATest.java b/src/test/java/org/mcphackers/launchwrapper/test/BTATest.java index a9f48dd..853152a 100644 --- a/src/test/java/org/mcphackers/launchwrapper/test/BTATest.java +++ b/src/test/java/org/mcphackers/launchwrapper/test/BTATest.java @@ -24,7 +24,6 @@ public Tweak getTweak(LaunchConfig config) { @Override public TestFeatureBuilder getTests() { return new TestFeatureBuilder() - //TODO LWJGL patch is applied partially so it doesn't "succeed" .tweakInfoList("LegacyTweak init", "Fix Shutdown", "Replace game directory"); }