SafetyScreen.java

net.minecraft.client.gui.screens.multiplayer.SafetyScreen

信息

  • 全限定名:net.minecraft.client.gui.screens.multiplayer.SafetyScreen
  • 类型:public class
  • 包:net.minecraft.client.gui.screens.multiplayer
  • 源码路径:src/main/java/net/minecraft/client/gui/screens/multiplayer/SafetyScreen.java
  • 起始行号:L14
  • 继承:WarningScreen
  • 职责:

    TODO

字段/常量

  • TITLE

    • 类型: Component
    • 修饰符: private static final
    • 源码定位: L15
    • 说明:

      TODO

  • CONTENT

    • 类型: Component
    • 修饰符: private static final
    • 源码定位: L16
    • 说明:

      TODO

  • CHECK

    • 类型: Component
    • 修饰符: private static final
    • 源码定位: L17
    • 说明:

      TODO

  • NARRATION

    • 类型: Component
    • 修饰符: private static final
    • 源码定位: L18
    • 说明:

      TODO

  • previous

    • 类型: Screen
    • 修饰符: private final
    • 源码定位: L19
    • 说明:

      TODO

内部类/嵌套类型

构造器

public SafetyScreen(Screen previous) @ L21

  • 构造器名:SafetyScreen
  • 源码定位:L21
  • 修饰符:public

参数:

  • previous: Screen

说明:

TODO

方法

下面的方法块按源码顺序生成。

protected Layout addFooterButtons() @ L26

  • 方法名:addFooterButtons
  • 源码定位:L26
  • 返回类型:Layout
  • 修饰符:protected

参数:

说明:

TODO

public void onClose() @ L41

  • 方法名:onClose
  • 源码定位:L41
  • 返回类型:void
  • 修饰符:public

参数:

说明:

TODO

代码

@OnlyIn(Dist.CLIENT)
public class SafetyScreen extends WarningScreen {
    private static final Component TITLE = Component.translatable("multiplayerWarning.header").withStyle(ChatFormatting.BOLD);
    private static final Component CONTENT = Component.translatable("multiplayerWarning.message");
    private static final Component CHECK = Component.translatable("multiplayerWarning.check").withColor(-2039584);
    private static final Component NARRATION = TITLE.copy().append("\n").append(CONTENT);
    private final Screen previous;
 
    public SafetyScreen(Screen previous) {
        super(TITLE, CONTENT, CHECK, NARRATION);
        this.previous = previous;
    }
 
    @Override
    protected Layout addFooterButtons() {
        LinearLayout footer = LinearLayout.horizontal().spacing(8);
        footer.addChild(Button.builder(CommonComponents.GUI_PROCEED, button -> {
            if (this.stopShowing.selected()) {
                this.minecraft.options.skipMultiplayerWarning = true;
                this.minecraft.options.save();
            }
 
            this.minecraft.setScreen(new JoinMultiplayerScreen(this.previous));
        }).build());
        footer.addChild(Button.builder(CommonComponents.GUI_BACK, button -> this.onClose()).build());
        return footer;
    }
 
    @Override
    public void onClose() {
        this.minecraft.setScreen(this.previous);
    }
}

引用的其他类

  • Button

    • 引用位置: 方法调用
    • 关联成员: Button.builder()
  • Layout

    • 引用位置: 返回值
  • LinearLayout

    • 引用位置: 方法调用
    • 关联成员: LinearLayout.horizontal()
  • Screen

    • 引用位置: 参数/字段
  • JoinMultiplayerScreen

    • 引用位置: 构造调用
    • 关联成员: JoinMultiplayerScreen()
  • WarningScreen

    • 引用位置: 继承
  • Component

    • 引用位置: 字段/方法调用
    • 关联成员: Component.translatable()