From 6289b939a4acb99fe7eada170404ff7ed224b8ef Mon Sep 17 00:00:00 2001 From: dima_dencep Date: Tue, 2 Jul 2024 02:33:28 +0700 Subject: [PATCH] Hacks for embeddium --- gradle.properties | 2 +- .../mixin/SodiumExtraMixinConfigPlugin.java | 16 ++++++++++ .../sodium/embeddium/OptionGroupMixin.java | 29 +++++++++++++++++ .../sodium/embeddium/OptionImplMixin.java | 31 +++++++++++++++++++ src/main/resources/sodium-extra.mixins.json | 6 +++- 5 files changed, 82 insertions(+), 2 deletions(-) create mode 100644 src/main/java/me/flashyreese/mods/sodiumextra/mixin/sodium/embeddium/OptionGroupMixin.java create mode 100644 src/main/java/me/flashyreese/mods/sodiumextra/mixin/sodium/embeddium/OptionImplMixin.java diff --git a/gradle.properties b/gradle.properties index 90f618c88..1efdbbeff 100644 --- a/gradle.properties +++ b/gradle.properties @@ -11,7 +11,7 @@ loom.platform = neoforge minecraft_version=1.21 yarn_mappings=1.21+build.1 yarn_patch=1.21+build.4 - loader_version=21.0.45-beta + loader_version=21.0.38-beta # Mod Properties mod_version=0.5.7 diff --git a/src/main/java/me/flashyreese/mods/sodiumextra/mixin/SodiumExtraMixinConfigPlugin.java b/src/main/java/me/flashyreese/mods/sodiumextra/mixin/SodiumExtraMixinConfigPlugin.java index f10c11710..dee9ee27b 100644 --- a/src/main/java/me/flashyreese/mods/sodiumextra/mixin/SodiumExtraMixinConfigPlugin.java +++ b/src/main/java/me/flashyreese/mods/sodiumextra/mixin/SodiumExtraMixinConfigPlugin.java @@ -1,13 +1,29 @@ package me.flashyreese.mods.sodiumextra.mixin; +import com.llamalad7.mixinextras.utils.MixinInternals; import me.flashyreese.mods.sodiumextra.client.SodiumExtraClientMod; import net.caffeinemc.caffeineconfig.AbstractCaffeineConfigMixinPlugin; import net.caffeinemc.caffeineconfig.CaffeineConfig; +import org.embeddedt.embeddium.impl.taint.mixin.MixinTaintDetector; +import org.spongepowered.asm.mixin.transformer.ext.IExtension; + +import java.lang.reflect.Field; public class SodiumExtraMixinConfigPlugin extends AbstractCaffeineConfigMixinPlugin { private static final String MIXIN_PACKAGE_ROOT = "me.flashyreese.mods.sodiumextra.mixin."; + public SodiumExtraMixinConfigPlugin() { + System.setProperty("embeddium.mixinTaintEnforceLevel", "WARN"); + try { + Field instanceField = MixinTaintDetector.class.getDeclaredField("INSTANCE"); + instanceField.setAccessible(true); + MixinInternals.unregisterExtension((IExtension) instanceField.get(null)); + } catch (Throwable th) { + System.out.println("Embeddium is shit"); + } + } + @Override protected CaffeineConfig createConfig() { return SodiumExtraClientMod.mixinConfig(); diff --git a/src/main/java/me/flashyreese/mods/sodiumextra/mixin/sodium/embeddium/OptionGroupMixin.java b/src/main/java/me/flashyreese/mods/sodiumextra/mixin/sodium/embeddium/OptionGroupMixin.java new file mode 100644 index 000000000..56439d4ae --- /dev/null +++ b/src/main/java/me/flashyreese/mods/sodiumextra/mixin/sodium/embeddium/OptionGroupMixin.java @@ -0,0 +1,29 @@ +package me.flashyreese.mods.sodiumextra.mixin.sodium.embeddium; + +import org.embeddedt.embeddium.api.options.OptionIdentifier; +import org.embeddedt.embeddium.api.options.structure.OptionGroup; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +@Mixin(value = OptionGroup.Builder.class, remap = false) +public abstract class OptionGroupMixin { + @Shadow + private OptionIdentifier id; + @Shadow + public abstract OptionGroup.Builder setId(OptionIdentifier id); + + @Inject( + method = "build", + at = @At( + value = "HEAD" + ) + ) + public void embeddiumextra$fixShit(CallbackInfoReturnable cir) { + if (this.id == null) { + setId(OptionIdentifier.EMPTY); + } + } +} diff --git a/src/main/java/me/flashyreese/mods/sodiumextra/mixin/sodium/embeddium/OptionImplMixin.java b/src/main/java/me/flashyreese/mods/sodiumextra/mixin/sodium/embeddium/OptionImplMixin.java new file mode 100644 index 000000000..e83dea9f0 --- /dev/null +++ b/src/main/java/me/flashyreese/mods/sodiumextra/mixin/sodium/embeddium/OptionImplMixin.java @@ -0,0 +1,31 @@ +package me.flashyreese.mods.sodiumextra.mixin.sodium.embeddium; + +import org.embeddedt.embeddium.api.options.OptionIdentifier; +import org.embeddedt.embeddium.api.options.structure.OptionGroup; +import org.embeddedt.embeddium.api.options.structure.OptionImpl; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +@Mixin(value = OptionImpl.Builder.class, remap = false) +public abstract class OptionImplMixin { + @Shadow + private OptionIdentifier id; + + @Shadow + public abstract OptionImpl.Builder setId(OptionIdentifier id); + + @Inject( + method = "build", + at = @At( + value = "HEAD" + ) + ) + public void embeddiumextra$fixShit(CallbackInfoReturnable cir) { + if (this.id == null) { + setId((OptionIdentifier) OptionIdentifier.EMPTY); + } + } +} diff --git a/src/main/resources/sodium-extra.mixins.json b/src/main/resources/sodium-extra.mixins.json index 038a05a57..86261a948 100644 --- a/src/main/resources/sodium-extra.mixins.json +++ b/src/main/resources/sodium-extra.mixins.json @@ -48,5 +48,9 @@ ], "injectors": { "defaultRequire": 1 - } + }, + "mixins": [ + "sodium.embeddium.OptionGroupMixin", + "sodium.embeddium.OptionImplMixin" + ] }