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 Componentprivate ClientRecipeBookprivate static final WidgetSpritesprotected StateSwitchingButtonprotected final GhostRecipeprivate intprivate booleanstatic final intstatic final intprivate Stringprotected RecipeBookMenu<?, ?> protected Minecraftprivate static final intprivate static final Componentprotected static final ResourceLocationstatic final WidgetSpritesprivate final RecipeBookPageprivate static final Componentprivate EditBoxprivate RecipeBookTabButtonprivate final StackedContentsprivate final List<RecipeBookTabButton> private intprivate booleanprivate intprivate booleanprivate intFields inherited from interface net.minecraft.client.gui.components.events.GuiEventListener
DOUBLE_CLICK_THRESHOLD_MS -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddItemToSlot(Ingredient item, int p_slot, int maxAmount, int x, int y) booleancharTyped(char codePoint, int modifiers) Called when a character is typed within the GUI element.private voidprotected ComponentbooleanhasClickedOutside(double mouseX, double mouseY, int x, int y, int width, int height, int p_100304_) voidinit(int width, int height, Minecraft minecraft, boolean widthTooNarrow, RecipeBookMenu<?, ?> menu) protected voidvoidbooleanbooleanisMouseOver(double mouseX, double mouseY) Checks if the given mouse coordinates are over the GUI element.private booleanbooleanprivate booleanbooleankeyPressed(int keyCode, int scanCode, int modifiers) Called when a keyboard key is pressed within the GUI element.booleankeyReleased(int keyCode, int scanCode, int modifiers) Called when a keyboard key is released within the GUI element.booleanmouseClicked(double mouseX, double mouseY, int button) Called when a mouse button is clicked within the GUI element.private voidCheck if we should activate the pirate speak easter egg.voidrecipesShown(List<RecipeHolder<?>> recipes) voidvoidrender(GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTick) Renders the graphical user interface (GUI) element.voidrenderGhostRecipe(GuiGraphics guiGraphics, int leftPos, int topPos, boolean p_283495_, float partialTick) private voidrenderGhostRecipeTooltip(GuiGraphics guiGraphics, int x, int y, int mouseX, int mouseY) voidrenderTooltip(GuiGraphics guiGraphics, int renderX, int renderY, int mouseX, int mouseY) protected voidvoidsetFocused(boolean focused) Sets the focus state of the GUI element.voidsetupGhostRecipe(RecipeHolder<?> recipe, List<Slot> slots) protected voidsetVisible(boolean visible) voidslotClicked(Slot slot) voidtick()private booleanvoidprivate voidupdateCollections(boolean resetPageNumber) private voidvoidupdateNarration(NarrationElementOutput narrationElementOutput) Updates the narration output with the current narration information.intupdateScreenPosition(int width, int imageWidth) private voidprivate voidMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface net.minecraft.client.gui.components.events.GuiEventListener
getCurrentFocusPath, getRectangle, mouseDragged, mouseMoved, mouseReleased, mouseScrolled, nextFocusPathMethods inherited from interface net.minecraft.client.gui.narration.NarratableEntry
isActiveMethods inherited from interface net.minecraft.recipebook.PlaceRecipe
placeRecipeMethods 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 width, int height, Minecraft minecraft, boolean widthTooNarrow, RecipeBookMenu<?, ?> menu) -
initVisuals
public void initVisuals() -
updateFilterButtonTooltip
private void updateFilterButtonTooltip() -
initFilterButtonTextures
protected void initFilterButtonTextures() -
updateScreenPosition
public int updateScreenPosition(int width, int imageWidth) -
toggleVisibility
public void toggleVisibility() -
isVisible
public boolean isVisible() -
isVisibleAccordingToBookData
private boolean isVisibleAccordingToBookData() -
setVisible
protected void setVisible(boolean visible) -
slotClicked
-
updateCollections
private void updateCollections(boolean resetPageNumber) -
updateTabs
private void updateTabs() -
tick
public void tick() -
updateStackedContents
private void updateStackedContents() -
render
Renders the graphical user interface (GUI) element.- Specified by:
renderin interfaceRenderable- Parameters:
guiGraphics- the GuiGraphics object used for rendering.mouseX- the x-coordinate of the mouse cursor.mouseY- the y-coordinate of the mouse cursor.partialTick- the partial tick time.
-
renderTooltip
public void renderTooltip(GuiGraphics guiGraphics, int renderX, int renderY, int mouseX, int mouseY) -
getRecipeFilterName
-
renderGhostRecipeTooltip
private void renderGhostRecipeTooltip(GuiGraphics guiGraphics, int x, int y, int mouseX, int mouseY) -
renderGhostRecipe
public void renderGhostRecipe(GuiGraphics guiGraphics, int leftPos, int topPos, boolean p_283495_, float partialTick) -
mouseClicked
public boolean mouseClicked(double mouseX, double mouseY, int button) Called when a mouse button is clicked within the GUI element.- Specified by:
mouseClickedin interfaceGuiEventListener- Parameters:
mouseX- the X coordinate of the mouse.mouseY- the Y coordinate of the mouse.button- the button that was clicked.- Returns:
trueif the event is consumed,falseotherwise.
-
toggleFiltering
private boolean toggleFiltering() -
hasClickedOutside
public boolean hasClickedOutside(double mouseX, double mouseY, int x, int y, int width, int height, int p_100304_) -
keyPressed
public boolean keyPressed(int keyCode, int scanCode, int modifiers) Called when a keyboard key is pressed within the GUI element.- Specified by:
keyPressedin interfaceGuiEventListener- Parameters:
keyCode- the key code of the pressed key.scanCode- the scan code of the pressed key.modifiers- the keyboard modifiers.- Returns:
trueif the event is consumed,falseotherwise.
-
keyReleased
public boolean keyReleased(int keyCode, int scanCode, int modifiers) Called when a keyboard key is released within the GUI element.- Specified by:
keyReleasedin interfaceGuiEventListener- Parameters:
keyCode- the key code of the released key.scanCode- the scan code of the released key.modifiers- the keyboard modifiers.- Returns:
trueif the event is consumed,falseotherwise.
-
charTyped
public boolean charTyped(char codePoint, int modifiers) Called when a character is typed within the GUI element.- Specified by:
charTypedin interfaceGuiEventListener- Parameters:
codePoint- the code point of the typed character.modifiers- the keyboard modifiers.- Returns:
trueif the event is consumed,falseotherwise.
-
isMouseOver
public boolean isMouseOver(double mouseX, double mouseY) Checks if the given mouse coordinates are over the GUI element.- Specified by:
isMouseOverin interfaceGuiEventListener- Parameters:
mouseX- the X coordinate of the mouse.mouseY- the Y coordinate of the mouse.- Returns:
trueif the mouse is over the GUI element,falseotherwise.
-
setFocused
public void setFocused(boolean focused) Sets the focus state of the GUI element.- Specified by:
setFocusedin interfaceGuiEventListener- Parameters:
focused-trueto apply focus,falseto remove focus
-
isFocused
public boolean isFocused()- Specified by:
isFocusedin 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:
recipesShownin interfaceRecipeShownListener
-
setupGhostRecipe
-
addItemToSlot
- Specified by:
addItemToSlotin interfacePlaceRecipe<Ingredient>
-
sendUpdateSettings
protected void sendUpdateSettings() -
narrationPriority
- Specified by:
narrationPriorityin interfaceNarratableEntry
-
updateNarration
Updates the narration output with the current narration information.- Specified by:
updateNarrationin interfaceNarrationSupplier- Parameters:
narrationElementOutput- the output to update with narration information.
-