Translate a Minecraft API symbol between eras
mc_translateSuggests the equivalent method or class name when porting Minecraft mod code between versions 1.8.9 and 1.21+.
Instructions
Given a method or class name from one era, suggests the equivalent in the other era. Looks across both classes and method tasks. Useful when porting code between 1.8.9 and 1.21+.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| symbol | Yes | Class name, method call, or partial symbol | |
| from | Yes |
Implementation Reference
- src/index.ts:306-318 (registration)Registration of the mc_translate tool via server.registerTool with inputSchema and handler.
server.registerTool( "mc_translate", { title: "Translate a Minecraft API symbol between eras", description: "Given a method or class name from one era, suggests the equivalent " + "in the other era. Looks across both classes and method tasks. Useful " + "when porting code between 1.8.9 and 1.21+.", inputSchema: { symbol: z.string().describe("Class name, method call, or partial symbol"), from: EraSchema, }, }, - src/index.ts:319-369 (handler)The async handler function for mc_translate — translates a symbol between 1.8.9 and 1.21+ using curated CLASSES and METHODS tables.
async ({ symbol, from }) => { // Curated tables only carry 1.8.9 / 1.21+ — collapse 26.1.x onto 1.21+. const fromCurated: CuratedEra = resolveCuratedEra(from); const to: CuratedEra = fromCurated === "1.8.9" ? "1.21+" : "1.8.9"; const classMatches = fuzzyFind( CLASSES, (c) => `${c.concept} ${c[fromCurated].fqn}`, symbol, { topK: 4 }, ); const methodMatches = fuzzyFind( METHODS, (m) => `${m.task} ${m[fromCurated]}`, symbol, { topK: 4 }, ); const blocks: string[] = []; if (from === "26.1.x") { blocks.push( "_Curated translation tables don't yet have 26.1.x-specific entries — " + "showing 1.21+ equivalents. Use `mc_mojang_mappings` for authoritative " + "26.1.x class names._", "", ); } if (classMatches.length) { blocks.push(`## Class translations (${fromCurated} → ${to})`); for (const { item: c } of classMatches) { blocks.push(`- **${c.concept}**: \`${c[fromCurated].fqn}\` → \`${c[to].fqn}\``); } blocks.push(""); } if (methodMatches.length) { blocks.push(`## API translations (${fromCurated} → ${to})`); for (const { item: m } of methodMatches) { blocks.push(`### ${m.task}`); blocks.push(code("java", `// ${fromCurated}\n${m[fromCurated]}\n\n// ${to}\n${m[to]}`)); if (m.notes) blocks.push(`> ${m.notes}`); blocks.push(""); } } if (blocks.length === 0) { blocks.push(`No close matches for "${symbol}" coming from ${from}.`); blocks.push( "Try a class name (e.g. 'TileEntity', 'EntityPlayerMP') or an action ('send chat', 'register item').", ); } return text(blocks.join("\n").trim()); }, ); - src/index.ts:308-317 (schema)Input schema for mc_translate requiring 'symbol' (string) and 'from' (EraSchema enum: 1.8.9, 1.21+, 26.1.x).
{ title: "Translate a Minecraft API symbol between eras", description: "Given a method or class name from one era, suggests the equivalent " + "in the other era. Looks across both classes and method tasks. Useful " + "when porting code between 1.8.9 and 1.21+.", inputSchema: { symbol: z.string().describe("Class name, method call, or partial symbol"), from: EraSchema, }, - src/index.ts:33-51 (helper)Imports of curated data tables (CLASSES, METHODS) and resolveCuratedEra used by the mc_translate handler.
import { VERSIONS, CLASSES, METHODS, EVENTS, MIXIN_PATTERNS, GOTCHAS, YARN_TO_MOJANG, GRADLE_TEMPLATES, SCAFFOLD_KINDS, DATA_COMPONENTS, PACKET_PATTERNS, REGISTRY_PATTERNS, scaffold, resolveCuratedEra, type Era, type CuratedEra, type Loader, } from "./knowledge.js";