How do i create a Fabric folder to put my scripts into?
Create a Fabric mod project root folder, then place your Java code under the split source sets:
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 codesrc/client/java/for client-only code such as rendering, keybinds, screens, and HUDssrc/main/resources/forfabric.mod.json, assets, data, models, textures, and language files
For example, your first Java file would be:
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.
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?
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:
build.gradle
gradlew.bat
settings.gradle
src/
2. Build the mod
Windows:
gradlew.bat build
macOS/Linux:
./gradlew build
If the build succeeds, your mod file will be in:
build/libs/
Use the normal .jar, for example:
build/libs/mymod-1.0.0.jar
Do not use files ending in:
-sources.jar
-dev.jar
3. Copy the .jar into your Minecraft mods folder
On Windows, press Win + R, enter:
%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.jsondepends on itAny 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.
can you do this?
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.
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
Yes. I can turn it into a Fabric mod, but I need the actual script file first.
Important distinction:
If it is a
.javafile, 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:
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:
gradlew.bat build
and copy the generated file from:
build/libs/
into your Minecraft mods folder.
it is a .java file
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:
Create the Fabric 1.21.11 project files.
Add your Java file in the correct package.
Create
fabric.mod.json.Configure Gradle with Minecraft 1.21.11, Yarn mappings, and Fabric Loader.
Make any required code changes so it loads as a mod.
Set it up to build a
.jarfor yourmodsfolder.
You can also tell me the desired:
Mod name:
Mod ID:
Java package name:
If you do not care, I can choose sensible defaults.
Mod name: Fake media. Mod Id: I have no clue, Java package name: no clue
Use these defaults:
Mod name: Fake Media
Mod ID: fake_media
Java package: com.fakemedia
Main class: FakeMediaMod
The resulting Java file should be located at:
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.
📄
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.");
This is not Java—it is JavaScript written for the JsMacros Fabric mod. The clues are:
JsMacros.on(...)
Hud.createDraw2D()
Chat.say(...)
JavaWrapper.methodToJava(...)
You have two options:
Easiest: run it with JsMacros
Install Fabric for Minecraft 1.21.11.
Install the JsMacros Fabric mod compatible with 1.21.11.
Start Minecraft once.
Save the code as:
fake_media.js
Put it in:
.minecraft/config/jsMacros/macros/
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
/paycommand
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.