Add GroundCraft plugin#1170
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Hey - 我发现了 1 个问题,并提供了一些整体反馈:
- GroundCraft.cs 已经变成了一个非常庞大、包含多种职责的类(插件生命周期、扫描、环境探测、配方导入/审计、配置/规格类型);建议将其中的支撑类型和逻辑拆分到单独的文件或辅助类中,以保持核心插件类更小、更易维护。
- ReloadFiles 会修改 _config、_recipes 和 _audit,而 OnGameUpdate/ScanDrops 可能会读取它们;在重载和扫描路径上加一个简单的锁,可以避免潜在的竞争条件以及被观察到的部分更新状态。
- TryCraftCluster 在找到集群的第一个匹配配方后就停止;如果希望在一次扫描中为同一个集群合成多条配方,可能需要在某个配方成功后继续迭代,而不是立即返回。
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- GroundCraft.cs has grown into a very large, multi-responsibility class (plugin lifecycle, scanning, environment probing, recipe import/audit, config/spec types); consider splitting supporting types and logic into separate files or helper classes to keep the core plugin class smaller and easier to maintain.
- ReloadFiles modifies _config, _recipes and _audit while OnGameUpdate/ScanDrops can read them; adding a simple lock around reload and scan paths would avoid potential race conditions and partially-updated state being observed.
- TryCraftCluster stops after the first matching recipe for a cluster; if multiple recipes per cluster are intended to be craftable in one scan, you may want to continue iterating rather than returning immediately once a recipe succeeds.
## Individual Comments
### Comment 1
<location path="src/GroundCraft/GroundCraft.cs" line_range="1259-1262" />
<code_context>
+ return $"{recipe.Id}: {ingredients} => {ItemName(recipe.OutputType)} x{recipe.OutputStack} @ {StationName(recipe.RequiredTiles)} {ConditionName(recipe.Conditions)}";
+ }
+
+ private static string StationName(IReadOnlyCollection<int> tileTypes)
+ {
+ if (tileTypes.Count == 0)
+ return "任意地点";
+
+ return string.Join("/", tileTypes.Select(tileType => tileType switch
+ {
+ TileID.WorkBenches => "工作台",
+ TileID.Furnaces => "熔炉",
+ TileID.Hellforge => "地狱熔炉",
+ TileID.Anvils => "铁砧/铅砧",
+ TileID.Sawmill => "锯木机",
+ TileID.Loom => "织布机",
+ TileID.Kegs => "酒桶",
+ TileID.Bottles => "瓶子/炼药桌",
+ TileID.CookingPots => "烹饪锅",
+ TileID.TinkerersWorkbench => "工匠作坊",
+ TileID.Extractinator => "提炼机",
+ TileID.MythrilAnvil => "秘银砧/山铜砧",
+ _ => $"图格 {tileType}"
+ }));
+ }
</code_context>
<issue_to_address>
**nitpick (typo):** 默认的工作台名称使用了“图格”,这看起来像是一个拼写错误。
回退标签目前是 `$"图格 {tileType}"`,在中文中读起来像是笔误。请更新这个字符串(比如改为“图块”或其他合适的术语),以便在向管理员展示未知的 tile ID 时,回退的工作台名称更加清晰易读。
```suggestion
TileID.MythrilAnvil => "秘银砧/山铜砧",
_ => $"图块 {tileType}"
}));
}
```
</issue_to_address>Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Original comment in English
Hey - I've found 1 issue, and left some high level feedback:
- GroundCraft.cs has grown into a very large, multi-responsibility class (plugin lifecycle, scanning, environment probing, recipe import/audit, config/spec types); consider splitting supporting types and logic into separate files or helper classes to keep the core plugin class smaller and easier to maintain.
- ReloadFiles modifies _config, _recipes and _audit while OnGameUpdate/ScanDrops can read them; adding a simple lock around reload and scan paths would avoid potential race conditions and partially-updated state being observed.
- TryCraftCluster stops after the first matching recipe for a cluster; if multiple recipes per cluster are intended to be craftable in one scan, you may want to continue iterating rather than returning immediately once a recipe succeeds.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- GroundCraft.cs has grown into a very large, multi-responsibility class (plugin lifecycle, scanning, environment probing, recipe import/audit, config/spec types); consider splitting supporting types and logic into separate files or helper classes to keep the core plugin class smaller and easier to maintain.
- ReloadFiles modifies _config, _recipes and _audit while OnGameUpdate/ScanDrops can read them; adding a simple lock around reload and scan paths would avoid potential race conditions and partially-updated state being observed.
- TryCraftCluster stops after the first matching recipe for a cluster; if multiple recipes per cluster are intended to be craftable in one scan, you may want to continue iterating rather than returning immediately once a recipe succeeds.
## Individual Comments
### Comment 1
<location path="src/GroundCraft/GroundCraft.cs" line_range="1259-1262" />
<code_context>
+ return $"{recipe.Id}: {ingredients} => {ItemName(recipe.OutputType)} x{recipe.OutputStack} @ {StationName(recipe.RequiredTiles)} {ConditionName(recipe.Conditions)}";
+ }
+
+ private static string StationName(IReadOnlyCollection<int> tileTypes)
+ {
+ if (tileTypes.Count == 0)
+ return "任意地点";
+
+ return string.Join("/", tileTypes.Select(tileType => tileType switch
+ {
+ TileID.WorkBenches => "工作台",
+ TileID.Furnaces => "熔炉",
+ TileID.Hellforge => "地狱熔炉",
+ TileID.Anvils => "铁砧/铅砧",
+ TileID.Sawmill => "锯木机",
+ TileID.Loom => "织布机",
+ TileID.Kegs => "酒桶",
+ TileID.Bottles => "瓶子/炼药桌",
+ TileID.CookingPots => "烹饪锅",
+ TileID.TinkerersWorkbench => "工匠作坊",
+ TileID.Extractinator => "提炼机",
+ TileID.MythrilAnvil => "秘银砧/山铜砧",
+ _ => $"图格 {tileType}"
+ }));
+ }
</code_context>
<issue_to_address>
**nitpick (typo):** The default station name uses "图格", which appears to be a typo.
The fallback label is currently `$"图格 {tileType}"`, which reads as a typo in Chinese. Please update this string (e.g., to "图块" or another appropriate term) so fallback station names are clear and readable when an unknown tile ID is shown to admins.
```suggestion
TileID.MythrilAnvil => "秘银砧/山铜砧",
_ => $"图块 {tileType}"
}));
}
```
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
ACaiCat
requested changes
Jun 29, 2026
Contributor
Author
|
已按 review 重新提交 GroundCraft 优化:
本地验证: |
Contributor
Author
|
补充了合成成功时的客户端粒子效果:
验证: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Validation
Summary by Sourcery
引入 GroundCraft Terraria/TShock 插件,用于基于 JSON 配方以及环境/首领条件的掉落物品合成。
New Features:
Documentation:
Chores:
Original summary in English
Summary by Sourcery
Introduce the GroundCraft Terraria/TShock plugin for dropped-item crafting driven by JSON recipes and environment/boss conditions.
New Features:
Documentation:
Chores: