Skip to content

Commit

Permalink
Fix dj2addons for real
Browse files Browse the repository at this point in the history
  • Loading branch information
kappa-maintainer committed Dec 20, 2024
1 parent 782dd6c commit bb7cb1a
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 1 deletion.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ mappings_version=39-1.12
mod_id=fugue
mod_name=Fugue
mod_main_class=Fugue
mod_version=0.17.4
mod_version=0.17.5
mod_base_package=com.cleanroommc.fugue
mod_authors=kappa_maintainer
mod_description=A mod that patch dead mods for Cleanroom
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.cleanroommc.fugue.config.FugueConfig;
import com.cleanroommc.fugue.modifiers.DJ2AddonsFixer;
import com.cleanroommc.fugue.modifiers.DJ2PhaseFixer;
import com.cleanroommc.fugue.modifiers.IC2ExtraFixer;
import com.cleanroommc.fugue.transformer.advancedrocket.ClassTransformerTransformer;
import com.cleanroommc.fugue.transformer.betterfc.HK_LoaderTransformer;
Expand All @@ -11,6 +12,7 @@
import com.cleanroommc.fugue.transformer.colytra.EntityLivingBaseTransformer;
import com.cleanroommc.fugue.transformer.crossbow.TransformerEntityArrowTransformer;
import com.cleanroommc.fugue.transformer.customskinloader.ForgeTweakerTransformer;
import com.cleanroommc.fugue.transformer.dj2addons.DJ2AddonsCoreTransformer;
import com.cleanroommc.fugue.transformer.dropt.ValidatorAdapterFactoryTransformer;
import com.cleanroommc.fugue.transformer.ears.EarsASMTransformer;
import com.cleanroommc.fugue.transformer.enchantmentcontrol.EnumInputClassTransformer;
Expand Down Expand Up @@ -253,6 +255,8 @@ public static void registerTransformers() {
}
if (FugueConfig.modPatchConfig.enableDivineJourney2Addons) {
Config.registerConfigModifier(new DJ2AddonsFixer(), "mixins.dj2addons.init.json");
Config.registerConfigModifier(new DJ2PhaseFixer(), "mixins.dj2addons.json");
TransformerDelegate.registerExplicitTransformer(new DJ2AddonsCoreTransformer(), "org.btpos.dj2addons.core.DJ2AddonsCore");
}

if (FugueConfig.getCodeSourcePatchTargets.length > 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ public class ModPatchConfig {
public boolean enableBetterPortals = true;
@Config.Name("Enable Essential Patch")
public boolean enableEssential = true;
@Config.Comment("Only use with dj2addons 1.2.1.1 or lower")
@Config.Name("Enable Divine Journey 2 Addons Patch")
public boolean enableDivineJourney2Addons = true;
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.cleanroommc.fugue.modifiers;

import org.spongepowered.asm.mixin.Mixins;
import org.spongepowered.asm.mixin.extensibility.IMixinConfigModifier;

import java.util.List;
Expand All @@ -8,6 +9,7 @@ public class DJ2AddonsFixer implements IMixinConfigModifier {
@Override
public List<String> modifyMixinClasses(List<String> list) {
list.removeIf(s -> s.endsWith("MLoader"));
Mixins.addConfiguration("mixins.dj2addons.json");
return list;
}
}
11 changes: 11 additions & 0 deletions src/main/java/com/cleanroommc/fugue/modifiers/DJ2PhaseFixer.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.cleanroommc.fugue.modifiers;

import org.spongepowered.asm.mixin.MixinEnvironment;
import org.spongepowered.asm.mixin.extensibility.IMixinConfigModifier;

public class DJ2PhaseFixer implements IMixinConfigModifier {

public MixinEnvironment modifyEnvironment(MixinEnvironment environment) {
return MixinEnvironment.getEnvironment(MixinEnvironment.Phase.MOD);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.cleanroommc.fugue.transformer.dj2addons;

import com.cleanroommc.fugue.common.Fugue;
import javassist.ClassPool;
import javassist.CtClass;
import top.outlands.foundation.IExplicitTransformer;

import java.io.ByteArrayInputStream;

public class DJ2AddonsCoreTransformer implements IExplicitTransformer {
@Override
public byte[] transform(byte[] bytes) {
try {
CtClass cc = ClassPool.getDefault().makeClass(new ByteArrayInputStream(bytes));
cc.getDeclaredMethod("verifyCoreLoaded").setBody("{}");
bytes = cc.toBytecode();
} catch (Throwable t) {
Fugue.LOGGER.error("Exception {} on {}", t, this.getClass().getSimpleName());
}
return bytes;
}
}

0 comments on commit bb7cb1a

Please sign in to comment.