OutOfMemoryScreen.java

net.minecraft.client.gui.screens.OutOfMemoryScreen

信息

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

    TODO

字段/常量

  • TITLE

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

      TODO

  • MESSAGE

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

      TODO

  • MESSAGE_WIDTH

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

      TODO

  • layout

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

      TODO

内部类/嵌套类型

构造器

public OutOfMemoryScreen() @ L19

  • 构造器名:OutOfMemoryScreen
  • 源码定位:L19
  • 修饰符:public

参数:

说明:

TODO

方法

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

protected void init() @ L23

  • 方法名:init
  • 源码定位:L23
  • 返回类型:void
  • 修饰符:protected

参数:

说明:

TODO

protected void repositionElements() @ L34

  • 方法名:repositionElements
  • 源码定位:L34
  • 返回类型:void
  • 修饰符:protected

参数:

说明:

TODO

public boolean shouldCloseOnEsc() @ L39

  • 方法名:shouldCloseOnEsc
  • 源码定位:L39
  • 返回类型:boolean
  • 修饰符:public

参数:

说明:

TODO

代码

@OnlyIn(Dist.CLIENT)
public class OutOfMemoryScreen extends Screen {
    private static final Component TITLE = Component.translatable("outOfMemory.title");
    private static final Component MESSAGE = Component.translatable("outOfMemory.message");
    private static final int MESSAGE_WIDTH = 300;
    private final HeaderAndFooterLayout layout = new HeaderAndFooterLayout(this);
 
    public OutOfMemoryScreen() {
        super(TITLE);
    }
 
    @Override
    protected void init() {
        this.layout.addTitleHeader(TITLE, this.font);
        this.layout.addToContents(FocusableTextWidget.builder(MESSAGE, this.font).maxWidth(300).build());
        LinearLayout footer = this.layout.addToFooter(LinearLayout.horizontal().spacing(8));
        footer.addChild(Button.builder(CommonComponents.GUI_TO_TITLE, button -> this.minecraft.setScreen(new TitleScreen())).build());
        footer.addChild(Button.builder(Component.translatable("menu.quit"), button -> this.minecraft.stop()).build());
        this.layout.visitWidgets(this::addRenderableWidget);
        this.repositionElements();
    }
 
    @Override
    protected void repositionElements() {
        this.layout.arrangeElements();
    }
 
    @Override
    public boolean shouldCloseOnEsc() {
        return false;
    }
}

引用的其他类

  • Button

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

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

    • 引用位置: 字段/构造调用
    • 关联成员: HeaderAndFooterLayout()
  • LinearLayout

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

    • 引用位置: 继承
  • TitleScreen

    • 引用位置: 构造调用
    • 关联成员: TitleScreen()
  • Component

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