Who calls this Minecraft method? Find callers and usages across your mod, Fabric API and the game jar

2026-11-29来源 dev.toEnglish

When I change a mixin or wrap a vanilla method, the first thing I want to know is: who else calls this? Vanilla code, Fabric API, my own sources, maybe another mod I depend on. In an IDE that's "Find Usages". From a terminal, or from an AI coding agent, it usually turns into unzip + javap + grep.

jdx answers that question as a command. Here is the workflow I use, with the limits up front.

Build a workspace over the jars you care about

jdx reads Maven/Gradle dependency caches on its own, but the Loom-remapped Minecraft jar is not auto-discovered, so pass it explicitly:

jdx ws create mc \ --jars "$HOME/.gradle/caches/fabric-loom/<minecraft-version>/minecraft-common.jar" \ --src ./src/main/java 

(Some Loom versions write minecraft-client.jar instead. Use whichever remapped jar is actually in that folder. For NeoForge/Forge, point --jars at that toolchain's remapped jar.) Add Fabric API or another mod's jar with more --jars globs.

Callers: who calls this method?

jdx -w mc callers 'net.minecraft.world.item.ItemStack#getMaxStackSize()' 

callers is override-aware by default: a call through a supertype or an override counts too. Add --exact when you only want calls that bind to exactly that declaration. Bytecode edges carry file:line from the class's LineNumberTable, so you can jump straight to the spot.

The other direction is calls: what does this method call?

Usages: every reference to a type, with context

jdx -w mc usages net.minecraft.world.item.ItemStack --context 

--context prints a short inline snippet for each hit instead of a bare list. Every command also has --json if you want to script it, and if a name is ambiguous jdx exits 2 and lists each candidate as a paste-ready ref instead of guessing.

Let your agent ask the same question

jdx mcp exposes the same engine as an MCP server (jdx_callers, jdx_usages, jdx_calls …), and jdx setup --agent claude-code --scope project (or cursor, codex, cline, …) wires it up. The agent gets a short, precise answer instead of a 60 KB javap dump in its context window.

Honest caveats

  • jdx does not remap. Names come out in whatever namespace the jar already uses (Yarn, Mojmap, intermediary). Query with the names that jar uses.
  • Pass the Loom jar with --jars; only Maven-style dependencies are discovered automatically.
  • callers/usages see the classpath you give them, nothing more. They are ordinary bytecode navigation, not a Minecraft-aware feature, and they don't understand mixin injection targets.
  • If you also diff two game versions, jdx diff only makes sense within one mapping namespace.
  • jdx parses bytecode with ASM and never loads or runs the classes, so inspecting a random mod jar doesn't execute it.

Try it

curl -fsSL https://raw.githubusercontent.com/MohammadMD1383/jdx/main/install-release.sh | bash 

Needs Java 21+, works on Linux, macOS and Windows, Apache-2.0. Docs and the Minecraft guide: https://mohammadmd1383.github.io/jdx/docs/minecraft-mods/

原文:https://www.a8q9.cn/en/article/who-calls-this-minecraft-method-find-callers-and-usages-across-your-mod-fabric-a-3a4f3e.html

相关文章