diff options
author | nea <nea@nea.moe> | 2023-05-30 19:05:16 +0200 |
---|---|---|
committer | nea <nea@nea.moe> | 2023-05-30 19:05:16 +0200 |
commit | 3139306088f8d3cad1b4906c3bbd1b412b9bda6f (patch) | |
tree | 4c7e6bf5ba982b9c1e37d383939fc302f006fbd8 | |
parent | 2ff8c59c74fb138f475a5ec309d57fc92fc79bf4 (diff) | |
download | firmament-3139306088f8d3cad1b4906c3bbd1b412b9bda6f.tar.gz firmament-3139306088f8d3cad1b4906c3bbd1b412b9bda6f.tar.bz2 firmament-3139306088f8d3cad1b4906c3bbd1b412b9bda6f.zip |
Auto discover mixins
-rw-r--r-- | build.gradle.kts | 7 | ||||
-rw-r--r-- | gradle/libs.versions.toml | 2 | ||||
-rw-r--r-- | src/main/java/moe/nea/firmament/init/MixinPlugin.java | 42 | ||||
-rw-r--r-- | src/main/resources/firmament.mixins.json | 17 |
4 files changed, 19 insertions, 49 deletions
diff --git a/build.gradle.kts b/build.gradle.kts index 67cba5b..83dd139 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -54,6 +54,11 @@ repositories { includeGroup("maven.modrinth") } } + maven("https://repo.sleeping.town") { + content { + includeGroup("com.unascribed") + } + } maven("https://server.bbkr.space/artifactory/libs-release") maven("https://repo.nea.moe/releases") mavenLocal() @@ -82,6 +87,8 @@ dependencies { modImplementation(libs.fabric.kotlin) modImplementation(libs.modmenu) modImplementation(libs.libgui) + modImplementation(libs.lib39.core) + include(libs.lib39.core) include(libs.libgui) modApi(libs.fabric.api) modApi(libs.architectury) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 95be67f..0e6a970 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -14,6 +14,7 @@ architectury = "8.1.79" neurepoparser = "1.1.0" qolify = "1.2.2-1.19.4" citresewn = "1.1.3+1.19.4" +lib39 = "1.4.2" ncr = "Fabric-1.19.4-v2.1.1" [libraries] @@ -27,6 +28,7 @@ repoparser = { module = "moe.nea:neurepoparser", version.ref = "neurepoparser" } dbus_java_core = { module = "com.github.hypfvieh:dbus-java-core", version.ref = "dbus_java" } dbus_java_unixsocket = { module = "com.github.hypfvieh:dbus-java-transport-native-unixsocket", version.ref = "dbus_java" } libgui = { module = "io.github.cottonmc:LibGui", version.ref = "libgui" } +lib39_core = { module = "com.unascribed:lib39-core", version.ref = "lib39" } # Runtime: architectury_fabric = { module = "dev.architectury:architectury-fabric", version.ref = "architectury" } diff --git a/src/main/java/moe/nea/firmament/init/MixinPlugin.java b/src/main/java/moe/nea/firmament/init/MixinPlugin.java index d61d428..79a1789 100644 --- a/src/main/java/moe/nea/firmament/init/MixinPlugin.java +++ b/src/main/java/moe/nea/firmament/init/MixinPlugin.java @@ -18,47 +18,25 @@ package moe.nea.firmament.init; -import org.objectweb.asm.tree.ClassNode; -import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin; -import org.spongepowered.asm.mixin.extensibility.IMixinInfo; +import com.unascribed.lib39.core.api.AutoMixin; import java.util.List; -import java.util.Set; -public class MixinPlugin implements IMixinConfigPlugin { - @Override - public void onLoad(String mixinPackage) { - - } - - @Override - public String getRefMapperConfig() { - return null; - } +// TODO: replace AutoMixin with KSP plugin? +public class MixinPlugin extends AutoMixin { @Override public boolean shouldApplyMixin(String targetClassName, String mixinClassName) { - return Boolean.getBoolean("firmament.debug") || - !mixinClassName.startsWith("moe.nea.firmament.mixins.devenv"); - } - - @Override - public void acceptTargets(Set<String> myTargets, Set<String> otherTargets) { - + if (!Boolean.getBoolean("firmament.debug") && mixinClassName.contains("devenv.")) { + return false; + } + return super.shouldApplyMixin(targetClassName, mixinClassName); } @Override public List<String> 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) { - + var autoDiscoveredMixins = super.getMixins(); + autoDiscoveredMixins.removeIf(it -> !shouldApplyMixin(null, it)); + return autoDiscoveredMixins; } } diff --git a/src/main/resources/firmament.mixins.json b/src/main/resources/firmament.mixins.json index 1f63bd0..43f3601 100644 --- a/src/main/resources/firmament.mixins.json +++ b/src/main/resources/firmament.mixins.json @@ -3,23 +3,6 @@ "plugin": "moe.nea.firmament.init.MixinPlugin", "package": "moe.nea.firmament.mixins", "compatibilityLevel": "JAVA_16", - "client": [ - "MixinDownloadingTerrainScreen", - "MixinMessageHandler", - "MixinMinecraft", - "MixinWorldRenderer", - "accessor.AccessorHandledScreen", - "devenv.DisableCommonPacketWarnings" - ], - "mixins": [ - "MixinClientPacketHandler", - "MixinClientPlayerEntity", - "MixinEntityIdFix", - "MixinHandledScreen", - "MixinPlayerInventory", - "devenv.DisableInvalidFishingHook", - "devenv.MixinScoreboard" - ], "injectors": { "defaultRequire": 1 } |