logo
0
0
WeChat Login
feat(包装器): 添加ScriptBlock包装器并扩展ScriptWorld和ScriptPlayer功能

ScriptBridge Logo ScriptBridge-Fabric

Fabric License GraalVM

中文文档 (Chinese) | API Documentation

Unleash the power of JavaScript in Minecraft. ScriptBridge-Fabric bridges the gap between Minecraft internals and runtime scripting, allowing you to run dynamic JavaScript code on both the client and server sides without restarting the game.


📖 Introduction

ScriptBridge-Fabric is a developer-friendly mod that embeds the GraalVM JavaScript engine into Minecraft. Unlike simple macro mods, ScriptBridge provides:

  1. Smart Native Access: Access net.minecraft.* classes directly. The engine automatically resolves mappings, so your scripts work in both Dev (Named) and Production (Intermediary) environments!
  2. Safe Wrappers: Use our high-level ScriptPlayer, ScriptWorld, and ScriptInventory APIs for stable and easy scripting.
  3. Dual Environment: Distinct contexts for Client (UI, Rendering, Chat) and Server (World, Players, Logic).
  4. Hot Reloading: Edit your scripts and apply changes instantly with /script reload.

✨ Features

  • High Performance: Powered by GraalVM for near-native execution speed.
  • 🔄 Hot Reload: No restart required. Tweak logic while the game runs.
  • 🛠️ Helper API: Built-in game object with rich wrappers (game.getPlayer(), game.getWorld()).
  • 🧠 Auto-Remapping: Write net.minecraft.client.MinecraftClient and let the mod handle the rest.
  • 🛡️ Sandboxed: Dangerous Java classes (Runtime, Process, IO) are blocked for security.
  • 💻 TypeScript Support: Includes type definitions for VS Code autocompletion.

📸 Screenshots

(Add your screenshots here. For example: A script sending a chat message, or a server script spawning a structure.)

Client Script DemoServer Management
Client DemoServer Demo
Custom HUD logicAdmin tools in action

📥 Installation

  1. Prerequisites: Install Fabric Loader for your Minecraft version.
  2. Download: Get the latest scriptbridge-fabric-*.jar from the Releases page.
  3. Install: Drop the jar file into your .minecraft/mods folder.
  4. Launch: Start the game. The scripts directory will be created automatically.

🚀 Getting Started

Directory Structure

After the first launch, you will see a scripts folder in your game directory:

.minecraft/ └── scripts/ ├── client/ <-- Scripts here run on your local client └── server/ <-- Scripts here run on the internal/dedicated server

Your First Script

Create a file named hello.js in scripts/client/:

// scripts/client/hello.js var player = game.getPlayer(); if (player) { player.chat("Hello " + player.getName() + "!"); player.jump(); }

Run it in-game:

/script run hello.js

Commands

CommandDescription
/script run <file>Run a script (defaults to client side).
/script reloadReload all scripts and refresh the engine.
/script listShow available scripts.
/script debugToggle debug output in chat.
/script openfileOpen the scripts folder in your OS file manager.

📚 API Reference

ScriptBridge offers a two-layered API.

  1. Helper API: Quick and easy.

    • game.getPlayer() -> Returns ScriptPlayer wrapper.
    • game.getWorld() -> Returns ScriptWorld wrapper.
    • game.setClipboard(text)
    • ...and more.
  2. Native API: Full Java access with auto-remapping.

    // Works everywhere! const MinecraftClient = Java.type('net.minecraft.client.MinecraftClient');

👉 Read the Full API Documentation

🧑‍💻 For Developers

We provide TypeScript definitions for a better coding experience.

  1. Open the scripts folder in VS Code.
  2. Copy scriptbridge.d.ts (found in the mod source or repo) to your workspace.
  3. Enjoy full autocomplete for game and Java objects!

🤝 Contributing

We welcome Pull Requests! Please see CONTRIBUTING.md for details.

📄 License

This project is licensed under the MIT License.


Made with ❤️ by MingPixel