From 2c1aabe78a67dc57589c6edddf1d6c2f7b08903b Mon Sep 17 00:00:00 2001 From: 1820982382 Date: Sat, 8 Aug 2026 03:14:17 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3readme?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 14 +++++++++----- README_EN.md | 17 ++++++++++------- example/infusion_example.js | 4 ++-- 3 files changed, 21 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 04b8b60..0604449 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # TC KubeJS Bridge (tckubejsbridge) +> **中文** | [English](README_EN.md) + 将 **神秘时代4(Thaumcraft 4 移植版)** 的配方系统桥接到 **KubeJS**,让整合包作者/服务器管理员 可以在 KubeJS 脚本中直接注册 TC 的注魔、炼金、奥术合成配方以及物品固有要素,并支持**替换原有配方**。 @@ -38,7 +40,7 @@ gradle :tckubejsbridge:build ## 脚本用法 -将脚本放入 `kubejs/server_scripts/`,**重启游戏生效**(见"注意事项"第 1 条)。 +将脚本放入 `kubejs/server_scripts/`,然后**重启游戏或执行 `/reload` 生效**(见"注意事项"第 1 条)。 ### 1. 注魔配方 @@ -153,10 +155,12 @@ ServerEvents.recipes(event => { ## 注意事项 -1. **改脚本后必须重启**,`/reload` 不生效: - - TC 配方在 `ThaumcraftApi.getCraftingRecipes()` 内存列表,KubeJS `/reload` 不清空它 - - 本 mod 的去重集合(按 research 键)也不随 `/reload` 清空 - - 若将来需要 `/reload` 支持,可在脚本中调用 `thaumcraft.clearRegistered()` 清空去重集合 +1. **支持热重载**:改脚本后执行 `/reload` 即可生效,无需重启游戏。 + - KubeJS 每次 `/reload` 都会重新执行 `ServerEvents.recipes`,脚本会再次运行。 + - 若脚本使用"先删后注册"(`thaumcraft.removeInfusion(...)` 再 `infusion(...)`)写法, + 删除步骤会清掉本 mod 的去重键并移除 TC 内存列表中的旧配方,因此新配方能正确重新注册。 + - 纯新增(不先删)的脚本重复 `/reload` 会被去重拦截(`skipping`),请配合 + `thaumcraft.clearRegistered()` 使用或在脚本开头调用它。 2. **research 键全局唯一**:重复键会被跳过(防止重复注册)。如需同名配方,请改键。 3. **配方不进原版 RecipeManager**:TC 注魔/炼金/奥术配方是 TC 自己的内存列表。 本桥接在脚本执行时直接调用 TC API 注册,并对 KubeJS 输出无害占位配方, diff --git a/README_EN.md b/README_EN.md index 6df33b7..066a23e 100644 --- a/README_EN.md +++ b/README_EN.md @@ -1,5 +1,7 @@ # TC KubeJS Bridge (tckubejsbridge) +> **English** | [中文](README.md) + Bridges the **Thaumcraft 4 (port)** recipe system to **KubeJS**, allowing modpack authors and server admins to register TC infusion, crucible, arcane crafting recipes and item aspect tags directly from KubeJS scripts — including **replacing existing recipes**. @@ -39,7 +41,7 @@ Compile dependencies (local jars, paths editable in `build.gradle`): ## Script Usage -Put scripts into `kubejs/server_scripts/` and **restart the game** (see Note #1). +Put scripts into `kubejs/server_scripts/`, then **restart the game or run `/reload`** (see Note #1). ### 1. Infusion Recipe @@ -154,12 +156,13 @@ ServerEvents.recipes(event => { ## Notes -1. **Restart after editing scripts — `/reload` does NOT work**: - - TC recipes live in the `ThaumcraftApi.getCraftingRecipes()` in-memory list, which KubeJS - `/reload` never clears. - - This mod's dedup set (keyed by research) is also not cleared on `/reload`. - - If you need `/reload` support later, call `thaumcraft.clearRegistered()` in the script - to reset the dedup set. +1. **Hot-reload supported**: after editing scripts, run `/reload` — no game restart needed. + - KubeJS re-runs `ServerEvents.recipes` on every `/reload`, so scripts execute again. + - With the "remove-then-register" pattern (`thaumcraft.removeInfusion(...)` followed by + `infusion(...)`), the removal step clears this mod's dedup key and drops the old recipe + from TC's in-memory list, so the new recipe registers correctly. + - Scripts that only add recipes (without removing first) will be dedup-skipped on repeated + `/reload`; call `thaumcraft.clearRegistered()` at the top of the script to reset the set. 2. **Research keys are globally unique**: duplicate keys are skipped (prevents double registration). Use a different key for same-name recipes. 3. **Recipes do NOT go into the vanilla RecipeManager**: TC infusion/crucible/arcane recipes diff --git a/example/infusion_example.js b/example/infusion_example.js index d35f840..66d1c51 100644 --- a/example/infusion_example.js +++ b/example/infusion_example.js @@ -1,6 +1,6 @@ // ============================================================ // TC KubeJS Bridge — 示例脚本 -// 放置到 kubejs/server_scripts/ 目录后【重启游戏】生效(/reload 不生效) +// 放置到 kubejs/server_scripts/ 目录后【重启游戏或 /reload】生效 // // 依赖:thaumcraft(TC4 移植版)、kubejs、tckubejsbridge // ============================================================ @@ -90,4 +90,4 @@ ServerEvents.recipes(event => { // - 要素 tag 用 TC4 移植版的拉丁文原名(aer/ignis/aqua/terra/ordo/perditio/vacuos/lux/motus/potentia/auram 等), // 完整表见 README // - 物品 id 支持 AE2 命名空间 ae2:xxx(如 ae2:interface) -// - 改脚本后必须重启游戏,/reload 不生效(TC 配方在内存列表) +// - 支持热重载:改脚本后 /reload 即可生效("先删后注册"写法会自动清掉去重键并移除旧配方)