Skip to content

MiracleLoader 1.5.2: redirects of inherited methods

Choose a tag to compare

@Hronosin Hronosin released this 04 Oct 11:56

1.5.2 fixes a trap in redirect: a method reference to an inherited method.

rgct.target("net.minecraft.server.level.ServerLevel")
    .method("tickChunk")
    .redirect(ServerLevel::getBlockRandomPos, MyMod::pos);

javac writes ServerLevel::getBlockRandomPos down as Level.getBlockRandomPos, the class that declares the method, while the game's own call names ServerLevel. Before 1.5.2 those didn't match, and the redirect only got the warning about a call the method never makes. Now a call naming a subclass, a subinterface or an implementing class matches: it's the same method. The loader reads who extends what from class files, so nothing loads early.

Everything else is as in 1.5.1 (the last word, Cool :D) and 1.5.0 (redirecting a new). Mods for 1.4 and 1.5 work as they are.

Checked

  • test.sh: 500 of 500, and the same as a Java agent, including a redirect of an inherited method on the plain and the obfuscated fake game.
  • Real client 26.3 with Ultra Somnia 0.5, which redirects ServerLevel::getBlockRandomPos and BlockState::randomTick (declared in Level and BlockStateBase).