|
24 | 24 |
|
25 | 25 | import com.falsepattern.lib.asm.ASMUtil; |
26 | 26 | import com.falsepattern.lib.mapping.MappingManager; |
27 | | -import com.falsepattern.lib.mapping.types.UniversalMethod; |
| 27 | +import com.falsepattern.lib.mapping.types.MappingType; |
| 28 | +import com.falsepattern.lib.mapping.types.NameType; |
28 | 29 | import com.falsepattern.lib.turboasm.ClassNodeHandle; |
29 | 30 | import com.falsepattern.lib.turboasm.TurboClassTransformer; |
| 31 | +import lombok.SneakyThrows; |
30 | 32 | import lombok.val; |
31 | 33 | import mega.fluidlogged.Tags; |
32 | 34 | import org.jetbrains.annotations.NotNull; |
@@ -75,29 +77,29 @@ public boolean shouldTransformClass(@NotNull String className, @NotNull ClassNod |
75 | 77 | return "net.minecraft.client.renderer.WorldRenderer".equals(className); |
76 | 78 | } |
77 | 79 |
|
| 80 | + @SneakyThrows |
78 | 81 | @Override |
79 | 82 | public boolean transformClass(@NotNull String className, @NotNull ClassNodeHandle classNode) { |
80 | 83 | val cn = classNode.getNode(); |
81 | 84 | if (cn == null) { |
82 | 85 | return false; |
83 | 86 | } |
| 87 | + val type = ASMUtil.discoverClassMappingType(cn); |
| 88 | + val block = MappingManager.classForName(NameType.Regular, MappingType.MCP, "net.minecraft.block.Block"); |
| 89 | + val blockMethod = block.getMethod(MappingType.MCP, "getRenderBlockPass", "()I"); |
| 90 | + val blockClassNameInternal = block.internalName().get(type); |
| 91 | + val blockMethodName = blockMethod.name().get(type); |
| 92 | + val blockMethodDesc = blockMethod.descriptor().get(type); |
84 | 93 | val method = ASMUtil.findMethodFromMCP(cn, "updateRenderer", "(Lnet/minecraft/entity/EntityLivingBase;)V", false); |
85 | 94 | val iter = method.instructions.iterator(); |
86 | 95 | while (iter.hasNext()) { |
87 | 96 | val insn = iter.next(); |
88 | 97 | if (!(insn instanceof MethodInsnNode)) |
89 | 98 | continue; |
90 | 99 | val mInsn = (MethodInsnNode) insn; |
91 | | - UniversalMethod uMethod; |
92 | | - try { |
93 | | - uMethod = MappingManager.getMethod(mInsn); |
94 | | - } catch (ClassNotFoundException | NoSuchMethodException ignored) { |
95 | | - continue; |
96 | | - } |
97 | | - if (!"net.minecraft.block.Block".equals(uMethod.parent().regularName().mcp())) { |
98 | | - continue; |
99 | | - } |
100 | | - if (!"getRenderBlockPass".equals(uMethod.name().mcp())) { |
| 100 | + if (!blockClassNameInternal.equals(mInsn.owner) || |
| 101 | + !blockMethodName.equals(mInsn.name) || |
| 102 | + !blockMethodDesc.equals(mInsn.desc)) { |
101 | 103 | continue; |
102 | 104 | } |
103 | 105 | iter.previous(); |
|
0 commit comments