RealmsParentalConsentScreen .java

com.mojang.realmsclient.gui.screens.RealmsParentalConsentScreen (class): members: textWidget, MESSAGE, SPACING, getNarrationMessage, lastScreen, layout.

com.mojang.realmsclient.gui.screensclass64 linescommonextends RealmsScreen2.3 KB

API Surface (4)

void init()
void onClose()
void repositionElements()
Component getNarrationMessage()

Fields & Constants (5)

MESSAGE
SPACING
layout
lastScreen
textWidget

String literals (2)

"mco.account.privacy.information"
"mco.account.privacy.info.button"

Full Source

RealmsParentalConsentScreen.java64 lines · Minecraft 26.3 · verbatim
1
package com.mojang.realmsclient.gui.screens;
2
3
import net.fabricmc.api.EnvType;
4
import net.fabricmc.api.Environment;
5
import net.minecraft.client.GameNarrator;
6
import net.minecraft.client.gui.components.Button;
7
import net.minecraft.client.gui.components.MultiLineTextWidget;
8
import net.minecraft.client.gui.layouts.FrameLayout;
9
import net.minecraft.client.gui.layouts.LinearLayout;
10
import net.minecraft.client.gui.screens.ConfirmLinkScreen;
11
import net.minecraft.client.gui.screens.Screen;
12
import net.minecraft.network.chat.CommonComponents;
13
import net.minecraft.network.chat.Component;
14
import net.minecraft.realms.RealmsScreen;
15
import net.minecraft.util.CommonLinks;
16
import org.jspecify.annotations.Nullable;
17
18
@Environment(EnvType.CLIENT)
19
public class RealmsParentalConsentScreen extends RealmsScreen {
20
	private static final Component MESSAGE = Component.translatable("mco.account.privacy.information");
21
	private static final int SPACING = 15;
22
	private final LinearLayout layout = LinearLayout.vertical();
23
	private final Screen lastScreen;
24
	private @Nullable MultiLineTextWidget textWidget;
25
26
	public RealmsParentalConsentScreen(final Screen lastScreen) {
27
		super(GameNarrator.NO_TITLE);
28
		this.lastScreen = lastScreen;
29
	}
30
31
	@Override
32
	public void init() {
33
		this.layout.spacing(15).defaultCellSetting().alignHorizontallyCenter();
34
		this.textWidget = new MultiLineTextWidget(MESSAGE, this.font).setCentered(true);
35
		this.layout.addChild(this.textWidget);
36
		LinearLayout buttonLayout = this.layout.addChild(LinearLayout.horizontal().spacing(8));
37
		Component privacyInfo = Component.translatable("mco.account.privacy.info.button");
38
		buttonLayout.addChild(Button.builder(privacyInfo, ConfirmLinkScreen.confirmLink(this, CommonLinks.GDPR)).build());
39
		buttonLayout.addChild(Button.builder(CommonComponents.GUI_BACK, button -> this.onClose()).build());
40
		this.layout.visitWidgets(x$0 -> this.addRenderableWidget(x$0));
41
		this.repositionElements();
42
	}
43
44
	@Override
45
	public void onClose() {
46
		this.minecraft.gui.setScreen(this.lastScreen);
47
	}
48
49
	@Override
50
	protected void repositionElements() {
51
		if (this.textWidget != null) {
52
			this.textWidget.setMaxWidth(this.width - 15);
53
		}
54
55
		this.layout.arrangeElements();
56
		FrameLayout.centerInRectangle(this.layout, this.getRectangle());
57
	}
58
59
	@Override
60
	public Component getNarrationMessage() {
61
		return MESSAGE;
62
	}
63
}
64

Decompiled Minecraft 26.3 source of RealmsParentalConsentScreen (com/mojang/realmsclient/gui/screens/RealmsParentalConsentScreen.java) with Mojang official mappings, stored verbatim on the site.