public class GuiElement extends net.minecraft.client.gui.Gui implements IGuiElement
| Modifier and Type | Field and Description |
|---|---|
protected IGuiElement |
cropElement |
protected int |
cropHeight |
protected int |
cropWidth |
protected int |
cropX |
protected int |
cropY |
protected int |
height |
protected IGuiElement |
parent |
protected boolean |
visible |
protected int |
width |
protected int |
xOffset |
protected int |
xPos |
protected int |
yOffset |
protected int |
yPos |
| Constructor and Description |
|---|
GuiElement(int width,
int height) |
GuiElement(int xPos,
int yPos,
int width,
int height) |
| Modifier and Type | Method and Description |
|---|---|
<E extends GuiElementEvent> |
addEventHandler(java.util.function.Consumer<E> eventHandler)
Adds an event handler that handles events that this element receives with
IGuiElement.receiveEvent(GuiElementEvent). |
IGuiElement |
addTooltip(java.util.Collection<java.lang.String> lines)
Adds an additional tooltip to the current tooltip of the element.
|
IGuiElement |
addTooltip(ITooltipSupplier supplier) |
IGuiElement |
addTooltip(java.lang.String line)
Adds an additional tooltip to the current tooltip of the element.
|
void |
clearTooltip()
Clears the tooltips that were added with
IGuiElement.addTooltip(String) and IGuiElement.addTooltip(Collection). |
void |
draw(int mouseX,
int mouseY)
Draws the element and his children.
|
void |
drawElement(int mouseX,
int mouseY)
Draws the element itself at the current position.
|
int |
getAbsoluteX() |
int |
getAbsoluteY() |
GuiElementAlignment |
getAlign()
The alignment of the
IGuiElement defines the position of the element relative to the position of its
parent. |
IGuiElement |
getCropElement() |
int |
getCropHeight() |
int |
getCropWidth() |
int |
getCropX() |
int |
getCropY() |
int |
getHeight() |
IGuiElement |
getParent()
The position of this element is relative to the position of its parent.
|
java.util.List<java.lang.String> |
getTooltip() |
java.util.List<java.lang.String> |
getTooltip(int mouseX,
int mouseY)
Returns the tooltip that this element provides at the given mouse position.
|
int |
getWidth() |
IWindowElement |
getWindow()
The root of the containment hierarchy that this element is part of.
|
int |
getX() |
int |
getY() |
boolean |
hasTooltip() |
void |
hide()
Hides this element.
|
boolean |
isCropped() |
boolean |
isEnabled()
The most elements are enabled by default.
|
boolean |
isMouseOver() |
boolean |
isMouseOver(int mouseX,
int mouseY) |
boolean |
isVisible()
The element can be hided with
IGuiElement.hide() and be made visible again with IGuiElement.show(). |
void |
onCreation()
Called at
IElementGroup.add(IGuiElement) after the element was added to the group and
IGuiElement.setParent(IGuiElement) was called at the element. |
void |
onDeletion()
Called at
IElementGroup.remove(IGuiElement...) after the element was removed from the group. |
protected void |
onUpdateClient()
Called if this element get updated on the client side.
|
void |
receiveEvent(GuiElementEvent event)
Receives an event and distributes them to the event handlers of this element.
|
IGuiElement |
setAlign(GuiElementAlignment align)
Sets the alignment of this element.
|
IGuiElement |
setBounds(int xPos,
int yPos,
int width,
int height)
Sets the dimensions and position of this element.
|
void |
setCroppedZone(IGuiElement cropElement,
int cropX,
int cropY,
int cropWidth,
int cropHeight)
Sets the cropped zone of this element and the element the zone is relative to.
|
void |
setHeight(int height) |
IGuiElement |
setLocation(int xPos,
int yPos)
Sets the position of this element.
|
IGuiElement |
setOffset(int xOffset,
int yOffset) |
IGuiElement |
setParent(IGuiElement parent)
Sets the parent of this element.
|
IGuiElement |
setSize(int width,
int height)
Sets the dimensions of this element.
|
void |
setWidth(int width) |
void |
setXPosition(int xPos)
Sets the x position of this element relative to the position of its parent.
|
void |
setYPosition(int yPos)
Sets the y position of this element relative to the position of its parent.
|
void |
show()
Makes this element visible again.
|
java.lang.String |
toString() |
void |
updateClient()
Updates the element.
|
drawCenteredString, drawGradientRect, drawHorizontalLine, drawModalRectWithCustomSizedTexture, drawRect, drawScaledCustomSizeModalRect, drawString, drawTexturedModalRect, drawTexturedModalRect, drawTexturedModalRect, drawVerticalLineclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitaddEventHandler, addEventHandler, addSelfEventHandler, canFocus, canMouseOver, postEvent, postEventprotected int xPos
protected int yPos
protected int xOffset
protected int yOffset
protected int width
protected int height
protected int cropX
protected int cropY
protected int cropWidth
protected int cropHeight
@Nullable protected IGuiElement cropElement
protected boolean visible
@Nullable protected IGuiElement parent
public GuiElement(int width,
int height)
public GuiElement(int xPos,
int yPos,
int width,
int height)
public void onCreation()
IGuiElementIElementGroup.add(IGuiElement) after the element was added to the group and
IGuiElement.setParent(IGuiElement) was called at the element.
Can be used to add other element to the element if the element is an IElementGroup.
onCreation in interface IGuiElementpublic void onDeletion()
IGuiElementIElementGroup.remove(IGuiElement...) after the element was removed from the group.onDeletion in interface IGuiElementpublic final int getX()
getX in interface IGuiElementpublic final int getY()
getY in interface IGuiElementpublic final int getAbsoluteX()
getAbsoluteX in interface IGuiElementpublic final int getAbsoluteY()
getAbsoluteY in interface IGuiElementpublic final void draw(int mouseX,
int mouseY)
IGuiElementdraw in interface IGuiElementmouseX - The x position of the mouse relative to the parent of the element.mouseY - The y position of the mouse relative to the parent of the element.public void drawElement(int mouseX,
int mouseY)
IGuiElementdrawElement in interface IGuiElementmouseX - The x position of the mouse relative to the parent of the element.mouseY - The y position of the mouse relative to the parent of the element.public int getWidth()
getWidth in interface IGuiElementpublic int getHeight()
getHeight in interface IGuiElementpublic void setHeight(int height)
setHeight in interface IGuiElementpublic void setWidth(int width)
setWidth in interface IGuiElementpublic IGuiElement setSize(int width, int height)
IGuiElementsetSize in interface IGuiElementwidth - the size of the element on the x-axis.height - the size of the element on the y-axis.public IGuiElement setOffset(int xOffset, int yOffset)
setOffset in interface IGuiElementpublic void setXPosition(int xPos)
IGuiElementsetXPosition in interface IGuiElementpublic void setYPosition(int yPos)
IGuiElementsetYPosition in interface IGuiElementpublic IGuiElement setLocation(int xPos, int yPos)
IGuiElementsetLocation in interface IGuiElementxPos - the x position of this element relative to the position of its parent.yPos - the y position of this element relative to the position of its parent.public IGuiElement setBounds(int xPos, int yPos, int width, int height)
IGuiElementsetBounds in interface IGuiElementxPos - the x position of this element relative to the position of its parent.yPos - the y position of this element relative to the position of its parent.width - the size of the element on the x-axis.height - the size of the element on the y-axis.public IGuiElement setAlign(GuiElementAlignment align)
IGuiElementsetAlign in interface IGuiElementpublic GuiElementAlignment getAlign()
IGuiElementIGuiElement defines the position of the element relative to the position of its
parent.getAlign in interface IGuiElementpublic void setCroppedZone(@Nullable
IGuiElement cropElement,
int cropX,
int cropY,
int cropWidth,
int cropHeight)
ICroppablesetCroppedZone in interface ICroppablecropElement - The element the zone is relative to.cropX - The x start coordinate of the zone.cropY - The y start coordinate of the zone.cropWidth - The width of the zone.cropHeight - The height of the zone.@Nullable public IGuiElement getCropElement()
getCropElement in interface ICroppablepublic int getCropX()
getCropX in interface ICroppablepublic int getCropY()
getCropY in interface ICroppablepublic int getCropWidth()
getCropWidth in interface ICroppablepublic int getCropHeight()
getCropHeight in interface ICroppablepublic boolean isCropped()
isCropped in interface ICroppableICroppable.setCroppedZone(IGuiElement, int, int, int, int) was ever called on this element.public IWindowElement getWindow()
IGuiElementgetWindow in interface IGuiElementpublic boolean isMouseOver(int mouseX,
int mouseY)
isMouseOver in interface IGuiElementmouseX - The x position of the mouse relative to the parent of the element.mouseY - The y position of the mouse relative to the parent of the element.public final boolean isMouseOver()
isMouseOver in interface IGuiElementprotected void onUpdateClient()
public void updateClient()
IGuiElementGuiScreen.updateScreen().updateClient in interface IGuiElementpublic boolean isVisible()
IGuiElementIGuiElement.hide() and be made visible again with IGuiElement.show().isVisible in interface IGuiElementpublic void show()
IGuiElementshow in interface IGuiElementpublic void hide()
IGuiElementhide in interface IGuiElementpublic boolean isEnabled()
IGuiElementisEnabled in interface IGuiElement@Nullable public IGuiElement getParent()
IGuiElementgetParent in interface IGuiElementpublic IGuiElement setParent(@Nullable IGuiElement parent)
IGuiElementsetParent in interface IGuiElementpublic java.util.List<java.lang.String> getTooltip(int mouseX,
int mouseY)
IGuiElementgetTooltip in interface IGuiElementmouseX - The x position of the mouse relative to the parent of the element.mouseY - The y position of the mouse relative to the parent of the element.public IGuiElement addTooltip(java.lang.String line)
IGuiElementaddTooltip in interface IGuiElementpublic IGuiElement addTooltip(java.util.Collection<java.lang.String> lines)
IGuiElementaddTooltip in interface IGuiElementpublic IGuiElement addTooltip(ITooltipSupplier supplier)
addTooltip in interface IGuiElementpublic boolean hasTooltip()
hasTooltip in interface IGuiElementpublic void clearTooltip()
IGuiElementIGuiElement.addTooltip(String) and IGuiElement.addTooltip(Collection).
It does not remove default tooltips of an element like the fluid information of a tank or the item information
of an slot element.clearTooltip in interface IGuiElementpublic java.util.List<java.lang.String> getTooltip()
getTooltip in interface IGuiElementIGuiElement.addTooltip(String) and IGuiElement.addTooltip(Collection).public <E extends GuiElementEvent> void addEventHandler(java.util.function.Consumer<E> eventHandler)
IGuiElementIGuiElement.receiveEvent(GuiElementEvent).addEventHandler in interface IGuiElementpublic void receiveEvent(GuiElementEvent event)
IGuiElementreceiveEvent in interface IGuiElementpublic java.lang.String toString()
toString in class java.lang.Object