public class WBar extends WWidget
PropertyDelegate.
Bars can be used for all kinds of bars including progress bars (and progress arrows) and energy bars.
| Modifier and Type | Class and Description |
|---|---|
static class |
WBar.Direction |
| Modifier and Type | Field and Description |
|---|---|
protected @Nullable Texture |
bar
The bar texture.
|
protected @Nullable Texture |
bg
The background texture.
|
protected WBar.Direction |
direction |
protected int |
field
The ID of the displayed property in the
properties. |
protected int |
max
The ID of the property representing the maximum value of the
field. |
protected int |
maxValue
The constant maximum value of the
field. |
protected net.minecraft.screen.PropertyDelegate |
properties |
protected java.lang.String |
tooltipLabel |
protected net.minecraft.text.Text |
tooltipTextComponent |
| Constructor and Description |
|---|
WBar(net.minecraft.util.Identifier bg,
net.minecraft.util.Identifier bar,
int field,
int maxfield) |
WBar(net.minecraft.util.Identifier bg,
net.minecraft.util.Identifier bar,
int field,
int maxfield,
WBar.Direction dir) |
WBar(Texture bg,
Texture bar,
int field,
int maxfield) |
WBar(Texture bg,
Texture bar,
int field,
int maxfield,
WBar.Direction dir) |
| Modifier and Type | Method and Description |
|---|---|
void |
addTooltip(TooltipBuilder information)
Adds lines to this widget's tooltip.
|
boolean |
canResize()
Checks whether this widget can be resized using
WWidget.setSize(int, int). |
@Nullable net.minecraft.screen.PropertyDelegate |
getProperties()
Gets the current properties of this bar.
|
void |
paint(net.minecraft.client.util.math.MatrixStack matrices,
int x,
int y,
int mouseX,
int mouseY)
Paints this widget.
|
WBar |
setProperties(net.minecraft.screen.PropertyDelegate properties)
Sets the current properties of this bar.
|
void |
validate(GuiDescription host)
Creates component peers, lays out children, and initializes animation data for this Widget and all its children.
|
static WBar |
withConstantMaximum(net.minecraft.util.Identifier bg,
net.minecraft.util.Identifier bar,
int field,
int maxValue,
WBar.Direction dir)
Creates a WBar that has a constant maximum-value instead of getting the maximum from a field.
|
WBar |
withTooltip(java.lang.String label)
Adds a tooltip to the WBar.
|
WBar |
withTooltip(net.minecraft.text.Text label) |
addPainters, canFocus, createPeers, cycleFocus, getAbsoluteX, getAbsoluteY, getHeight, getHost, getParent, getWidth, getX, getY, hit, isActivationKey, isFocused, isWithinBounds, onCharTyped, onClick, onFocusGained, onFocusLost, onHidden, onKeyPressed, onKeyReleased, onMouseDown, onMouseDrag, onMouseMove, onMouseScroll, onMouseUp, onShown, releaseFocus, renderTooltip, requestFocus, setHost, setLocation, setParent, setSize, tick@Nullable protected final @Nullable Texture bg
@Nullable protected final @Nullable Texture bar
protected final int field
properties.protected final int max
protected int maxValue
protected net.minecraft.screen.PropertyDelegate properties
protected final WBar.Direction direction
protected java.lang.String tooltipLabel
protected net.minecraft.text.Text tooltipTextComponent
public WBar(Texture bg, Texture bar, int field, int maxfield, WBar.Direction dir)
public WBar(net.minecraft.util.Identifier bg,
net.minecraft.util.Identifier bar,
int field,
int maxfield)
public WBar(net.minecraft.util.Identifier bg,
net.minecraft.util.Identifier bar,
int field,
int maxfield,
WBar.Direction dir)
public WBar withTooltip(java.lang.String label)
String.format and can receive two integers
(%d) - the first is the current value of the bar's focused field, and the second is the
bar's focused maximum.label - Translation key of the string to render on the tooltip.public WBar withTooltip(net.minecraft.text.Text label)
public boolean canResize()
WWidgetWWidget.setSize(int, int).@Environment(value=CLIENT)
public void paint(net.minecraft.client.util.math.MatrixStack matrices,
int x,
int y,
int mouseX,
int mouseY)
WWidget@Environment(value=CLIENT) public void addTooltip(TooltipBuilder information)
WWidgetaddTooltip in class WWidgetinformation - the builder to add tooltip lines topublic void validate(GuiDescription host)
WWidget@Nullable public @Nullable net.minecraft.screen.PropertyDelegate getProperties()
public WBar setProperties(net.minecraft.screen.PropertyDelegate properties)
This method is meant for situations when a GUI description is unavailable (such as HUDs).
GuiDescription.getPropertyDelegate() should be preferred over this if available.
properties - the propertiespublic static WBar withConstantMaximum(net.minecraft.util.Identifier bg, net.minecraft.util.Identifier bar, int field, int maxValue, WBar.Direction dir)
bg - the background image to use for the barbar - the foreground image that represents the filled barfield - the field index for bar valuesmaxValue - the constant maximum value for the bardir - the direction the bar should grow towards