Skip to content

[1.21.11] Share structure previews 共用结构渲染与只读界面预览 - #286

Merged
Gu-ZT merged 1 commit into
Anvil-Dev:dev/1.21.11from
WhereisFff:codex/shared-preview-1.21.11
Nov 14, 2026
Merged

Gu-ZT merged 1 commit into
Anvil-Dev:dev/1.21.11from
WhereisFff:codex/shared-preview-1.21.11

Conversation

@WhereisFff

Copy link
Copy Markdown
Contributor

将结构渲染、隔离沙盒、相机拾取和只读 GUI 浮窗移入砧库,让手册与机器界面共用实现,避免机器功能依赖手册模组。

  • 提供特殊方块 GUI 注册、减少动态效果参数及附加模型和后处理接口
  • 适配 1.21.11 的原生渲染与透明度补丁,保留结构中的方块实体和实体
  • 提供通用翻译、接口说明和只读作用域回归检查

验证::anvillib-rendering-neoforge-1.21.11:build(含 previewTest)与 git diff --check 通过;已对照当前版本源码核查 Mixin 目标。客户端画面尚未实测。

- 迁移隔离结构沙盒、相机拾取与原生界面浮窗
- 提供自定义界面注册和附加渲染接口,解除对手册的依赖
- 适配当前游戏版本的渲染与透明度补丁
- 补充通用翻译、接口说明及只读作用域回归检查
@Gugle2308

Copy link
Copy Markdown

🌿 Roseau API Breaking Change Report

Module Status Breaking Changes
codec ✅ Compatible 0
collision ✅ Compatible 0
cube ✅ Compatible 0
config ✅ Compatible 0
integration ✅ Compatible 0
moveable-entity-block ✅ Compatible 0
network ✅ Compatible 0
rendering ✅ Compatible 0
space-select ✅ Compatible 0
font ✅ Compatible 0
util ✅ Compatible 0
explosion ✅ Compatible 0
rpc ✅ Compatible 0
math ✅ Compatible 0
multiblock ✅ Compatible 0
recipe ✅ Compatible 0
registrum ✅ Compatible 0
sync ✅ Compatible 0
ui ✅ Compatible 0
wheel ✅ Compatible 0
main ✅ Compatible 0

Full CSVs: see the Artifacts section of this workflow run.

@Gu-ZT
Gu-ZT merged commit 5c94d5e into Anvil-Dev:dev/1.21.11 Nov 14, 2026
1 check passed

@Gugle2308 Gugle2308 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

结论:PR #286 已合并(squash 5c94d5e8,dev/1.21.11 tip,合并树与 head b82ead84 完全一致,2026-11-14T18:45:25Z)。本线把 6 个注入点逐个按 1.21.11 的 client_mappings 与字节码核对完毕(含 1.21.11 新增的 submitTiledBlit 与改用 renderBackground),全部命中;需要跟进的是 PiP 内复用了真实世界相机做实体剔除、getSeaLevel() 与旧线不一致、沙盒音效被改成空实现,以及 defaultRequire: 1 下 pin 死 record 构造器没有运行时保险。

一、合并态与范围

判据 结果
state / merged / merged_at closed / true / 2026-11-14T18:45:25Z
merge_commit_sha 5c94d5e8450a5377e036c8607a99285b120b7dd4 = dev/1.21.11 tip
合并树 vs head 空 diff ⇒ 进主干的就是 b82ead84
规模 35 文件 +3307/−1,与收到的 diff 完全对应
head CI build / build ✅
既有评论 仅 Roseau API 报告
语言文件 en_us / en_ud / zh_cn 各 107 条,三份齐全 ✅(1.21.8 线只有两份)

二、注入点逐条核实(1.21.11 mappings + 混淆 client.jar 字节码)

注入 核对结果
submitBlit(RenderPipeline, GpuTextureView, **GpuSampler**, IIII, FFFF, I) ordinal=4 方法 487:488;int 依次为 4 个坐标 + 末位 color,ordinal=4 = 第 5 个 int = color ✅(比 1.21.8 多了 GpuSampler,描述符已同步更新)
submitTiledBlit(…, GpuSampler, IIIIII, FFFF, I) ordinal=6 方法 491:492;共 7 个 int(6 个在 3–8、color 在 13),ordinal=6 = 第 7 个 int = color ✅。这是本线新增的平铺入口(1.21.8 没有),作者跟上了
submitColoredRectangle(…, IIIII, Integer) 两个 handler 方法 209:218,只有一个重载 ⇒ ordinal=4 = 第 5 个 int(color)✅;另一个 handler 接尾部 Integer(渐变)✅
drawString(Font, FormattedCharSequence, IIIZ) ordinal=2 方法 256:260;int 在 2/3/4 ⇒ ordinal=2 = color ✅
Screen.renderBackground(GuiGraphics, int, int, float) 方法 374:385 ✅ 存在。注意本线从 1.21.8 的「拦 renderTransparentBackground」改成「拦 renderBackground」⇒ 连模糊与暗色遮罩一起跳过,与 PiP 内自绘窗口自洽,但两条线行为不同(见第四节)
RecipeBookComponent.isVisibleAccordingToBookData() 226:226 ✅
GuiRenderer.submitBlitFromItemAtlas + BlitRenderState.<init> 方法 436:449 ✅;字节码显示 GuiRenderer(gpp)只用 gqb.<init>:(RenderPipeline,TextureSetup,Matrix3x2f,IIIIFFFFI,ScreenRectangle,ScreenRectangle)V(整类仅 1 处构造)⇒ @ModifyArgs 唯一命中,index 11 = int color ✅
PictureInPictureRenderer.blitTexture 67:78 ✅,父类构造器 (MultiBufferSource$BufferSource) ✅

三、需要跟进(合并后)

  • PiP 里复用了真实世界的相机(最实质的一项):renderToTexture 取 mc.gameRenderer.getLevelRenderState().cameraRenderState,随后 entityRenderDispatcher.submit(entityState, camera, …) 与 blockEntityRenderer.submit(state, pose, nodes, camera) 都用它。实体的裁剪距离、shouldRender、阴影/悬停判定会按玩家真实视角计算 ⇒ 结构里的实体在玩家背后或超出视距时会被剔除(预览窗里「东西凭空少一半」)。建议构造一个与预览相机一致的 CameraRenderState(位置放预览中心、朝向与 state.transform() 对齐),或至少用固定正交相机参数。
  • SandboxRenderLevel.getSeaLevel() 返回 0,而 1.21.4 / 1.21.8 都是 63。跨线不一致,会影响依赖海平面的流体/高度逻辑;建议统一(预览用 63 更接近真实世界观感)。
  • DelegatingServerLevelAccessor.playSound / levelEvent 在本线变成空实现(1.21.8 是委托 delegate)⇒ 预览里箱子开盖、方块破坏等音效与粒子被完全吞掉。若是有意的「沙盒静音」请补一行注释,否则是移植时漏改;getCurrentDifficultyAt 改成常量 DifficultyInstance 则是合理的。
  • defaultRequire: 1 + required: true 下 pin 死 record 构造器没有运行时保险:两个 @ModifyArgs 精确绑定了 BlitRenderState 的 14 参 canonical 构造器,而 build / previewTest 不会加载 mixin,CI 绿不能证明命中(本次由我按字节码手工证)。上游一旦改用 13 参便捷构造器或增删字段就是启动崩溃,建议给这两个纯视觉注入加 require = 0。
  • mixins.json 的 compatibilityLevel 是本线独有的 JAVA_8(1.21.1 / 1.21.4 / 1.21.8 都是 JAVA_21)——既有配置,但新增 6 个 mixin 后建议统一,避免以后有人用 record/pattern 等新特性踩坑。
  • StructureRenderEvents.fallingBlocks 本线改为 state.movingBlockRenderState(1.21.11 的 render-state 结构),判定条件仍是 entity.level() instanceof SandboxRenderLevel;属全局注册的修正,影响面与 1.21.8 相同,建议注释说明。
  • 既有项(跨线通病):getFilledBlocks() 返回复用的 MutableBlockPos;StructureGuiProviders.register 冲突直接抛 IllegalStateException(客户端初始化期);StructureBlockEntityDetails.describe / StructureDetailsPager 仍无生产调用方(107×3 条 lang 随之闲置)。

四、与 1.21.8 的差异对照(便于后续统一)

维度 1.21.8(#285) 1.21.11(本 PR)
透明度入口 4 个(blit / 填充 / 渐变 / 文本) 5 个(新增 submitTiledBlit)✅ 跟上了新 API
背景拦截 renderTransparentBackground renderBackground(更强,连模糊一起去掉)
提交体系 直接 renderer.submit(…) / BlockEntityRenderer.render(…) SubmitNodeStorage + FeatureRenderDispatcher + CameraRenderState
沙盒 recipe / fuel 委托 Minecraft.getInstance().level(断开时 NPE) 本地 ClientRecipeContainer / FuelValues.Builder ⇒ 更稳,建议回填到 1.21.4 / 1.21.8 ✅
sea level 63 0
音效 / levelEvent 委托 delegate 空实现
lang en_us + zh_cn en_us + en_ud + zh_cn ✅
结构实体坐标键 block_pos block_pos(一致)

Effects 接口在本线收 SubmitNodeCollector,与 README「1.21.8、1.21.11、26.1 在 PiP 纹理目标中执行」的表述一致 ✅。

五、验证边界

未执行 Gradle 构建、runClient 与游戏内实测(PR 自述「客户端画面尚未实测」);previewTest 只覆盖 provider 注册、renderOnly 嵌套/异常恢复与缓动函数,不加载 mixin、不渲染。本文结论来自静态读码 + 1.21.11 官方 client_mappings/混淆 client.jar 的成员与字节码核对(上表逐项已注明方法与行号,含 gqb.<init> 唯一构造的事实)+ 合并树/head 对账 + head CI + 三份 lang 的键数比对。建议实机补测:真实容器屏在不同 GUI scale 下的浮窗裁剪与层级、F3 隐藏 GUI、结构内实体位于玩家背后/远处的可见性(对应第三节第一条)、大尺寸物品淡出、悬挂实体与乘客位置,以及同一结构在 1.21.8 与 1.21.11 上的观感一致性(背景拦截与海平面两处差异最可能表现为「版本间看起来不一样」)。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants