ErrorScreen.java

net.minecraft.client.gui.screens.ErrorScreen

信息

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

    TODO

字段/常量

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

      TODO

内部类/嵌套类型

构造器

public ErrorScreen(Component title, Component message) @ L14

  • 构造器名:ErrorScreen
  • 源码定位:L14
  • 修饰符:public

参数:

  • title: Component
  • message: Component

说明:

TODO

方法

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

protected void init() @ L19

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

参数:

说明:

TODO

public void extractRenderState(GuiGraphicsExtractor graphics, int mouseX, int mouseY, float a) @ L27

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

参数:

  • graphics: GuiGraphicsExtractor
  • mouseX: int
  • mouseY: int
  • a: float

说明:

TODO

public void extractBackground(GuiGraphicsExtractor graphics, int mouseX, int mouseY, float a) @ L34

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

参数:

  • graphics: GuiGraphicsExtractor
  • mouseX: int
  • mouseY: int
  • a: float

说明:

TODO

public boolean shouldCloseOnEsc() @ L39

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

参数:

说明:

TODO

代码

@OnlyIn(Dist.CLIENT)
public class ErrorScreen extends Screen {
    private final Component message;
 
    public ErrorScreen(Component title, Component message) {
        super(title);
        this.message = message;
    }
 
    @Override
    protected void init() {
        super.init();
        this.addRenderableWidget(
            Button.builder(CommonComponents.GUI_CANCEL, button -> this.minecraft.setScreen(null)).bounds(this.width / 2 - 100, 140, 200, 20).build()
        );
    }
 
    @Override
    public void extractRenderState(GuiGraphicsExtractor graphics, int mouseX, int mouseY, float a) {
        super.extractRenderState(graphics, mouseX, mouseY, a);
        graphics.centeredText(this.font, this.title, this.width / 2, 90, -1);
        graphics.centeredText(this.font, this.message, this.width / 2, 110, -1);
    }
 
    @Override
    public void extractBackground(GuiGraphicsExtractor graphics, int mouseX, int mouseY, float a) {
        graphics.fillGradient(0, 0, this.width, this.height, -12574688, -11530224);
    }
 
    @Override
    public boolean shouldCloseOnEsc() {
        return false;
    }
}

引用的其他类