Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add dev mappings to ASM transformers #173

Merged
merged 1 commit into from
Mar 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
fix: add dev mappings to ASM transformers
  • Loading branch information
My-Name-Is-Jeff committed Mar 10, 2024

Unverified

This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
commit 11c9fee35aa28a683dd5217dabcfceabe1ce64c8
Original file line number Diff line number Diff line change
@@ -38,7 +38,7 @@ public void transform(ClassNode classNode, String name) {
if (next instanceof MethodInsnNode && next.getOpcode() == Opcodes.INVOKEVIRTUAL) {
final String methodInsnName = mapMethodNameFromNode(next);
if (methodInsnName.equals("getY") || methodInsnName.equals("func_177956_o")) {
((MethodInsnNode) next).name = "func_177952_p"; // getZ
((MethodInsnNode) next).name = isDevelopment() ? "getZ" : "func_177952_p";
break;
}
}
Original file line number Diff line number Diff line change
@@ -41,7 +41,7 @@ public void transform(ClassNode classNode, String name) {
// auto-closing stream
if (next instanceof MethodInsnNode && ((MethodInsnNode) next).name.equals("read")) {
((MethodInsnNode) next).owner = "net/minecraft/client/renderer/texture/TextureUtil";
((MethodInsnNode) next).name = "func_177053_a"; // readBufferedImage
((MethodInsnNode) next).name = isDevelopment() ? "readBufferedImage" : "func_177053_a";
((MethodInsnNode) next).desc = "(Ljava/io/InputStream;)Ljava/awt/image/BufferedImage;";
break;
}
Original file line number Diff line number Diff line change
@@ -34,26 +34,26 @@ public void transform(ClassNode classNode, String name) {
}
}
} else if (next instanceof VarInsnNode && next.getOpcode() == Opcodes.ISTORE && ((VarInsnNode) next).var == 17) {
methodNode.instructions.insert(next, new MethodInsnNode(Opcodes.INVOKESTATIC, "net/minecraft/client/renderer/GlStateManager", "func_179097_i", "()V", false));
methodNode.instructions.insert(next, new MethodInsnNode(Opcodes.INVOKESTATIC, "net/minecraft/client/renderer/GlStateManager", isDevelopment() ? "disableDepth" : "func_179097_i", "()V", false));
}
}

methodNode.instructions.insert(getMoveForward());
methodNode.instructions.insertBefore(
methodNode.instructions.getLast().getPrevious(),
new MethodInsnNode(Opcodes.INVOKESTATIC, "net/minecraft/client/renderer/GlStateManager", "func_179121_F", "()V", false)
new MethodInsnNode(Opcodes.INVOKESTATIC, "net/minecraft/client/renderer/GlStateManager", isDevelopment() ? "popMatrix" : "func_179121_F", "()V", false)
);
}
}
}

private InsnList getMoveForward() {
InsnList insnList = new InsnList();
insnList.add(new MethodInsnNode(Opcodes.INVOKESTATIC, "net/minecraft/client/renderer/GlStateManager", "func_179094_E", "()V", false));
insnList.add(new MethodInsnNode(Opcodes.INVOKESTATIC, "net/minecraft/client/renderer/GlStateManager", isDevelopment() ? "pushMatrix" : "func_179094_E", "()V", false));
insnList.add(new LdcInsnNode(0F));
insnList.add(new LdcInsnNode(0F));
insnList.add(new LdcInsnNode(-1F));
insnList.add(new MethodInsnNode(Opcodes.INVOKESTATIC, "net/minecraft/client/renderer/GlStateManager", "func_179109_b", "(FFF)V", false));
insnList.add(new MethodInsnNode(Opcodes.INVOKESTATIC, "net/minecraft/client/renderer/GlStateManager", isDevelopment() ? "translate" : "func_179109_b", "(FFF)V", false));
return insnList;
}
}
Original file line number Diff line number Diff line change
@@ -48,8 +48,8 @@ public void transform(ClassNode classNode, String name) {
private InsnList optimizeReflection() {
InsnList list = new InsnList();
list.add(new VarInsnNode(Opcodes.ALOAD, 0));
list.add(new FieldInsnNode(Opcodes.GETFIELD, "net/minecraft/client/renderer/EntityRenderer", "field_78531_r", "Lnet/minecraft/client/Minecraft;"));
list.add(new FieldInsnNode(Opcodes.GETFIELD, "net/minecraft/client/Minecraft", "field_71462_r", "Lnet/minecraft/client/gui/GuiScreen;"));
list.add(new FieldInsnNode(Opcodes.GETFIELD, "net/minecraft/client/renderer/EntityRenderer", isDevelopment() ? "mc" : "field_78531_r", "Lnet/minecraft/client/Minecraft;"));
list.add(new FieldInsnNode(Opcodes.GETFIELD, "net/minecraft/client/Minecraft", isDevelopment() ? "currentScreen" : "field_71462_r", "Lnet/minecraft/client/gui/GuiScreen;"));
list.add(new VarInsnNode(Opcodes.ILOAD, 8));
list.add(new VarInsnNode(Opcodes.ILOAD, 9));
list.add(new VarInsnNode(Opcodes.FLOAD, 1));
Original file line number Diff line number Diff line change
@@ -16,7 +16,7 @@ public String[] getClassName() {
public void transform(ClassNode classNode, String name) {
for (MethodNode methodNode : classNode.methods) {
final String methodName = mapMethodName(classNode, methodNode);
if (methodName.equals("func_177484_a")) {
if (methodName.equals("set") || methodName.equals("func_177484_a")) {
final InsnList instructions = methodNode.instructions;
final Iterator<AbstractInsnNode> iterator = instructions.iterator();
while (iterator.hasNext()) {
Original file line number Diff line number Diff line change
@@ -45,7 +45,7 @@ public void transform(ClassNode classNode, String name) {
private InsnList checkVisibility() {
InsnList list = new InsnList();
list.add(new VarInsnNode(Opcodes.ALOAD, 0));
list.add(new MethodInsnNode(Opcodes.INVOKEVIRTUAL, "net/minecraft/entity/boss/EntityWither", "func_82150_aj", "()Z", false));
list.add(new MethodInsnNode(Opcodes.INVOKEVIRTUAL, "net/minecraft/entity/boss/EntityWither", isDevelopment() ? "isInvisible" : "func_82150_aj", "()Z", false));
LabelNode ifeq = new LabelNode();
list.add(new JumpInsnNode(Opcodes.IFEQ, ifeq));
list.add(new InsnNode(Opcodes.RETURN));
Original file line number Diff line number Diff line change
@@ -46,15 +46,15 @@ public void transform(ClassNode classNode, String name) {
}
}

public static InsnList checkMapBytesLength() {
public InsnList checkMapBytesLength() {
InsnList list = new InsnList();

LabelNode checkSize = new LabelNode();
list.add(new VarInsnNode(Opcodes.ALOAD, 0));
list.add(new FieldInsnNode(
Opcodes.GETFIELD,
"net/minecraft/network/play/server/S34PacketMaps",
"field_179741_h",
isDevelopment() ? "mapDataBytes" : "field_179741_h",
"[B"
));
list.add(new InsnNode(Opcodes.DUP));
Original file line number Diff line number Diff line change
@@ -58,15 +58,15 @@ private InsnList reassignRotation() {
list.add(new LdcInsnNode(0.017453292F));
list.add(new VarInsnNode(Opcodes.FSTORE, 3));
// actual fix for mc-74764
list.add(new MethodInsnNode(Opcodes.INVOKESTATIC, "net/minecraft/client/renderer/ActiveRenderInfo", "func_178808_b", "()F", false));
list.add(new MethodInsnNode(Opcodes.INVOKESTATIC, "net/minecraft/client/renderer/ActiveRenderInfo", isDevelopment() ? "getRotationX" : "func_178808_b", "()F", false));
list.add(new VarInsnNode(Opcodes.FSTORE, 4));
list.add(new MethodInsnNode(Opcodes.INVOKESTATIC, "net/minecraft/client/renderer/ActiveRenderInfo", "func_178803_d", "()F", false));
list.add(new MethodInsnNode(Opcodes.INVOKESTATIC, "net/minecraft/client/renderer/ActiveRenderInfo", isDevelopment() ? "getRotationZ" : "func_178803_d", "()F", false));
list.add(new VarInsnNode(Opcodes.FSTORE, 5));
list.add(new MethodInsnNode(Opcodes.INVOKESTATIC, "net/minecraft/client/renderer/ActiveRenderInfo", "func_178805_e", "()F", false));
list.add(new MethodInsnNode(Opcodes.INVOKESTATIC, "net/minecraft/client/renderer/ActiveRenderInfo", isDevelopment() ? "getRotationYZ" : "func_178805_e", "()F", false));
list.add(new VarInsnNode(Opcodes.FSTORE, 6));
list.add(new MethodInsnNode(Opcodes.INVOKESTATIC, "net/minecraft/client/renderer/ActiveRenderInfo", "func_178807_f", "()F", false));
list.add(new MethodInsnNode(Opcodes.INVOKESTATIC, "net/minecraft/client/renderer/ActiveRenderInfo", isDevelopment() ? "getRotationXY" : "func_178807_f", "()F", false));
list.add(new VarInsnNode(Opcodes.FSTORE, 7));
list.add(new MethodInsnNode(Opcodes.INVOKESTATIC, "net/minecraft/client/renderer/ActiveRenderInfo", "func_178809_c", "()F", false));
list.add(new MethodInsnNode(Opcodes.INVOKESTATIC, "net/minecraft/client/renderer/ActiveRenderInfo", isDevelopment() ? "getRotationXZ" : "func_178809_c", "()F", false));
list.add(new VarInsnNode(Opcodes.FSTORE, 8));
return list;
}
Original file line number Diff line number Diff line change
@@ -158,15 +158,15 @@ private InsnList checkChat(LabelNode gotoInsn) {
LabelNode ifne = new LabelNode();
list.add(new JumpInsnNode(Opcodes.IFNE, ifne));
list.add(new VarInsnNode(Opcodes.ALOAD, 0));
list.add(new FieldInsnNode(Opcodes.GETFIELD, "net/minecraft/client/gui/GuiChat", "field_146297_k", "Lnet/minecraft/client/Minecraft;"));
list.add(new FieldInsnNode(Opcodes.GETFIELD, "net/minecraft/client/gui/GuiChat", isDevelopment() ? "mc" : "field_146297_k", "Lnet/minecraft/client/Minecraft;"));
list.add(new InsnNode(Opcodes.ACONST_NULL));
list.add(new MethodInsnNode(Opcodes.INVOKEVIRTUAL, "net/minecraft/client/Minecraft", "func_147108_a", "(Lnet/minecraft/client/gui/GuiScreen;)V", false));
list.add(new MethodInsnNode(Opcodes.INVOKEVIRTUAL, "net/minecraft/client/Minecraft", isDevelopment() ? "displayGuiScreen" : "func_147108_a", "(Lnet/minecraft/client/gui/GuiScreen;)V", false));
list.add(new JumpInsnNode(Opcodes.GOTO, gotoInsn));
list.add(ifne);
list.add(new VarInsnNode(Opcodes.ALOAD, 0));
list.add(new FieldInsnNode(Opcodes.GETFIELD, "net/minecraft/client/gui/GuiChat", "field_146415_a", "Lnet/minecraft/client/gui/GuiTextField;"));
list.add(new FieldInsnNode(Opcodes.GETFIELD, "net/minecraft/client/gui/GuiChat", isDevelopment() ? "inputField" : "field_146415_a", "Lnet/minecraft/client/gui/GuiTextField;"));
list.add(new LdcInsnNode(""));
list.add(new MethodInsnNode(Opcodes.INVOKEVIRTUAL, "net/minecraft/client/gui/GuiTextField", "func_146180_a", "(Ljava/lang/String;)V", false));
list.add(new MethodInsnNode(Opcodes.INVOKEVIRTUAL, "net/minecraft/client/gui/GuiTextField", isDevelopment() ? "setText" : "func_146180_a", "(Ljava/lang/String;)V", false));
list.add(new JumpInsnNode(Opcodes.GOTO, gotoInsn));
list.add(ifeq);
return list;
@@ -180,16 +180,16 @@ private InsnList setText() {
list.add(new VarInsnNode(Opcodes.ALOAD, 0));
list.add(new FieldInsnNode(Opcodes.GETFIELD,
"net/minecraft/client/gui/GuiChat",
"field_146415_a", // inputField
isDevelopment() ? "inputField" : "field_146415_a",
"Lnet/minecraft/client/gui/GuiTextField;"));
list.add(new VarInsnNode(Opcodes.ALOAD, 0));
list.add(new FieldInsnNode(Opcodes.GETFIELD,
"net/minecraft/client/gui/GuiChat",
"field_146409_v", // defaultInputFieldText
isDevelopment() ? "defaultInputFieldText" : "field_146409_v",
"Ljava/lang/String;"));
list.add(new MethodInsnNode(Opcodes.INVOKEVIRTUAL,
"net/minecraft/client/gui/GuiTextField",
"func_146180_a", // setText
isDevelopment() ? "setText" : "func_146180_a",
"(Ljava/lang/String;)V",
false));
LabelNode gotoInsn = new LabelNode();
@@ -198,12 +198,12 @@ private InsnList setText() {
list.add(new VarInsnNode(Opcodes.ALOAD, 0));
list.add(new FieldInsnNode(Opcodes.GETFIELD,
"net/minecraft/client/gui/GuiChat",
"field_146415_a", // inputField
isDevelopment() ? "inputField" : "field_146415_a",
"Lnet/minecraft/client/gui/GuiTextField;"));
list.add(new VarInsnNode(Opcodes.ALOAD, 2));
list.add(new MethodInsnNode(Opcodes.INVOKEVIRTUAL,
"net/minecraft/client/gui/GuiTextField",
"func_146180_a", // setText
isDevelopment() ? "setText" : "func_146180_a",
"(Ljava/lang/String;)V",
false));
list.add(gotoInsn);
@@ -215,7 +215,7 @@ private InsnList createWasInitBefore() {
list.add(new VarInsnNode(Opcodes.ALOAD, 0));
list.add(new FieldInsnNode(Opcodes.GETFIELD,
"net/minecraft/client/gui/GuiChat",
"field_146415_a", // inputField
isDevelopment() ? "inputField" : "field_146415_a",
"Lnet/minecraft/client/gui/GuiTextField;"));
LabelNode ifnull = new LabelNode();
list.add(new JumpInsnNode(Opcodes.IFNULL, ifnull));
@@ -232,11 +232,11 @@ private InsnList createWasInitBefore() {
list.add(new VarInsnNode(Opcodes.ALOAD, 0));
list.add(new FieldInsnNode(Opcodes.GETFIELD,
"net/minecraft/client/gui/GuiChat",
"field_146415_a", // inputField
isDevelopment() ? "inputField" : "field_146415_a",
"Lnet/minecraft/client/gui/GuiTextField;"));
list.add(new MethodInsnNode(Opcodes.INVOKEVIRTUAL,
"net/minecraft/client/gui/GuiTextField",
"func_146179_b", // getText
isDevelopment() ? "getText" : "func_146179_b",
"()Ljava/lang/String;",
false));
LabelNode gotoInsn2 = new LabelNode();
@@ -251,7 +251,7 @@ private InsnList createWasInitBefore() {
private InsnList getOption(LabelNode ifne) {
InsnList list = new InsnList();
list.add(new VarInsnNode(Opcodes.ALOAD, 0));
list.add(new MethodInsnNode(Opcodes.INVOKESTATIC, "net/minecraft/client/gui/GuiChat", "func_146272_n", "()Z", false));
list.add(new MethodInsnNode(Opcodes.INVOKESTATIC, "net/minecraft/client/gui/GuiChat", isDevelopment() ? "isShiftKeyDown" : "func_146272_n", "()Z", false));
list.add(new FieldInsnNode(Opcodes.PUTFIELD, "net/minecraft/client/gui/GuiChat", "holdingShift", "Z"));
list.add(getPatcherSetting("transparentChatInputField", "Z"));
list.add(new JumpInsnNode(Opcodes.IFNE, ifne));
Original file line number Diff line number Diff line change
@@ -64,15 +64,15 @@ private InsnList newEffectLogic() {
list.add(new JumpInsnNode(Opcodes.IFEQ, ifeq));
list.add(new VarInsnNode(Opcodes.ALOAD, 0));
list.add(new VarInsnNode(Opcodes.ALOAD, 0));
list.add(new FieldInsnNode(Opcodes.GETFIELD, "net/minecraft/client/renderer/InventoryEffectRenderer", "field_146294_l", // width
list.add(new FieldInsnNode(Opcodes.GETFIELD, "net/minecraft/client/renderer/InventoryEffectRenderer", isDevelopment() ? "width" : "field_146294_l",
"I"));
list.add(new VarInsnNode(Opcodes.ALOAD, 0));
list.add(new FieldInsnNode(Opcodes.GETFIELD, "net/minecraft/client/renderer/InventoryEffectRenderer", "field_146999_f", // xSize
list.add(new FieldInsnNode(Opcodes.GETFIELD, "net/minecraft/client/renderer/InventoryEffectRenderer", isDevelopment() ? "xSize" : "field_146999_f",
"I"));
list.add(new InsnNode(Opcodes.ISUB));
list.add(new InsnNode(Opcodes.ICONST_2));
list.add(new InsnNode(Opcodes.IDIV));
list.add(new FieldInsnNode(Opcodes.PUTFIELD, "net/minecraft/client/renderer/InventoryEffectRenderer", "field_147003_i", // guiLeft
list.add(new FieldInsnNode(Opcodes.PUTFIELD, "net/minecraft/client/renderer/InventoryEffectRenderer", isDevelopment() ? "guiLeft" : "field_147003_i",
"I"));
list.add(new InsnNode(Opcodes.RETURN));
list.add(ifeq);
Original file line number Diff line number Diff line change
@@ -76,12 +76,12 @@ public void transform(ClassNode classNode, String name) {
if (next.getOpcode() == Opcodes.INVOKEVIRTUAL) {
if (methodInsnName.equals("getClosestDistance") || methodInsnName.equals("func_177729_b")) {
methodNode.instructions.insertBefore(next.getPrevious().getPrevious().getPrevious(),
new MethodInsnNode(Opcodes.INVOKESTATIC, "net/minecraft/client/renderer/GlStateManager", "func_179106_n", "()V", false));
new MethodInsnNode(Opcodes.INVOKESTATIC, "net/minecraft/client/renderer/GlStateManager", isDevelopment() ? "disableFog" : "func_179106_n", "()V", false));
}
} else if (next.getOpcode() == Opcodes.INVOKESTATIC) {
if ((methodInsnName.equals("depthMask") || methodInsnName.equals("func_179132_a")) && next.getPrevious().getOpcode() == Opcodes.ICONST_1) {
methodNode.instructions.insert(next,
new MethodInsnNode(Opcodes.INVOKESTATIC, "net/minecraft/client/renderer/GlStateManager", "func_179127_m", "()V", false)
new MethodInsnNode(Opcodes.INVOKESTATIC, "net/minecraft/client/renderer/GlStateManager", isDevelopment() ? "enableFog" : "func_179127_m", "()V", false)
);
}
}
Original file line number Diff line number Diff line change
@@ -38,7 +38,7 @@ public void transform(ClassNode classNode, String name) {
for (MethodNode methodNode : classNode.methods) {
String methodName = mapMethodName(classNode, methodNode);

MethodInsnNode disableBlend = new MethodInsnNode(Opcodes.INVOKESTATIC, "net/minecraft/client/renderer/GlStateManager", "func_179084_k", "()V", false);
MethodInsnNode disableBlend = new MethodInsnNode(Opcodes.INVOKESTATIC, "net/minecraft/client/renderer/GlStateManager", isDevelopment() ? "disableBlend" : "func_179084_k", "()V", false);
switch (methodName) {
//#if MC==10809
case "renderRightArm":
@@ -110,18 +110,18 @@ private InsnList checkHatLayer() {
InsnList list = new InsnList();
list.add(new VarInsnNode(Opcodes.ALOAD, 1));
list.add(new FieldInsnNode(Opcodes.GETSTATIC, "net/minecraft/entity/player/EnumPlayerModelParts", "HAT", "Lnet/minecraft/entity/player/EnumPlayerModelParts;"));
list.add(new MethodInsnNode(Opcodes.INVOKEVIRTUAL, "net/minecraft/client/entity/AbstractClientPlayer", "func_175148_a", "(Lnet/minecraft/entity/player/EnumPlayerModelParts;)Z", false));
list.add(new MethodInsnNode(Opcodes.INVOKEVIRTUAL, "net/minecraft/client/entity/AbstractClientPlayer", isDevelopment() ? "func_175148_a" : "isWearing", "(Lnet/minecraft/entity/player/EnumPlayerModelParts;)Z", false));
return list;
}

public static InsnList enableBlend() {
public InsnList enableBlend() {
InsnList list = new InsnList();
list.add(new MethodInsnNode(Opcodes.INVOKESTATIC, "net/minecraft/client/renderer/GlStateManager", "func_179147_l", "()V", false));
list.add(new MethodInsnNode(Opcodes.INVOKESTATIC, "net/minecraft/client/renderer/GlStateManager", isDevelopment() ? "enableBlend" : "func_179147_l", "()V", false));
list.add(new IntInsnNode(Opcodes.SIPUSH, GL11.GL_SRC_ALPHA));
list.add(new IntInsnNode(Opcodes.SIPUSH, GL11.GL_ONE_MINUS_SRC_ALPHA));
list.add(new InsnNode(Opcodes.ICONST_1));
list.add(new InsnNode(Opcodes.ICONST_0));
list.add(new MethodInsnNode(Opcodes.INVOKESTATIC, "net/minecraft/client/renderer/GlStateManager", "func_179120_a", "(IIII)V", false));
list.add(new MethodInsnNode(Opcodes.INVOKESTATIC, "net/minecraft/client/renderer/GlStateManager", isDevelopment() ? "tryBlendFuncSeparate" : "func_179120_a", "(IIII)V", false));
return list;
}
}
Original file line number Diff line number Diff line change
@@ -45,7 +45,7 @@ private InsnList dynamicShadowScale() {
list.add(new VarInsnNode(Opcodes.ALOAD, 0));
list.add(new VarInsnNode(Opcodes.FLOAD, 3));
list.add(new MethodInsnNode(Opcodes.INVOKESTATIC, "java/lang/Math", "abs", "(F)F", false));
list.add(new FieldInsnNode(Opcodes.PUTFIELD, "net/minecraft/client/renderer/entity/RenderWither", "field_76989_e", "F"));
list.add(new FieldInsnNode(Opcodes.PUTFIELD, "net/minecraft/client/renderer/entity/RenderWither", isDevelopment() ? "shadowSize" : "field_76989_e", "F"));
return list;
}
}
Loading