Skip to content

🎛️ Интерфейс экрана сна

ПараметрТехнические детали
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. По умолчанию в ванили внизу экрана находится одна широкая кнопка Встать с постели (шириной $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.