🎛️ Interface da Cama e Layout
| Parâmetro | Detalhes técnicos |
|---|---|
| Target Screen Class | net.minecraft.client.gui.screens.InBedChatScreen |
| Superclass | net.minecraft.client.gui.screens.ChatScreen |
| Mixin Handler | InBedChatScreenMixin.java |
| Ponto de injeção | @Inject(method = "init", at = @At("TAIL")) |
| Largura do botão | $98\text{ px}$ (Esquerda: Sair da cama, Direita: Alternar chat) |
| Button Height | $20\text{ px}$ |
| Button Gap | $4\text{ px}$ |
| Vertical Anchor | $Y = H - 40\text{ px}$ |
| Translation Keys | vanilla-outsider-bed-chat-hider.hideChat, ...showChat |
🎮 Fluxo de interação do jogador
Quando um jogador entra na cama:
- O Minecraft abre a tela
InBedChatScreen. - Por padrão no vanilla, um único botão largo Sair da cama ($200\text{px}$ de largura) fica na parte inferior da tela.
- O Bed Chat Hider redimensiona dinamicamente o botão Sair da cama para $98\text{px}$ e adiciona um botão correspondente de $98\text{px}$ Ocultar chat / Mostrar chat ao lado.
- Clicar no botão de alternância inverte o estado na memória, atualizando imediatamente todos os widgets sem fechar a tela ou acordar o jogador.
📐 Geometria de coordenadas e matemática de divisão
O Minecraft vanilla calcula a posição do botão único da seguinte forma: $$X_{\text{vanilla}} = \frac{W}{2} - 100, \quad \text{Width} = 200, \quad Y = H - 40$$
O Bed Chat Hider divide esse intervalo de $200\text{px}$ em um conjunto simétrico de dois botões com uma divisão central de $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}$$
🖼️ Layout visual da tela em ASCII
Tela de sono vanilla:
+-------------------------------------------------------------+
| [Chat Log Overlay Area] |
| <Player1> Good night everyone! |
| |
| [Chat Input EditBox] ______________________________________ |
| |
| [ Leave Bed (200px) ] |
+-------------------------------------------------------------+Tela de sono Bed Chat Hider (chat visível):
+-------------------------------------------------------------+
| [Chat Log Overlay Area] |
| <Player1> Good night everyone! |
| |
| [Chat Input EditBox] ______________________________________ |
| |
| [ Leave Bed (98px) ] [ Hide Chat (98px) ] |
+-------------------------------------------------------------+Tela de sono Bed Chat Hider (chat oculto):
+-------------------------------------------------------------+
| |
| (Clean, Unobstructed Sleep View) |
| |
| |
| [ Leave Bed (98px) ] [ Show Chat (98px) ] |
+-------------------------------------------------------------+💻 Implementação técnica no código
// 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();
}Páginas relacionadas: Início | Visibilidade do Chat e Bloqueio de Entrada | Arquitetura e Análise de Mixins
