Package net.minecraft.client.gui.widget
Class EntryListWidget<E extends EntryListWidget.Entry<E>>
java.lang.Object
net.minecraft.client.gui.DrawableHelper
net.minecraft.client.gui.AbstractParentElement
net.minecraft.client.gui.widget.EntryListWidget<E>
- All Implemented Interfaces:
Drawable
,Element
,ParentElement
- Direct Known Subclasses:
AlwaysSelectedEntryListWidget
,ElementListWidget
@Environment(CLIENT) public abstract class EntryListWidget<E extends EntryListWidget.Entry<E>> extends AbstractParentElement implements Drawable
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) class
EntryListWidget.Entries
static class
EntryListWidget.Entry<E extends EntryListWidget.Entry<E>>
static class
EntryListWidget.MoveDirection
Represents the direction in which the selection is moved. -
Field Summary
Fields Modifier and Type Field Description protected int
bottom
protected boolean
centerListVertically
private List<E>
children
protected MinecraftClient
client
private boolean
field_26846
private boolean
field_26847
protected int
headerHeight
protected int
height
protected int
itemHeight
protected int
left
private boolean
renderHeader
private boolean
renderSelection
protected int
right
private double
scrollAmount
private boolean
scrolling
private E
selected
protected int
top
protected int
width
Fields inherited from class net.minecraft.client.gui.DrawableHelper
GUI_ICONS_TEXTURE, OPTIONS_BACKGROUND_TEXTURE, STATS_ICON_TEXTURE
-
Constructor Summary
Constructors Constructor Description EntryListWidget(MinecraftClient client, int width, int height, int top, int bottom, int itemHeight)
-
Method Summary
Modifier and Type Method Description protected int
addEntry(E entry)
protected void
centerScrollOn(E entry)
List<E>
children()
Gets a list of all child GUI elements.protected void
clearEntries()
protected void
clickedHeader(int x, int y)
protected void
ensureVisible(E entry)
protected E
getEntry(int index)
protected E
getEntryAtPosition(double x, double y)
E
getFocused()
protected int
getItemCount()
protected int
getMaxPosition()
int
getMaxScroll()
private int
getRowBottom(int index)
int
getRowLeft()
protected int
getRowTop(int index)
int
getRowWidth()
double
getScrollAmount()
protected int
getScrollbarPositionX()
E
getSelected()
protected boolean
isFocused()
boolean
isMouseOver(double mouseX, double mouseY)
Checks if the mouse position is within the bound of the element.protected boolean
isSelectedItem(int index)
boolean
keyPressed(int keyCode, int scanCode, int modifiers)
Callback for when a key down event has been captured.private void
method_29621(EntryListWidget.Entry<E> entry)
protected void
method_30015()
void
method_31322(boolean bool)
void
method_31323(boolean bool)
int
method_31383()
boolean
mouseClicked(double mouseX, double mouseY, int button)
Callback for when a mouse button down event has been captured.boolean
mouseDragged(double mouseX, double mouseY, int button, double deltaX, double deltaY)
Callback for when a mouse button drag event has been captured.boolean
mouseReleased(double mouseX, double mouseY, int button)
Callback for when a mouse button release event has been captured.boolean
mouseScrolled(double mouseX, double mouseY, double amount)
Callback for when a mouse button scroll event has been captured.protected void
moveSelection(EntryListWidget.MoveDirection direction)
protected void
moveSelectionIf(EntryListWidget.MoveDirection direction, Predicate<E> predicate)
Moves the selection in the specified direction until the predicate returns true.protected E
remove(int index)
protected boolean
removeEntry(E entry)
void
render(MatrixStack matrices, int mouseX, int mouseY, float delta)
protected void
renderBackground(MatrixStack matrices)
protected void
renderDecorations(MatrixStack matrixStack, int int2, int int3)
protected void
renderHeader(MatrixStack matrices, int x, int y, Tessellator tessellator)
protected void
renderList(MatrixStack matrices, int x, int y, int mouseX, int mouseY, float delta)
protected void
replaceEntries(Collection<E> newEntries)
private void
scroll(int amount)
void
setLeftPos(int left)
protected void
setRenderHeader(boolean renderHeader, int headerHeight)
void
setRenderSelection(boolean renderSelection)
void
setScrollAmount(double amount)
void
setSelected(E entry)
protected void
updateScrollingState(double mouseX, double mouseY, int button)
void
updateSize(int width, int height, int top, int bottom)
Methods inherited from class net.minecraft.client.gui.AbstractParentElement
isDragging, setDragging, setFocused
Methods inherited from class net.minecraft.client.gui.DrawableHelper
drawCenteredString, drawCenteredText, drawHorizontalLine, drawSprite, drawStringWithShadow, drawTexture, drawTexture, drawTexture, drawTexture, drawTextWithShadow, drawVerticalLine, fill, fillGradient, fillGradient, getZOffset, method_29343, setZOffset
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.Element
mouseMoved
Methods inherited from interface net.minecraft.client.gui.ParentElement
changeFocus, charTyped, focusOn, hoveredElement, keyReleased, setInitialFocus
-
Field Details
-
client
-
itemHeight
protected final int itemHeight -
children
-
width
protected int width -
height
protected int height -
top
protected int top -
bottom
protected int bottom -
right
protected int right -
left
protected int left -
centerListVertically
protected boolean centerListVertically -
scrollAmount
private double scrollAmount -
renderSelection
private boolean renderSelection -
renderHeader
private boolean renderHeader -
headerHeight
protected int headerHeight -
scrolling
private boolean scrolling -
selected
-
field_26846
private boolean field_26846 -
field_26847
private boolean field_26847
-
-
Constructor Details
-
EntryListWidget
public EntryListWidget(MinecraftClient client, int width, int height, int top, int bottom, int itemHeight)
-
-
Method Details
-
setRenderSelection
public void setRenderSelection(boolean renderSelection) -
setRenderHeader
protected void setRenderHeader(boolean renderHeader, int headerHeight) -
getRowWidth
public int getRowWidth() -
getSelected
-
setSelected
-
method_31322
public void method_31322(boolean bool) -
method_31323
public void method_31323(boolean bool) -
getFocused
- Specified by:
getFocused
in interfaceParentElement
- Overrides:
getFocused
in classAbstractParentElement
-
children
Gets a list of all child GUI elements.- Specified by:
children
in interfaceParentElement
-
clearEntries
protected final void clearEntries() -
replaceEntries
-
getEntry
-
addEntry
-
getItemCount
protected int getItemCount() -
isSelectedItem
protected boolean isSelectedItem(int index) -
getEntryAtPosition
-
updateSize
public void updateSize(int width, int height, int top, int bottom) -
setLeftPos
public void setLeftPos(int left) -
getMaxPosition
protected int getMaxPosition() -
clickedHeader
protected void clickedHeader(int x, int y) -
renderHeader
-
renderBackground
-
renderDecorations
-
render
-
centerScrollOn
-
ensureVisible
-
scroll
private void scroll(int amount) -
getScrollAmount
public double getScrollAmount() -
setScrollAmount
public void setScrollAmount(double amount) -
getMaxScroll
public int getMaxScroll() -
updateScrollingState
protected void updateScrollingState(double mouseX, double mouseY, int button) -
getScrollbarPositionX
protected int getScrollbarPositionX() -
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 inGLFW
class.- Specified by:
mouseClicked
in interfaceElement
- Specified by:
mouseClicked
in interfaceParentElement
- Parameters:
mouseX
- the X coordinate of the mousemouseY
- the Y coordinate of the mousebutton
- 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
-
mouseReleased
public boolean mouseReleased(double mouseX, double mouseY, int button)Callback for when a mouse button release event has been captured. The button number is identified by the constants inGLFW
class.- Specified by:
mouseReleased
in interfaceElement
- Specified by:
mouseReleased
in interfaceParentElement
- Parameters:
mouseX
- the X coordinate of the mousemouseY
- the Y coordinate of the mousebutton
- 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
-
mouseDragged
public boolean mouseDragged(double mouseX, double mouseY, int button, double deltaX, double deltaY)Callback for when a mouse button drag event has been captured. The button number is identified by the constants inGLFW
class.- Specified by:
mouseDragged
in interfaceElement
- Specified by:
mouseDragged
in interfaceParentElement
- Parameters:
mouseX
- the current X coordinate of the mousemouseY
- the current Y coordinate of the mousebutton
- the mouse button numberdeltaX
- the difference of the current X with the previous X coordinatedeltaY
- the difference of the current Y with the previous Y coordinate- Returns:
true
to indicate that the event handling is successful/valid- See Also:
Mouse.onCursorPos(long, double, double)
,GLFW.GLFW_MOUSE_BUTTON_1
-
mouseScrolled
public boolean mouseScrolled(double mouseX, double mouseY, double amount)Callback for when a mouse button scroll event has been captured.- Specified by:
mouseScrolled
in interfaceElement
- Specified by:
mouseScrolled
in interfaceParentElement
- Parameters:
mouseX
- the X coordinate of the mousemouseY
- the Y coordinate of the mouseamount
- value is> 1
if scrolled down,< 1
if scrolled up- Returns:
true
to indicate that the event handling is successful/valid- See Also:
Mouse.onMouseScroll(long, double, double)
-
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 inGLFW
class.- Specified by:
keyPressed
in interfaceElement
- Specified by:
keyPressed
in interfaceParentElement
- Parameters:
keyCode
- the named key code of the event as described in theGLFW
classscanCode
- the unique/platform-specific scan code of the keyboard inputmodifiers
- 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)
-
moveSelection
-
method_30015
protected void method_30015() -
moveSelectionIf
Moves the selection in the specified direction until the predicate returns true.- Parameters:
direction
- the direction to move the selection
-
isMouseOver
public boolean isMouseOver(double mouseX, double mouseY)Checks if the mouse position is within the bound of the element.- Specified by:
isMouseOver
in interfaceElement
- Parameters:
mouseX
- the X coordinate of the mousemouseY
- the Y coordinate of the mouse- Returns:
true
if the mouse is within the bound of the element, otherwisefalse
-
renderList
-
getRowLeft
public int getRowLeft() -
method_31383
public int method_31383() -
getRowTop
protected int getRowTop(int index) -
getRowBottom
private int getRowBottom(int index) -
isFocused
protected boolean isFocused() -
remove
-
removeEntry
-
method_29621
-