Interface GuidePainter

All Known Implementing Classes:
AbstractPainter, EdgeFadePainter, RevealPainter, ScreenPainter, WorldPainter

public interface GuidePainter
What a page draws with. The same calls draw it on a screen and on the pages of a book held in the world, so a page is written once for every kind of book.

Coordinates are page pixels: (0, 0) is the page's top left, GuideLayout.PAGE_WIDTH by GuideLayout.PAGE_HEIGHT, one pixel being one GUI pixel on a screen. push(), translate(float, float) and scale(float) move what follows, and the pointer's place with it, so hovered(int, int, int, int) and link(int, int, int, int, String) take the same coordinates as the drawing.

There is no click handler on a page: it marks what can be pressed (link(int, int, int, int, String), action(int, int, int, int, Component, Runnable)) while it draws, and a press lands on what was marked under the pointer in the last frame.

  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static interface 
    What a dragged rectangle does as the pointer moves while it is held: by how far, in page pixels.
    static interface 
    What a rectangle does when the mouse wheel turns over it: by how many notches, away from the reader positive.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    action(int x, int y, int width, int height, @Nullable net.minecraft.network.chat.Component tooltip, Runnable onPress)
    Makes a rectangle run something when pressed (on the client, during the press).
    default void
    centeredText(net.minecraft.network.chat.Component text, int centerX, int y, int argb)
     
    boolean
    drag(int x, int y, int width, int height, GuidePainter.Drag drag)
    Makes a rectangle draggable: held with the left button, it is told how far the pointer moves until let go.
    void
    fill(int x0, int y0, int x1, int y1, int argb)
     
    boolean
    Whether the page is on a screen (true), or on a book in the world (false).
    net.minecraft.client.gui.Font
     
    boolean
    hovered(int x, int y, int width, int height)
    Whether the pointer is over a rectangle; never while the page is turning or covered.
    void
    item(net.minecraft.world.item.ItemStack stack, int x, int y)
    An item's icon, 16 pixels square; hovering shows its tooltip, and it links to the book's entry about it, if any.
    default void
    item(net.minecraft.world.item.ItemStack stack, int x, int y, int argb)
    As item(ItemStack, int, int), tinted by argb: its alpha fades the item, its colour tints it (white leaves it as it is).
    boolean
    link(int x, int y, int width, int height, String target)
    Makes a rectangle open a link when pressed: entry:<id>, entry:<id>#<anchor>, category:<id>, http(s)://..., or a bare entry id.
     
    void
    pop()
     
    void
     
    void
    scale(float scale)
     
    void
    scene(net.ixdarklord.coolcatcanvas.api.client.viewport.SceneViewport viewport, int x, int y, int width, int height)
    A scene's picture; the painter keeps it in use while it is drawn.
    default void
    scene(net.ixdarklord.coolcatcanvas.api.client.viewport.SceneViewport viewport, int x, int y, int width, int height, float u0, float u1)
    As scene(SceneViewport, int, int, int, int), showing only the part of it from u0 to u1 across (0 to 1).
    default void
    scene(net.ixdarklord.coolcatcanvas.api.client.viewport.SceneViewport viewport, int x, int y, int width, int height, float u0, float v0, float u1, float v1, int argb)
    As scene(SceneViewport, int, int, int, int), showing only the part of it from (u0, v0) to (u1, v1) (0 to 1, from its top left), tinted by argb: its alpha fades the picture.
    boolean
    scroll(int x, int y, int width, int height, GuidePainter.Scroll scroll)
    Makes a rectangle take the mouse wheel while the pointer is over it, rather than the wheel turning the page.
    default void
    text(net.minecraft.network.chat.Component text, int x, int y, int argb)
     
    void
    text(net.minecraft.util.FormattedCharSequence text, int x, int y, int argb)
     
    void
    texture(net.minecraft.resources.Identifier texture, int x, int y, int width, int height, float u0, float v0, float u1, float v1, int argb)
    A part of a texture, from its (u0, v0) to its (u1, v1), each 0 to 1, tinted by argb.
    float
    Seconds since the book was opened: for what moves or cycles on a page.
    void
    tooltip(List<net.minecraft.network.chat.Component> lines)
    A tooltip of several lines: a name, then lines saying more.
    void
    tooltip(net.minecraft.network.chat.Component text)
    Shows a tooltip at the pointer this frame.
    void
    tooltip(net.minecraft.world.item.ItemStack stack)
     
    void
    translate(float x, float y)
     
  • Method Details

    • font

      net.minecraft.client.gui.Font font()
    • palette

      GuidePalette palette()
    • time

      float time()
      Seconds since the book was opened: for what moves or cycles on a page.
    • flat

      boolean flat()
      Whether the page is on a screen (true), or on a book in the world (false).
    • fill

      void fill(int x0, int y0, int x1, int y1, int argb)
    • text

      void text(net.minecraft.util.FormattedCharSequence text, int x, int y, int argb)
    • text

      default void text(net.minecraft.network.chat.Component text, int x, int y, int argb)
    • centeredText

      default void centeredText(net.minecraft.network.chat.Component text, int centerX, int y, int argb)
    • texture

      void texture(net.minecraft.resources.Identifier texture, int x, int y, int width, int height, float u0, float v0, float u1, float v1, int argb)
      A part of a texture, from its (u0, v0) to its (u1, v1), each 0 to 1, tinted by argb.
    • item

      void item(net.minecraft.world.item.ItemStack stack, int x, int y)
      An item's icon, 16 pixels square; hovering shows its tooltip, and it links to the book's entry about it, if any.
    • item

      default void item(net.minecraft.world.item.ItemStack stack, int x, int y, int argb)
      As item(ItemStack, int, int), tinted by argb: its alpha fades the item, its colour tints it (white leaves it as it is). A painter that can't fade items shows it once its alpha is past half.
    • scene

      void scene(net.ixdarklord.coolcatcanvas.api.client.viewport.SceneViewport viewport, int x, int y, int width, int height)
      A scene's picture; the painter keeps it in use while it is drawn.
    • scene

      default void scene(net.ixdarklord.coolcatcanvas.api.client.viewport.SceneViewport viewport, int x, int y, int width, int height, float u0, float u1)
      As scene(SceneViewport, int, int, int, int), showing only the part of it from u0 to u1 across (0 to 1).
    • scene

      default void scene(net.ixdarklord.coolcatcanvas.api.client.viewport.SceneViewport viewport, int x, int y, int width, int height, float u0, float v0, float u1, float v1, int argb)
      As scene(SceneViewport, int, int, int, int), showing only the part of it from (u0, v0) to (u1, v1) (0 to 1, from its top left), tinted by argb: its alpha fades the picture.
    • push

      void push()
    • pop

      void pop()
    • translate

      void translate(float x, float y)
    • scale

      void scale(float scale)
    • hovered

      boolean hovered(int x, int y, int width, int height)
      Whether the pointer is over a rectangle; never while the page is turning or covered.
    • link

      boolean link(int x, int y, int width, int height, String target)
      Makes a rectangle open a link when pressed: entry:<id>, entry:<id>#<anchor>, category:<id>, http(s)://..., or a bare entry id. Hovering it shows where it goes.
      Returns:
      whether it is hovered
    • action

      boolean action(int x, int y, int width, int height, @Nullable net.minecraft.network.chat.Component tooltip, Runnable onPress)
      Makes a rectangle run something when pressed (on the client, during the press).
      Parameters:
      tooltip - shown while it is hovered; null for none
      Returns:
      whether it is hovered
    • drag

      boolean drag(int x, int y, int width, int height, GuidePainter.Drag drag)
      Makes a rectangle draggable: held with the left button, it is told how far the pointer moves until let go.
      Returns:
      whether it is hovered
    • scroll

      boolean scroll(int x, int y, int width, int height, GuidePainter.Scroll scroll)
      Makes a rectangle take the mouse wheel while the pointer is over it, rather than the wheel turning the page.
      Returns:
      whether it is hovered
    • tooltip

      void tooltip(net.minecraft.network.chat.Component text)
      Shows a tooltip at the pointer this frame.
    • tooltip

      void tooltip(List<net.minecraft.network.chat.Component> lines)
      A tooltip of several lines: a name, then lines saying more.
    • tooltip

      void tooltip(net.minecraft.world.item.ItemStack stack)