Skip to content

Commit

Permalink
Update CCC and NEI Compat (Not working yet)
Browse files Browse the repository at this point in the history
  • Loading branch information
thecatcore committed Apr 18, 2024
1 parent d0c5e1d commit e9af0f4
Show file tree
Hide file tree
Showing 12 changed files with 304 additions and 264 deletions.
Binary file not shown.
Binary file not shown.
4 changes: 2 additions & 2 deletions mod-compat/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ dependencies {
// add the intermediary jar of the mod in rootfolder/lib with a dummy fabric.mod.json file in it
// if the file is named like "filename-fileversion.jar" then import it this way:
// modCompileOnly(group: "local", name: "filename", version: "fileversion")
modCompileOnly(group: "local", name: "CodeChickenCore", version: "0.8.1.3")
modCompileOnly(group: "local", name: "NotEnoughItems", version: "1.4.7.1")
modCompileOnly(group: "local", name: "CodeChickenCore", version: "0.8.1.6")
modCompileOnly(group: "local", name: "NotEnoughItems", version: "1.4.7.4")
}

base {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package fr.catcore.fabricatedforge.compat.mixin.codechickencore;

import codechicken.core.asm.DelegatedTransformer;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

import java.io.File;
import java.util.jar.JarFile;

@Mixin(DelegatedTransformer.class)
public class DelegatedTransformerMixin {
@Inject(method = "addTransformer", at = @At("HEAD"), remap = false)
private static void wtfDoesThisDo(String transformer, JarFile jar, File jarFile, CallbackInfo ci) {
System.out.println(transformer + " -> " + jar.getName() + " -> " + jarFile.getName());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,48 +15,48 @@

@Mixin(FeatureHackTransformer.class)
public class FeatureHackTransformerMixin {
@Shadow(remap = false)
ObfuscationMappings.DescriptorMapping f_lastBrightness;

/**
* @author CatCore
* @reason fix mappings
*/
@Overwrite(remap = false)
private byte[] transformer002(String name, byte[] bytes) {
ClassNode cnode = ASMHelper.createClassNode(bytes);
FieldNode fnode = ASMHelper.findField(this.f_lastBrightness, cnode);
if (fnode == null) {
cnode.fields.add(new FieldNode(9, this.f_lastBrightness.s_name, this.f_lastBrightness.s_desc, null, null));
MethodNode mlightmap = ASMHelper.findMethod(new ObfuscationMappings.DescriptorMapping("bfe", "a", "(IFF)V"), cnode);
InsnList hook = new InsnList();
LabelNode lend = new LabelNode();
hook.add(new VarInsnNode(21, 0));
hook.add(new ObfuscationMappings.DescriptorMapping("bfe", "b", "I").toFieldInsn(178));
hook.add(new JumpInsnNode(160, lend));
hook.add(new VarInsnNode(23, 2));
hook.add(new InsnNode(139));
hook.add(new IntInsnNode(16, 16));
hook.add(new InsnNode(120));
hook.add(new VarInsnNode(23, 1));
hook.add(new InsnNode(139));
hook.add(new InsnNode(128));
hook.add(this.f_lastBrightness.toFieldInsn(179));
hook.add(lend);
InsnList needle = new InsnList();
needle.add(new InsnNode(177));
List ret = InstructionComparator.insnListFindEnd(mlightmap.instructions, needle);
if (ret.size() != 1) {
throw new RuntimeException(
"Needle not found in Haystack: " + ASMHelper.printInsnList(mlightmap.instructions) + "\n" + ASMHelper.printInsnList(needle)
);
}

mlightmap.instructions.insertBefore((AbstractInsnNode)ret.get(0), hook);
bytes = ASMHelper.createBytes(cnode, 3);
System.out.println("Brightness hook injected");
}

return bytes;
}
// @Shadow(remap = false)
// ObfuscationMappings.DescriptorMapping f_lastBrightness;
//
// /**
// * @author CatCore
// * @reason fix mappings
// */
// @Overwrite(remap = false)
// private byte[] transformer002(String name, byte[] bytes) {
// ClassNode cnode = ASMHelper.createClassNode(bytes);
// FieldNode fnode = ASMHelper.findField(this.f_lastBrightness, cnode);
// if (fnode == null) {
// cnode.fields.add(new FieldNode(9, this.f_lastBrightness.s_name, this.f_lastBrightness.s_desc, null, null));
// MethodNode mlightmap = ASMHelper.findMethod(new ObfuscationMappings.DescriptorMapping("bfe", "a", "(IFF)V"), cnode);
// InsnList hook = new InsnList();
// LabelNode lend = new LabelNode();
// hook.add(new VarInsnNode(21, 0));
// hook.add(new ObfuscationMappings.DescriptorMapping("bfe", "b", "I").toFieldInsn(178));
// hook.add(new JumpInsnNode(160, lend));
// hook.add(new VarInsnNode(23, 2));
// hook.add(new InsnNode(139));
// hook.add(new IntInsnNode(16, 16));
// hook.add(new InsnNode(120));
// hook.add(new VarInsnNode(23, 1));
// hook.add(new InsnNode(139));
// hook.add(new InsnNode(128));
// hook.add(this.f_lastBrightness.toFieldInsn(179));
// hook.add(lend);
// InsnList needle = new InsnList();
// needle.add(new InsnNode(177));
// List ret = InstructionComparator.insnListFindEnd(mlightmap.instructions, needle);
// if (ret.size() != 1) {
// throw new RuntimeException(
// "Needle not found in Haystack: " + ASMHelper.printInsnList(mlightmap.instructions) + "\n" + ASMHelper.printInsnList(needle)
// );
// }
//
// mlightmap.instructions.insertBefore((AbstractInsnNode)ret.get(0), hook);
// bytes = ASMHelper.createBytes(cnode, 3);
// System.out.println("Brightness hook injected");
// }
//
// return bytes;
// }
}
Loading

0 comments on commit e9af0f4

Please sign in to comment.