Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/1.3.2-forge' into 1.4-forge
Browse files Browse the repository at this point in the history
# Conflicts:
#	gradle.properties
#	mod-compat/src/main/resources/fabric.mod.json
#	mod-compat/src/main/resources/fabricated-forge.mods.mixins.json
#	src/main/java/cpw/mods/fml/relauncher/RelaunchClassLoader.java
#	src/main/resources/fabric.mod.json
  • Loading branch information
thecatcore committed Aug 21, 2023
2 parents ff356e2 + a1c270a commit 5924fc5
Show file tree
Hide file tree
Showing 10 changed files with 134 additions and 16 deletions.
17 changes: 11 additions & 6 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,9 @@ allprojects {
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"

modApi("maven.modrinth:mod-remapping-api:${project.mod_remapping_api}")
// modApi(group: "local", name: "mod-remapping-api", version: "1.8.0")

modApi("maven.modrinth:spasm:${project.spasm_version}")
modApi(annotationProcessor("com.github.LlamaLad7.MixinExtras:mixinextras-fabric:${project.mixin_extras_version}"))
implementation(annotationProcessor("com.github.llamalad7.mixinextras:mixinextras-fabric:${project.mixin_extras_version}"))

implementation(group: "local", name: "argo", version: "2.25")
implementation(group: "local", name: "guava", version: "12.0.1")
Expand All @@ -69,9 +68,13 @@ allprojects {

processResources {
inputs.property "version", project.version
inputs.property "mc_version", project.minecraft_version
inputs.property "mrapi_version", project.mod_remapping_api

filesMatching("fabric.mod.json") {
expand "version": project.version
expand "version": project.version,
"mc_version": rootProject.minecraft_version,
"mrapi_version": project.mod_remapping_api
}
}

Expand Down Expand Up @@ -107,8 +110,6 @@ loom {
dependencies {
include(group: "local", name: "argo", version: "2.25")
include(group: "local", name: "guava", version: "12.0.1")

include("org.apache.commons:commons-lang3:3.12.0")
}

subprojects {
Expand Down Expand Up @@ -165,7 +166,11 @@ modrinth {
token = System.getenv("MODRINTH_TOKEN") == null ? "dev" : System.getenv("MODRINTH_TOKEN") // This is the default. Remember to have the MODRINTH_TOKEN environment variable set or else this will fail, or set it to whatever you want - just make sure it stays private!
projectId = "JpHZ1Cyv" // This can be the project ID or the slug. Either will work!
versionName = displayVersion
changelog = "Update to MRAPI 1.14.2.\nFix more compatibility issues with CodeChickenCore and NEI.\nNEI plugins still do not work for now."
changelog = """
Update MRAPI to 1.15.0.\\
ClassTransformers now run after mixins are applied on a class instead of before, improving compatibility with ClassTransformers by a lot.\\
Some more improvements on NEI Compatibility.
"""
uploadFile = remapJar
gameVersions = [project.minecraft_version] // Must be an array, even with only one version
debugMode = debug
Expand Down
8 changes: 4 additions & 4 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ org.gradle.jvmargs=-Xmx2G
loader_version = 0.14.22

# Legacy Fabric API
mod_remapping_api = 1.14.2
mod_remapping_api = 1.15.0
forge_version = 5.0.0.326
mixin_extras_version=0.2.0-beta.8
spasm_version=0.1.2
mixin_extras_version=0.2.0-beta.10
spasm_version=0.2

# Mod Properties
mod_version = 2.6.0
mod_version = 2.6.1
maven_group = fr.catcore
archives_base_name = fabricated-forge
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package fr.catcore.fabricatedforge.compat;

import net.fabricmc.loader.api.FabricLoader;
import org.objectweb.asm.ClassReader;
import org.objectweb.asm.ClassWriter;

public class BetterClassWriter extends ClassWriter {
public BetterClassWriter(int flags) {
super(flags);
}

public BetterClassWriter(ClassReader classReader, int flags) {
super(classReader, flags);
}

@Override
protected String getCommonSuperClass(String type1, String type2) {
try {
return super.getCommonSuperClass(type1, type2);
} catch (TypeNotPresentException e) {
if ("net/minecraft/class_1071".equals(type1) && "net/minecraft/class_987".equals(type2)) {
return "java/lang/Object";
}

if ("net/minecraft/class_987".equals(type1) && "java/lang/Object".equals(type2)) {
return type2;
}

System.out.println("Common of: " + type1 + " " + type2);
e.printStackTrace();
return "java/lang/Object";
}
}

@Override
protected ClassLoader getClassLoader() {
return FabricLoader.getInstance().getClass().getClassLoader();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package fr.catcore.fabricatedforge.compat;

import org.objectweb.asm.ClassReader;
import org.objectweb.asm.Opcodes;
import org.objectweb.asm.tree.ClassNode;

public class CompatUtils {
public static ClassNode createNode(byte[] bytes, int parsingOptions) {
ClassNode node = new ClassNode(Opcodes.ASM4);
ClassReader reader = new ClassReader(bytes);
reader.accept(node, parsingOptions);

return node;
}

public static byte[] writeClass(ClassNode node, int flags) {
BetterClassWriter classWriter = new BetterClassWriter(flags);
node.accept(classWriter);

return classWriter.toByteArray();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@
public class Dummy implements PreLaunchEntrypoint {
@Override
public void onPreLaunch() {
System.out.println("Gotcha Mixin!");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package fr.catcore.fabricatedforge.compat.mixin.nei;

import codechicken.core.asm.ClassHeirachyManager;
import codechicken.core.asm.InstructionComparator;
import codechicken.core.asm.ObfuscationManager;
import codechicken.nei.asm.NEITransformer;
import fr.catcore.fabricatedforge.compat.CompatUtils;
import org.objectweb.asm.ClassReader;
import org.objectweb.asm.ClassWriter;
import org.objectweb.asm.tree.ClassNode;
import org.objectweb.asm.tree.InsnList;
import org.objectweb.asm.tree.MethodNode;
import org.objectweb.asm.tree.VarInsnNode;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;

@Mixin(NEITransformer.class)
public class NEITransformerMixin {
/**
* @author CatCore
* @reason fix classwriter
*/
@Overwrite(remap = false)
public byte[] transformer001(String name, byte[] bytes) {
ObfuscationManager.ClassMapping classmap = new ObfuscationManager.ClassMapping("aqh");

if (ClassHeirachyManager.classExtends(name, classmap.classname, bytes)) {
ClassNode node = CompatUtils.createNode(bytes, 0);

ObfuscationManager.MethodMapping methodmap = new ObfuscationManager.MethodMapping("apn", "c", "()V");
ObfuscationManager.MethodMapping supermap = new ObfuscationManager.MethodMapping(node.superName, methodmap);
InsnList supercall = new InsnList();
supercall.add(new VarInsnNode(25, 0));
supercall.add(supermap.toInsn(183));

for(MethodNode methodnode : node.methods) {
if (methodmap.matches(methodnode)) {
InsnList importantNodeList = InstructionComparator.getImportantList(methodnode.instructions);

if (!InstructionComparator.insnListMatches(importantNodeList, supercall, 0)) {
methodnode.instructions.insertBefore(methodnode.instructions.getFirst(), supercall);
System.out.println("Inserted super call into " + name + "." + supermap.name);
}
}
}

bytes = CompatUtils.writeClass(node, 3);
}

return bytes;
}
}
3 changes: 1 addition & 2 deletions mod-compat/src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
"mixins": [
],
"depends": {
"fabricloader": ">0.14.3",
"mod-remapping-api": ">=1.14.2"
"fabricloader": ">0.14.3"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ default boolean handlesClass(String s, String s1) {
}

transformed.get(this).add(s);
if (s.equals("net.minecraft.class_415") && this.getClass().getName().equals("codechicken.nei.asm.NEITransformer")) return false;

return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public RelaunchClassLoader() {
public void registerTransformer(String transformerClassName) {
try {
IClassTransformer classTransformer = (IClassTransformer)Class.forName(transformerClassName).newInstance();
ClassTransformer.registerTransformer(classTransformer);
ClassTransformer.registerPostTransformer(classTransformer);
System.out.println("Registered ClassTransformer: " + transformerClassName);
this.transformers.add(classTransformer);
} catch (Exception var3) {
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
],
"depends": {
"fabricloader": ">0.14.3",
"minecraft": "1.4",
"mod-remapping-api": ">=1.14.2"
"minecraft": "${mc_version}",
"mod-remapping-api": ">=${mrapi_version}"
},
"custom": {
"loom:injected_interfaces": {
Expand Down

0 comments on commit 5924fc5

Please sign in to comment.