注意
本项目是原模组的分支,如需访问原版 GitHub 仓库,请前往
<a href="https://github.com/Synnerz/ctjs/releases">
<img src="https://img.shields.io/github/v/release/Synnerz/ctjs.svg?include_prereleases" alt="Releases" />
</a>
<a href="https://github.com/Synnerz/ctjs/actions/workflows/build.yml">
<img src="https://github.com/Synnerz/ctjs/actions/workflows/build.yml/badge.svg" alt="Build Status" />
</a>
ChatTriggers (CT) 是一个 Minecraft 框架,允许使用 JavaScript 进行实时脚本编写和客户端修改。我们提供库、包装器、对象等,以尽可能简化模组开发工作。即使我们不支持你需要的某些功能,你仍然可以访问任何 Java 类和原生字段/方法。
通过 CT,你可以拥有模组开发环境的全部功能,同时具备易于使用的语言优势,并且无需重启游戏即可重新加载你的脚本。CT 还提供了 定义你自己的 Mixins 的方式!
CT 目前为 Fabric 1.21.x 版本编写。请参阅 此仓库 获取已弃用的 Forge 1.8.9 版本。
示例
想要隐藏每次进入世界时看到的烦人服务器消息吗?
register('chat', event => {
cancel(event);
}).setCriteria("Check out our store at www.some-mc-server.com for 50% off!");
或者将一系列常用命令自动化为一个命令?
register('command', () => {
ChatLib.command('command1');
ChatLib.command('command2');
ChatLib.command('command3');
}).setName('commandgroup');
甚至是像计算器这样的有趣命令:
register('command', (...args) => {
// 评估用户提供的参数...
const result = new Function('return ' + args.join(' '))();
// ...并以漂亮的绿色显示结果
ChatLib.chat(`&aResult: ${result}`);
}).command('calc');
通过 CT 的注册系统,你可以监听我们发出的自定义事件并作出响应。例如,当你切换世界、点击 GUI、击打方块、悬停在物品上查看其提示框时,我们会发出相应的事件,还有更多!你甚至可以为其他模块作者提供自定义事件。
开始使用
首先,下载并安装 Fabric,选择其中一个受支持的版本,然后前往我们的 发布页面 下载最新版本。该模组的安装方式与其他模组相同;只需将其拖入你的 mods 文件夹即可。安装完成后,你可以在游戏中通过输入 /ct import <moduleName> 导入模块,其中 <moduleName> 是模块的名称。你可以在 我们的网站 浏览可用的模块。
编写模块
如果你在我们的网站上找不到完全符合你需求的模块(这很常见),那么你需要自己编写一个!以下是操作步骤:
-
导航到
.minecraft/config/ChatTriggers/modules文件夹。如果你不知道它的位置,也可以执行/ct files,这将自动打开正确的目录。 -
创建一个以你的模块命名的新目录
-
在该目录中创建一个名为
metadata.json的文件,并在其中放入以下文本:{ "name": "<module name>", "entry": "index.js" }这意味着当我们的模块首次运行时,CT 将运行
index.js文件请注意,
<module name>必须与你的文件夹名称完全匹配! -
创建
index.js文件,并在其中写入一些代码。具体写什么取决于你想让 CT 做什么。要了解有关可用 API 的更多信息,请查看 Slate。- Slate 上的部分内容可能已过时,我们正在努力改进这一点
文档
NOTE
This project is a fork from the original mod, for the original github you can head over to
<a href="https://github.com/Synnerz/ctjs/releases">
<img src="https://img.shields.io/github/v/release/Synnerz/ctjs.svg?include_prereleases" alt="Releases" />
</a>
<a href="https://github.com/Synnerz/ctjs/actions/workflows/build.yml">
<img src="https://github.com/Synnerz/ctjs/actions/workflows/build.yml/badge.svg" alt="Build Status" />
</a>
ChatTriggers (CT) is a framework for Minecraft that enables live scripting and client modification using JavaScript. We provide libraries, wrappers, objects, and more to make your life as a modder as easy as possible. Even if we don't support something you need, you can still access any Java classes and native fields/methods.
With CT, you have all the power of a modding environment with the benefit of an easy-to-use language and the ability to reload your scripts without restarting the game. CT also provides a way to define your own Mixins!
CT is currently written for Fabric 1.21.x. See this repo for the deprecated Forge 1.8.9 version.
Examples
Want to hide an annoying server message that you see every time you join a world?
register('chat', event => {
cancel(event);
}).setCriteria("Check out our store at www.some-mc-server.com for 50% off!");
How about automating a series of common commands into one?
register('command', () => {
ChatLib.command('command1');
ChatLib.command('command2');
ChatLib.command('command3');
}).setName('commandgroup');
Or even something silly like a calculator command
register('command', (...args) => {
// Evaluate all args the user gives us...
const result = new Function('return ' + args.join(' '))();
// ...and show the result is a nice green color
ChatLib.chat(`&aResult: ${result}`);
}).command('calc');
With CT's register system, you can listen to custom events that we emit and react to them. For example, we emit events when you switch worlds, click on a GUI, hit a block, hover over an item and see its tooltip, and much more! You can even provide custom events for other module authors to use.
Getting Started
To begin, download and install Fabric for one of the supported versions, then head over to our releases page and download the latest version. The mod is installed like any mod; just drag it into your mods folder. Once installed, you can import modules in-game by typing /ct import <moduleName>, where <moduleName> is the name of the module. You can browse the available modules on our website.
Writing Modules
If you can't find any modules on the website that do exactly what you want, which is quite likely, you'll have you write your own! Here are the steps you'll want to take:
-
Navigate to the
.minecraft/config/ChatTriggers/modulesfolder. If you don't know where this is, you can also execute/ct files, which will open the correct directory automatically. -
Create a new directory with the name of your module
-
Inside the directory, create a file called
metadata.json, and inside of that, put the following text:{ "name": "<module name>", "entry": "index.js" }This means that when our module first runs, CT will run the
index.jsfileNote that
<module name>must match the name of your folder exactly! -
Create the
index.jsfile, and put some code in there. What exactly you write will depend on what you want CT to do. To learn more about the available APIs, take a look at the Slate.- Some things on the Slate may be outdated, we are working on improving this
Documentation
下载 ctjs
下载 ctjs
下载 ctjs
下载 ctjs
下载 ctjs
下载 ctjs
下载 ctjs
下载 ctjs
下载 ctjs
下载 ctjs
- 新增对 26.2 的支持
- 由于此版本采用了全新的渲染系统,某些渲染内容可能会出现问题
关于这个资源的讨论、问题反馈与使用心得
还没有讨论,来发第一帖吧
你是这个资源的作者?登录后可认领此资源。
相似资源
模组
一个用于收集生物掉落物的多区块模组。
模组
可定制的鞘翅模组,支持装饰纹饰、旗帜图案等更多功能!
模组
显示你正在注视的方块的信息。(适用于 Minecraft 1.16+ 的 Hwyla/Waila 分支)
模组
查看物品与配方
模组
原版世界生成优化模组
模组
在游戏画面角落显示附近世界地形、玩家、生物和实体的地图。可创建路径点,帮助你找到标记过的位置。
评论 0
登录后参与评分
还没有评论,来抢沙发吧