Class BookScreen

All Implemented Interfaces:
Drawable, Element, ParentElement, TickableElement
Direct Known Subclasses:
LecternScreen

@Environment(CLIENT)
public class BookScreen
extends Screen
  • Field Details

    • EMPTY_PROVIDER

      public static final BookScreen.Contents EMPTY_PROVIDER
    • BOOK_TEXTURE

      public static final Identifier BOOK_TEXTURE
    • contents

      private BookScreen.Contents contents
    • pageIndex

      private int pageIndex
    • cachedPage

      private List<OrderedText> cachedPage
    • cachedPageIndex

      private int cachedPageIndex
    • pageIndexText

      private Text pageIndexText
    • nextPageButton

      private PageTurnWidget nextPageButton
    • previousPageButton

      private PageTurnWidget previousPageButton
    • pageTurnSound

      private final boolean pageTurnSound
  • Constructor Details

    • BookScreen

      public BookScreen​(BookScreen.Contents pageProvider)
    • BookScreen

      public BookScreen()
    • BookScreen

      private BookScreen​(BookScreen.Contents contents, boolean playPageTurnSound)
  • Method Details

    • setPageProvider

      public void setPageProvider​(BookScreen.Contents pageProvider)
    • setPage

      public boolean setPage​(int index)
    • jumpToPage

      protected boolean jumpToPage​(int page)
    • init

      protected void init()
      Called when a screen should be initialized.

      This method is called when this screen is opened or resized.

      Overrides:
      init in class Screen
    • addCloseButton

      protected void addCloseButton()
    • addPageButtons

      protected void addPageButtons()
    • getPageCount

      private int getPageCount()
    • goToPreviousPage

      protected void goToPreviousPage()
    • goToNextPage

      protected void goToNextPage()
    • updatePageButtons

      private void updatePageButtons()
    • keyPressed

      public boolean keyPressed​(int keyCode, int scanCode, int modifiers)
      Callback for when a key down event has been captured. The key code is identified by the constants in GLFW class.
      Specified by:
      keyPressed in interface Element
      Specified by:
      keyPressed in interface ParentElement
      Overrides:
      keyPressed in class Screen
      Parameters:
      keyCode - the named key code of the event as described in the GLFW class
      scanCode - the unique/platform-specific scan code of the keyboard input
      modifiers - a GLFW bitfield describing the modifier keys that are held down (see {@linkplain https://www.glfw.org/docs/3.3/group__mods.html GLFW Modifier key flags})
      Returns:
      true to indicate that the event handling is successful/valid
      See Also:
      Keyboard.onKey(long, int, int, int, int), GLFW.GLFW_KEY_Q, GLFWKeyCallbackI.invoke(long, int, int, int, int)
    • render

      public void render​(MatrixStack matrices, int mouseX, int mouseY, float delta)
      Specified by:
      render in interface Drawable
      Overrides:
      render in class Screen
    • mouseClicked

      public boolean mouseClicked​(double mouseX, double mouseY, int button)
      Callback for when a mouse button down event has been captured. The button number is identified by the constants in GLFW class.
      Parameters:
      mouseX - the X coordinate of the mouse
      mouseY - the Y coordinate of the mouse
      button - the mouse button number
      Returns:
      true to indicate that the event handling is successful/valid
      See Also:
      Mouse.onMouseButton(long, int, int, int), GLFW.GLFW_MOUSE_BUTTON_1
    • handleTextClick

      public boolean handleTextClick​(Style style)
      Overrides:
      handleTextClick in class Screen
    • getTextAt

      @Nullable public Style getTextAt​(double x, double y)
    • readPages

      public static List<String> readPages​(CompoundTag tag)