DiagramMatcher
基本信息
api.diagram.matcher 包 —— 决定「某个物品/流体能查到哪些图」的策略层。
接口注释:This interface contains the logic for figuring out which diagrams match an item or fluid.
三个实现
| 类 | 机制 | 使用者示例 |
|---|---|---|
ComponentDiagramMatcher |
声明式 Builder:先 addDiagram(diagram),再 addComponent(component) 登记组件 |
由图内组件反查图 |
CustomDiagramMatcher |
函数式:接 BiFunction<RecipeType, Component, Collection<Diagram>> |
GregTech Ore Dictionary、materialtools、oreprefixes |
DiagramMatcher(接口) |
all() + match(recipeType, component) |
— |
ComponentDiagramMatcher 的内部结构
Builder 用 EnumMap<Interactable.RecipeType, ...>(第 53 行)按配方类型分别登记,
因此 match() 能区分「作为输入」与「作为产物」两种查找。
DiagramSubBuilder.addComponent(Interactable.RecipeType, Component)(第 103 行)
是带类型的登记入口。
为什么用集合运算而不是计数
判定某物品是否命中,必须用 match(recipeType, component) 返回的集合,
不能用「数调用点」估算 —— 同一张图会被登记到多个组件下,
组件与图是多对多关系。
相关条目
源码
src/main/java/com/github/dcysteine/neicustomdiagram/api/diagram/matcher/DiagramMatcher.javasrc/main/java/com/github/dcysteine/neicustomdiagram/api/diagram/matcher/ComponentDiagramMatcher.javasrc/main/java/com/github/dcysteine/neicustomdiagram/api/diagram/matcher/CustomDiagramMatcher.java