Skip to content

🛡️ チャット表示と入力ブロック

パラメータ技術的仕様
Target Screen Classnet.minecraft.client.gui.screens.ChatScreen
Mixin HandlerChatScreenMixin.java
In-Memory StateBedChatHiderClient.hideChat (boolean)
Interception TargetsextractRenderState, keyPressed, mouseClicked, mouseScrolled
Focus Gatekeeperbedchathider$updateChatState()

🔄 ステートマシンのライフサイクル

                 [ User Clicks 'Hide Chat' ]


                BedChatHiderClient.hideChat = true


                   this.rebuildWidgets()

         ┌────────────────────┴────────────────────┐
         ▼                                         ▼
[ EditBox Input State ]                   [ Input Interception ]
• input.visible = false                   • extractRenderState -> cancel
• input.active  = false                   • keyPressed -> super.keyPressed
• input.setFocused(false)                 • mouseClicked -> super.mouseClicked
• screen.setFocused(null)                 • mouseScrolled -> super.mouseScrolled

🛡️ 4点入力インターセプト機構の詳細

チャットが非表示の場合、ChatScreenMixin は 4 つの重要な入力経路をインターセプトし、バックグラウンドでの誤入力やリンクの誤クリックを防止します:

インターセプトメソッドバニラの挙動非表示時の動作結果
extractRenderStateチャット背景、履歴テキスト、コマンド候補を描画します。super.extractRenderState を呼び出し ci.cancel() を実行します。チャットテキストと背景ボックスが完全に不可視になります。
keyPressedinput に文字を入力し、コマンド補全や履歴切替を行います。cir.setReturnValue(super.keyPressed(event)) を返します。入力と矢印キー操作が無効化されます。Escape は通常通り画面を閉じます。
mouseClickedチャットの URL、候補、ログ選択をクリックします。cir.setReturnValue(super.mouseClicked(event, doubleClick)) を返します。チャット選択は無効化され、GUI ボタン(ベッドから出るチャット表示)のみ正常動作します。
mouseScrolledチャットログの履歴を上下にスクロールします。cir.setReturnValue(super.mouseScrolled(x, y, scrollX, scrollY)) を返します。ログのスクロールは無効化され、画面は静止したままになります。

💻 ソースコードの検証と確認

java
// Sourced from ChatScreenMixin.java
@Inject(method = "extractRenderState", at = @At("HEAD"), cancellable = true)
private void onExtractRenderState(GuiGraphicsExtractor graphics, int mouseX, int mouseY, float a, CallbackInfo ci) {
    if ((Object) this instanceof InBedChatScreen && BedChatHiderClient.hideChat) {
        super.extractRenderState(graphics, mouseX, mouseY, a);
        ci.cancel();
    }
}

@Inject(method = "keyPressed", at = @At("HEAD"), cancellable = true)
private void onKeyPressed(KeyEvent event, CallbackInfoReturnable<Boolean> cir) {
    if ((Object) this instanceof InBedChatScreen && BedChatHiderClient.hideChat) {
        cir.setReturnValue(super.keyPressed(event));
    }
}

関連ページ: ホーム | ベッド画面UIとレイアウト | アーキテクチャとMixin詳細

Official documentation & web portal for Dasik Igaijinn mods.