Riblet Joe

How do i create a Fabric folder to put my scripts into?

Kodari AI
KodariSep 8 at 11:21 pm 1
FabricScriptFolderCreator
Creates a standardized Fabric mod development folder structure for Minecraft 1.21.11. The tool generates the complete directory hierarchy including src/main/java, src/main/resources, assets, data, and configuration folders. It establishes proper package naming conventions and resource organization for Fabric mods, ensuring developers have a clean, organized workspace ready for script and mod development. The structure follows Fabric's official template layout, supporting both client and server-side mod components with separate directories for mixins, models, textures, and language files.

Create a Fabric mod project root folder, then place your Java code under the split source sets:

Plain Text
MyFabricMod/
├── build.gradle
├── gradle.properties
├── settings.gradle
├── gradlew
├── gradlew.bat
├── src/
│   ├── main/
│   │   ├── java/
│   │   │   └── com/example/mymod/
│   │   │       └── MyMod.java
│   │   └── resources/
│   │       ├── fabric.mod.json
│   │       └── assets/mymod/
│   └── client/
│       └── java/
│           └── com/example/mymod/
│               └── MyModClient.java

Use:

  • src/main/java/ for common/server-safe Java code

  • src/client/java/ for client-only code such as rendering, keybinds, screens, and HUDs

  • src/main/resources/ for fabric.mod.json, assets, data, models, textures, and language files

For example, your first Java file would be:

Plain Text
src/main/java/com/example/mymod/MyMod.java

Fabric mods do not normally use “scripts”; they use Java source files compiled with Gradle. The easiest way to create the complete folder is to start from the official Fabric example/template generator, then open the generated folder in IntelliJ IDEA or VS Code.

Riblet Joe

Now that my script is in my file what do i need to do now to get a fabric file and put it into my mods?

Kodari AI
KodariSep 8 at 11:22 pm 1

A Fabric mod is installed as a compiled .jar file. If you only have a .java script, it must first be inside a complete Fabric mod project.

1. Open a terminal in your Fabric project folder

The folder should contain files such as:

Plain Text
build.gradle
gradlew.bat
settings.gradle
src/

2. Build the mod

Windows:

Shell
gradlew.bat build

macOS/Linux:

Shell
./gradlew build

If the build succeeds, your mod file will be in:

Plain Text
build/libs/

Use the normal .jar, for example:

Plain Text
build/libs/mymod-1.0.0.jar

Do not use files ending in:

Plain Text
-sources.jar
-dev.jar

3. Copy the .jar into your Minecraft mods folder

On Windows, press Win + R, enter:

Plain Text
%appdata%\.minecraft\mods

Then copy your mod JAR into that folder.

For a custom launcher or modpack, place it in that instance’s mods folder instead.

4. Install the required dependencies

You need:

  • Fabric Loader matching your Minecraft version

  • Fabric API, if your fabric.mod.json depends on it

  • Any other libraries your mod uses

For Minecraft 1.21.11, use versions compatible with 1.21.11.

5. Launch Minecraft with the Fabric profile

Your mod should load when you start Minecraft through the Fabric installation.

If build fails, copy the error message from the terminal. If you do not have build.gradle, gradlew.bat, and the other project files yet, the Java file is not currently inside a buildable Fabric project.

Riblet Joe

can you do this?

Kodari AI
KodariSep 8 at 11:23 pm 1

Yes—but the current workspace only contains a file named fake_media; there is no Fabric project, Java source, or build.gradle to compile.

Upload or provide:

  • Your script/source file

  • Minecraft version

  • Mod ID and name

  • Whether it uses Fabric API or other libraries

Then I can create the Fabric project structure, add the code, configure Gradle, and produce the .jar for your mods folder.

Riblet Joe

My script is for 1.21.11 it does not use Fabric APi. I just don't know how to make it into a mod in fabric

Kodari AI
KodariSep 8 at 11:24 pm 1

Yes. I can turn it into a Fabric mod, but I need the actual script file first.

Important distinction:

  • If it is a .java file, I can place it into a Fabric 1.21.11 project and create the build files.

  • If it is a Python, JavaScript, or another scripting-language file, it cannot be packaged directly as a normal Fabric mod. It must be rewritten in Java, or you would need a separate scripting mod.

Upload the script or paste its contents here. I’ll then create:

Plain Text
your-mod/
├── build.gradle
├── gradle.properties
├── settings.gradle
├── src/main/java/.../YourMod.java
├── src/main/resources/fabric.mod.json
└── gradlew.bat

Since you are not using Fabric API, the project will depend only on:

  • Minecraft 1.21.11

  • Fabric Loader

  • Yarn mappings

  • Fabric Loom for building

Afterward, you would run:

Shell
gradlew.bat build

and copy the generated file from:

Plain Text
build/libs/

into your Minecraft mods folder.

Riblet Joe

it is a .java file

Kodari AI
KodariSep 8 at 11:24 pm 1

A .java file is the right starting point, but I don’t currently have the file contents. Upload the Java file here or paste its contents into the chat.

I’ll then:

  1. Create the Fabric 1.21.11 project files.

  2. Add your Java file in the correct package.

  3. Create fabric.mod.json.

  4. Configure Gradle with Minecraft 1.21.11, Yarn mappings, and Fabric Loader.

  5. Make any required code changes so it loads as a mod.

  6. Set it up to build a .jar for your mods folder.

You can also tell me the desired:

Plain Text
Mod name: 
Mod ID: 
Java package name:

If you do not care, I can choose sensible defaults.

Riblet Joe

Mod name: Fake media. Mod Id: I have no clue, Java package name: no clue

Kodari AI
KodariSep 8 at 11:25 pm 1

Use these defaults:

Plain Text
Mod name: Fake Media
Mod ID: fake_media
Java package: com.fakemedia
Main class: FakeMediaMod

The resulting Java file should be located at:

Plain Text
src/main/java/com/fakemedia/FakeMediaMod.java

The mod ID must be lowercase and contain only letters, numbers, and underscores.

Please upload the .java file or paste its contents here. I’ll then place it into a complete Fabric 1.21.11 project and adapt it into the mod’s main entrypoint if necessary.

Riblet Joe
📎 1 file 7,696 chars
📄
pasted-code-1788909959467.txt
txt 210 lines
▶
const TARGET_PLAYER = "RibletJoe2";
        const PAY_TO = "duckytuffy1";
        const TIMEOUT = 3000;
let running = false;

// Initialize global storage for custom scoreboard stats
if (typeof globalThis.customStats === "undefined") {
globalThis.customStats = {
name: "ShopHistory",
money: "$2.5K",
shards: "1.3K",
kills: "1843",
deaths: "873",
playtime: "23d 3h"
        };
        }

// -------------------------------------------------------------
// 1. REAL-TIME 2D HUD SCOREBOARD OVERLAY
// -------------------------------------------------------------
        const hud2D = Hud.createDraw2D();

hud2D.setOnDraw(JavaWrapper.methodToJava(() => {
        const stats = globalThis.customStats;
    const startX = 10;
        const startY = 100;
        const width = 110;
        const height = 110;

        // Background Container (Dark translucent card with dark purple border)
        hud2D.fill(startX, startY, startX + width, startY + height, 0xAA11111B);
    hud2D.rect(startX, startY, startX + width, startY + height, 0xFF74C7EC, 1);

// Header Title
    hud2D.addText(`§l${stats.name}`, startX + 8, startY + 8, 0xFFFFFF, true);

        // Scoreboard Stat Rows with Icons
        hud2D.addText(`§a$  §f${stats.money}`, startX + 8, startY + 26, 0xFFFFFF, true);      // Money ($)
        hud2D.addText(`§d★  §f${stats.shards}`, startX + 8, startY + 42, 0xFFFFFF, true);     // Shards (★)
        hud2D.addText(`§c⚔  §f${stats.kills}`, startX + 8, startY + 58, 0xFFFFFF, true);      // Kills (⚔)
        hud2D.addText(`§6💀 §f${stats.deaths}`, startX + 8, startY + 74, 0xFFFFFF, true);     // Deaths (💀)
        hud2D.addText(`§e🕒 §f${stats.playtime}`, startX + 8, startY + 90, 0xFFFFFF, true);   // Playtime (🕒)
        }));

        Hud.registerDraw2D(hud2D);

// -------------------------------------------------------------
// 2. COLORED GUI EDITOR SCREEN (Triggered by F10)
// -------------------------------------------------------------
JsMacros.on("Key", JavaWrapper.methodToJava((event) => {
        // Keycode 299 = F10, Action 1 = Key Press
        if (event.key === 299 && event.action === 1) {
openEditorGUI();
    }
            }));

function openEditorGUI() {
    const screen = Hud.createScreen("§dDonutSMP Stats Editor", false);
    const stats = globalThis.customStats;

    // Header Title
    screen.addText("§d§l=== DonutSMP HUD Editor ===", 10, 10, 0xCBA6F7, true);

    // Input Fields
    screen.addText("§bTitle / Name:", 10, 35, 0x89B4FA, true);
    const nameIn = screen.addTextInput(100, 30, 130, 20, "", stats.name, JavaWrapper.methodToJava(() => {}));

    screen.addText("§aMoney ($):", 10, 65, 0xA6E3A1, true);
    const moneyIn = screen.addTextInput(100, 60, 130, 20, "", stats.money, JavaWrapper.methodToJava(() => {}));

    screen.addText("§dShards (★):", 10, 95, 0xCBA6F7, true);
    const shardsIn = screen.addTextInput(100, 90, 130, 20, "", stats.shards, JavaWrapper.methodToJava(() => {}));

    screen.addText("§cKills (⚔):", 10, 125, 0xF38BA8, true);
    const killsIn = screen.addTextInput(100, 120, 130, 20, "", stats.kills, JavaWrapper.methodToJava(() => {}));

    screen.addText("§6Deaths (💀):", 10, 155, 0xFAB387, true);
    const deathsIn = screen.addTextInput(100, 150, 130, 20, "", stats.deaths, JavaWrapper.methodToJava(() => {}));

    screen.addText("§ePlaytime (🕒):", 10, 185, 0xF9E2AF, true);
    const timeIn = screen.addTextInput(100, 180, 130, 20, "", stats.playtime, JavaWrapper.methodToJava(() => {}));

    // Save Button
    screen.addButton(10, 215, 220, 22, "§a§lSave & Update Overlay", JavaWrapper.methodToJava(() => {
            globalThis.customStats = {
                    name: nameIn.getText(),
            money: moneyIn.getText(),
            shards: shardsIn.getText(),
            kills: killsIn.getText(),
            deaths: deathsIn.getText(),
            playtime: timeIn.getText()
        };

    Chat.log("§a[AutoPay & HUD] Updated custom scoreboard display!");
    Hud.openScreen(null); // Close GUI Screen
    }));

    Hud.openScreen(screen);
}

// -------------------------------------------------------------
// 3. AUTOMATIC BALANCE DETECTION & PAYMENT SCRIPT
// -------------------------------------------------------------
function parseMoney(input) {
    if (!input) return null;
    let cleaned = input.toLowerCase().replace(/[$,\s]/g, "").trim();

    let multiplier = 1;
    const lastChar = cleaned.slice(-1);

    if (["k", "m", "b", "t"].includes(lastChar)) {
        if (lastChar === "k") multiplier = 1e3;
        if (lastChar === "m") multiplier = 1e6;
        if (lastChar === "b") multiplier = 1e9;
        if (lastChar === "t") multiplier = 1e12;
        cleaned = cleaned.slice(0, -1);
    }

    const number = parseFloat(cleaned);
    if (isNaN(number) || !isFinite(number)) return null;

    return Math.round(number * multiplier);
}

function findBalance(text) {
    if (!text) return null;
    const clean = text.replace(/§[0-9a-fk-or]/gi, "");

    const matches = clean.match(/\$?\s*\d+(?:,\d{3})*(?:\.\d+)?\s*[kKmMbBtT]?/g);
    if (!matches) return null;

    for (const match of matches) {
        if (/[kKmMbBtT]/.test(match)) {
            const parsed = parseMoney(match);
            if (parsed !== null) return parsed;
        }
    }

    for (const match of matches) {
        const parsed = parseMoney(match);
        if (parsed !== null) return parsed;
    }

    return null;
}

function startPayment() {
    if (running) {
        Chat.log("§c[AutoPay] Balance check already in progress.");
        return;
    }

    running = true;
    Chat.log(`§e[AutoPay] Checking balance of §f${TARGET_PLAYER}§e...`);

    const listener = JsMacros.on(
            "RecvMessage",
            JavaWrapper.methodToJava((event) => {
    try {
                const rawMsg = event.text ? event.text.getString() : String(event);
                const cleanMsg = rawMsg.replace(/§[0-9a-fk-or]/gi, "");
                const lowerMsg = cleanMsg.toLowerCase();
                const targetLower = TARGET_PLAYER.toLowerCase();

                const isTargetMsg = lowerMsg.includes(targetLower);
                const isBalMsg = lowerMsg.includes("balance") || lowerMsg.includes("bal") || lowerMsg.includes("$");

        if (!isTargetMsg || !isBalMsg) return;

                const balance = findBalance(cleanMsg);
        if (balance === null) return;

        listener.unregister();
        running = false;

        if (balance <= 0) {
            Chat.log(`§c[AutoPay] ${TARGET_PLAYER} has $0 balance.`);
            return;
        }

        Chat.log(`§a[AutoPay] Balance found: §f$${balance.toLocaleString()}`);

        Client.runOnThread(() => {
                Time.sleep(50);
        Chat.say(`/pay ${PAY_TO} ${balance}`);
        Chat.log(`§a[AutoPay] Successfully sent §f/pay ${PAY_TO} ${balance}`);
                });

    } catch (error) {
        try { listener.unregister(); } catch (e) {}
        running = false;
        Chat.log(`§c[AutoPay] Error parsing balance: ${error}`);
    }
        })
    );

    Chat.say(`/bal ${TARGET_PLAYER}`);

    Client.runOnThread(() => {
            Time.sleep(TIMEOUT);
    if (running) {
        try { listener.unregister(); } catch (e) {}
        running = false;
        Chat.log(`§c[AutoPay] Timed out waiting for ${TARGET_PLAYER}'s balance response.`);
    }
    });
}

// Initial chat status message on script load
Chat.log("§a[Script Loaded] Auto-Pay ready. Press §dF10§a to edit custom scoreboard.");
Kodari AI
KodariSep 8 at 11:26 pm 1

This is not Java—it is JavaScript written for the JsMacros Fabric mod. The clues are:

JavaScript
JsMacros.on(...)
Hud.createDraw2D()
Chat.say(...)
JavaWrapper.methodToJava(...)

You have two options:

Easiest: run it with JsMacros

  1. Install Fabric for Minecraft 1.21.11.

  2. Install the JsMacros Fabric mod compatible with 1.21.11.

  3. Start Minecraft once.

  4. Save the code as:

Plain Text
fake_media.js
  1. Put it in:

Plain Text
.minecraft/config/jsMacros/macros/
  1. Start Minecraft with Fabric and run the script through the JsMacros menu.

Do not save it as .java; it should remain .js.

Make it a standalone Fabric mod

That requires rewriting the script in Java. The following parts would need to be recreated using Fabric/Minecraft APIs:

  • HUD overlay

  • F10 keybind

  • GUI text fields and button

  • Chat-message listener

  • Balance parsing

  • Automatic /pay command

The current script cannot simply be renamed to .java or placed inside a Fabric project and compiled. It also depends on JsMacros, so using JsMacros is the practical way to run it.

Be aware that the automatic balance/payment feature may violate the rules of the server you use. Only enable it where automation and automatic payments are permitted.

Kodari can make mistakes. Review important code before using.
Files
fake_media
Code
1 2