From a2ec63559eee0ec9cd85d59be985c8e1e3e1d412 Mon Sep 17 00:00:00 2001
From: TBPig <147127248+TBPig@users.noreply.github.com>
Date: Tue, 26 May 2026 17:52:59 +0800
Subject: [PATCH] Update paths and refactor ItemLink handling
---
scripts/GuideME2Ageratum.py | 28 ++++++----------------------
1 file changed, 6 insertions(+), 22 deletions(-)
diff --git a/scripts/GuideME2Ageratum.py b/scripts/GuideME2Ageratum.py
index d262c10..71d82ee 100644
--- a/scripts/GuideME2Ageratum.py
+++ b/scripts/GuideME2Ageratum.py
@@ -2,8 +2,8 @@
import os
import re
-GuideME_path = r"D:\usualUsing\ProgramAndScript\PY\study\guidebook"
-Ageratum_path = r"D:\usualUsing\ProgramAndScript\Java\AnvilCraft\AnvilCraft\run\ageratum_preview"
+GuideME_path = r"D:\usualUsing\ProgramAndScript\Java\AnvilCraft-PigsPlus\src\main\resources\assets\anvilcraft_guideme"
+Ageratum_path = r"D:\usualUsing\ProgramAndScript\Java\AnvilCraft-PigsPlus\src\main\resources\assets\anvilcraft\zh_cn"
# 删除 Ageratum_path 下的所有内容
if os.path.exists(Ageratum_path):
@@ -60,26 +60,10 @@
new_content = re.sub(r'', r' ', new_content)
# 将 *
替换为 *
(支持跨行内容)
new_content = re.sub(r'(.*?)
', r'\1
', new_content, flags=re.DOTALL)
- # 将 替换为 ()[对应文件相对路径]
- def replace_item_link(m, current_dir=os.path.relpath(root, Ageratum_path)):
- namespace = m.group(1)
- item_name = m.group(2)
- full_id = f"{namespace}:{item_name}"
- # 含 "block" 的物品使用 block 键前缀,否则使用 item 键前缀(因为游戏内方块和物品的翻译键不同)
- if 'block' in item_name:
- translated = f''
- else:
- translated = f''
- if full_id in item_id_to_file:
- target_path = item_id_to_file[full_id]
- # 计算从当前文件目录到目标文件的相对路径
- if current_dir == '.':
- rel = target_path
- else:
- rel = os.path.relpath(target_path, current_dir).replace('\\', '/')
- return f'[{translated}]({rel})'
- return translated
- new_content = re.sub(r'', replace_item_link, new_content)
+ # 将 替换为
+ new_content = re.sub(r'', r'', new_content)
+ new_content = re.sub(r'', r'', new_content)
+ new_content = re.sub(r'\s*', r'', new_content)
# 将 {C} 替换为 {C}
new_content = re.sub(r'(.*?)', r'\3', new_content, flags=re.DOTALL)
# 将 替换为