generated from Legacy-Fabric/fabric-example-mod
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CodeChickenCore and NEI compat for 1.4.2
Please use CCC 0.6.6.2 and NEI 1.4.1.2 as more recent versions are broken.
- Loading branch information
1 parent
7b3d29b
commit 576ad27
Showing
19 changed files
with
290 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,14 @@ | ||
//project.name = "fabricated-forge-mod-compat" | ||
|
||
dependencies { | ||
// How to add a mod | ||
// 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.6.12") | ||
modCompileOnly(group: "local", name: "NotEnoughItems", version: "1.4.2.1") | ||
} | ||
|
||
base { | ||
archivesName = "fabricated-forge-mod-compat" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
...va/fr/catcore/fabricatedforge/compat/mixin/codechickencore/ClassHeirachyManagerMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package fr.catcore.fabricatedforge.compat.mixin.codechickencore; | ||
|
||
import codechicken.core.asm.ClassHeirachyManager; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Redirect; | ||
|
||
@Mixin(ClassHeirachyManager.class) | ||
public class ClassHeirachyManagerMixin { | ||
@Redirect(method = "classExtends(Ljava/lang/String;Ljava/lang/String;)Z", at = @At(value = "INVOKE", target = "Ljava/lang/Class;forName(Ljava/lang/String;)Ljava/lang/Class;", remap = false), remap = false) | ||
private static Class<?> fixClassExtends(String className) throws ClassNotFoundException { | ||
return Class.forName(className, false, ClassHeirachyManager.class.getClassLoader()); | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
.../main/java/fr/catcore/fabricatedforge/compat/mixin/codechickencore/ClassMappingMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package fr.catcore.fabricatedforge.compat.mixin.codechickencore; | ||
|
||
import codechicken.core.asm.ObfuscationManager; | ||
import fr.catcore.fabricatedforge.Constants; | ||
import fr.catcore.fabricatedforge.compat.nei.NEIFixer; | ||
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.CallbackInfo; | ||
|
||
@Mixin(ObfuscationManager.ClassMapping.class) | ||
public class ClassMappingMixin { | ||
@Shadow(remap = false) public String classname; | ||
|
||
@Inject(method = "<init>", remap = false, at = @At("RETURN")) | ||
private void remapClassName(String classname, CallbackInfo ci) { | ||
if (NEIFixer.FIX_CLASSES.containsKey(classname)) { | ||
this.classname = NEIFixer.FIX_CLASSES.get(classname); | ||
} else if (!this.classname.contains(".")) { | ||
this.classname = Constants.getRemappedClassName(this.classname); | ||
} | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
...ain/java/fr/catcore/fabricatedforge/compat/mixin/codechickencore/ClassOverriderMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package fr.catcore.fabricatedforge.compat.mixin.codechickencore; | ||
|
||
import codechicken.core.asm.ClassOverrider; | ||
import codechicken.core.asm.ObfuscationManager; | ||
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.CallbackInfoReturnable; | ||
|
||
import java.io.File; | ||
|
||
@Mixin(ClassOverrider.class) | ||
public class ClassOverriderMixin { | ||
@Inject(method = "overrideBytes", remap = false, at = @At("HEAD"), cancellable = true) | ||
private static void disableClassOverwriting(String name, byte[] bytes, ObfuscationManager.ClassMapping classMapping, File location, CallbackInfoReturnable<byte[]> cir) { | ||
if (classMapping.classname.equals(name)) { | ||
System.out.println("[ClassOverrider] Canceled class overwrite of " + name); | ||
} | ||
|
||
cir.setReturnValue(bytes); | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
.../main/java/fr/catcore/fabricatedforge/compat/mixin/codechickencore/FieldMappingMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package fr.catcore.fabricatedforge.compat.mixin.codechickencore; | ||
|
||
import codechicken.core.asm.ObfuscationManager; | ||
import fr.catcore.fabricatedforge.Constants; | ||
import net.fabricmc.tinyremapper.extension.mixin.common.data.Pair; | ||
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.CallbackInfo; | ||
|
||
@Mixin(ObfuscationManager.FieldMapping.class) | ||
public class FieldMappingMixin { | ||
@Shadow(remap = false) public String owner; | ||
|
||
@Shadow(remap = false) public String name; | ||
|
||
@Shadow(remap = false) public String type; | ||
|
||
@Inject(method = "<init>", at = @At("RETURN"), remap = false) | ||
private void remap(String declaringclass, String fieldname, String type, CallbackInfo ci) { | ||
if (!this.owner.contains(".")) { | ||
this.owner = Constants.getRemappedClassName(this.owner); | ||
} | ||
Pair<String, String> pair = Constants.getRemappedFieldName(this.owner, this.name, this.type); | ||
this.name = pair.first(); | ||
this.type = pair.second(); | ||
} | ||
} |
54 changes: 54 additions & 0 deletions
54
...main/java/fr/catcore/fabricatedforge/compat/mixin/codechickencore/MethodMappingMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package fr.catcore.fabricatedforge.compat.mixin.codechickencore; | ||
|
||
import codechicken.core.asm.ObfuscationManager; | ||
import fr.catcore.fabricatedforge.Constants; | ||
import fr.catcore.fabricatedforge.compat.nei.NEIFixer; | ||
import net.fabricmc.tinyremapper.extension.mixin.common.data.Pair; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Shadow; | ||
import org.spongepowered.asm.mixin.Unique; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
|
||
@Mixin(ObfuscationManager.MethodMapping.class) | ||
public class MethodMappingMixin { | ||
@Shadow(remap = false) public String owner; | ||
|
||
@Shadow(remap = false) public String name; | ||
|
||
@Shadow(remap = false) public String desc; | ||
|
||
@Inject(method = "<init>(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V", remap = false, at = @At("RETURN")) | ||
private void remap(String declaringclass, String methodname, String descriptor, CallbackInfo ci) { | ||
this.remap(); | ||
} | ||
|
||
@Inject(method = "<init>(Ljava/lang/String;Lcodechicken/core/asm/ObfuscationManager$MethodMapping;)V", remap = false, at = @At("RETURN")) | ||
private void remap(String declaringclass, ObfuscationManager.MethodMapping methodmap, CallbackInfo ci) { | ||
this.remap(); | ||
} | ||
|
||
@Unique | ||
private void remap() { | ||
if (NEIFixer.FIX_CLASSES.containsKey(this.owner)) { | ||
this.owner = NEIFixer.FIX_CLASSES.get(this.owner); | ||
} else if (!this.owner.contains(".")) { | ||
this.owner = Constants.getRemappedClassName(this.owner); | ||
} | ||
|
||
Pair<String, String> pair = Constants.getRemappedMethodName(this.owner, this.name, this.desc); | ||
|
||
if (NEIFixer.FIX_METHOD_NAMES.containsKey(this.name)) { | ||
this.name = NEIFixer.FIX_METHOD_NAMES.get(this.name); | ||
} else { | ||
this.name = pair.first(); | ||
} | ||
|
||
if (NEIFixer.FIX_METHOD_ARGS.containsKey(this.desc)) { | ||
this.desc = NEIFixer.FIX_METHOD_ARGS.get(this.desc); | ||
} else { | ||
this.desc = pair.second(); | ||
} | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
.../src/main/java/fr/catcore/fabricatedforge/compat/mixin/nei/FurnaceRecipeHandlerMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package fr.catcore.fabricatedforge.compat.mixin.nei; | ||
|
||
import codechicken.nei.recipe.FurnaceRecipeHandler; | ||
import fr.catcore.modremapperapi.remapping.RemapUtil; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Redirect; | ||
|
||
import java.lang.reflect.Method; | ||
|
||
@Mixin(FurnaceRecipeHandler.class) | ||
public class FurnaceRecipeHandlerMixin { | ||
@Redirect(method = "findFuels", remap = false, at = @At(value = "INVOKE", target = "Ljava/lang/Class;getDeclaredMethod(Ljava/lang/String;[Ljava/lang/Class;)Ljava/lang/reflect/Method;")) | ||
private static Method fixFindFuels(Class<?> instance, String name, Class<?>[] parameterTypes) throws NoSuchMethodException { | ||
name = RemapUtil.getRemappedMethodName(instance, name, parameterTypes); | ||
|
||
return instance.getDeclaredMethod(name, parameterTypes); | ||
} | ||
} |
Oops, something went wrong.