Skip to content

🎛️ ベッド画面UIとレイアウト

パラメータ技術的仕様
Target Screen Classnet.minecraft.client.gui.screens.InBedChatScreen
Superclassnet.minecraft.client.gui.screens.ChatScreen
Mixin HandlerInBedChatScreenMixin.java
注入ポイント@Inject(method = "init", at = @At("TAIL"))
ボタンの幅$98\text{ px}$ (左:ベッドから出る、右:チャット切り替え)
Button Height$20\text{ px}$
Button Gap$4\text{ px}$
Vertical Anchor$Y = H - 40\text{ px}$
Translation Keysvanilla-outsider-bed-chat-hider.hideChat, ...showChat

🎮 プレイヤーインタラクションの流れ

プレイヤーがベッドに入ると:

  1. Minecraft が InBedChatScreen 画面を開きます。
  2. バニラのデフォルトでは、画面下部に1つの幅広な「ベッドから出る」ボタン(幅 $200\text{px}$)が配置されます。
  3. Bed Chat Hider は「ベッドから出る」ボタンを動的に $98\text{px}$ に縮小し、その隣に揃いの $98\text{px}$ の「チャット非表示」/「チャット表示」ボタンを追加します。
  4. 切り替えボタンをクリックするとメモリ内の状態が反転し、画面を閉じたりプレイヤーを起こしたりすることなく、すべてのウィジェットが即座に再描画されます。

📐 座標ジオメトリと分割計算式

バニラ Minecraft での単一ボタンの配置計算式は以下の通りです: $$X_{\text{vanilla}} = \frac{W}{2} - 100, \quad \text{Width} = 200, \quad Y = H - 40$$

Bed Chat Hider はこの $200\text{px}$ の幅を、中央に $4\text{px}$ の隙間を設けた対称的なデュアルボタンクラスターに分割します:

$$\text{Leave Bed Button: } X_1 = \frac{W}{2} - 100, \quad \text{Width}_1 = 98, \quad Y_1 = H - 40$$ $$\text{Center Gap: } \Delta X = 4\text{ px}$$ $$\text{Toggle Chat Button: } X_2 = \frac{W}{2} + 2, \quad \text{Width}_2 = 98, \quad Y_2 = H - 40$$

$$\text{Total Span: } W_1 + \Delta X + W_2 = 98 + 4 + 98 = 200\text{ px}$$


🖼️ 画面レイアウトの ASCII 図解

バニラの睡眠画面:

+-------------------------------------------------------------+
| [Chat Log Overlay Area]                                     |
| <Player1> Good night everyone!                              |
|                                                             |
| [Chat Input EditBox] ______________________________________ |
|                                                             |
|                 [      Leave Bed (200px)      ]             |
+-------------------------------------------------------------+

Bed Chat Hider 睡眠画面 (チャット表示):

+-------------------------------------------------------------+
| [Chat Log Overlay Area]                                     |
| <Player1> Good night everyone!                              |
|                                                             |
| [Chat Input EditBox] ______________________________________ |
|                                                             |
|           [ Leave Bed (98px) ]  [ Hide Chat (98px) ]         |
+-------------------------------------------------------------+

Bed Chat Hider 睡眠画面 (チャット非表示):

+-------------------------------------------------------------+
|                                                             |
|              (Clean, Unobstructed Sleep View)               |
|                                                             |
|                                                             |
|           [ Leave Bed (98px) ]  [ Show Chat (98px) ]         |
+-------------------------------------------------------------+

💻 技術的なコード実装

java
// Sourced from InBedChatScreenMixin.java
@Inject(method = "init", at = @At("TAIL"))
private void onInit(CallbackInfo ci) {
    if (this.leaveBedButton != null) {
        this.leaveBedButton.setX(this.width / 2 - 100);
        this.leaveBedButton.setWidth(98);
    }

    Button toggleButton = Button.builder(
        bedchathider$getButtonMessage(),
        button -> {
            BedChatHiderClient.hideChat = !BedChatHiderClient.hideChat;
            this.rebuildWidgets();
        }
    ).bounds(this.width / 2 + 2, this.height - 40, 98, 20).build();

    this.addRenderableWidget(toggleButton);
    bedchathider$updateChatState();
}

関連ページ: ホーム | チャット表示と入力ブロック | アーキテクチャとMixin詳細

Official documentation & web portal for Dasik Igaijinn mods.