mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-23 21:49:46 +00:00
Add coremod that injects bouncer methods to work around name conflicts with official names.
Fixes a binary break.
This commit is contained in:
1 parent
0ad8e2c27f
commit
5f9e6f3b56
2 files changed
+45
-1
No files matched your search
@@ -1,4 +1,5 @@
|
||||
{
|
||||
"fieldtomethodtransformers": "META-INF/fieldtomethodtransformers.js",
|
||||
"field_to_instanceof": "coremods/field_to_instanceof.js"
|
||||
"field_to_instanceof": "coremods/field_to_instanceof.js",
|
||||
"add_bouncer_method": "coremods/add_bouncer_method.js"
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
var ASMAPI = Java.type('net.minecraftforge.coremod.api.ASMAPI')
|
||||
var Opcodes = Java.type('org.objectweb.asm.Opcodes')
|
||||
|
||||
function initializeCoreMod() {
|
||||
return {
|
||||
"getLanguage_bouncer": addBouncer("net.minecraft.network.play.client.CClientSettingsPacket", "getLanguage", "func_227987_b_ ", false, "()V"),
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: hasArg -> compute actual list of arg instructions?
|
||||
function addBouncer(className, conflictingName, srgName, hasArg, descriptor, signature) {
|
||||
if (signature == null)
|
||||
signature = descriptor;
|
||||
return {
|
||||
'target': {
|
||||
'type': 'CLASS',
|
||||
'name': className
|
||||
},
|
||||
'transformer': function(node) {
|
||||
var mappedName = ASMAPI.mapMethod(srgName);
|
||||
if (mappedName == conflictingName)
|
||||
return; // No work to do!
|
||||
|
||||
var method = new MethodNode(
|
||||
/* access = */ Opcodes.ACC_PUBLIC,
|
||||
/* name = */ mappedName,
|
||||
/* descriptor = */ descriptor,
|
||||
/* signature = */ signature,
|
||||
/* exceptions = */ null
|
||||
);
|
||||
|
||||
method.instructions.add(new VarInsnNode(Opcodes.ALOAD, 0)); /*this*/
|
||||
if (hasArg)
|
||||
method.instructions.add(new VarInsnNode(Opcodes.ALOAD, 1)); /*first arg*/
|
||||
method.instructions.add(new MethodInsnNode(Opcodes.INVOKEVIRTUAL, className.replace(".","/"), mappedName, descriptor));
|
||||
method.instructions.add(new InsnNode(Opcodes.RETURN));
|
||||
|
||||
classNode.methods.add(method);
|
||||
|
||||
return classNode;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user