CatFrame 兼容层
这是 CatFrame 的模组兼容性层,同时也为模组开发提供了一些实用工具。
兼容性支持
1. IME 输入法兼容
- IngameIME compat:针对所有文本输入框组件,使其能够输入中日韩(CJK)字符。
- IMEBackport:功能与 IngameIME 相同。
2. MCPatcher 兼容
- MCPatcherForge 系列(除 MCPatcherForge 外),例如 NotFine、Angelica、OptiFuture:支持 CTM 方法,使其能够在 JSON 模型化的方块上正常工作。
- MCPatcherForge (OptiFuture <= 1.2.3):由于存在 8 个参数且其中一个无用参数无法移除,因此目前不支持此模组。
- OptiFuture:支持自然纹理(Natural textures)。
- Right Proper MCPatcher:支持 CTM 方法使其在 JSON 模型化方块上工作,并支持自然纹理。
3. Tag 标签兼容
- PineappleTags:允许 CatFrame 注册和使用这些标签。
- HogUtils (HogTags):开发中…
4. 物理模型支持
- Item Physic:
(官方版本)不可用,并可能导致我的物品变换出现短路错误;由于 ASM 短路是完全性的,意味着难以恢复,因此该版本会导致崩溃。
(非官方版本)测试良好,旋转和自旋将通过 Mixin 完全应用。
5. 副手兼容
- Backhand (GTNH edition 1.8.x):使 CatFrame 的手部渲染在副手/左手(对于右撇子而言,左撇子则为右手)中正确显示。
6. 提示框兼容
- Chromatic Tooltips:允许 Chromatic 提示框在现代屏幕上渲染。
- NotEnoughItems (非官方,GTNH 版本):保持 NEI 的单个提示框框架,同时 CatFrame 的结构化提示框组件(例如合成表网格)渲染在其中,而不是两个模组叠加两个框架。
已知限制
CTM 部分
玻璃板 CTM 角落连接:当在玻璃板上使用 CTM 时,角落连接可能会显示错误的变体。这是一个限制:CatFrame 的 VMM 渲染绕过了处理薄板连通性的专用面板渲染逻辑(PaneRenderHelper/GlassPaneRenderer)。CTM 引擎使用通用的邻居检测机制,未考虑面板的薄板几何结构。基本的面板 CTM 连接工作正常;仅角落/边缘变体可能不准确。
通过内置资源包修复。
Backhand
第三人称副手持握的物品方块:CatFrame 的 RenderJsonItemModel.resolveHeadSlotKind 基于 stack != entity.getHeldItem() 将头槽所有权标记给头部插槽,而 Backhand 的第三人称传递不进行槽位交换,因此副手中持握的 ItemBlock 被错误分类为头槽渲染(ITEM_HEAD 阶段 + 头部预变换),直到 CatFrame 核心学会区分副手之前,渲染位置会错位。
Better Foliage (Issue #6)
未计划支持。Better Foliage - Legacy Edition 将其渲染覆盖安装在其主体 RenderBlocks.renderBlockByRenderType 内部,而 CatFrame 在其托管的每个方块的入口处拦截该方法——因此对于这些方块(原版树叶、原木、草、沙子等),Better Foliage 的功能(Extra Leaves、Round Logs 等)永远不会执行。两个模组都想绘制相同的方块,而每个方块的外观只能来自一个管线——让 Better Foliage 渲染这些方块意味着将其完全交给它,代价是 CatFrame 在其上的渲染(CTM、自然纹理、渲染扩展)。这种权衡被拒绝,因此不计划此兼容性;Better Foliage 继续在 CatFrame 未托管的方块上工作(例如模组树叶)。
提示框部分
NotEnoughItems
- 为什么需要桥接器。 NEI 使用 ASM
MethodReplacer 重写 GuiContainer.drawScreen 内部的 renderToolTip 调用点,因此 CatFrame 自己的 renderToolTip 覆盖从未运行——尽管 CatFrame 的 extractTooltip 仍然排队其延迟的九宫格提示框。结果是出现两个包含相同文本的框架。
文本行根本不需要任何处理:NEI 通过 ItemStack.getTooltip 解析它们,因此通过 ItemTooltipEvent 贡献的所有内容(包括本模组的标签提示框)都已经共享。受影响的主要是框架和结构化组件。
桥接器的作用。 在 post-init 阶段,它在 NEI (GuiContainerManager.addTooltipHandler) 中提前注册了物品提示框挂钩。当悬停的物品堆栈具有 CatFrame 提示框组件(例如 ItemTooltipImages,如合成表网格)时,该组件被包装成 CodeChickenLib 行处理器(GuiDraw.TOOLTIP_HANDLER + GuiDraw.getTipLineId)并插入到索引 1,即物品名称下方——与 CatFrame 使用的槽位相同。然后框架被标记为 NEI 所有,并通过后期 Mixin 取消 CatFrame 对该框架的 extractTooltip,从而只绘制一个框架。桥接器不是屏幕范围的:组件也注入到其他模组的容器 GUI 中,其中 NEI 已经是提示框渲染器。取消操作才是屏幕范围的(只有 CatFrame 屏幕会绘制第二个框架)。
Chromatic Tooltips
- 当安装 Chromatic Tooltips 时,它胜出:CT 全盘替换提示框并在
DrawScreenEvent.Post 上绘制,位于 NEI 框架之后,因此两者无法合并。桥接器随后在 CatFrame 屏幕上抑制 NEI 的容器提示框(IContainerObjectHandler.shouldShowTooltip),而不是将组件转换为它,由 CT 渲染所有内容。
CatFrame 的提示框样式和定位器未生效。 在此配置下,NEI 负责放置(mousex + 12, mousey - 12)和分页;CatFrame 的 TOOLTIP_STYLE 和 ClientTooltipPositioner 仅在无 NEI 时生效。
启用 showTooltipWithItemInHand() == true 的组件在持有物品时不显示提示。 NEI 的替换实现保留了原版 carried == null 的检查逻辑,因此在鼠标光标持有物品时,物品提示分支永远不会执行。目前 CatFrame 没有组件采用此行为,因此这是一个面向未来的限制。
组件高度参与分页。 CodeChickenLib 使用 handler.getSize().height 和提示框显示区域高度进行分页,因此高于 displaySize().height - 26 的组件会获得独立的一页,并可能溢出。组件应保持在几个物品行的高度范围内。
每个屏幕仅有一个渲染所有者。 当存在 NEI 时,NEI 的框架被扩展而非替换:CatFrame 无法重新添加其自己的背景/内边距。当存在 CT 时,NEI 的框架被抑制而非合并,因此在该配置下,NEI 特定的物品提示部分(其自身的处理器、数量详情)不会出现在 CatFrame 屏幕上。处理器是按帧的。 CodeChickenLib 在 drawMultilineTip 结束时清除其行处理器表,因此桥接代码每帧都会构建新的处理器并重新读取行 ID;标记无法跨帧缓存。
欢迎提交打破这些限制的 PR。
工具
配置
添加支持多种配置文件类型的配置功能。
模型
- ModelBound:从 CatFrame JSON 方块模型派生方块边界。
- BlockState Transformation:来自现代 NeoForge 的方块状态转换。
UI
- 用于现代 UI 开发的主题系统。
- 用于现代 UI 开发的动画。(仅包含少量功能,且存在诸多限制。)
- 类似 HTML 浏览器的 UI 创建。(开发中…)
本地化
- 该模块是一个扩展工具,允许加载任意包中的 JSON 语言文件。
依赖
CatFrame (0.9.0 以上版本), JarUtils (0.0.2 以上版本)。
许可
源代码: MIT License
二进制 JAR: Redistribution License
CatFrame Compat
The mod compatibility layer for CatFrame, also provide some useful tools for mod develop.
Compat
1. IME Compat
- IngameIME compat: For all the text input box components let it input CJK
- IMEBackport: Same as IngameIME.
2. MCPatcher Compat
- MCPatcherForge series (Except MCPatcherForge), e.g., NotFine, Angelica, OptiFuture: Support CTM methods to let it working on the json-modelized blocks.
- MCPatcherForge (OptiFutrue <= 1.2.3): Because have 8 parameter and one useless parameter is cannot be removed, so this mod support is currently unavailable.
- OptiFuture: Support the Natural textures.
- Right Proper MCPatcher: Support CTM methods to let it working on the json-modelized blocks, and natural textures.
3. Tag Compat
- PineappleTags: For the tags is can be registered and used by CatFrame.
- HogUtils (HogTags): Developing…
4. Model for physics
- Item Physic:
(Official version) is not available and potentially causing a short in my item transformation, and cannot avoid because the asm short is fully short which means hard to retrieve, so this version will cause a crash.
(Unofficial version) is tested fine and the rotation and spin will be fully applied by Mixin.
5. Offhand Compat
- Backhand (GTNH edition 1.8.x): Let the CatFrame hand things render correctly in the offhand/left hand (For right-handed person, but for the left-handed person is right hand).
6. Tooltip Compat
- Chromatic Tooltips: Allow Chromatic tooltips rendering on the modern screen.
- NotEnoughItems (Unofficial, GTNH edition): Keeps NEI's single tooltip frame while CatFrame's structured tooltip components (e.g. the bundle grid) are rendered inside it, instead of the two mods stacking two frames.
Known Limitations
CTM Part
Glass Pane CTM Corner Connection: When using CTM on glass panes, the corner connections may display incorrect variants. This is a limitation: CatFrame's VMM rendering bypasses the specialized pane rendering logic (PaneRenderHelper/GlassPaneRenderer) that handles thin-pane connectivity. The CTM engine uses generic neighbor detection which doesn't account for pane thin-plate geometry. Basic pane CTM connections work correctly; only corner/edge variants may be inaccurate.
Fixed via the built-in texture packs.
Backhand
Third-person offhand block items: CatFrame's RenderJsonItemModel.resolveHeadSlotKind keys head-slot ownership off stack != entity.getHeldItem(), and Backhand's third-person pass does no slot swap, so an ItemBlock held in the offhand is misclassified as a head-slot render (ITEM_HEAD phase + head preTransform) and renders misplaced until the CatFrame core learns to distinguish the offhand.
Better Foliage (Issue #6)
Not planned. Better Foliage - Legacy Edition installs its render override inside the body of RenderBlocks.renderBlockByRenderType, while CatFrame intercepts that method at its entry for every block it hosts — so on those blocks (vanilla leaves, logs, grass, sand, etc.) Better Foliage's features (Extra Leaves, Round Logs, etc.) never execute. Both mods want to draw the same blocks, and each block's appearance can only come from one pipeline — making Better Foliage render these blocks would mean yielding them entirely to it, at the cost of CatFrame's rendering on them (CTM, Natural textures, render extensions). That trade-off is declined, so this compatibility is not planned; Better Foliage keeps working on blocks CatFrame does not host (e.g., modded leaves).
Tooltip Part
NotEnoughItems
- Why a bridge is needed. NEI rewrites the
renderToolTip call site inside GuiContainer.drawScreen with an ASM MethodReplacer, so CatFrame's own renderToolTip override never runs - while CatFrame's extractTooltip still queues its deferred nine-slice tooltip. The result is two frames with the same text.
Text lines need no work at all: NEI resolves them through ItemStack.getTooltip, so everything contributed via ItemTooltipEvent (including this mod's tag tooltips) is already shared. Only the frame and the structured components are affected.
What the bridge does. At post-init it registers ahead-of-the-item-tooltip hook with NEI (GuiContainerManager.addTooltipHandler). When the hovered stack has a CatFrame tooltip component (ItemTooltipImages, e.g. the bundle grid), the component is wrapped into a CodeChickenLib line handler (GuiDraw.TOOLTIP_HANDLER + GuiDraw.getTipLineId) and inserted at index 1, i.e. right under the item name - the same slot CatFrame uses. The frame is then flagged as NEI-owned and a late mixin cancels CatFrame's extractTooltip for that frame, so exactly one frame is painted. The bridge is not screen-scoped: components are also injected in other mods' container GUIs, where NEI is already the tooltip renderer. Only the cancellation is screen-scoped (CatFrame screens are the only ones that would paint a second frame).
Chromatic Tooltips
- When Chromatic Tooltips is installed it wins: CT replaces the tooltip wholesale and draws it on
DrawScreenEvent.Post, after NEI's frame, so the two cannot be merged. The bridge then suppresses NEI's container tooltip on CatFrame screens (IContainerObjectHandler.shouldShowTooltip) instead of translating components into it, and CT renders everything.
CatFrame's tooltip style and positioner are not applied. NEI owns placement (mousex + 12, mousey - 12) and paging in this setup; CatFrame's TOOLTIP_STYLE and ClientTooltipPositioner only take effect without NEI.
Components with showTooltipWithItemInHand() == true do not show while an item is carried. NEI's replacement keeps the vanilla carried == null guard, so the item tooltip branch never runs while something is held on the cursor. No current CatFrame component opts into that behaviour, so this is a forward-looking limitation.
Component height participates in pagination. CodeChickenLib pages the tooltip using handler.getSize().height and the tooltip display area height, so a component taller than displaySize().height - 26 is given a page of its own and may overflow it. Components are expected to stay in the range of a few item rows.
One rendering owner per screen. With NEI present, NEI's frame is extended, not replaced: CatFrame cannot re-add its own background/padding. With CT present, NEI's frame is suppressed instead of merged, so NEI-specific parts of the item tooltip (its own handlers, count details) do not appear on CatFrame screens in that setup. Handlers are per-frame. CodeChickenLib clears its line-handler table at the end of drawMultilineTip, so the bridge builds a fresh handler and re-reads the line id on every frame; the marker cannot be cached across frames.
PRs that break these limitation are welcomed.
Tools
Configuration
Add the configurations that support mutiple config file type.
Model
- ModelBound: Derives block bounds from CatFrame JSON block models.
- BlockState Transformation: Transformation for Block State From Modern NeoForge.
UI
- Theme systems for modern UI developing.
- Animation for modern UI developing. (Just a few functions with a lot of limitation.)
- HTML Browser Like UI Creating. (Developing…)
Localization
- This module is a widened tool that let JSON language that in any package loading.
Dependency
CatFrame (Over 0.9.0), JarUtils (over 0.0.2).
License
Source Code: MIT License
Binary Jars: Redistribution License
评论 0
登录后参与评分
还没有评论,来抢沙发吧