Skip to content

Commit

Permalink
Hacks for embeddium
Browse files Browse the repository at this point in the history
  • Loading branch information
dima-dencep committed Jul 1, 2024
1 parent 23cb4e4 commit 6289b93
Show file tree
Hide file tree
Showing 5 changed files with 82 additions and 2 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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();
Expand Down
Original file line number Diff line number Diff line change
@@ -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<Void> id;
@Shadow
public abstract OptionGroup.Builder setId(OptionIdentifier<Void> id);

@Inject(
method = "build",
at = @At(
value = "HEAD"
)
)
public void embeddiumextra$fixShit(CallbackInfoReturnable<OptionGroup> cir) {
if (this.id == null) {
setId(OptionIdentifier.EMPTY);
}
}
}
Original file line number Diff line number Diff line change
@@ -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<S, T> {
@Shadow
private OptionIdentifier<T> id;

@Shadow
public abstract OptionImpl.Builder<S, T> setId(OptionIdentifier<T> id);

@Inject(
method = "build",
at = @At(
value = "HEAD"
)
)
public void embeddiumextra$fixShit(CallbackInfoReturnable<OptionGroup> cir) {
if (this.id == null) {
setId((OptionIdentifier<T>) OptionIdentifier.EMPTY);
}
}
}
6 changes: 5 additions & 1 deletion src/main/resources/sodium-extra.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,9 @@
],
"injectors": {
"defaultRequire": 1
}
},
"mixins": [
"sodium.embeddium.OptionGroupMixin",
"sodium.embeddium.OptionImplMixin"
]
}

0 comments on commit 6289b93

Please sign in to comment.