菜单 GUI
基本信息
| 属性 | 值 |
|---|---|
| 文件 | src/main/java/sedridor/forgeamidst/GuiIngameMenuAmidst.java(35 行)、GuiMainMenuAmidst.java(24 行) |
| 启用版本 | Minecraft 1.7.10 |
两个覆写原版菜单以插入 AMIDST 按钮的类。
本 mod 不注册任何 IGuiHandler,也没有自定义 GuiScreen 容器 ——
全部靠继承原版菜单实现。
GuiIngameMenuAmidst
| 项 | 值 |
|---|---|
| 继承 | extends GuiIngameMenu |
| 注解 | @SideOnly(Side.CLIENT) |
| 按钮文案 | "ForgeAMIDST"(全大写 AMIDST) |
initGui()
super.initGui();
this.buttonList.set(3, new GuiButton(12, this.width / 2 + 2,
this.height / 4 + 80, 98, 20, "ForgeAMIDST"));
| 参数 | 值 |
|---|---|
| 替换索引 | buttonList.set(3, …) —— 直接覆盖索引 3 的原版按钮 |
| 按钮 id | 12 |
| 宽 × 高 | 98 × 20 |
| x | width / 2 + 2 |
| y | height / 4 + 80 |
⚠️ set(3, …) 是覆盖而非 add ——
原版暂停菜单索引 3 的按钮(1.7.10 里是「Options / 选项」位置附近)
被直接替换掉,玩家失去该按钮。
这是 1.7.10 菜单布局的脆弱假设:原版改版即错位。
⚠️ 按钮 id 12 与原版 GuiIngameMenu 的 id 有潜在冲突风险
(1.7.10 原版用到 0–11),此处取 12 是为规避,但无显式断言。
actionPerformed(GuiButton)
仅处理 id == 12:与 TickHandler 同源的懒加载
(FinderWindow.instance == null → loadAmidst() + loadMap(),
否则 setVisible(true))。
前置条件:if (ForgeAmidst.getWorld() != null)。
GuiMainMenuAmidst
| 项 | 值 |
|---|---|
| 继承 | extends GuiMainMenu implements GuiYesNoCallback |
| 注解 | @SideOnly(Side.CLIENT) |
| 按钮文案 | "AMIDST"(不含 Forge 前缀) |
initGui()
super.initGui();
int i = this.height / 4 + 48;
this.buttonList.add(new GuiButton(15, this.width / 2 - 152, i + 48, 48, 20, "AMIDST"));
| 参数 | 值 |
|---|---|
| 添加方式 | add(追加,不覆盖) |
| 按钮 id | 15 |
| 宽 × 高 | 48 × 20 |
| x | width / 2 - 152 |
| y | (height / 4 + 48) + 48 |
⚠️ 与 GuiIngameMenuAmidst 不同,这里是追加按钮,不破坏原版布局。
⚠️ 按钮文案有三种写法并存:
"ForgeAMIDST"(暂停菜单 + F6 键名)、"AMIDST"(主菜单)、
ForgeAmidst(@Mod name)、ForgeAmidst-GTNH(gradle.properties modName)。
actionPerformed(GuiButton)
先 super.actionPerformed(...),再判 id == 15:
只调 loadAmidst(),不调 loadMap() —— 与另两处入口不同。
⚠️ 因此主菜单按钮只初始化 AMIDST 库,不打开地图。
且它没有 ForgeAmidst.getWorld() != null 前置检查
(主菜单时本就没有 world)。
implements GuiYesNoCallback
⚠️ GuiMainMenuAmidst 实现了 GuiYesNoCallback 但
actionPerformed 中未见到对 id == 15 之外确认框的处理;
该接口通常用于「退出确认」弹窗。属于反编译版本的冗余实现。
关联
- TickHandler - F6 键,同源懒加载逻辑
- CommandAmidst -
/amidst,第三种入口 - ForgeAmidst -
loadAmidst()/loadMap() - FinderWindow - 被打开的地图窗口