Class WPlayerInvPanel
java.lang.Object
io.github.cottonmc.cotton.gui.widget.WWidget
io.github.cottonmc.cotton.gui.widget.WPanel
io.github.cottonmc.cotton.gui.widget.WPanelWithInsets
io.github.cottonmc.cotton.gui.widget.WPlainPanel
io.github.cottonmc.cotton.gui.widget.WPlayerInvPanel
A player inventory widget that has a visually separate hotbar.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final WItemSlotA 9 by 1WItemSlotthat represents the player's hotbar.protected final WItemSlotA 9 by 3WItemSlotthat represents the player's inventory.The label seen aboveinventory.Fields inherited from class io.github.cottonmc.cotton.gui.widget.WPanelWithInsets
insets -
Constructor Summary
ConstructorsConstructorDescriptionWPlayerInvPanel(PlayerInventory playerInventory) Constructs a player inventory panel with a label.WPlayerInvPanel(PlayerInventory playerInventory, boolean hasLabel) Constructs a player inventory panel.WPlayerInvPanel(PlayerInventory playerInventory, @Nullable WWidget label) Constructs a player inventory panel. -
Method Summary
Modifier and TypeMethodDescriptionbooleanChecks whether this widget can be resized usingWWidget.setSize(int, int).static WLabelcreateInventoryLabel(PlayerInventory playerInventory) Creates a vanilla-style inventory label for a player inventory.setBackgroundPainter(BackgroundPainter painter) Sets the background painter of this inventory widget's slots.voidCreates component peers and initializes animation data for this Widget and all its children.Methods inherited from class io.github.cottonmc.cotton.gui.widget.WPlainPanel
add, add, setInsetsMethods inherited from class io.github.cottonmc.cotton.gui.widget.WPanelWithInsets
expandToFit, getInsetsMethods inherited from class io.github.cottonmc.cotton.gui.widget.WPanel
addPainters, expandToFit, getBackgroundPainter, hit, layout, onHidden, onShown, paint, remove, setHost, streamChildren, tick, toStringMethods inherited from class io.github.cottonmc.cotton.gui.widget.WWidget
addNarrations, addTooltip, canFocus, canHover, getAbsoluteX, getAbsoluteY, getFocusModel, getHeight, getHost, getParent, getWidth, getX, getY, hoveredProperty, isActivationKey, isFocused, isHovered, isNarratable, isWithinBounds, onCharTyped, onClick, onFocusGained, onFocusLost, onKeyPressed, onKeyReleased, onMouseDown, onMouseDrag, onMouseMove, onMouseScroll, onMouseUp, releaseFocus, renderTooltip, requestFocus, setHovered, setLocation, setParent, setSize, shouldRenderInDarkMode
-
Field Details
-
inventory
A 9 by 3WItemSlotthat represents the player's inventory.- Since:
- 8.1.0
- See Also:
-
hotbar
A 9 by 1WItemSlotthat represents the player's hotbar.- Since:
- 8.1.0
- See Also:
-
label
The label seen aboveinventory.In vanilla and
WPlayerInvPanel(PlayerInventory), this label is always 'Inventory'- Since:
- 8.1.0
- See Also:
-
-
Constructor Details
-
WPlayerInvPanel
Constructs a player inventory panel with a label.- Parameters:
playerInventory- the player inventory
-
WPlayerInvPanel
Constructs a player inventory panel.- Parameters:
playerInventory- the player inventoryhasLabel- whether there should be an "Inventory" label- Since:
- 2.0.0
-
WPlayerInvPanel
Constructs a player inventory panel.- Parameters:
playerInventory- the player inventorylabel- the label widget, can be null- Since:
- 2.0.0
-
-
Method Details
-
canResize
public boolean canResize()Description copied from class:WWidgetChecks whether this widget can be resized usingWWidget.setSize(int, int). -
createInventoryLabel
Creates a vanilla-style inventory label for a player inventory.- Parameters:
playerInventory- the player inventory- Returns:
- the created label
- Since:
- 3.1.0
-
setBackgroundPainter
Sets the background painter of this inventory widget's slots.- Overrides:
setBackgroundPainterin classWPanel- Parameters:
painter- the new painter- Returns:
- this panel
-
validate
Description copied from class:WPanelCreates component peers and initializes animation data for this Widget and all its children. The host screen handler must clear any heavyweight peers from its records before this method is called.This method must be called on the root panel of any screen once the widgets have been initialized.
Subclasses should call
super.validate(c)to ensure that children are validated.
-