| 1 | package net.minecraft.client.gui.screens.multiplayer;
|
| 2 |
|
| 3 | import net.fabricmc.api.EnvType;
|
| 4 | import net.fabricmc.api.Environment;
|
| 5 | import net.minecraft.ChatFormatting;
|
| 6 | import net.minecraft.client.gui.components.Button;
|
| 7 | import net.minecraft.client.gui.layouts.Layout;
|
| 8 | import net.minecraft.client.gui.layouts.LinearLayout;
|
| 9 | import net.minecraft.client.gui.screens.Screen;
|
| 10 | import net.minecraft.network.chat.CommonComponents;
|
| 11 | import net.minecraft.network.chat.Component;
|
| 12 |
|
| 13 | @Environment(EnvType.CLIENT)
|
| 14 | public class SafetyScreen extends WarningScreen {
|
| 15 | private static final Component TITLE = Component.translatable("multiplayerWarning.header").withStyle(ChatFormatting.BOLD);
|
| 16 | private static final Component CONTENT = Component.translatable("multiplayerWarning.message");
|
| 17 | private static final Component CHECK = Component.translatable("multiplayerWarning.check").withColor(-2039584);
|
| 18 | private static final Component NARRATION = TITLE.copy().append("\n").append(CONTENT);
|
| 19 | private final Screen previous;
|
| 20 |
|
| 21 | public SafetyScreen(final Screen previous) {
|
| 22 | super(TITLE, CONTENT, CHECK, NARRATION);
|
| 23 | this.previous = previous;
|
| 24 | }
|
| 25 |
|
| 26 | @Override
|
| 27 | protected Layout addFooterButtons() {
|
| 28 | LinearLayout footer = LinearLayout.horizontal().spacing(8);
|
| 29 | footer.addChild(Button.builder(CommonComponents.GUI_PROCEED, button -> {
|
| 30 | if (this.stopShowing.selected()) {
|
| 31 | this.minecraft.options.skipMultiplayerWarning = true;
|
| 32 | this.minecraft.options.save();
|
| 33 | }
|
| 34 |
|
| 35 | this.minecraft.gui.setScreen(new JoinMultiplayerScreen(this.previous));
|
| 36 | }).build());
|
| 37 | footer.addChild(Button.builder(CommonComponents.GUI_BACK, button -> this.onClose()).build());
|
| 38 | return footer;
|
| 39 | }
|
| 40 |
|
| 41 | @Override
|
| 42 | public void onClose() {
|
| 43 | this.minecraft.gui.setScreen(this.previous);
|
| 44 | }
|
| 45 | }
|
| 46 |
|