WaitingForResponseScreen.java

net.minecraft.client.gui.screens.dialog.WaitingForResponseScreen

信息

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

    TODO

字段/常量

  • TITLE

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

      TODO

  • BUTTON_LABELS

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

      TODO

  • BUTTON_VISIBLE_AFTER

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

      TODO

  • BUTTON_ACTIVE_AFTER

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

      TODO

  • previousScreen

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

      TODO

  • layout

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

      TODO

  • closeButton

    • 类型: Button
    • 修饰符: private final
    • 源码定位: L28
    • 说明:

      TODO

  • ticks

    • 类型: int
    • 修饰符: private
    • 源码定位: L29
    • 说明:

      TODO

内部类/嵌套类型

构造器

public WaitingForResponseScreen(Screen nextScreen) @ L31

  • 构造器名:WaitingForResponseScreen
  • 源码定位:L31
  • 修饰符:public

参数:

  • nextScreen: Screen

说明:

TODO

方法

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

protected void init() @ L38

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

参数:

说明:

TODO

protected void repositionElements() @ L49

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

参数:

说明:

TODO

public void tick() @ L55

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

参数:

说明:

TODO

public boolean isPauseScreen() @ L69

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

参数:

说明:

TODO

public boolean shouldCloseOnEsc() @ L74

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

参数:

说明:

TODO

public void onClose() @ L79

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

参数:

说明:

TODO

public Screen previousScreen() @ L84

  • 方法名:previousScreen
  • 源码定位:L84
  • 返回类型:Screen
  • 修饰符:public

参数:

说明:

TODO

代码

@OnlyIn(Dist.CLIENT)
public class WaitingForResponseScreen extends Screen {
    private static final Component TITLE = Component.translatable("gui.waitingForResponse.title");
    private static final Component[] BUTTON_LABELS = new Component[]{
        Component.empty(),
        Component.translatable("gui.waitingForResponse.button.inactive", 4),
        Component.translatable("gui.waitingForResponse.button.inactive", 3),
        Component.translatable("gui.waitingForResponse.button.inactive", 2),
        Component.translatable("gui.waitingForResponse.button.inactive", 1),
        CommonComponents.GUI_BACK
    };
    private static final int BUTTON_VISIBLE_AFTER = 1;
    private static final int BUTTON_ACTIVE_AFTER = 5;
    private final @Nullable Screen previousScreen;
    private final HeaderAndFooterLayout layout;
    private final Button closeButton;
    private int ticks;
 
    public WaitingForResponseScreen(@Nullable Screen nextScreen) {
        super(TITLE);
        this.previousScreen = nextScreen;
        this.layout = new HeaderAndFooterLayout(this, 33, 0);
        this.closeButton = Button.builder(CommonComponents.GUI_BACK, button -> this.onClose()).width(200).build();
    }
 
    @Override
    protected void init() {
        super.init();
        this.layout.addTitleHeader(TITLE, this.font);
        this.layout.addToContents(this.closeButton);
        this.closeButton.visible = false;
        this.closeButton.active = false;
        this.layout.visitWidgets(x$0 -> this.addRenderableWidget(x$0));
        this.repositionElements();
    }
 
    @Override
    protected void repositionElements() {
        this.layout.arrangeElements();
        FrameLayout.centerInRectangle(this.layout, this.getRectangle());
    }
 
    @Override
    public void tick() {
        super.tick();
        if (!this.closeButton.active) {
            int secondsVisible = this.ticks++ / 20;
            this.closeButton.visible = secondsVisible >= 1;
            this.closeButton.setMessage(BUTTON_LABELS[secondsVisible]);
            if (secondsVisible == 5) {
                this.closeButton.active = true;
                this.triggerImmediateNarration(true);
            }
        }
    }
 
    @Override
    public boolean isPauseScreen() {
        return false;
    }
 
    @Override
    public boolean shouldCloseOnEsc() {
        return this.closeButton.active;
    }
 
    @Override
    public void onClose() {
        this.minecraft.setScreen(this.previousScreen);
    }
 
    public @Nullable Screen previousScreen() {
        return this.previousScreen;
    }
}

引用的其他类

  • Button

    • 引用位置: 字段/方法调用
    • 关联成员: Button.builder()
  • FrameLayout

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

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

    • 引用位置: 参数/字段/继承/返回值
  • Component

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