From 2974616d813f01510eecd77c2215cd58457c7067 Mon Sep 17 00:00:00 2001 From: Refactoring Date: Sun, 11 Feb 2024 12:21:04 -0500 Subject: [PATCH] (feat) UNIMINED port --- .github/workflows/build.yml | 50 ++++++++------- build.gradle | 31 +++++++++- .../java/dev/refactoring/launch/Main.java | 2 +- .../launch/tweak/LaunchTweaker.java | 62 ------------------- .../dev/refactoring/mixin/MinecraftMixin.java | 18 ------ 5 files changed, 59 insertions(+), 104 deletions(-) delete mode 100644 src/main/java/dev/refactoring/launch/tweak/LaunchTweaker.java delete mode 100644 src/main/java/dev/refactoring/mixin/MinecraftMixin.java diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 47c2bd9..95cf8a7 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,29 +1,37 @@ -# Automatically build the project and run any configured tests for every push -# and submitted pull request. This can help catch issues that only occur on -# certain Java versions, and provides a first line of defence against bad commits. - -name: Build - -on: [push, pull_request] - +name: Building JAR +on: [workflow_dispatch, push] jobs: - build: + gradle: strategy: matrix: - java: [ - "8", "11", "17", # LTS - "21" # Latest version - ] - runs-on: ubuntu-latest + os: [ubuntu-latest] + runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v3 - - uses: gradle/wrapper-validation-action@v1 + - id: commit + uses: pr-mpt/actions-commit-hash@v2 + - name: Get branch name + id: branch-name + uses: tj-actions/branch-names@v6 - uses: actions/setup-java@v3 with: - distribution: "temurin" - java-version: ${{ matrix.java }} + distribution: temurin + java-version: 8 - - name: Grant execute permission - run: chmod +x ./gradlew - - name: Build with Gradle - run: ./gradlew build \ No newline at end of file + - name: Setup Gradle + uses: gradle/gradle-build-action@v2 + + - name: Execute Gradle build + run: ./gradlew setupDecompWorkspace clean build --refresh-dependencies + + - name: Copying JAR to AutoBuilder + working-directory: ./autobuilder + run: mkdir ./jars && cp ../build/libs/client-1.8.9.jar ./jars/Client.jar + + # - name: Obfuscating Jar + # working-directory: ./autobuilder + # run: mkdir ./jars && java -jar obfuscator.jar --jarIn ../build/libs/client-1.8.9.jar --jarOut ./jars/Client.jar --scriptFile obfuscationScript.js --config config + + - name: Building Jar with Libraries + working-directory: ./autobuilder + run: npm install && LOGIN=${{ secrets.LOGIN }} PASSWORD=${{ secrets.PASSWORD }} node index --version 1.8.9 --branch ${{ steps.branch-name.outputs.current_branch }} --commit ${{ steps.commit.outputs.short }} diff --git a/build.gradle b/build.gradle index 412aa85..3dc2333 100644 --- a/build.gradle +++ b/build.gradle @@ -53,11 +53,22 @@ processResources { inputs.property "version", project.version } +configurations { + embed + implementation.extendsFrom(embed) +} + dependencies { - implementation("com.github.heni123321:LegacyLauncher:ac106bbe00") { + embed("com.github.heni123321:LegacyLauncher:ac106bbe00") { transitive = false } - implementation 'org.spongepowered:mixin:0.7.11-SNAPSHOT' + embed("org.spongepowered:mixin:0.7.11-SNAPSHOT") { + exclude module: 'launchwrapper' + exclude module: 'guava' + exclude module: 'gson' + exclude module: 'commons-io' + } + implementation fileTree(dir: 'lib', include: ['*.jar']) } java { @@ -71,6 +82,22 @@ jar { from("LICENSE") { rename { "${it}_${base.archivesName.get()}" } } + from { + configurations.embed.collect { + it.isDirectory() ? it : zipTree(it) + } + } + manifest.attributes( + "MixinConfigs": 'mixins.SilentClient.json', + "TweakClass": "net.silentclient.client.mixin.SilentClientTweaker", + "TweakOrder": 0, + "Manifest-Version": 1.0 + ) + configurations.embed.each { dep -> + from(project.zipTree(dep)) { + exclude 'META-INF', 'META-INF/**' + } + } } tasks.withType(JavaCompile).configureEach { diff --git a/src/main/java/dev/refactoring/launch/Main.java b/src/main/java/dev/refactoring/launch/Main.java index 717fe89..f7462af 100644 --- a/src/main/java/dev/refactoring/launch/Main.java +++ b/src/main/java/dev/refactoring/launch/Main.java @@ -8,6 +8,6 @@ import org.apache.commons.lang3.ArrayUtils; */ public class Main { public static void main(String[] args) { - Launch.main(ArrayUtils.addAll(args, "--tweakClass", "dev.refactoring.launch.tweak.LaunchTweaker")); + Launch.main(ArrayUtils.addAll(args, "--tweakClass", "net.silentclient.client.mixin.SilentClientTweaker")); } } diff --git a/src/main/java/dev/refactoring/launch/tweak/LaunchTweaker.java b/src/main/java/dev/refactoring/launch/tweak/LaunchTweaker.java deleted file mode 100644 index 7c45b77..0000000 --- a/src/main/java/dev/refactoring/launch/tweak/LaunchTweaker.java +++ /dev/null @@ -1,62 +0,0 @@ -package dev.refactoring.launch.tweak; - -import net.minecraft.launchwrapper.ITweaker; -import net.minecraft.launchwrapper.LaunchClassLoader; -import org.spongepowered.asm.launch.MixinBootstrap; -import org.spongepowered.asm.mixin.MixinEnvironment; -import org.spongepowered.asm.mixin.Mixins; - -import java.io.File; -import java.util.ArrayList; -import java.util.List; - -/** - * @author refactoring - */ -public class LaunchTweaker implements ITweaker { - private final List launchArguments = new ArrayList<>(); - - @Override - public void acceptOptions(List args, File gameDir, File assetsDir, String profile) { - this.launchArguments.addAll(args); - - if (!args.contains("--version") && profile != null) { - launchArguments.add("--version"); - launchArguments.add(profile); - } - - if (!args.contains("--assetsDir") && assetsDir != null) { - launchArguments.add("--assetsDir"); - launchArguments.add(assetsDir.getAbsolutePath()); - } - - if (!args.contains("--gameDir") && gameDir != null) { - launchArguments.add("--gameDir"); - launchArguments.add(gameDir.getAbsolutePath()); - } - } - - @Override - public void injectIntoClassLoader(LaunchClassLoader classLoader) { - MixinBootstrap.init(); - - MixinEnvironment env = MixinEnvironment.getDefaultEnvironment(); - Mixins.addConfiguration("mixins.example.json"); - - if (env.getObfuscationContext() == null) { - env.setObfuscationContext("notch"); - } - - env.setSide(MixinEnvironment.Side.CLIENT); - } - - @Override - public String getLaunchTarget() { - return "net.minecraft.client.main.Main"; - } - - @Override - public String[] getLaunchArguments() { - return launchArguments.toArray(new String[0]); - } -} \ No newline at end of file diff --git a/src/main/java/dev/refactoring/mixin/MinecraftMixin.java b/src/main/java/dev/refactoring/mixin/MinecraftMixin.java deleted file mode 100644 index 3dc0acb..0000000 --- a/src/main/java/dev/refactoring/mixin/MinecraftMixin.java +++ /dev/null @@ -1,18 +0,0 @@ -package dev.refactoring.mixin; - -import net.minecraft.client.Minecraft; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; - -/** - * @author refactoring - */ -@Mixin(Minecraft.class) -public class MinecraftMixin { - @Inject(method = "startGame", at = @At("HEAD")) - public void example$startGame(CallbackInfo ci) { - System.out.printf("hello %s\n", ci.getId()); - } -}