From e771276e938455117e9e29bf9c72389f571326cb Mon Sep 17 00:00:00 2001 From: MineGame159 Date: Sun, 21 Jul 2024 16:33:56 +0200 Subject: [PATCH] Meteor changes --- build.gradle | 6 +- fabric/build.gradle | 29 ++++++-- .../baritone/launch/FabricMixinPlugin.java | 71 +++++++++++++++++++ fabric/src/main/resources/fabric.mod.json | 4 +- gradle.properties | 4 +- scripts/proguard.pro | 6 ++ src/api/java/baritone/api/Settings.java | 2 +- .../launch/BaritoneMixinConnector.java | 2 +- ...itone.json => mixins.baritone-meteor.json} | 3 +- .../java/baritone/launch/BaritoneTweaker.java | 2 +- 10 files changed, 115 insertions(+), 14 deletions(-) create mode 100644 fabric/src/main/java/baritone/launch/FabricMixinPlugin.java rename src/launch/resources/{mixins.baritone.json => mixins.baritone-meteor.json} (93%) diff --git a/build.gradle b/build.gradle index d802ac566..a7d8cffad 100755 --- a/build.gradle +++ b/build.gradle @@ -22,7 +22,7 @@ allprojects { archivesBaseName = rootProject.archives_base_name - def vers = "" + /*def vers = "" try { vers = 'git describe --always --tags --first-parent --dirty'.execute().text.trim() } catch (Exception e) { @@ -34,7 +34,9 @@ allprojects { } else { version = vers.substring(1) println "Detected version " + version - } + }*/ + + version = rootProject.mod_version group = rootProject.maven_group sourceCompatibility = targetCompatibility = JavaVersion.VERSION_21 diff --git a/fabric/build.gradle b/fabric/build.gradle index bf3e6c38d..c94808829 100644 --- a/fabric/build.gradle +++ b/fabric/build.gradle @@ -87,18 +87,39 @@ task createDist(type: CreateDistTask, dependsOn: proguard) { compType "fabric" } +task sourcesJar(type: Jar, dependsOn: classes) { + from rootProject.sourceSets.main.allJava + from rootProject.sourceSets.api.allJava + archiveClassifier.set("sources") +} + build.finalizedBy(createDist) publishing { publications { - mavenFabric(MavenPublication) { - artifactId = rootProject.archives_base_name + "-" + project.name - from components.java + maven(MavenPublication) { + groupId "meteordevelopment" + artifactId "baritone" + + artifact "../dist/baritone-api-fabric-" + version + ".jar" + artifact sourcesJar } } // See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing. repositories { - // Add repositories to publish to here. + maven { + name = "meteor-maven" + url = "https://maven.meteordev.org/snapshots" + + credentials { + username = System.getenv("MAVEN_METEOR_ALIAS") + password = System.getenv("MAVEN_METEOR_TOKEN") + } + + authentication { + basic(BasicAuthentication) + } + } } } diff --git a/fabric/src/main/java/baritone/launch/FabricMixinPlugin.java b/fabric/src/main/java/baritone/launch/FabricMixinPlugin.java new file mode 100644 index 000000000..655de50d4 --- /dev/null +++ b/fabric/src/main/java/baritone/launch/FabricMixinPlugin.java @@ -0,0 +1,71 @@ +/* + * This file is part of Baritone. + * + * Baritone 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, either version 3 of the License, or + * (at your option) any later version. + * + * Baritone 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Baritone. If not, see . + */ + +package baritone.launch; + +import net.fabricmc.loader.api.FabricLoader; +import org.objectweb.asm.tree.ClassNode; +import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin; +import org.spongepowered.asm.mixin.extensibility.IMixinInfo; + +import java.util.List; +import java.util.Set; + +public class FabricMixinPlugin implements IMixinConfigPlugin { + private static final String mixinPackage = "baritone.launch.mixins"; + + private static boolean loaded; + + private static boolean isBaritonePresent; + + @Override + public void onLoad(String mixinPackage) { + if (loaded) return; + + isBaritonePresent = FabricLoader.getInstance().isModLoaded("baritone"); + + loaded = true; + } + + @Override + public String getRefMapperConfig() { + return null; + } + + @Override + public boolean shouldApplyMixin(String targetClassName, String mixinClassName) { + if (!mixinClassName.startsWith(mixinPackage)) { + throw new RuntimeException("Mixin " + mixinClassName + " is not in the mixin package"); + } else { + return !isBaritonePresent; + } + } + + @Override + public void acceptTargets(Set myTargets, Set otherTargets) {} + + @Override + public List getMixins() { + return null; + } + + @Override + public void preApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) {} + + @Override + public void postApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) {} +} diff --git a/fabric/src/main/resources/fabric.mod.json b/fabric/src/main/resources/fabric.mod.json index 2f036c08c..4f2ef2769 100644 --- a/fabric/src/main/resources/fabric.mod.json +++ b/fabric/src/main/resources/fabric.mod.json @@ -1,6 +1,6 @@ { "schemaVersion": 1, - "id": "baritone", + "id": "baritone-meteor", "version": "${version}", "name": "Baritone", @@ -20,7 +20,7 @@ "entrypoints": { }, "mixins": [ - "mixins.baritone.json" + "mixins.baritone-meteor.json" ], "depends": { diff --git a/gradle.properties b/gradle.properties index 9a7b5417c..4f9b8973b 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,8 +1,8 @@ org.gradle.jvmargs=-Xmx4G -available_loaders=fabric,forge,neoforge,tweaker +available_loaders=fabric -mod_version=1.11.0 +mod_version=1.21-SNAPSHOT maven_group=baritone archives_base_name=baritone diff --git a/scripts/proguard.pro b/scripts/proguard.pro index 34b76170f..0b5211b04 100644 --- a/scripts/proguard.pro +++ b/scripts/proguard.pro @@ -1,3 +1,9 @@ +# Meteor +-keep class * + + + + -keepattributes Signature -keepattributes *Annotation* -keepattributes InnerClasses diff --git a/src/api/java/baritone/api/Settings.java b/src/api/java/baritone/api/Settings.java index 8609a0a88..782574ab2 100644 --- a/src/api/java/baritone/api/Settings.java +++ b/src/api/java/baritone/api/Settings.java @@ -669,7 +669,7 @@ public final class Settings { * Allow chat based control of Baritone. Most likely should be disabled when Baritone is imported for use in * something else */ - public final Setting chatControl = new Setting<>(true); + public final Setting chatControl = new Setting<>(false); /** * Some clients like Impact try to force chatControl to off, so here's a second setting to do it anyway diff --git a/src/launch/java/baritone/launch/BaritoneMixinConnector.java b/src/launch/java/baritone/launch/BaritoneMixinConnector.java index 86069e14f..d32b83cbd 100644 --- a/src/launch/java/baritone/launch/BaritoneMixinConnector.java +++ b/src/launch/java/baritone/launch/BaritoneMixinConnector.java @@ -24,6 +24,6 @@ public class BaritoneMixinConnector implements IMixinConnector { @Override public void connect() { - Mixins.addConfiguration("mixins.baritone.json"); + Mixins.addConfiguration("mixins.baritone-meteor.json"); } } \ No newline at end of file diff --git a/src/launch/resources/mixins.baritone.json b/src/launch/resources/mixins.baritone-meteor.json similarity index 93% rename from src/launch/resources/mixins.baritone.json rename to src/launch/resources/mixins.baritone-meteor.json index 9d526addc..87c9c86f6 100644 --- a/src/launch/resources/mixins.baritone.json +++ b/src/launch/resources/mixins.baritone-meteor.json @@ -29,5 +29,6 @@ "MixinWorldRenderer" ], "mixins": [ - ] + ], + "plugin": "baritone.launch.FabricMixinPlugin" } diff --git a/tweaker/src/main/java/baritone/launch/BaritoneTweaker.java b/tweaker/src/main/java/baritone/launch/BaritoneTweaker.java index b9db9b6a5..02e269506 100644 --- a/tweaker/src/main/java/baritone/launch/BaritoneTweaker.java +++ b/tweaker/src/main/java/baritone/launch/BaritoneTweaker.java @@ -50,6 +50,6 @@ public void injectIntoClassLoader(LaunchClassLoader classLoader) { MixinEnvironment.getDefaultEnvironment().setSide(MixinEnvironment.Side.CLIENT); MixinEnvironment.getDefaultEnvironment().setObfuscationContext(obfuscation); - Mixins.addConfiguration("mixins.baritone.json"); + Mixins.addConfiguration("mixins.baritone-meteor.json"); } }