Screen.java

net.minecraft.client.gui.screens.Screen

信息

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

    TODO

字段/常量

  • LOGGER

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

      TODO

  • SCREEN_USAGE_NARRATION

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

      TODO

  • MENU_BACKGROUND

    • 类型: Identifier
    • 修饰符: public static final
    • 源码定位: L56
    • 说明:

      TODO

  • HEADER_SEPARATOR

    • 类型: Identifier
    • 修饰符: public static final
    • 源码定位: L57
    • 说明:

      TODO

  • FOOTER_SEPARATOR

    • 类型: Identifier
    • 修饰符: public static final
    • 源码定位: L58
    • 说明:

      TODO

  • INWORLD_MENU_BACKGROUND

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

      TODO

  • INWORLD_HEADER_SEPARATOR

    • 类型: Identifier
    • 修饰符: public static final
    • 源码定位: L60
    • 说明:

      TODO

  • INWORLD_FOOTER_SEPARATOR

    • 类型: Identifier
    • 修饰符: public static final
    • 源码定位: L61
    • 说明:

      TODO

  • FADE_IN_TIME

    • 类型: float
    • 修饰符: protected static final
    • 源码定位: L62
    • 说明:

      TODO

  • title

    • 类型: Component
    • 修饰符: protected final
    • 源码定位: L63
    • 说明:

      TODO

  • children

    • 类型: List<GuiEventListener>
    • 修饰符: private final
    • 源码定位: L64
    • 说明:

      TODO

  • narratables

    • 类型: List<NarratableEntry>
    • 修饰符: private final
    • 源码定位: L65
    • 说明:

      TODO

  • minecraft

    • 类型: Minecraft
    • 修饰符: protected final
    • 源码定位: L66
    • 说明:

      TODO

  • initialized

    • 类型: boolean
    • 修饰符: private
    • 源码定位: L67
    • 说明:

      TODO

  • width

    • 类型: int
    • 修饰符: public
    • 源码定位: L68
    • 说明:

      TODO

  • height

    • 类型: int
    • 修饰符: public
    • 源码定位: L69
    • 说明:

      TODO

  • renderables

    • 类型: List<Renderable>
    • 修饰符: private final
    • 源码定位: L70
    • 说明:

      TODO

  • font

    • 类型: Font
    • 修饰符: protected final
    • 源码定位: L71
    • 说明:

      TODO

  • NARRATE_SUPPRESS_AFTER_INIT_TIME

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

      TODO

  • NARRATE_DELAY_NARRATOR_ENABLED

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

      TODO

  • NARRATE_DELAY_MOUSE_MOVE

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

      TODO

  • NARRATE_DELAY_MOUSE_ACTION

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

      TODO

  • NARRATE_DELAY_KEYBOARD_ACTION

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

      TODO

  • narrationState

    • 类型: ScreenNarrationCollector
    • 修饰符: private final
    • 源码定位: L77
    • 说明:

      TODO

  • narrationSuppressTime

    • 类型: long
    • 修饰符: private
    • 源码定位: L78
    • 说明:

      TODO

  • nextNarrationTime

    • 类型: long
    • 修饰符: private
    • 源码定位: L79
    • 说明:

      TODO

  • narratorButton

    • 类型: CycleButton<NarratorStatus>
    • 修饰符: protected
    • 源码定位: L80
    • 说明:

      TODO

  • lastNarratable

    • 类型: NarratableEntry
    • 修饰符: private
    • 源码定位: L81
    • 说明:

      TODO

  • screenExecutor

    • 类型: Executor
    • 修饰符: protected final
    • 源码定位: L82
    • 说明:

      TODO

内部类/嵌套类型

  • net.minecraft.client.gui.screens.Screen.NarratableSearchResult
    • 类型: record
    • 修饰符: public
    • 源码定位: L622
    • 说明:

      TODO

构造器

protected Screen(Component title) @ L84

  • 构造器名:Screen
  • 源码定位:L84
  • 修饰符:protected

参数:

  • title: Component

说明:

TODO

protected Screen(Minecraft minecraft, Font font, Component title) @ L88

  • 构造器名:Screen
  • 源码定位:L88
  • 修饰符:protected

参数:

  • minecraft: Minecraft
  • font: Font
  • title: Component

说明:

TODO

方法

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

public Component getTitle() @ L99

  • 方法名:getTitle
  • 源码定位:L99
  • 返回类型:Component
  • 修饰符:public

参数:

说明:

TODO

public Component getNarrationMessage() @ L103

  • 方法名:getNarrationMessage
  • 源码定位:L103
  • 返回类型:Component
  • 修饰符:public

参数:

说明:

TODO

public final void extractRenderStateWithTooltipAndSubtitles(GuiGraphicsExtractor graphics, int mouseX, int mouseY, float a) @ L107

  • 方法名:extractRenderStateWithTooltipAndSubtitles
  • 源码定位:L107
  • 返回类型:void
  • 修饰符:public final

参数:

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

说明:

TODO

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

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

参数:

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

说明:

TODO

public boolean keyPressed(KeyEvent event) @ L122

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

参数:

  • event: KeyEvent

说明:

TODO

private FocusNavigationEvent.TabNavigation createTabEvent(boolean forward) @ L154

  • 方法名:createTabEvent
  • 源码定位:L154
  • 返回类型:FocusNavigationEvent.TabNavigation
  • 修饰符:private

参数:

  • forward: boolean

说明:

TODO

private FocusNavigationEvent.ArrowNavigation createArrowEvent(ScreenDirection direction) @ L158

  • 方法名:createArrowEvent
  • 源码定位:L158
  • 返回类型:FocusNavigationEvent.ArrowNavigation
  • 修饰符:private

参数:

  • direction: ScreenDirection

说明:

TODO

protected void setInitialFocus() @ L162

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

参数:

说明:

TODO

protected void setInitialFocus(GuiEventListener target) @ L172

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

参数:

  • target: GuiEventListener

说明:

TODO

public void clearFocus() @ L179

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

参数:

说明:

TODO

protected void changeFocus(ComponentPath componentPath) @ L186

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

参数:

  • componentPath: ComponentPath

说明:

TODO

public boolean shouldCloseOnEsc() @ L192

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

参数:

说明:

TODO

public void onClose() @ L196

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

参数:

说明:

TODO

protected <T extends GuiEventListener &Renderable &NarratableEntry> T addRenderableWidget(T widget) @ L200

  • 方法名:addRenderableWidget
  • 源码定位:L200
  • 返回类型:<T extends GuiEventListener &Renderable &NarratableEntry> T
  • 修饰符:protected

参数:

  • widget: T

说明:

TODO

protected <T extends Renderable> T addRenderableOnly(T renderable) @ L205

  • 方法名:addRenderableOnly
  • 源码定位:L205
  • 返回类型: T
  • 修饰符:protected

参数:

  • renderable: T

说明:

TODO

protected <T extends GuiEventListener &NarratableEntry> T addWidget(T widget) @ L210

  • 方法名:addWidget
  • 源码定位:L210
  • 返回类型:<T extends GuiEventListener &NarratableEntry> T
  • 修饰符:protected

参数:

  • widget: T

说明:

TODO

protected void removeWidget(GuiEventListener widget) @ L216

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

参数:

  • widget: GuiEventListener

说明:

TODO

protected void clearWidgets() @ L232

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

参数:

说明:

TODO

public static List<Component> getTooltipFromItem(Minecraft minecraft, ItemStack itemStack) @ L238

  • 方法名:getTooltipFromItem
  • 源码定位:L238
  • 返回类型:List
  • 修饰符:public static

参数:

  • minecraft: Minecraft
  • itemStack: ItemStack

说明:

TODO

protected void insertText(String text, boolean replace) @ L246

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

参数:

  • text: String
  • replace: boolean

说明:

TODO

protected static void defaultHandleGameClickEvent(ClickEvent event, Minecraft minecraft, Screen activeScreen) @ L249

  • 方法名:defaultHandleGameClickEvent
  • 源码定位:L249
  • 返回类型:void
  • 修饰符:protected static

参数:

  • event: ClickEvent
  • minecraft: Minecraft
  • activeScreen: Screen

说明:

TODO

protected static void defaultHandleClickEvent(ClickEvent event, Minecraft minecraft, Screen activeScreen) @ L269

  • 方法名:defaultHandleClickEvent
  • 源码定位:L269
  • 返回类型:void
  • 修饰符:protected static

参数:

  • event: ClickEvent
  • minecraft: Minecraft
  • activeScreen: Screen

说明:

TODO

protected static boolean clickUrlAction(Minecraft minecraft, Screen screen, URI uri) @ L301

  • 方法名:clickUrlAction
  • 源码定位:L301
  • 返回类型:boolean
  • 修饰符:protected static

参数:

  • minecraft: Minecraft
  • screen: Screen
  • uri: URI

说明:

TODO

protected static void clickCommandAction(LocalPlayer player, String command, Screen screenAfterCommand) @ L321

  • 方法名:clickCommandAction
  • 源码定位:L321
  • 返回类型:void
  • 修饰符:protected static

参数:

  • player: LocalPlayer
  • command: String
  • screenAfterCommand: Screen

说明:

TODO

public final void init(int width, int height) @ L325

  • 方法名:init
  • 源码定位:L325
  • 返回类型:void
  • 修饰符:public final

参数:

  • width: int
  • height: int

说明:

TODO

protected void rebuildWidgets() @ L344

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

参数:

说明:

TODO

protected void fadeWidgets(float widgetFade) @ L351

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

参数:

  • widgetFade: float

说明:

TODO

public List<?extends GuiEventListener> children() @ L359

  • 方法名:children
  • 源码定位:L359
  • 返回类型:List<?extends GuiEventListener>
  • 修饰符:public

参数:

说明:

TODO

protected void init() @ L364

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

参数:

说明:

TODO

public void tick() @ L367

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

参数:

说明:

TODO

public void removed() @ L370

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

参数:

说明:

TODO

public void added() @ L373

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

参数:

说明:

TODO

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

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

参数:

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

说明:

TODO

protected void extractBlurredBackground(GuiGraphicsExtractor graphics) @ L391

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

参数:

  • graphics: GuiGraphicsExtractor

说明:

TODO

protected void extractPanorama(GuiGraphicsExtractor graphics, float a) @ L398

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

参数:

  • graphics: GuiGraphicsExtractor
  • a: float

说明:

TODO

protected void extractMenuBackground(GuiGraphicsExtractor graphics) @ L402

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

参数:

  • graphics: GuiGraphicsExtractor

说明:

TODO

protected void extractMenuBackground(GuiGraphicsExtractor graphics, int x, int y, int width, int height) @ L406

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

参数:

  • graphics: GuiGraphicsExtractor
  • x: int
  • y: int
  • width: int
  • height: int

说明:

TODO

public static void extractMenuBackgroundTexture(GuiGraphicsExtractor graphics, Identifier menuBackground, int x, int y, float u, float v, int width, int height) @ L410

  • 方法名:extractMenuBackgroundTexture
  • 源码定位:L410
  • 返回类型:void
  • 修饰符:public static

参数:

  • graphics: GuiGraphicsExtractor
  • menuBackground: Identifier
  • x: int
  • y: int
  • u: float
  • v: float
  • width: int
  • height: int

说明:

TODO

public void extractTransparentBackground(GuiGraphicsExtractor graphics) @ L417

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

参数:

  • graphics: GuiGraphicsExtractor

说明:

TODO

public boolean isPauseScreen() @ L421

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

参数:

说明:

TODO

public boolean isInGameUi() @ L425

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

参数:

说明:

TODO

protected boolean panoramaShouldSpin() @ L429

  • 方法名:panoramaShouldSpin
  • 源码定位:L429
  • 返回类型:boolean
  • 修饰符:protected

参数:

说明:

TODO

public boolean isAllowedInPortal() @ L433

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

参数:

说明:

TODO

protected void repositionElements() @ L437

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

参数:

说明:

TODO

public void resize(int width, int height) @ L441

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

参数:

  • width: int
  • height: int

说明:

TODO

public void fillCrashDetails(CrashReport report) @ L447

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

参数:

  • report: CrashReport

说明:

TODO

protected boolean isValidCharacterForName(String currentName, int newChar, int cursorPos) @ L452

  • 方法名:isValidCharacterForName
  • 源码定位:L452
  • 返回类型:boolean
  • 修饰符:protected

参数:

  • currentName: String
  • newChar: int
  • cursorPos: int

说明:

TODO

public boolean isMouseOver(double mouseX, double mouseY) @ L464

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

参数:

  • mouseX: double
  • mouseY: double

说明:

TODO

public void onFilesDrop(List<Path> files) @ L469

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

参数:

  • files: List

说明:

TODO

private void scheduleNarration(long delay, boolean ignoreSuppression) @ L472

  • 方法名:scheduleNarration
  • 源码定位:L472
  • 返回类型:void
  • 修饰符:private

参数:

  • delay: long
  • ignoreSuppression: boolean

说明:

TODO

private void suppressNarration(long duration) @ L479

  • 方法名:suppressNarration
  • 源码定位:L479
  • 返回类型:void
  • 修饰符:private

参数:

  • duration: long

说明:

TODO

private void setNarrationSuppressTime(long narrationSuppressTime) @ L483

  • 方法名:setNarrationSuppressTime
  • 源码定位:L483
  • 返回类型:void
  • 修饰符:private

参数:

  • narrationSuppressTime: long

说明:

TODO

public void afterMouseMove() @ L487

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

参数:

说明:

TODO

public void afterMouseAction() @ L491

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

参数:

说明:

TODO

public void afterKeyboardAction() @ L495

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

参数:

说明:

TODO

private boolean shouldRunNarration() @ L499

  • 方法名:shouldRunNarration
  • 源码定位:L499
  • 返回类型:boolean
  • 修饰符:private

参数:

说明:

TODO

public void handleDelayedNarration() @ L503

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

参数:

说明:

TODO

public void triggerImmediateNarration(boolean onlyChanged) @ L513

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

参数:

  • onlyChanged: boolean

说明:

TODO

private void runNarration(boolean onlyChanged) @ L519

  • 方法名:runNarration
  • 源码定位:L519
  • 返回类型:void
  • 修饰符:private

参数:

  • onlyChanged: boolean

说明:

TODO

protected boolean shouldNarrateNavigation() @ L527

  • 方法名:shouldNarrateNavigation
  • 源码定位:L527
  • 返回类型:boolean
  • 修饰符:protected

参数:

说明:

TODO

protected void updateNarrationState(NarrationElementOutput output) @ L531

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

参数:

  • output: NarrationElementOutput

说明:

TODO

protected void updateNarratedWidget(NarrationElementOutput output) @ L536

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

参数:

  • output: NarrationElementOutput

说明:

TODO

protected Component getUsageNarration() @ L562

  • 方法名:getUsageNarration
  • 源码定位:L562
  • 返回类型:Component
  • 修饰符:protected

参数:

说明:

TODO

public static Screen.NarratableSearchResult findNarratableWidget(List<?extends NarratableEntry> narratableEntries, NarratableEntry lastNarratable) @ L566

  • 方法名:findNarratableWidget
  • 源码定位:L566
  • 返回类型:Screen.NarratableSearchResult
  • 修饰符:public static

参数:

  • narratableEntries: List<?extends NarratableEntry>
  • lastNarratable: NarratableEntry

说明:

TODO

public void updateNarratorStatus(boolean wasDisabled) @ L590

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

参数:

  • wasDisabled: boolean

说明:

TODO

public Font getFont() @ L600

  • 方法名:getFont
  • 源码定位:L600
  • 返回类型:Font
  • 修饰符:public

参数:

说明:

TODO

public boolean showsActiveEffects() @ L604

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

参数:

说明:

TODO

public boolean canInterruptWithAnotherScreen() @ L608

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

参数:

说明:

TODO

public ScreenRectangle getRectangle() @ L612

  • 方法名:getRectangle
  • 源码定位:L612
  • 返回类型:ScreenRectangle
  • 修饰符:public

参数:

说明:

TODO

public Music getBackgroundMusic() @ L617

  • 方法名:getBackgroundMusic
  • 源码定位:L617
  • 返回类型:Music
  • 修饰符:public

参数:

说明:

TODO

代码

@OnlyIn(Dist.CLIENT)
public abstract class Screen extends AbstractContainerEventHandler implements Renderable {
    private static final Logger LOGGER = LogUtils.getLogger();
    private static final Component SCREEN_USAGE_NARRATION = Component.translatable("narrator.screen.usage");
    public static final Identifier MENU_BACKGROUND = Identifier.withDefaultNamespace("textures/gui/menu_background.png");
    public static final Identifier HEADER_SEPARATOR = Identifier.withDefaultNamespace("textures/gui/header_separator.png");
    public static final Identifier FOOTER_SEPARATOR = Identifier.withDefaultNamespace("textures/gui/footer_separator.png");
    private static final Identifier INWORLD_MENU_BACKGROUND = Identifier.withDefaultNamespace("textures/gui/inworld_menu_background.png");
    public static final Identifier INWORLD_HEADER_SEPARATOR = Identifier.withDefaultNamespace("textures/gui/inworld_header_separator.png");
    public static final Identifier INWORLD_FOOTER_SEPARATOR = Identifier.withDefaultNamespace("textures/gui/inworld_footer_separator.png");
    protected static final float FADE_IN_TIME = 2000.0F;
    protected final Component title;
    private final List<GuiEventListener> children = Lists.newArrayList();
    private final List<NarratableEntry> narratables = Lists.newArrayList();
    protected final Minecraft minecraft;
    private boolean initialized;
    public int width;
    public int height;
    private final List<Renderable> renderables = Lists.newArrayList();
    protected final Font font;
    private static final long NARRATE_SUPPRESS_AFTER_INIT_TIME = TimeUnit.SECONDS.toMillis(2L);
    private static final long NARRATE_DELAY_NARRATOR_ENABLED = NARRATE_SUPPRESS_AFTER_INIT_TIME;
    private static final long NARRATE_DELAY_MOUSE_MOVE = 750L;
    private static final long NARRATE_DELAY_MOUSE_ACTION = 200L;
    private static final long NARRATE_DELAY_KEYBOARD_ACTION = 200L;
    private final ScreenNarrationCollector narrationState = new ScreenNarrationCollector();
    private long narrationSuppressTime = Long.MIN_VALUE;
    private long nextNarrationTime = Long.MAX_VALUE;
    protected @Nullable CycleButton<NarratorStatus> narratorButton;
    private @Nullable NarratableEntry lastNarratable;
    protected final Executor screenExecutor;
 
    protected Screen(Component title) {
        this(Minecraft.getInstance(), Minecraft.getInstance().font, title);
    }
 
    protected Screen(Minecraft minecraft, Font font, Component title) {
        this.minecraft = minecraft;
        this.font = font;
        this.title = title;
        this.screenExecutor = runnable -> minecraft.execute(() -> {
            if (minecraft.screen == this) {
                runnable.run();
            }
        });
    }
 
    public Component getTitle() {
        return this.title;
    }
 
    public Component getNarrationMessage() {
        return this.getTitle();
    }
 
    public final void extractRenderStateWithTooltipAndSubtitles(GuiGraphicsExtractor graphics, int mouseX, int mouseY, float a) {
        graphics.nextStratum();
        this.extractBackground(graphics, mouseX, mouseY, a);
        graphics.nextStratum();
        this.extractRenderState(graphics, mouseX, mouseY, a);
        graphics.extractDeferredElements(mouseX, mouseY, a);
    }
 
    @Override
    public void extractRenderState(GuiGraphicsExtractor graphics, int mouseX, int mouseY, float a) {
        for (Renderable renderable : this.renderables) {
            renderable.extractRenderState(graphics, mouseX, mouseY, a);
        }
    }
 
    @Override
    public boolean keyPressed(KeyEvent event) {
        if (event.isEscape() && this.shouldCloseOnEsc()) {
            this.onClose();
            return true;
        } else if (super.keyPressed(event)) {
            return true;
        } else {
            FocusNavigationEvent navigationEvent = (FocusNavigationEvent)(switch (event.key()) {
                case 258 -> this.createTabEvent(!event.hasShiftDown());
                default -> null;
                case 262 -> this.createArrowEvent(ScreenDirection.RIGHT);
                case 263 -> this.createArrowEvent(ScreenDirection.LEFT);
                case 264 -> this.createArrowEvent(ScreenDirection.DOWN);
                case 265 -> this.createArrowEvent(ScreenDirection.UP);
            });
            if (navigationEvent != null) {
                ComponentPath focusPath = super.nextFocusPath(navigationEvent);
                if (focusPath == null && navigationEvent instanceof FocusNavigationEvent.TabNavigation) {
                    this.clearFocus();
                    focusPath = super.nextFocusPath(navigationEvent);
                }
 
                if (focusPath != null) {
                    this.changeFocus(focusPath);
                }
            }
 
            return false;
        }
    }
 
    private FocusNavigationEvent.TabNavigation createTabEvent(boolean forward) {
        return new FocusNavigationEvent.TabNavigation(forward);
    }
 
    private FocusNavigationEvent.ArrowNavigation createArrowEvent(ScreenDirection direction) {
        return new FocusNavigationEvent.ArrowNavigation(direction);
    }
 
    protected void setInitialFocus() {
        if (this.minecraft.getLastInputType().isKeyboard()) {
            FocusNavigationEvent.TabNavigation forwardTabEvent = new FocusNavigationEvent.TabNavigation(true);
            ComponentPath focusPath = super.nextFocusPath(forwardTabEvent);
            if (focusPath != null) {
                this.changeFocus(focusPath);
            }
        }
    }
 
    protected void setInitialFocus(GuiEventListener target) {
        ComponentPath path = ComponentPath.path(this, target.nextFocusPath(new FocusNavigationEvent.InitialFocus()));
        if (path != null) {
            this.changeFocus(path);
        }
    }
 
    public void clearFocus() {
        ComponentPath componentPath = this.getCurrentFocusPath();
        if (componentPath != null) {
            componentPath.applyFocus(false);
        }
    }
 
    @VisibleForTesting
    protected void changeFocus(ComponentPath componentPath) {
        this.clearFocus();
        componentPath.applyFocus(true);
    }
 
    public boolean shouldCloseOnEsc() {
        return true;
    }
 
    public void onClose() {
        this.minecraft.setScreen(null);
    }
 
    protected <T extends GuiEventListener & Renderable & NarratableEntry> T addRenderableWidget(T widget) {
        this.renderables.add(widget);
        return this.addWidget(widget);
    }
 
    protected <T extends Renderable> T addRenderableOnly(T renderable) {
        this.renderables.add(renderable);
        return renderable;
    }
 
    protected <T extends GuiEventListener & NarratableEntry> T addWidget(T widget) {
        this.children.add(widget);
        this.narratables.add(widget);
        return widget;
    }
 
    protected void removeWidget(GuiEventListener widget) {
        if (widget instanceof Renderable) {
            this.renderables.remove((Renderable)widget);
        }
 
        if (widget instanceof NarratableEntry) {
            this.narratables.remove((NarratableEntry)widget);
        }
 
        if (this.getFocused() == widget) {
            this.clearFocus();
        }
 
        this.children.remove(widget);
    }
 
    protected void clearWidgets() {
        this.renderables.clear();
        this.children.clear();
        this.narratables.clear();
    }
 
    public static List<Component> getTooltipFromItem(Minecraft minecraft, ItemStack itemStack) {
        return itemStack.getTooltipLines(
            Item.TooltipContext.of(minecraft.level),
            minecraft.player,
            minecraft.options.advancedItemTooltips ? TooltipFlag.Default.ADVANCED : TooltipFlag.Default.NORMAL
        );
    }
 
    protected void insertText(String text, boolean replace) {
    }
 
    protected static void defaultHandleGameClickEvent(ClickEvent event, Minecraft minecraft, @Nullable Screen activeScreen) {
        LocalPlayer player = Objects.requireNonNull(minecraft.player, "Player not available");
        switch (event) {
            case ClickEvent.RunCommand(String var11):
                clickCommandAction(player, var11, activeScreen);
                break;
            case ClickEvent.ShowDialog dialog:
                player.connection.showDialog(dialog.dialog(), activeScreen);
                break;
            case ClickEvent.Custom custom:
                player.connection.send(new ServerboundCustomClickActionPacket(custom.id(), custom.payload()));
                if (minecraft.screen != activeScreen) {
                    minecraft.setScreen(activeScreen);
                }
                break;
            default:
                defaultHandleClickEvent(event, minecraft, activeScreen);
        }
    }
 
    protected static void defaultHandleClickEvent(ClickEvent event, Minecraft minecraft, @Nullable Screen activeScreen) {
        boolean shouldActivateScreen = switch (event) {
            case ClickEvent.OpenUrl(URI var17) -> {
                clickUrlAction(minecraft, activeScreen, var17);
                yield false;
            }
            case ClickEvent.OpenFile openFile -> {
                Util.getPlatform().openFile(openFile.file());
                yield true;
            }
            case ClickEvent.SuggestCommand(String var22) -> {
                String var18 = var22;
                if (activeScreen != null) {
                    activeScreen.insertText(var18, true);
                }
 
                yield true;
            }
            case ClickEvent.CopyToClipboard(String var13) -> {
                minecraft.keyboardHandler.setClipboard(var13);
                yield true;
            }
            default -> {
                LOGGER.error("Don't know how to handle {}", event);
                yield true;
            }
        };
        if (shouldActivateScreen && minecraft.screen != activeScreen) {
            minecraft.setScreen(activeScreen);
        }
    }
 
    protected static boolean clickUrlAction(Minecraft minecraft, @Nullable Screen screen, URI uri) {
        if (!minecraft.options.chatLinks().get()) {
            return false;
        } else {
            if (minecraft.options.chatLinksPrompt().get()) {
                minecraft.setScreen(new ConfirmLinkScreen(result -> {
                    if (result) {
                        Util.getPlatform().openUri(uri);
                    }
 
                    minecraft.setScreen(screen);
                }, uri.toString(), false));
            } else {
                Util.getPlatform().openUri(uri);
            }
 
            return true;
        }
    }
 
    protected static void clickCommandAction(LocalPlayer player, String command, @Nullable Screen screenAfterCommand) {
        player.connection.sendUnattendedCommand(Commands.trimOptionalPrefix(command), screenAfterCommand);
    }
 
    public final void init(int width, int height) {
        this.width = width;
        this.height = height;
        if (!this.initialized) {
            this.init();
            this.setInitialFocus();
        } else {
            this.repositionElements();
        }
 
        this.initialized = true;
        this.triggerImmediateNarration(false);
        if (this.minecraft.getLastInputType().isKeyboard()) {
            this.setNarrationSuppressTime(Long.MAX_VALUE);
        } else {
            this.suppressNarration(NARRATE_SUPPRESS_AFTER_INIT_TIME);
        }
    }
 
    protected void rebuildWidgets() {
        this.clearWidgets();
        this.clearFocus();
        this.init();
        this.setInitialFocus();
    }
 
    protected void fadeWidgets(float widgetFade) {
        for (GuiEventListener button : this.children()) {
            if (button instanceof AbstractWidget widget) {
                widget.setAlpha(widgetFade);
            }
        }
    }
 
    @Override
    public List<? extends GuiEventListener> children() {
        return this.children;
    }
 
    protected void init() {
    }
 
    public void tick() {
    }
 
    public void removed() {
    }
 
    public void added() {
    }
 
    public void extractBackground(GuiGraphicsExtractor graphics, int mouseX, int mouseY, float a) {
        if (this.isInGameUi()) {
            this.extractTransparentBackground(graphics);
        } else {
            if (this.minecraft.level == null) {
                this.extractPanorama(graphics, a);
            }
 
            this.extractBlurredBackground(graphics);
            this.extractMenuBackground(graphics);
        }
 
        this.minecraft.gui.extractDeferredSubtitles();
    }
 
    protected void extractBlurredBackground(GuiGraphicsExtractor graphics) {
        float blurRadius = this.minecraft.options.getMenuBackgroundBlurriness();
        if (blurRadius >= 1.0F) {
            graphics.blurBeforeThisStratum();
        }
    }
 
    protected void extractPanorama(GuiGraphicsExtractor graphics, float a) {
        this.minecraft.gameRenderer.getPanorama().extractRenderState(graphics, this.width, this.height, this.panoramaShouldSpin());
    }
 
    protected void extractMenuBackground(GuiGraphicsExtractor graphics) {
        this.extractMenuBackground(graphics, 0, 0, this.width, this.height);
    }
 
    protected void extractMenuBackground(GuiGraphicsExtractor graphics, int x, int y, int width, int height) {
        extractMenuBackgroundTexture(graphics, this.minecraft.level == null ? MENU_BACKGROUND : INWORLD_MENU_BACKGROUND, x, y, 0.0F, 0.0F, width, height);
    }
 
    public static void extractMenuBackgroundTexture(
        GuiGraphicsExtractor graphics, Identifier menuBackground, int x, int y, float u, float v, int width, int height
    ) {
        int size = 32;
        graphics.blit(RenderPipelines.GUI_TEXTURED, menuBackground, x, y, u, v, width, height, 32, 32);
    }
 
    public void extractTransparentBackground(GuiGraphicsExtractor graphics) {
        graphics.fillGradient(0, 0, this.width, this.height, -1072689136, -804253680);
    }
 
    public boolean isPauseScreen() {
        return true;
    }
 
    public boolean isInGameUi() {
        return false;
    }
 
    protected boolean panoramaShouldSpin() {
        return true;
    }
 
    public boolean isAllowedInPortal() {
        return this.isPauseScreen();
    }
 
    protected void repositionElements() {
        this.rebuildWidgets();
    }
 
    public void resize(int width, int height) {
        this.width = width;
        this.height = height;
        this.repositionElements();
    }
 
    public void fillCrashDetails(CrashReport report) {
        CrashReportCategory category = report.addCategory("Affected screen", 1);
        category.setDetail("Screen name", () -> this.getClass().getCanonicalName());
    }
 
    protected boolean isValidCharacterForName(String currentName, int newChar, int cursorPos) {
        int colonPos = currentName.indexOf(58);
        int slashPos = currentName.indexOf(47);
        if (newChar == 58) {
            return (slashPos == -1 || cursorPos <= slashPos) && colonPos == -1;
        } else {
            return newChar == 47
                ? cursorPos > colonPos
                : newChar == 95 || newChar == 45 || newChar >= 97 && newChar <= 122 || newChar >= 48 && newChar <= 57 || newChar == 46;
        }
    }
 
    @Override
    public boolean isMouseOver(double mouseX, double mouseY) {
        return true;
    }
 
    public void onFilesDrop(List<Path> files) {
    }
 
    private void scheduleNarration(long delay, boolean ignoreSuppression) {
        this.nextNarrationTime = Util.getMillis() + delay;
        if (ignoreSuppression) {
            this.narrationSuppressTime = Long.MIN_VALUE;
        }
    }
 
    private void suppressNarration(long duration) {
        this.setNarrationSuppressTime(Util.getMillis() + duration);
    }
 
    private void setNarrationSuppressTime(long narrationSuppressTime) {
        this.narrationSuppressTime = narrationSuppressTime;
    }
 
    public void afterMouseMove() {
        this.scheduleNarration(750L, false);
    }
 
    public void afterMouseAction() {
        this.scheduleNarration(200L, true);
    }
 
    public void afterKeyboardAction() {
        this.scheduleNarration(200L, true);
    }
 
    private boolean shouldRunNarration() {
        return SharedConstants.DEBUG_UI_NARRATION || this.minecraft.getNarrator().isActive();
    }
 
    public void handleDelayedNarration() {
        if (this.shouldRunNarration()) {
            long currentTime = Util.getMillis();
            if (currentTime > this.nextNarrationTime && currentTime > this.narrationSuppressTime) {
                this.runNarration(true);
                this.nextNarrationTime = Long.MAX_VALUE;
            }
        }
    }
 
    public void triggerImmediateNarration(boolean onlyChanged) {
        if (this.shouldRunNarration()) {
            this.runNarration(onlyChanged);
        }
    }
 
    private void runNarration(boolean onlyChanged) {
        this.narrationState.update(this::updateNarrationState);
        String narration = this.narrationState.collectNarrationText(!onlyChanged);
        if (!narration.isEmpty()) {
            this.minecraft.getNarrator().saySystemNow(narration);
        }
    }
 
    protected boolean shouldNarrateNavigation() {
        return true;
    }
 
    protected void updateNarrationState(NarrationElementOutput output) {
        output.add(NarratedElementType.TITLE, this.getNarrationMessage());
        this.updateNarratedWidget(output);
    }
 
    protected void updateNarratedWidget(NarrationElementOutput output) {
        List<? extends NarratableEntry> activeNarratables = this.narratables
            .stream()
            .flatMap(narratableEntry -> narratableEntry.getNarratables().stream())
            .filter(NarratableEntry::isActive)
            .sorted(Comparator.comparingInt(TabOrderedElement::getTabOrderGroup))
            .toList();
        Screen.NarratableSearchResult result = findNarratableWidget(activeNarratables, this.lastNarratable);
        if (result != null) {
            if (result.priority.isTerminal()) {
                this.lastNarratable = result.entry;
            }
 
            if (activeNarratables.size() > 1) {
                output.add(NarratedElementType.POSITION, Component.translatable("narrator.position.screen", result.index + 1, activeNarratables.size()));
                if (result.priority == NarratableEntry.NarrationPriority.FOCUSED) {
                    output.add(NarratedElementType.USAGE, this.getUsageNarration());
                }
            }
 
            result.entry.updateNarration(output.nest());
        } else if (this.shouldNarrateNavigation()) {
            output.add(NarratedElementType.USAGE, SCREEN_USAGE_NARRATION);
        }
    }
 
    protected Component getUsageNarration() {
        return Component.translatable("narration.component_list.usage");
    }
 
    public static Screen.@Nullable NarratableSearchResult findNarratableWidget(
        List<? extends NarratableEntry> narratableEntries, @Nullable NarratableEntry lastNarratable
    ) {
        Screen.NarratableSearchResult result = null;
        Screen.NarratableSearchResult lowPrioNarratable = null;
        int i = 0;
 
        for (int narratablesSize = narratableEntries.size(); i < narratablesSize; i++) {
            NarratableEntry narratable = narratableEntries.get(i);
            NarratableEntry.NarrationPriority priority = narratable.narrationPriority();
            if (priority.isTerminal()) {
                if (narratable != lastNarratable) {
                    return new Screen.NarratableSearchResult(narratable, i, priority);
                }
 
                lowPrioNarratable = new Screen.NarratableSearchResult(narratable, i, priority);
            } else if (priority.compareTo(result != null ? result.priority : NarratableEntry.NarrationPriority.NONE) > 0) {
                result = new Screen.NarratableSearchResult(narratable, i, priority);
            }
        }
 
        return result != null ? result : lowPrioNarratable;
    }
 
    public void updateNarratorStatus(boolean wasDisabled) {
        if (wasDisabled) {
            this.scheduleNarration(NARRATE_DELAY_NARRATOR_ENABLED, false);
        }
 
        if (this.narratorButton != null) {
            this.narratorButton.setValue(this.minecraft.options.narrator().get());
        }
    }
 
    public Font getFont() {
        return this.font;
    }
 
    public boolean showsActiveEffects() {
        return false;
    }
 
    public boolean canInterruptWithAnotherScreen() {
        return this.shouldCloseOnEsc();
    }
 
    @Override
    public ScreenRectangle getRectangle() {
        return new ScreenRectangle(0, 0, this.width, this.height);
    }
 
    public @Nullable Music getBackgroundMusic() {
        return null;
    }
 
    @OnlyIn(Dist.CLIENT)
    public record NarratableSearchResult(NarratableEntry entry, int index, NarratableEntry.NarrationPriority priority) {
    }
}

引用的其他类

  • CrashReport

    • 引用位置: 参数
  • Minecraft

    • 引用位置: 参数/字段/方法调用
    • 关联成员: Minecraft.getInstance()
  • NarratorStatus

    • 引用位置: 字段
  • ComponentPath

    • 引用位置: 参数/方法调用
    • 关联成员: ComponentPath.path()
  • Font

    • 引用位置: 参数/字段/返回值
  • GuiGraphicsExtractor

    • 引用位置: 参数
  • CycleButton

    • 引用位置: 字段
  • Renderable

    • 引用位置: 字段/实现/返回值
  • AbstractContainerEventHandler

    • 引用位置: 继承
  • GuiEventListener

    • 引用位置: 参数/字段/返回值
  • NarratableEntry

    • 引用位置: 参数/字段/返回值
  • NarrationElementOutput

    • 引用位置: 参数
  • ScreenNarrationCollector

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

    • 引用位置: 方法调用/构造调用/返回值
    • 关联成员: ArrowNavigation(), FocusNavigationEvent.ArrowNavigation(), FocusNavigationEvent.InitialFocus(), FocusNavigationEvent.TabNavigation(), InitialFocus(), TabNavigation()
  • ScreenDirection

    • 引用位置: 参数
  • ScreenRectangle

    • 引用位置: 构造调用/返回值
    • 关联成员: ScreenRectangle()
  • ConfirmLinkScreen

    • 引用位置: 构造调用
    • 关联成员: ConfirmLinkScreen()
  • KeyEvent

    • 引用位置: 参数
  • LocalPlayer

    • 引用位置: 参数
  • Commands

    • 引用位置: 方法调用
    • 关联成员: Commands.trimOptionalPrefix()
  • ClickEvent

    • 引用位置: 参数/方法调用
    • 关联成员: ClickEvent.CopyToClipboard(), ClickEvent.OpenUrl(), ClickEvent.RunCommand(), ClickEvent.SuggestCommand()
  • Component

    • 引用位置: 参数/字段/方法调用/返回值
    • 关联成员: Component.translatable()
  • ServerboundCustomClickActionPacket

    • 引用位置: 构造调用
    • 关联成员: ServerboundCustomClickActionPacket()
  • Identifier

    • 引用位置: 参数/字段/方法调用
    • 关联成员: Identifier.withDefaultNamespace()
  • Music

    • 引用位置: 返回值
  • Util

    • 引用位置: 方法调用
    • 关联成员: Util.getMillis(), Util.getPlatform()
  • Item

    • 引用位置: 方法调用
    • 关联成员: Item.TooltipContext.of()
  • ItemStack

    • 引用位置: 参数