diff --git a/build.gradle b/build.gradle index deacc1c..47480ed 100644 --- a/build.gradle +++ b/build.gradle @@ -15,7 +15,7 @@ apply plugin: 'idea' apply plugin: 'maven' group = 'io.github.crucible' -version = '1.12.2-1.0.3a' +version = '1.12.2-1.0.4a' archivesBaseName = "[0]Grimoire" @@ -44,7 +44,7 @@ repositories { } dependencies { - shade("org.spongepowered:mixin:0.8-SNAPSHOT") { + shade("org.spongepowered:mixin:0.8.1-SNAPSHOT") { exclude module: "launchwrapper" exclude module: 'guava' } diff --git a/src/main/java/io/github/crucible/grimoire/mixins/forge/MixinLoader.java b/src/main/java/io/github/crucible/grimoire/mixins/forge/MixinLoader.java index 20b75a7..c0ab335 100644 --- a/src/main/java/io/github/crucible/grimoire/mixins/forge/MixinLoader.java +++ b/src/main/java/io/github/crucible/grimoire/mixins/forge/MixinLoader.java @@ -12,7 +12,7 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import org.spongepowered.asm.mixin.transformer.IMixinTransformer; +import org.spongepowered.asm.mixin.transformer.MixinProcessor; import org.spongepowered.asm.mixin.transformer.Proxy; import java.lang.reflect.Field; @@ -36,7 +36,6 @@ public class MixinLoader { @Inject(method = "loadMods", at = @At(value = "INVOKE", target = "Lnet/minecraftforge/fml/common/LoadController;transition(Lnet/minecraftforge/fml/common/LoaderState;Z)V", ordinal = 1), remap = false) private void beforeConstructingMods(CallbackInfo ci) { // Add all mods to class loader - for (ModContainer mod : mods) { try { modClassLoader.addFile(mod.getSource()); @@ -47,14 +46,27 @@ private void beforeConstructingMods(CallbackInfo ci) { Grimoire.instance.loadAllMixins();//Add all configs - //Reload the Mixin! Proxy mixinProxy = (Proxy) Launch.classLoader.getTransformers().stream().filter(transformer -> transformer instanceof Proxy).findFirst().get(); try { + //This will very likely break on the next major mixin release. + Class mixinTransformerClass = Class.forName("org.spongepowered.asm.mixin.transformer.MixinTransformer"); + Field transformerField = Proxy.class.getDeclaredField("transformer"); transformerField.setAccessible(true); - IMixinTransformer transformer = (IMixinTransformer) transformerField.get(mixinProxy); + Object transformer = transformerField.get(mixinProxy); + + //Get MixinProcessor from MixinTransformer + Field processorField = mixinTransformerClass.getDeclaredField("processor"); + processorField.setAccessible(true); + Object processor = processorField.get(transformer); + + Method selectConfigsMethod = MixinProcessor.class.getDeclaredMethod("selectConfigs", MixinEnvironment.class); + selectConfigsMethod.setAccessible(true); + selectConfigsMethod.invoke(processor, MixinEnvironment.getCurrentEnvironment()); - transformer.audit(MixinEnvironment.getCurrentEnvironment()); + Method prepareConfigsMethod = MixinProcessor.class.getDeclaredMethod("prepareConfigs", MixinEnvironment.class); + prepareConfigsMethod.setAccessible(true); + prepareConfigsMethod.invoke(processor, MixinEnvironment.getCurrentEnvironment()); } catch (ReflectiveOperationException e) { throw new RuntimeException(e); } diff --git a/src/main/resources/mixins/mixins.grimoire.json b/src/main/resources/mixins/mixins.grimoire.json index 7841d2c..a4f0511 100644 --- a/src/main/resources/mixins/mixins.grimoire.json +++ b/src/main/resources/mixins/mixins.grimoire.json @@ -7,7 +7,7 @@ "server": [], "client": [], "compatibilityLevel": "JAVA_8", - "minVersion": "0.7.11", + "minVersion": "0.8.0", "target": "@env(PREINIT)", "refmap":"grimoire.refmap.json" } \ No newline at end of file