<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[[Guide] Typescript definition for Minecraft and LiquidBounce]]></title><description><![CDATA[<p dir="auto">Following <a href="https://github.com/commandblock2/minecraft-LBNG-types" target="_blank" rel="noopener noreferrer nofollow ugc"><code>repo</code></a> means</p>
<h2><a href="https://github.com/commandblock2/minecraft-LBNG-types/blob/master/README.md" target="_blank" rel="noopener noreferrer nofollow ugc">demo</a></h2>
<p dir="auto"><a href="https://github.com/commandblock2/minecraft-LBNG-types" target="_blank" rel="noopener noreferrer nofollow ugc">https://github.com/commandblock2/minecraft-LBNG-types</a>.<br />
<img src="/assets/uploads/files/1743439569889-9094e21e-c6b5-4f3b-b562-92cd701ba7e3-image-resized.png" alt="9094e21e-c6b5-4f3b-b562-92cd701ba7e3-image.png" class=" img-fluid img-markdown" /></p>
<h1>minecraft-LBNG-types</h1>
<hr />
<p dir="auto"><strong>DISCLAIMER: Use this at your own risk!!! This is an unofficial project not endorsed by Mojang or fabric developers. This repo does NOT</strong></p>
<ul>
<li><strong>contains any generated minecraft type definitions by itself</strong></li>
<li><strong>redistribute the game itself</strong></li>
<li><strong>guarentee the correctness of the generated definition</strong></li>
</ul>
<hr />
<p dir="auto">This repo contains</p>
<ul>
<li>instruction and scripts for creating typescript definitions
<ul>
<li>for Minecraft (with mods*)</li>
<li>for LiquidBounce NextGen</li>
<li>for everything inside of the jvm</li>
</ul>
</li>
<li>typescript definitions for <strong>embedded context</strong> of LiquidBounce NextGen scriptAPI</li>
<li>a set of manually maintained patches to make the script api work properly</li>
<li>a set of examples LiquidBounce NextGen script using typescript</li>
<li>a compiler script that will compile all the .ts files into .js files that could run in graaljs (LiquidBounce NextGen runtime) with watch mode</li>
<li>some prompt files to use on LLMs, specifically for claude + continue.dev vscode extension, at <a href=".continue/prompts">.continue/prompts</a>.</li>
</ul>
<p dir="auto">Note: the mods are only limited to those presented at the development environment of LiquidBounce NextGen.</p>
<p dir="auto"><strong>When writing your script in typescript, expect inconsistencies with script API in js, but please report them to this repo if you can</strong></p>
<h2>Instruction (subject to change)</h2>
<p dir="auto">Adjust the order flexibly to your needs.</p>
<h3>Generating the typescript definitions</h3>
<ol>
<li>
<p dir="auto">Setup development environment for Liquidbounce NextGen</p>
</li>
<li>
<p dir="auto"><strong>Clone LBNG</strong>, run <code>git checkout 451cb31e9bf093fe07f9b28202bc2471921ea13d</code> (for version 0.29.0 release) and launch with gradle <code>./gradlew runClient</code> without intellij idea(recommened because of the sheer amount of memory it takes to generate the definition).</p>
</li>
<li>
<p dir="auto">Place the <code>LBNG-script/ts-defgen.js</code> in your script folder for LiquidBounce</p>
</li>
<li>
<p dir="auto">Build or <a href="https://github.com/commandblock2/ts-generator/releases" target="_blank" rel="noopener noreferrer nofollow ugc">download the latest released ts-generator jar from github</a>, place it in your script folder as well.</p>
</li>
<li>
<p dir="auto">Do a <code>.script reload</code> in your client, this should load the <code>ts-defgen.js</code></p>
</li>
<li>
<p dir="auto">Run the <code>.ts-defgen</code> command</p>
</li>
<li>
<p dir="auto">See messages from chat and wait for around a few minute or more or less depending on your setup, this may take a while and also nearly 7GB of additional RAM (other than your intellij idea plus the what Minecraft needs in it's original state, causes OOM for me a lot of times xD).</p>
</li>
</ol>
<p dir="auto">Now you can find a <code>types-gen</code> folder in your script folder, this contains the generated typescript definitions.</p>
<pre><code>.
├── ts-defgen.js
├── ts-generator-1.1.1.jar
└── types-gen
    └── minecraft-yarn-definitions
        ├── package.json
        ├── tsconfig.json
        └── types
            ├── ai
            ├── com
            ├── _COROUTINE
            ├── de
            ├── io
            ├── it
            ├── java
            ├── javax
            ├── jdk
            ├── joptsimple
            ├── kotlin
            ├── kotlinx
            ├── net
            ├── okhttp3
            ├── okio
            ├── org
            ├── oshi
            └── sun
├── ... other scripts.js

</code></pre>
<h3>Writing scripts with TypeScript Support</h3>
<ol>
<li>Run <code>npm install</code> in this directory.</li>
<li>copy the generated folder <code>types-gen</code> to <code>generated-modules</code> folder in the root of your project.</li>
<li>Run the script <code>apply-patch</code> with <code>npm run apply-patches</code></li>
<li>Run <code>npm install file:./generated-modules/types-gen/minecraft-yarn-definitions/ --no-save</code>, no-save for now, not sure if I should do this.</li>
<li>Open the <code>template.ts</code> file and try start writing your script, you should see TypeScript type hints for all the classes that are available. vscode will automatically generate working imports, but <strong>you should not touch the import statement with <code>@embedded</code> namespace.</strong></li>
<li>Run the script <code>compile</code> with npm like step 4 or <code>npm run watch</code></li>
<li>Corresponding javascript file is generated in the <code>dist</code> directory, you can link this dist directory to your scripts directory in LB.</li>
</ol>
<h2>Contribution and TODOs</h2>
<p dir="auto">If you know how to better organize this project (architecture), please feel free to submit a PR.</p>
<p dir="auto">If you find errors on generated definitions about Minecraft classes or LiquidBounce classes, please file your tick at <a href="https://github.com/commandblock2/ts-generator/issues" target="_blank" rel="noopener noreferrer nofollow ugc">ts-generator</a>.</p>
<p dir="auto">If you find a un-intended behavior in the <code>ts-defgen.js</code>, compile script or manually maintained definitions(TODO), please file an issue here.</p>
<h2>License</h2>
<p dir="auto">This project is licensed under the GNU General Public license, see LICENSE for more information.</p>
<p dir="auto"><img src="/assets/uploads/files/1738500020404-vscode-file___vscode-app_opt_vscodium_resources_app_out_vs_code_electron-sandbox_workbench_workbench.html-cropped.png" alt="vscode-file___vscode-app_opt_vscodium_resources_app_out_vs_code_electron-sandbox_workbench_workbench.html-cropped.png" class=" img-fluid img-markdown" /></p>
]]></description><link>https://forum.liquidbounce.net/topic/8400/guide-typescript-definition-for-minecraft-and-liquidbounce</link><generator>RSS for Node</generator><lastBuildDate>Fri, 10 Apr 2026 16:56:50 GMT</lastBuildDate><atom:link href="https://forum.liquidbounce.net/topic/8400.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 25 Jan 2025 16:03:23 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to [Guide] Typescript definition for Minecraft and LiquidBounce on Mon, 31 Mar 2025 16:12:40 GMT]]></title><description><![CDATA[<p dir="auto">Update for LiquidBounce v0.29.0:<br />
What's new:</p>
<ul>
<li>refined disclaimer in <a href="http://README.md" target="_blank" rel="noopener noreferrer nofollow ugc">README.md</a></li>
<li><code>localStorage</code> in definition (no java.utils class definition yet)</li>
<li><code>multiChoose</code> in manually maintained patch</li>
</ul>
]]></description><link>https://forum.liquidbounce.net/post/40076</link><guid isPermaLink="true">https://forum.liquidbounce.net/post/40076</guid><dc:creator><![CDATA[commandblock2]]></dc:creator><pubDate>Mon, 31 Mar 2025 16:12:40 GMT</pubDate></item><item><title><![CDATA[Reply to [Guide] Typescript definition for Minecraft and LiquidBounce on Fri, 07 Feb 2025 17:12:29 GMT]]></title><description><![CDATA[<p dir="auto">Update: subsequent updates will be available on <a href="https://github.com/commandblock2/minecraft-LBNG-types" target="_blank" rel="noopener noreferrer nofollow ugc">https://github.com/commandblock2/minecraft-LBNG-types</a></p>
<p dir="auto">and the generated script was reverted to a state where it was not as readable as the following example (for correctness) but still largely remained the same.</p>
<p dir="auto">Now it can kinda generate a working script, but the ts file has a few squiggles.</p>
<p dir="auto"><img src="/assets/uploads/files/1738243517052-e3e18814-1645-4bd5-8244-7b8f44663aff-image.png" alt="image.png" class=" img-fluid img-markdown" /></p>
<p dir="auto">template.ts</p>
<pre><code class="language-typescript">// imports
import {
    Setting,
    Vec3i,
    Vec3d,
    MathHelper,
    BlockPos,
    Hand,
    RotationAxis,
    mc,
    Client,
    RotationUtil,
    ItemUtil,
    NetworkUtil,
    InteractionUtil,
    BlockUtil,
    MovementUtil,
    ReflectionUtil,
    ParameterValidator,
    UnsafeThread,
    registerScript
} from "@embedded";

import { ScriptModule } from "@minecraft-yarn-definitions/types/net/ccbluex/liquidbounce/script/bindings/features/ScriptModule";
import { Matrix2d } from "@minecraft-yarn-definitions/types/org/joml/Matrix2d";


const script = registerScript.apply({
    name: "template",
    version: "1.0.0",
    authors: ["commandblock2"]
});

script.registerModule({
    // @ts-ignore   
    name: "example-from-template",
    // @ts-ignore   
    description: "Ths is an example module generated in ts",
    // @ts-ignore   
    category: "Client"

}, (mod: ScriptModule) =&gt; {
    mod.on("enable", () =&gt; {
        Client.displayChatMessage(`${mc.player}`)
        Client.displayChatMessage(`${new Vec3i(1, 2, 3)}`)
        Client.displayChatMessage(`${new Matrix2d(1.2, 1.3, 1.4, 15)}`)
        Client.displayChatMessage("enabled")
    })
    mod.on("disable", () =&gt; Client.displayChatMessage("disabled"))
})
</code></pre>
<p dir="auto">compiled template.js</p>
<pre><code class="language-javascript">
function __require(path) {
    if (path.startsWith("@embedded")) {
        return {
            _embedded: globalThis
        }
    }

    if (path.startsWith("@minecraft-yarn-definitions/types/")) {
        return {
            [path.substring(path.lastIndexOf("/") + 1)]: Java.type(path
                .replaceAll("@minecraft-yarn-definitions/types/", "")
                .replaceAll("/", ".")
            )
        }
    }
    return require(path);
}
var exports = {}

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const { _embedded } = __require("@embedded");
const { Matrix2d } = __require("@minecraft-yarn-definitions/types/org/joml/Matrix2d");
const script = _embedded.registerScript.apply({
    name: "template",
    version: "1.0.0",
    authors: ["commandblock2"]
});
script.registerModule({
    // @ts-ignore   
    name: "example-from-template",
    // @ts-ignore   
    description: "Ths is an example module generated in ts",
    // @ts-ignore   
    category: "Client"
}, (mod) =&gt; {
    mod.on("enable", () =&gt; {
        _embedded.Client.displayChatMessage(`${_embedded.mc.player}`);
        _embedded.Client.displayChatMessage(`${new Vec3i(1, 2, 3)}`);
        _embedded.Client.displayChatMessage(`${new Matrix2d(1.2, 1.3, 1.4, 15)}`);
        _embedded.Client.displayChatMessage("enabled");
    });
    mod.on("disable", () =&gt; _embedded.Client.displayChatMessage("disabled"));
});
</code></pre>
<p dir="auto"><img src="/assets/uploads/files/1738243717904-1cb70c51-cc7f-4a90-a122-eff6ab0ad68f-image.png" alt="1cb70c51-cc7f-4a90-a122-eff6ab0ad68f-image.png" class=" img-fluid img-markdown" /></p>
]]></description><link>https://forum.liquidbounce.net/post/39964</link><guid isPermaLink="true">https://forum.liquidbounce.net/post/39964</guid><dc:creator><![CDATA[commandblock2]]></dc:creator><pubDate>Fri, 07 Feb 2025 17:12:29 GMT</pubDate></item><item><title><![CDATA[Reply to [Guide] Typescript definition for Minecraft and LiquidBounce on Tue, 28 Jan 2025 19:24:30 GMT]]></title><description><![CDATA[<p dir="auto">Update: now the script will also print the embedded context made available by the script api</p>
<pre><code class="language-js">// Import required Java classes

// type: array
/** @type any[]*/
var globalEntries = Object.entries(this);

const System = Java.type("java.lang.System");
const URLClassLoader = Java.type("java.net.URLClassLoader");
const File = Java.type("java.io.File");
const URL = Java.type("java.net.URL");
const Thread = Java.type("java.lang.Thread");
const Paths = Java.type("java.nio.file.Paths");
const Map = Java.type("java.util.HashMap");
const ArrayList = Java.type("java.util.ArrayList");
const JvmClassMappingKt = Java.type("kotlin.jvm.JvmClassMappingKt");
const Class = Java.type("java.lang.Class");

// Function to create a URLClassLoader from a JAR path
function createClassLoaderFromJar(jarPath) {
    try {
        // Create File object for the JAR
        const jarFile = new File(jarPath);

        // Convert File to URL
        const jarUrl = jarFile.toURI().toURL();

        // Create URLClassLoader with the system class loader as parent
        return new URLClassLoader(
            [jarUrl],
            Thread.currentThread().getContextClassLoader()
        );
    } catch (e) {
        console.error("Error creating ClassLoader:", e);
        throw e;
    }
}

// Function to load a class from a given ClassLoader
function loadClassFromJar(classLoader, className) {
    try {
        return classLoader.loadClass(className);
    } catch (e) {
        console.error(`Error loading class ${className}:`, e);
        throw e;
    }
}

const script = registerScript({
    name: "for-repl",
    version: "1.0.0",
    authors: ["commandblock2"],
});

script.registerModule(
    {
        name: "for-repl",
        category: "Client",
        description: "Sausage",
        settings: {
            path: Setting.text({
                name: "Path",
                default:
                    "/mnt/old-linux/home/commandblock2/git_repo/MultiMC5/build/instances/LBNG-Production/minecraft/LiquidBounce/scripts",
            }),
            packageName: Setting.text({
                name: "NPMPackageName",
                default: "minecraft-yarn-definitions",
            }),
        },
    },
    (mod) =&gt; {
        mod.on("enable", (event) =&gt; {
            const loader = createClassLoaderFromJar(
                mod.settings.path.value + "/ts-generator-1.0.0.jar"
            );
            const NPMGen = loadClassFromJar(
                loader,
                "me.commandblock2.tsGenerator.NPMPackageGenerator"
            );
            const TsGen = loadClassFromJar(
                loader,
                "me.ntrrgc.tsGenerator.TypeScriptGenerator"
            );
            const VoidType = loadClassFromJar(
                loader,
                "me.ntrrgc.tsGenerator.VoidType"
            );
            const NULL = VoidType.getEnumConstants()[0];

            const javaClasses = globalEntries
                .filter((entry) =&gt; entry[1] != undefined)
                .map((entry) =&gt; (entry[1] instanceof Class ? entry[1] : entry[1].class))
                .filter((entry) =&gt; entry != undefined);

            const kotlinClasses = javaClasses.map((entry) =&gt;
                JvmClassMappingKt.getKotlinClass(entry)
            );

            const classes = new ArrayList(kotlinClasses);

            try {
                const generated = new TsGen(
                    classes,
                    new Map(),
                    new ArrayList(),
                    new ArrayList(),
                    "number",
                    NULL
                );
                const npmPack = new NPMGen(generated, mod.settings.packageName.value);
                npmPack.writePackageTo(
                    Paths.get(mod.settings.path.value + "/types-gen")
                );

                const embeddedDefinition = `
// imports
${javaClasses
                        .map((clazz) =&gt; {
                            return `import { ${clazz.simpleName} } from "@${mod.settings.packageName.value}/types/${clazz.name.replaceAll(".", "/")}";`;
                        })
                        .join("\n")}


// definitions for objects
${globalEntries
                        .filter((entry) =&gt; entry[1] != undefined)
                        .filter((entry) =&gt; !(entry[1] instanceof Class))
                        .filter((entry) =&gt; entry[1].class != undefined)
                        .map((entry) =&gt; `export var ${entry[0]}: ${entry[1].class.simpleName};`)
                        .join("\n\n")}

`;
                console.log(embeddedDefinition)
            } catch (e) {
                e.printStackTrace();
                console.error(e);
                throw e;
            }

            // ReflectionUtil.invokeMethod(mc.player, "getName")
            // event.context.drawGuiTexture(RenderLayer.getGuiTextured, CLOSE_TEXTURE, 0, 0, 16, 16, -1);
        });
    }
);

</code></pre>
]]></description><link>https://forum.liquidbounce.net/post/39961</link><guid isPermaLink="true">https://forum.liquidbounce.net/post/39961</guid><dc:creator><![CDATA[commandblock2]]></dc:creator><pubDate>Tue, 28 Jan 2025 19:24:30 GMT</pubDate></item></channel></rss>