Package net.uku3lig.ukulib.utils
Class IconButton
java.lang.Object
net.minecraft.client.gui.widget.ClickableWidget
net.minecraft.client.gui.widget.PressableWidget
net.minecraft.client.gui.widget.ButtonWidget
net.uku3lig.ukulib.utils.IconButton
- All Implemented Interfaces:
net.minecraft.client.gui.Drawable,net.minecraft.client.gui.Element,net.minecraft.client.gui.Narratable,net.minecraft.client.gui.navigation.Navigable,net.minecraft.client.gui.Selectable,net.minecraft.client.gui.widget.Widget
public class IconButton
extends net.minecraft.client.gui.widget.ButtonWidget
A simple button with an icon. Works best when the button is square.
-
Nested Class Summary
Nested classes/interfaces inherited from class net.minecraft.client.gui.widget.ButtonWidget
net.minecraft.client.gui.widget.ButtonWidget.Builder, net.minecraft.client.gui.widget.ButtonWidget.NarrationSupplier, net.minecraft.client.gui.widget.ButtonWidget.PressActionNested classes/interfaces inherited from interface net.minecraft.client.gui.Selectable
net.minecraft.client.gui.Selectable.SelectionType -
Field Summary
Fields inherited from class net.minecraft.client.gui.widget.ButtonWidget
DEFAULT_HEIGHT, DEFAULT_NARRATION_SUPPLIER, DEFAULT_WIDTH, DEFAULT_WIDTH_SMALL, field_46856, field_49479, narrationSupplier, onPressFields inherited from class net.minecraft.client.gui.widget.PressableWidget
field_43050Fields inherited from class net.minecraft.client.gui.widget.ClickableWidget
active, alpha, height, hovered, visible, widthFields inherited from interface net.minecraft.client.gui.Element
MAX_DOUBLE_CLICK_INTERVAL -
Constructor Summary
ConstructorsConstructorDescriptionIconButton(int x, int y, int width, int height, net.minecraft.util.Identifier texture, int u, int v, int iconWidth, int iconHeight, int textureWidth, int textureHeight, net.minecraft.client.gui.widget.ButtonWidget.PressAction pressAction) Makes a new button with a centered icon.IconButton(int x, int y, int width, int height, net.minecraft.util.Identifier texture, int textureWidth, int textureHeight, net.minecraft.client.gui.widget.ButtonWidget.PressAction pressAction) Makes a new button with a centered icon. -
Method Summary
Modifier and TypeMethodDescriptionintThe height of the iconintThe width of the iconnet.minecraft.util.IdentifierThe texture of the iconintThe height of the textureintThe width of the textureintgetU()The x position of the icon in the textureintgetV()The y position of the icon in the texturevoidrenderWidget(net.minecraft.client.gui.DrawContext context, int mouseX, int mouseY, float delta) voidsetIconHeight(int iconHeight) The height of the iconvoidsetIconWidth(int iconWidth) The width of the iconvoidsetTexture(net.minecraft.util.Identifier texture) The texture of the iconvoidsetTextureHeight(int textureHeight) The height of the texturevoidsetTextureWidth(int textureWidth) The width of the texturevoidsetU(int u) The x position of the icon in the texturevoidsetV(int v) The y position of the icon in the textureMethods inherited from class net.minecraft.client.gui.widget.ButtonWidget
appendClickableNarrations, builder, getNarrationMessage, onPressMethods inherited from class net.minecraft.client.gui.widget.PressableWidget
drawMessage, keyPressed, onClickMethods inherited from class net.minecraft.client.gui.widget.ClickableWidget
appendDefaultNarrations, appendNarrations, clicked, drawScrollableText, drawScrollableText, drawScrollableText, forEachChild, getBottom, getHeight, getMessage, getNarrationMessage, getNavigationFocus, getNavigationOrder, getNavigationPath, getRight, getTooltip, getType, getWidth, getX, getY, isFocused, isHovered, isMouseOver, isNarratable, isSelected, isValidClickButton, mouseClicked, mouseDragged, mouseReleased, onDrag, onRelease, playDownSound, render, setAlpha, setDimensions, setDimensionsAndPosition, setFocused, setHeight, setMessage, setNavigationOrder, setTooltip, setTooltipDelay, setWidth, setX, setYMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface net.minecraft.client.gui.Element
charTyped, getFocusedPath, keyReleased, mouseMoved, mouseScrolledMethods inherited from interface net.minecraft.client.gui.widget.Widget
setPosition
-
Constructor Details
-
IconButton
public IconButton(int x, int y, int width, int height, net.minecraft.util.Identifier texture, int u, int v, int iconWidth, int iconHeight, int textureWidth, int textureHeight, net.minecraft.client.gui.widget.ButtonWidget.PressAction pressAction) Makes a new button with a centered icon.- Parameters:
x- The x position of the buttony- The y position of the buttonwidth- The width of the buttonheight- The height of the buttontexture- The texture of the iconu- The x position of the icon in the texturev- The y position of the icon in the textureiconWidth- The width of the iconiconHeight- The height of the icontextureWidth- The width of the texturetextureHeight- The height of the texturepressAction- The action to perform when the button is pressed
-
IconButton
public IconButton(int x, int y, int width, int height, net.minecraft.util.Identifier texture, int textureWidth, int textureHeight, net.minecraft.client.gui.widget.ButtonWidget.PressAction pressAction) Makes a new button with a centered icon. The rendered icon will be the whole texture.- Parameters:
x- The x position of the buttony- The y position of the buttonwidth- The width of the buttonheight- The height of the buttontexture- The texture of the icontextureWidth- The width of the texturetextureHeight- The height of the texturepressAction- The action to perform when the button is pressed
-
-
Method Details
-
renderWidget
public void renderWidget(net.minecraft.client.gui.DrawContext context, int mouseX, int mouseY, float delta) - Overrides:
renderWidgetin classnet.minecraft.client.gui.widget.PressableWidget
-
getTexture
public net.minecraft.util.Identifier getTexture()The texture of the icon- Returns:
- The texture
-
getU
public int getU()The x position of the icon in the texture- Returns:
- The x position
-
getV
public int getV()The y position of the icon in the texture- Returns:
- The y position
-
getIconWidth
public int getIconWidth()The width of the icon- Returns:
- The width
-
getIconHeight
public int getIconHeight()The height of the icon- Returns:
- The height
-
getTextureWidth
public int getTextureWidth()The width of the texture- Returns:
- The width
-
getTextureHeight
public int getTextureHeight()The height of the texture- Returns:
- The height
-
setTexture
public void setTexture(net.minecraft.util.Identifier texture) The texture of the icon- Parameters:
texture- The new texture
-
setU
public void setU(int u) The x position of the icon in the texture- Parameters:
u- The new x position
-
setV
public void setV(int v) The y position of the icon in the texture- Parameters:
v- The new y position
-
setIconWidth
public void setIconWidth(int iconWidth) The width of the icon- Parameters:
iconWidth- The new width
-
setIconHeight
public void setIconHeight(int iconHeight) The height of the icon- Parameters:
iconHeight- The new height
-
setTextureWidth
public void setTextureWidth(int textureWidth) The width of the texture- Parameters:
textureWidth- The new width
-
setTextureHeight
public void setTextureHeight(int textureHeight) The height of the texture- Parameters:
textureHeight- The new height
-