Class RecipeBookComponent
java.lang.Object
net.minecraft.client.gui.screens.recipebook.RecipeBookComponent
- All Implemented Interfaces:
GuiEventListener
,Renderable
,TabOrderedElement
,NarratableEntry
,NarrationSupplier
,RecipeShownListener
,PlaceRecipe<Ingredient>
- Direct Known Subclasses:
AbstractFurnaceRecipeBookComponent
public class RecipeBookComponent
extends Object
implements PlaceRecipe<Ingredient>, Renderable, GuiEventListener, NarratableEntry, RecipeShownListener
-
Nested Class Summary
Nested classes/interfaces inherited from interface net.minecraft.client.gui.narration.NarratableEntry
NarratableEntry.NarrationPriority
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final Component
private ClientRecipeBook
private static final WidgetSprites
protected StateSwitchingButton
protected final GhostRecipe
private int
private boolean
static final int
static final int
private String
protected RecipeBookMenu
<?, ?> protected Minecraft
private static final int
private static final Component
protected static final ResourceLocation
static final WidgetSprites
private final RecipeBookPage
private static final Component
private EditBox
private RecipeBookTabButton
private final StackedContents
private final List
<RecipeBookTabButton> private int
private boolean
private int
private boolean
private int
Fields inherited from interface net.minecraft.client.gui.components.events.GuiEventListener
DOUBLE_CLICK_THRESHOLD_MS
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addItemToSlot
(Ingredient pItem, int pSlot, int pMaxAmount, int pX, int pY) boolean
charTyped
(char pCodePoint, int pModifiers) Called when a character is typed within the GUI element.private void
protected Component
boolean
hasClickedOutside
(double pMouseX, double pMouseY, int pX, int pY, int pWidth, int pHeight, int p_100304_) void
init
(int pWidth, int pHeight, Minecraft pMinecraft, boolean pWidthTooNarrow, RecipeBookMenu<?, ?> pMenu) protected void
void
boolean
boolean
isMouseOver
(double pMouseX, double pMouseY) Checks if the given mouse coordinates are over the GUI element.private boolean
boolean
private boolean
boolean
keyPressed
(int pKeyCode, int pScanCode, int pModifiers) Called when a keyboard key is pressed within the GUI element.boolean
keyReleased
(int pKeyCode, int pScanCode, int pModifiers) Called when a keyboard key is released within the GUI element.boolean
mouseClicked
(double pMouseX, double pMouseY, int pButton) Called when a mouse button is clicked within the GUI element.private void
pirateSpeechForThePeople
(String pText) Check if we should activate the pirate speak easter egg.void
recipesShown
(List<RecipeHolder<?>> pRecipes) void
void
render
(GuiGraphics pGuiGraphics, int pMouseX, int pMouseY, float pPartialTick) Renders the graphical user interface (GUI) element.void
renderGhostRecipe
(GuiGraphics pGuiGraphics, int pLeftPos, int pTopPos, boolean p_283495_, float pPartialTick) private void
renderGhostRecipeTooltip
(GuiGraphics pGuiGraphics, int pX, int pY, int pMouseX, int pMouseY) void
renderTooltip
(GuiGraphics pGuiGraphics, int pRenderX, int pRenderY, int pMouseX, int pMouseY) protected void
void
setFocused
(boolean pFocused) Sets the focus state of the GUI element.void
setupGhostRecipe
(RecipeHolder<?> pRecipe, List<Slot> pSlots) protected void
setVisible
(boolean pVisible) void
slotClicked
(Slot pSlot) void
tick()
private boolean
void
private void
updateCollections
(boolean pResetPageNumber) private void
void
updateNarration
(NarrationElementOutput pNarrationElementOutput) Updates the narration output with the current narration information.int
updateScreenPosition
(int pWidth, int pImageWidth) private void
private void
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface net.minecraft.client.gui.components.events.GuiEventListener
getCurrentFocusPath, getRectangle, mouseDragged, mouseMoved, mouseReleased, mouseScrolled, nextFocusPath
Methods inherited from interface net.minecraft.client.gui.narration.NarratableEntry
isActive
Methods inherited from interface net.minecraft.recipebook.PlaceRecipe
placeRecipe
Methods inherited from interface net.minecraft.client.gui.components.TabOrderedElement
getTabOrderGroup
-
Field Details
-
RECIPE_BUTTON_SPRITES
-
FILTER_BUTTON_SPRITES
-
RECIPE_BOOK_LOCATION
-
SEARCH_HINT
-
IMAGE_WIDTH
public static final int IMAGE_WIDTH- See Also:
-
IMAGE_HEIGHT
public static final int IMAGE_HEIGHT- See Also:
-
OFFSET_X_POSITION
private static final int OFFSET_X_POSITION- See Also:
-
ONLY_CRAFTABLES_TOOLTIP
-
ALL_RECIPES_TOOLTIP
-
xOffset
private int xOffset -
width
private int width -
height
private int height -
ghostRecipe
-
tabButtons
-
selectedTab
-
filterButton
-
minecraft
-
searchBox
-
lastSearch
-
book
-
recipeBookPage
-
stackedContents
-
timesInventoryChanged
private int timesInventoryChanged -
ignoreTextInput
private boolean ignoreTextInput -
visible
private boolean visible -
widthTooNarrow
private boolean widthTooNarrow
-
-
Constructor Details
-
RecipeBookComponent
public RecipeBookComponent()
-
-
Method Details
-
init
public void init(int pWidth, int pHeight, Minecraft pMinecraft, boolean pWidthTooNarrow, RecipeBookMenu<?, ?> pMenu) -
initVisuals
public void initVisuals() -
updateFilterButtonTooltip
private void updateFilterButtonTooltip() -
initFilterButtonTextures
protected void initFilterButtonTextures() -
updateScreenPosition
public int updateScreenPosition(int pWidth, int pImageWidth) -
toggleVisibility
public void toggleVisibility() -
isVisible
public boolean isVisible() -
isVisibleAccordingToBookData
private boolean isVisibleAccordingToBookData() -
setVisible
protected void setVisible(boolean pVisible) -
slotClicked
-
updateCollections
private void updateCollections(boolean pResetPageNumber) -
updateTabs
private void updateTabs() -
tick
public void tick() -
updateStackedContents
private void updateStackedContents() -
render
Renders the graphical user interface (GUI) element.- Specified by:
render
in interfaceRenderable
- Parameters:
pGuiGraphics
- the GuiGraphics object used for rendering.pMouseX
- the x-coordinate of the mouse cursor.pMouseY
- the y-coordinate of the mouse cursor.pPartialTick
- the partial tick time.
-
renderTooltip
public void renderTooltip(GuiGraphics pGuiGraphics, int pRenderX, int pRenderY, int pMouseX, int pMouseY) -
getRecipeFilterName
-
renderGhostRecipeTooltip
private void renderGhostRecipeTooltip(GuiGraphics pGuiGraphics, int pX, int pY, int pMouseX, int pMouseY) -
renderGhostRecipe
public void renderGhostRecipe(GuiGraphics pGuiGraphics, int pLeftPos, int pTopPos, boolean p_283495_, float pPartialTick) -
mouseClicked
public boolean mouseClicked(double pMouseX, double pMouseY, int pButton) Called when a mouse button is clicked within the GUI element.- Specified by:
mouseClicked
in interfaceGuiEventListener
- Parameters:
pMouseX
- the X coordinate of the mouse.pMouseY
- the Y coordinate of the mouse.pButton
- the button that was clicked.- Returns:
true
if the event is consumed,false
otherwise.
-
toggleFiltering
private boolean toggleFiltering() -
hasClickedOutside
public boolean hasClickedOutside(double pMouseX, double pMouseY, int pX, int pY, int pWidth, int pHeight, int p_100304_) -
keyPressed
public boolean keyPressed(int pKeyCode, int pScanCode, int pModifiers) Called when a keyboard key is pressed within the GUI element.- Specified by:
keyPressed
in interfaceGuiEventListener
- Parameters:
pKeyCode
- the key code of the pressed key.pScanCode
- the scan code of the pressed key.pModifiers
- the keyboard modifiers.- Returns:
true
if the event is consumed,false
otherwise.
-
keyReleased
public boolean keyReleased(int pKeyCode, int pScanCode, int pModifiers) Called when a keyboard key is released within the GUI element.- Specified by:
keyReleased
in interfaceGuiEventListener
- Parameters:
pKeyCode
- the key code of the released key.pScanCode
- the scan code of the released key.pModifiers
- the keyboard modifiers.- Returns:
true
if the event is consumed,false
otherwise.
-
charTyped
public boolean charTyped(char pCodePoint, int pModifiers) Called when a character is typed within the GUI element.- Specified by:
charTyped
in interfaceGuiEventListener
- Parameters:
pCodePoint
- the code point of the typed character.pModifiers
- the keyboard modifiers.- Returns:
true
if the event is consumed,false
otherwise.
-
isMouseOver
public boolean isMouseOver(double pMouseX, double pMouseY) Checks if the given mouse coordinates are over the GUI element.- Specified by:
isMouseOver
in interfaceGuiEventListener
- Parameters:
pMouseX
- the X coordinate of the mouse.pMouseY
- the Y coordinate of the mouse.- Returns:
true
if the mouse is over the GUI element,false
otherwise.
-
setFocused
public void setFocused(boolean pFocused) Sets the focus state of the GUI element.- Specified by:
setFocused
in interfaceGuiEventListener
- Parameters:
pFocused
-true
to apply focus,false
to remove focus
-
isFocused
public boolean isFocused()- Specified by:
isFocused
in interfaceGuiEventListener
-
checkSearchStringUpdate
private void checkSearchStringUpdate() -
pirateSpeechForThePeople
Check if we should activate the pirate speak easter egg. -
isOffsetNextToMainGUI
private boolean isOffsetNextToMainGUI() -
recipesUpdated
public void recipesUpdated() -
recipesShown
- Specified by:
recipesShown
in interfaceRecipeShownListener
-
setupGhostRecipe
-
addItemToSlot
- Specified by:
addItemToSlot
in interfacePlaceRecipe<Ingredient>
-
sendUpdateSettings
protected void sendUpdateSettings() -
narrationPriority
- Specified by:
narrationPriority
in interfaceNarratableEntry
-
updateNarration
Updates the narration output with the current narration information.- Specified by:
updateNarration
in interfaceNarrationSupplier
- Parameters:
pNarrationElementOutput
- the output to update with narration information.
-