Col-E / Recaf

The modern Java bytecode editor
https://recaf.coley.software
MIT License
6.06k stars 467 forks source link

Some methods/fields are not properly remapped (4.0.0-SNAPSHOT) #862

Closed solonovamax closed 1 month ago

solonovamax commented 1 month ago

Describe the bug

Some methods/fields do not seem to be properly remapped. (Using yarn mappings, unsure if this occurs for other mappings formats)

To Reproduce

Steps to reproduce the behavior:

  1. Download this mod: https://modrinth.com/mod/dev-tools-unlocker/version/1.0.0
  2. Open it in recaf
  3. Download and extract the latest yarn build for 1.21.1 (in this case, https://maven.fabricmc.net/net/fabricmc/yarn/1.21.1%2Bbuild.3/)
  4. Apply the downloaded yarn mappings
  5. Open com.eightsidedsquare.devtools.ModInit
  6. The methods LivingEntity.getStackInHand (net.minecraft.class_1309.method_5998) and ServerCommonNetworkHandler.sendPacket (net.minecraft.class_8609.method_14364) & field ActionResult.PASS (net.minecraft.class_1269.field_5811) are not remapped

According to linkie, all of these fields & methods have existing mappings.

Additionally, they are definitely present in the mappings file:

$ rg method_14364 yarn-1.21.1+build.3-tiny
20059:METHOD    arr (Lzg;)V b   method_14364    sendPacket
20266:METHOD    arx (Lzg;)V b   method_14364    sendPacket

Exception

N/A

Screenshots

image

Col-E commented 1 month ago

Problem:

  1. method_5998 belongs to net/minecraft/entity/LivingEntity / class_1309
  2. The method reference in the code is net/minecraft/class_1657.method_5998 which is not class_1309
    • class_1657 is PlayerEntity
  3. There is no way for Recaf to know that PlayerEntity extends LivingEntity / class_1657 extends class_1309 without generating phantoms
    • And those will only generate what can be inferred
    • JPhantom does not find any code that strongly implies this, even though we may know it intuitively as people familiar with the game's logic

Solution: Add a secondary resource to the workspace with code that proves class_1657 extends class_1309

Col-E commented 1 month ago

Phantom generation is also disabled by default ATM btw

image

Longer term we'll probably want to bake-in some support for common minecraft-isms: https://github.com/Col-E/Recaf/issues/667

solonovamax commented 1 month ago

Problem:

  1. method_5998 belongs to net/minecraft/entity/LivingEntity / class_1309
  2. The method reference in the code is net/minecraft/class_1657.method_5998 which is not class_1309
    • class_1657 is PlayerEntity
  3. There is no way for Recaf to know that PlayerEntity extends LivingEntity / class_1657 extends class_1309 without generating
    • And those will only generate what can be inferred
    • JPhantom does not find any code that strongly implies this, even though we may know it intuitively as people familiar with the game's logic

Solution: Add a secondary resource to the workspace with code that proves class_1657 extends class_1309

Might want to slap this somewhere in the docs and/or present this to the user when first applying mappings.

Col-E commented 1 month ago

Might want to slap this somewhere in the docs

Definitely planned. I've been focusing on the dev-docs first as they solidify. There's still a number of UI changes to make so I haven't really started hammering out user-docs.