Class RecipeBookWidget

java.lang.Object
net.minecraft.client.gui.DrawableHelper
net.minecraft.client.gui.screen.recipebook.RecipeBookWidget
All Implemented Interfaces:
Drawable, Element, RecipeDisplayListener, RecipeGridAligner<Ingredient>
Direct Known Subclasses:
AbstractFurnaceRecipeBookScreen

@Environment(CLIENT)
public class RecipeBookWidget
extends DrawableHelper
implements Drawable, Element, RecipeDisplayListener, RecipeGridAligner<Ingredient>
  • Field Details

  • Constructor Details

    • RecipeBookWidget

      public RecipeBookWidget()
  • Method Details

    • initialize

      public void initialize​(int parentWidth, int parentHeight, MinecraftClient client, boolean narrow, AbstractRecipeScreenHandler<?> craftingScreenHandler)
    • reset

      public void reset​(boolean narrow)
    • changeFocus

      public boolean changeFocus​(boolean lookForwards)
      Changes the focusing element by cycling to the next/previous element. This action is done typically when the user has pressed the 'Tab' or 'Ctrl+Tab' key.
      Specified by:
      changeFocus in interface Element
      Parameters:
      lookForwards - true to cycle forwards, otherwise cycle backwards
      Returns:
      true to indicate that the event handling is successful/valid
    • setBookButtonTexture

      protected void setBookButtonTexture()
    • close

      public void close()
    • findLeftEdge

      public int findLeftEdge​(boolean narrow, int width, int parentWidth)
    • toggleOpen

      public void toggleOpen()
    • isOpen

      public boolean isOpen()
    • setOpen

      protected void setOpen​(boolean opened)
    • slotClicked

      public void slotClicked​(@Nullable Slot slot)
    • refreshResults

      private void refreshResults​(boolean resetCurrentPage)
    • refreshTabButtons

      private void refreshTabButtons()
    • update

      public void update()
    • refreshInputs

      private void refreshInputs()
    • render

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

      public void drawTooltip​(MatrixStack matrixStack, int int2, int int3, int int4, int int5)
    • getCraftableButtonText

      private Text getCraftableButtonText()
    • getToggleCraftableButtonText

      protected Text getToggleCraftableButtonText()
    • drawGhostSlotTooltip

      private void drawGhostSlotTooltip​(MatrixStack matrixStack, int int2, int int3, int int4, int int5)
    • drawGhostSlots

      public void drawGhostSlots​(MatrixStack matrixStack, int int2, int int3, boolean bool, float float2)
    • 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.
      Specified by:
      mouseClicked in interface Element
      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
    • toggleFilteringCraftable

      private boolean toggleFilteringCraftable()
    • isClickOutsideBounds

      public boolean isClickOutsideBounds​(double double2, double double3, int int2, int int3, int int4, int int5, int int6)
    • 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
      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)
    • keyReleased

      public boolean keyReleased​(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:
      keyReleased in interface Element
      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)
    • charTyped

      public boolean charTyped​(char chr, int keyCode)
      Callback for when a character input has been captured. The key code is identified by the constants in GLFW class.
      Specified by:
      charTyped in interface Element
      Parameters:
      chr - the captured character
      keyCode - the associated key code
      Returns:
      true to indicate that the event handling is successful/valid
      See Also:
      Keyboard.onChar(long, int, int), GLFW.GLFW_KEY_Q, GLFWKeyCallbackI.invoke(long, int, int, int, int)
    • isMouseOver

      public boolean isMouseOver​(double mouseX, double mouseY)
      Checks if the mouse position is within the bound of the element.
      Specified by:
      isMouseOver in interface Element
      Parameters:
      mouseX - the X coordinate of the mouse
      mouseY - the Y coordinate of the mouse
      Returns:
      true if the mouse is within the bound of the element, otherwise false
    • refreshSearchResults

      private void refreshSearchResults()
    • triggerPirateSpeakEasterEgg

      private void triggerPirateSpeakEasterEgg​(String string)
    • isWide

      private boolean isWide()
    • refresh

      public void refresh()
    • onRecipesDisplayed

      public void onRecipesDisplayed​(List<Recipe<?>> recipes)
      Specified by:
      onRecipesDisplayed in interface RecipeDisplayListener
    • showGhostRecipe

      public void showGhostRecipe​(Recipe<?> recipe, List<Slot> slots)
    • acceptAlignedInput

      public void acceptAlignedInput​(Iterator<Ingredient> inputs, int slot, int amount, int gridX, int gridY)
      Specified by:
      acceptAlignedInput in interface RecipeGridAligner<Ingredient>
    • sendBookDataPacket

      protected void sendBookDataPacket()