Find a Mixin target in Minecraft from the terminal
Find a mixin target method, the Minecraft method descriptor, and a mixin injection point by inspecting a Minecraft class from the terminal.
The workflow below is what you run before writing a mixin: find the class, see its type chain, read the member and its descriptor, read the body, then see who calls it and what it calls. jdx needs JDK 21 or later. Install with the one-line installer. Pass the mapped jar Fabric Loom or NeoForge ModDevGradle already wrote with --jars. The same commands, against any jar, are the quickstart. Broader mod questions — metadata, deprecated members, a version diff — are in Minecraft mods.
The docs build has no Minecraft jar, so the Minecraft recipes on this page are bash blocks and are not executed. Each console block was produced by running that command when the page was built, against Gson 2.14.0 or the JDK. Swap --coord com.google.code.gson:gson:2.14.0 --fetch for --jars "$MAPPED_JAR" --no-jdk when the jar is yours. --fetch allows a download when the coordinate is not already in ~/.gradle/caches or ~/.m2. A coordinate is not downloaded without that flag.
Pass the mapped jar#
$MAPPED_JAR is the Yarn or Mojmap jar Loom or ModDevGradle already produced. jdx reads the names stored in that file. An obfuscated jar stays obfuscated. --no-jdk leaves the JDK out, which you want here: otherwise callers and hierarchy are full of java.*.
--jars takes a jar, a class directory, or a glob, and it is repeatable. Quote globs so the shell does not expand them (--jars 'mods/*.jar'). An unquoted expansion exits 3. Always quote a reference in the shell: #, (, and $ are shell syntax.
Inside a Gradle project, with no classpath flags, jdx discovers build/classes/... and dependency jars named as group:artifact:version in the build scripts. It never runs Gradle to do that. The remapped Minecraft jar is usually not one of those coordinates, so pass it with --jars. See Classpath & workspaces.
Find the class#
jdx search is the partial name. --kind class keeps classes. A bare word matches case-insensitively as a substring of the simple name, or as camel humps. jdx resolve takes one exact name: a simple name, a binary name, or a dotted name. Several resolve candidates exit 0, and each row names the kind, the canonical name, and the jar file name. A miss exits 1. jdx ls with an exact package lists the types in that package, each with the jar file name.
jdx search 'ItemStack' --kind class --jars "$MAPPED_JAR" --no-jdk
jdx resolve net.minecraft.world.item.ItemStack --jars "$MAPPED_JAR" --no-jdk
jdx ls net.minecraft.world.item --jars "$MAPPED_JAR" --no-jdkThe same three commands, run here against Gson:
jdx search 'Json*' --kind class --limit 6 --in 'gson*' --coord com.google.code.gson:gson:2.14.0 --fetch --no-jdk
search results for 'Json*'
class com.google.gson.JsonArray gson-2.14.0.jar
class com.google.gson.JsonElement gson-2.14.0.jar
class com.google.gson.JsonIOException gson-2.14.0.jar
class com.google.gson.JsonNull gson-2.14.0.jar
class com.google.gson.JsonObject gson-2.14.0.jar
class com.google.gson.JsonParseException gson-2.14.0.jar
6 of 18 results shown (--limit 18 to see more)
warning MULTI_RELEASE_VARIANT: multi-release gson-2.14.0.jar serves version-specific variants for this JDK (21)
jdx resolve com.google.gson.JsonArray --coord com.google.code.gson:gson:2.14.0 --fetch --no-jdk
search results for 'com.google.gson.JsonArray'
class com.google.gson.JsonArray gson-2.14.0.jar
warning MULTI_RELEASE_VARIANT: multi-release gson-2.14.0.jar serves version-specific variants for this JDK (21)
jdx ls com.google.gson --limit 6 --coord com.google.code.gson:gson:2.14.0 --fetch --no-jdk
types in package 'com.google.gson'
package com.google.gson (51 types)
interface com.google.gson.ExclusionStrategy gson-2.14.0.jar
class com.google.gson.FieldAttributes gson-2.14.0.jar
enum com.google.gson.FieldNamingPolicy gson-2.14.0.jar
enum com.google.gson.FieldNamingPolicy$1 gson-2.14.0.jar
enum com.google.gson.FieldNamingPolicy$2 gson-2.14.0.jar
6 of 52 rows shown (--limit 52 to see more)
warning MULTI_RELEASE_VARIANT: multi-release gson-2.14.0.jar serves version-specific variants for this JDK (21)Real output — this example ran against the current jdx when the page was built.
A method name whose class you do not know is jdx search '<name>' --kind method. That scan reads members. Default --kind all covers types, packages, and modules, and a miss under that default names --kind method.
Reference: search, resolve, ls. Finding which file in a directory holds a class is Find which JAR contains a class.
See the type chain#
jdx hierarchy prints supertypes upward and subtypes downward. Supertype lines say extends or implements. Subtype lines name the class and the jar, so a second --jars 'mods/*.jar' shows which mods extend the class. --up or --down picks a direction. --direct stops at one level. --depth N caps it. A member reference exits 3; this command wants a type.
jdx hierarchy net.minecraft.world.item.Item --jars "$MAPPED_JAR" --no-jdk
jdx hierarchy net.minecraft.world.item.Item --down --jars "$MAPPED_JAR" --jars 'mods/*.jar' --no-jdkjdx hierarchy com.google.gson.JsonElement --coord com.google.code.gson:gson:2.14.0 --fetch --no-jdk
hierarchy of 'com.google.gson.JsonElement'
supertypes
extends java.lang.Object
subtypes in workspace (4)
class com.google.gson.JsonArray gson-2.14.0.jar
class com.google.gson.JsonNull gson-2.14.0.jar
class com.google.gson.JsonObject gson-2.14.0.jar
class com.google.gson.JsonPrimitive gson-2.14.0.jar
warning MULTI_RELEASE_VARIANT: multi-release gson-2.14.0.jar serves version-specific variants for this JDK (21)Real output — this example ran against the current jdx when the page was built.
Reference: hierarchy. More of the graph is in Usages, hierarchy & calls.
List members and read the signature#
jdx members lists what you can call. Inherited members are the default; --declared keeps the type's own members. The default visibility is public and protected. A mixin often targets a private or package-private method, so pass --access all (or --access private). --kind method keeps methods. --grep '^use' keeps names matching that regex. jdx outline is the same list for declared members only: one line each, never inherited, with the same filters.
jdx members net.minecraft.world.item.ItemStack --declared --kind method --access all --grep '^use' --jars "$MAPPED_JAR" --no-jdk
jdx outline net.minecraft.world.item.ItemStack --kind method --access all --jars "$MAPPED_JAR" --no-jdkjdx members com.google.gson.JsonArray --declared --kind method --access all --limit 6 --coord com.google.code.gson:gson:2.14.0 --fetch --no-jdk
members of com.google.gson.JsonArray
methods declared on com.google.gson.JsonArray:
method private com.google.gson.JsonElement getAsSingleElement()
method public boolean contains(com.google.gson.JsonElement element)
method public boolean equals(java.lang.Object o)
method public boolean getAsBoolean()
method public boolean isEmpty()
method public boolean remove(com.google.gson.JsonElement element)
6 of 31 members shown (--limit 31 to see more)
source: gson-2.14.0.jar (bytecode)
warning MULTI_RELEASE_VARIANT: multi-release gson-2.14.0.jar serves version-specific variants for this JDK (21)
warning UNRESOLVED_SUPERTYPE: supertype java.lang.Iterable is not in the workspace — members inherited from it are missing
warning UNRESOLVED_SUPERTYPE: supertype java.lang.Object is not in the workspace — members inherited from it are missing
jdx outline com.google.gson.JsonArray --kind method --access all --limit 6 --coord com.google.code.gson:gson:2.14.0 --fetch --no-jdk
members of com.google.gson.JsonArray
methods declared on com.google.gson.JsonArray:
method private com.google.gson.JsonElement getAsSingleElement()
method public boolean contains(com.google.gson.JsonElement element)
method public boolean equals(java.lang.Object o)
method public boolean getAsBoolean()
method public boolean isEmpty()
method public boolean remove(com.google.gson.JsonElement element)
6 of 31 members shown (--limit 31 to see more)
source: gson-2.14.0.jar (bytecode)
warning MULTI_RELEASE_VARIANT: multi-release gson-2.14.0.jar serves version-specific variants for this JDK (21)
warning UNRESOLVED_SUPERTYPE: supertype java.lang.Iterable is not in the workspace — members inherited from it are missing
warning UNRESOLVED_SUPERTYPE: supertype java.lang.Object is not in the workspace — members inherited from it are missingReal output — this example ran against the current jdx when the page was built.
With --no-jdk, a JDK supertype is not in the workspace. jdx warns UNRESOLVED_SUPERTYPE and omits members inherited from it. --declared is the list a mixin uses: the methods on the class itself, private ones included when you passed --access all.
jdx signature prints one source-style line per overload: visibility, fully qualified parameter and return types, and parameter names from the class file (arg0, arg1, … when the jar has none). An under-specified name lists every overload and exits 0. A missing member exits 1. A type reference exits 3. Bridge and synthetic members are hidden unless you pass --include-synthetic.
That line identifies the overload. It is a source-style signature. A Mixin method selector that pins one overload is the JVM method name immediately followed by the JVM descriptor, such as get(Ljava/lang/Object;)Ljava/lang/Object;. jdx does not print that selector, and it does not print an @At target. The canonical ref uses dotted names (java.util.HashMap#get(java.lang.Object)), not the internal owner form.
The JVM descriptor is the descriptor: line from jdx body '<ref>' --engine javap, which disassembles that one member. Take the method name from the signature line and the descriptor from that line. --json on signature repeats the source-style line and adds the canonical ref. It has no descriptor field. The descriptor: line is part of the disassembly text.
You can paste a descriptor into jdx. Type#name(Lpkg/Arg;)Lpkg/Return; selects that one member. The printed signature stays source-style. The ref grammar is Symbol references.
Kotlin mods are read from @Metadata, so the default signature is the Kotlin declaration. A mixin targets the JVM method: jdx signature --view jvm (and the same flag on jdx members) prints the JVM name, including a mangled name or a hidden Continuation parameter. The descriptor still comes from jdx body --engine javap.
jdx signature 'net.minecraft.world.item.ItemStack#use' --jars "$MAPPED_JAR" --no-jdk
jdx signature 'net.minecraft.world.item.ItemStack#use' --view jvm --jars "$MAPPED_JAR" --no-jdk
jdx body '<canonical ref>' --engine javap --max-lines 20 --jars "$MAPPED_JAR" --no-jdkRun here against HashMap#get. The first command is the source-style line. The second passes the JVM descriptor and prints the same kind of line. The third is the disassembly: its source line says disassembled by javap and ⚠ reconstructed, and the descriptor: line is the JVM descriptor.
jdx signature 'java.util.HashMap#get'
signatures of java.util.HashMap#get
public V get(java.lang.Object key)
source: java.base (jrt)
next: jdx show java.util.HashMap
jdx signature 'java.util.HashMap#get(Ljava/lang/Object;)Ljava/lang/Object;'
signatures of java.util.HashMap#get
public V get(java.lang.Object key)
source: java.base (jrt)
next: jdx show java.util.HashMap
jdx body 'java.util.HashMap#get(java.lang.Object)' --engine javap
java.util.HashMap#get(java.lang.Object)
source: disassembled by javap from java.base · java/util/HashMap.java:346-359 ⚠ reconstructed
public V get(java.lang.Object);
descriptor: (Ljava/lang/Object;)Ljava/lang/Object;
Code:
0: aload_0
1: aload_1
2: invokevirtual #158 // Method getNode:(Ljava/lang/Object;)Ljava/util/HashMap$Node;
5: dup
6: astore_2
… 7 more lines (run it yourself to see them all)Real output — this example ran against the current jdx when the page was built.
A name with several overloads is not a guess. jdx body on that name exits 2 and prints every candidate as a canonical ref. Paste one of them:
jdx body 'com.google.gson.Gson#toJson' --coord com.google.code.gson:gson:2.14.0 --fetch
ambiguous: 8 candidates for com.google.gson.Gson#toJson
com.google.gson.Gson#toJson(com.google.gson.JsonElement)
com.google.gson.Gson#toJson(com.google.gson.JsonElement, com.google.gson.stream.JsonWriter)
com.google.gson.Gson#toJson(com.google.gson.JsonElement, java.lang.Appendable)
com.google.gson.Gson#toJson(java.lang.Object)
com.google.gson.Gson#toJson(java.lang.Object, java.lang.Appendable)
com.google.gson.Gson#toJson(java.lang.Object, java.lang.reflect.Type)
com.google.gson.Gson#toJson(java.lang.Object, java.lang.reflect.Type, com.google.gson.stream.JsonWriter)
com.google.gson.Gson#toJson(java.lang.Object, java.lang.reflect.Type, java.lang.Appendable)
hint: re-run with one of the refs above
[exit 2]Real output — this example ran against the current jdx when the page was built.
Reference: members, outline, signature, body.
Read the method body#
jdx body prints one method. With a paired -sources.jar (a sibling foo-sources.jar, or the same file name in the Gradle or Maven cache layout under that version) the text is the real file. A sources jar with a different file name is not paired. With no pair, jdx decompiles with Vineflower and the source line says decompiled by vineflower and ⚠ reconstructed. --engine javap is the disassembly in the previous section. --engine vineflower forces a reconstruction even when sources are paired. When Vineflower returns only a $VF: Could not decompile… stub, the default ladder falls through to javap instead of serving the stub. jdx body --max-lines 80 caps a long method.
jdx body '<canonical ref from signature>' --jars "$MAPPED_JAR" --no-jdk
jdx body '<canonical ref from signature>' --max-lines 80 --jars "$MAPPED_JAR" --no-jdkmembers and signature always come from bytecode, so those lines stay exact with or without sources. The same ladder, with runnable Gson and JDK examples, is in Read and decompile a JAR from the terminal.
Find a mixin injection point#
jdx callers lists who calls the method. It is override-aware by default: a query for an interface or base method also finds call sites that go through overrides, and a query for an override also finds polymorphic calls through its declaring supertypes. Constructors, static methods, and private methods stay exact. --exact restricts every query to invoke-owner matching. --depth N walks further (cycles are marked …(cycle)). Pass every jar that might contain a call site. callers only accepts methods and constructors; a type or field ref exits 3.
jdx calls lists what that method calls. That is the invoke you aim an injection at. Callees stay bytecode-exact: the invoke names one owner, so calls does not expand overrides.
Each row is a canonical ref. Paste it into jdx body to read that caller or callee.
jdx callers '<canonical ref from signature>' --jars "$MAPPED_JAR" --jars 'mods/*.jar' --no-jdk
jdx callers '<canonical ref from signature>' --exact --limit 30 --jars "$MAPPED_JAR" --no-jdk
jdx calls '<canonical ref from signature>' --jars "$MAPPED_JAR" --no-jdkjdx callers 'com.google.gson.JsonArray#add(com.google.gson.JsonElement)' --limit 5 --coord com.google.code.gson:gson:2.14.0 --fetch --no-jdk
callers of 'com.google.gson.JsonArray#add(com.google.gson.JsonElement)'
call com.google.gson.JsonArray#deepCopy() gson-2.14.0.jar
call com.google.gson.internal.bind.JsonElementTypeAdapter#read(com.google.gson.stream.JsonReader) gson-2.14.0.jar
call com.google.gson.internal.bind.JsonTreeWriter#put(com.google.gson.JsonElement) gson-2.14.0.jar
warning MULTI_RELEASE_VARIANT: multi-release gson-2.14.0.jar serves version-specific variants for this JDK (21)
jdx calls 'com.google.gson.Gson#toJson(java.lang.Object)' --limit 8 --coord com.google.code.gson:gson:2.14.0 --fetch --no-jdk
calls from 'com.google.gson.Gson#toJson(java.lang.Object)'
call java.lang.Object#getClass()
call com.google.gson.Gson#toJson(com.google.gson.JsonElement) gson-2.14.0.jar
call com.google.gson.Gson#toJson(java.lang.Object, java.lang.reflect.Type) gson-2.14.0.jar
warning MULTI_RELEASE_VARIANT: multi-release gson-2.14.0.jar serves version-specific variants for this JDK (21)Real output — this example ran against the current jdx when the page was built.
Reference: callers, calls. More on the graph is in Usages, hierarchy & calls.
A constant or a field#
jdx usages is every reference, not only calls: reads, writes, constructors, instanceof, annotations. --kind read and --kind write are the field edges. --kind call is the call edge. jdx literals searches string constants: bytecode LDC loads, String field ConstantValues, and .properties keys and values. JSON lang files are not in literals; those are jdx resources. Nothing matched exits 1.
jdx usages '<field ref from members>' --kind read --jars "$MAPPED_JAR" --jars 'mods/*.jar' --no-jdk
jdx usages '<field ref from members>' --kind write --jars "$MAPPED_JAR" --no-jdk
jdx literals 'item.minecraft.diamond' --jars "$MAPPED_JAR" --no-jdkjdx usages com.google.gson.JsonNull --limit 5 --coord com.google.code.gson:gson:2.14.0 --fetch --no-jdk
usages of 'com.google.gson.JsonNull'
gson-2.14.0.jar (5)
read com.google.gson.Gson#toJson(java.lang.Object) Gson.java:544 -> #INSTANCE
read com.google.gson.Gson#toJson(java.lang.Object, java.lang.Appendable) Gson.java:593 -> #INSTANCE
read com.google.gson.Gson#toJsonTree(java.lang.Object) Gson.java:498 -> #INSTANCE
read com.google.gson.JsonArray#add(com.google.gson.JsonElement) JsonArray.java:127 -> #INSTANCE
read com.google.gson.JsonArray#add(java.lang.Boolean) JsonArray.java:87 -> #INSTANCE
5 of 30 usages shown (--limit 30 to see more)
warning MULTI_RELEASE_VARIANT: multi-release gson-2.14.0.jar serves version-specific variants for this JDK (21)
jdx literals 'com.google.gson' --coord com.google.code.gson:gson:2.14.0 --fetch --limit 5 --no-jdk
literals matching 'com.google.gson'
gson-2.14.0.jar (2)
ldc com.google.gson.internal.bind.TypeAdapters#javaTimeTypeAdapterFactory() "com.google.gson.internal.bind.JavaTimeTypeAdapters" TypeAdapters.java:951
ldc com.google.gson.internal.reflect.ReflectionHelper#getInaccessibleTroubleshootingSuffix(java.lang.Exception) "to module com.google.gson" ReflectionHelper.java:51Real output — this example ran against the current jdx when the page was built.
Reference: usages, literals, resources.
From an AI agent#
jdx setup writes the MCP config for the agent you name. jdx mcp is the stdio server: one typed tool per query (jdx_search, jdx_resolve, jdx_hierarchy, jdx_members, jdx_outline, jdx_signature, jdx_body, jdx_callers, jdx_calls, jdx_usages, jdx_literals), so the agent does not quote # and (. The server does not take a jar path. Create a workspace, then start the server on it. jdx setup writes args as mcp only. Add -w by hand when the workspace is not default.
jdx setup --agent cursor --scope project
jdx setup --agent claude-code --scope project
jdx ws create mc --jars "$MAPPED_JAR" --jars 'mods/*.jar' --no-jdk
jdx mcp -w mcjdx setup --agent claude-code --scope project --check
claude-code project setup not installed
./.mcp.json
detected: claude-code not found on PATH
next: jdx setup --agent claude-code --scope project
[exit 1]Real output — this example ran against the current jdx when the page was built.
--check exits 1 when jdx is not wired yet and 0 when it is. The server never downloads. Other agents and the tool list are in Use with AI agents and An MCP server for Java and Kotlin bytecode.
Reference: setup, mcp, MCP tools.
Names, mappings, and what never runs#
jdx does not remap. It reads whatever names the jar uses, so query the names of the mapping namespace in that jar: the Loom-mapped jar, a Mojmap jar, a Yarn jar, or an obfuscated jar. Reading Tiny, SRG, or ProGuard mappings is phase-2 backlog.
jdx diff compares two artifacts that already use the same names. A Yarn jar diffed against a Mojmap jar, or an intermediary jar diffed against a named jar, looks like nearly every member was removed and re-added. Compare two Yarn jars, or two Mojmap jars, or two builds in one namespace. See See what changed between two Minecraft or mod versions, Minecraft mods, and API diff for upgrades.
Bytecode is parsed with ASM. Inspected classes are never loaded, so no static initialiser and no other code from the jar runs. jdx writes only inside its own cache, config, and runtime directories. --jars reads the file you named and does not download it.
Where next#
- Minecraft mods — mod metadata, deprecated members, and a version diff.
- See what changed between two Minecraft or mod versions —
difftwo mapped jars, then one member. - Find which JAR contains a class — which file in
mods/*.jarholds a class. - Read and decompile a JAR — one method, source, or a decompilation.
- Usages, hierarchy & calls — the rest of the graph.
- Symbol references — canonical refs, and JVM descriptors as input.
- Command catalogue — every flag.