跳到正文

LiveScript

作者:Graf_Kakashi

In-game JavaScript and Lua scripting for NeoForge with a built-in live code editor, hot-reload, autocomplete, and runtime event APIs.

收藏

介绍

中文介绍正在准备中,下面暂时显示原文。

LiveScript

LiveScript is an in-game JavaScript and Lua scripting mod for NeoForge 1.21.1.
It combines the flexibility of KubeJS with the live editing experience of ComputerCraft — but with a modern fullscreen editor directly inside Minecraft.

Security & Sandboxing

LiveScript embeds Mozilla Rhino (JavaScript) and LuaJ (Lua) as sandboxed scripting engines. Scripts cannot:

  • Access the filesystem (java.io.File, java.nio.file.* blocked)
  • Start subprocesses (java.lang.Runtime, java.lang.ProcessBuilder blocked)
  • Use reflection (java.lang.reflect.* blocked)
  • Make network requests (java.net.* blocked)

Each script has a 5-second CPU timeout. Only server operators (permission level 2, i.e. /op) can open the editor or execute scripts. The /scripteditor command uses the same permission gate as /give or /setblock.

This is the same security model as KubeJS, GroovyScript, CraftTweaker, and ComputerCraft.

Full source code: https://github.com/GrafKakashi/livescript — verify the sandbox in JsEngine.java and LuaEngine.java.

Features

  • Fullscreen in-game code editor
  • JavaScript (Rhino) and Lua (LuaJ) support
  • Live script execution and hot-reload
  • Syntax highlighting
  • Autocomplete
  • Undo / Redo
  • Code folding
  • Find & Replace
  • Runtime event APIs
  • Recipe manipulation APIs
  • Custom item registration via items.json with runtime textures
  • Tag and item utilities
  • Startup scripts with priority ordering
  • Built-in script console
  • Sandbox and timeout protection
  • CurseForge update notifications for operators

Included APIs

Events

Listen to gameplay events like:

  • player.join, player.leave, player.chat, player.death, player.respawn, player.dimension_change
  • block.break, block.place
  • item.craft, item.smelt, item.use, item.use_block, item.pickup
  • entity.spawn, entity.death, entity.damage
  • mob.target
  • explosion.start, explosion.detonate
  • server.tick

Recipes

Add or remove recipes at runtime — all 5 cooking types (smelting, smoking, blasting, campfire, stonecutting) plus shaped/shapeless crafting:

“`javascript
recipe.shapedAdd({
id: ‘livescript:magic_diamond’,
pattern: [‘DDD’, ‘DND’, ‘DDD’],
key: { D: ‘minecraft:diamond’, N: ‘minecraft:nether_star’ },
result: {
item: ‘minecraft:diamond’,
name: ‘§bMagic Diamond’,
lore: [‘§7Pulsates with arcane energy’],
glow: true
}
});

recipe.removeByOutput(‘minecraft:torch’);
“`

Custom Items

Define custom items in config/livescript/items.json, drop PNG textures in config/livescript/textures/, restart server:

“`json
{
"items": {
"magic_dust": {
"display_name": "Magic Dust",
"max_stack_size": 64,
"rarity": "rare"
}
}
}
“`

Tags & Items

tag.itemsIn('minecraft:logs'), tag.itemHas(itemStack, 'minecraft:logs'), item.byId('minecraft:diamond'), and more.

Quick Start

  1. Install the mod (NeoForge 1.21.1)
  2. Start your world / server
  3. As operator, run /scripteditor
  4. Press the + button, create example.js, write some code, click Save & Run

Links

Compatibility

  • Minecraft 1.21.1 only
  • NeoForge 21.1+
  • Works alongside KubeJS, CC: Tweaked, and other scripting mods (no classpath conflicts thanks to shaded Rhino/LuaJ)

常见问题

LiveScript 支持哪些 Minecraft 版本?

LiveScript 支持 Minecraft Java 版 1.21.1,可用的加载器:NeoForge。下载时注意选择和你游戏版本一致的文件。

LiveScript 怎么安装?

先用 PCL2 或 HMCL 启动器安装对应版本的 NeoForge,再把下载的 .jar 文件放进游戏目录的 mods 文件夹,重新启动游戏即可。开启了版本隔离的,mods 文件夹在 versions/版本名 下面。

评论

登录后评论和评分

Graf_Kakashi 的其他作品

查看全部 →