Class ItemDisplay
java.lang.Object
com.trevlar.menukit.api.element.AbstractPanelElement
com.trevlar.menukit.api.element.ItemDisplay
- All Implemented Interfaces:
PanelElement
An item drawn at a fixed size, with its count and durability bar, and
optionally a colored outline. No input, no storage: it only draws.
ItemDisplay.builder().item(() -> player.getMainHandItem()).size(16, 16)
.outline(() -> locked ? 0xFFFF5555 : 0)
.build();
Count and durability overlays show by default, as vanilla draws a slot;
hideCount() and hideDurability() turn them off. A size other
than 16 scales the item through the pose matrix (items are square: the smaller
side is used).
Outline
outline(argb) draws a one-pixel line of that color around the item's
own silhouette, read every frame (0 for none). It is
SlotRendering.drawItemOutline(GuiGraphicsExtractor, ItemStack, int, int, int), the same primitive a slot decoration
uses.-
Nested Class Summary
Nested Classes -
Field Summary
FieldsFields inherited from class AbstractPanelElement
authoredWidth, childX, childY, height, width -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic ItemDisplay.Builderbuilder()voidfillWidth(int width) Column fill: the column's widest extent becomes this element's authored width.net.minecraft.world.item.ItemStackThe stack the display would draw right now.voidlayoutWithin(int budget) Caps the live width to the room the panel gives, reversibly.voidrender(RenderContext ctx) Renders this element at(ctx.originX() + getChildX(), ctx.originY() + getChildY()).Methods inherited from class AbstractPanelElement
applyReflowedY, childContext, declId, disabled, disabled, getChildX, getChildY, getHeight, getWidth, isElementOpaque, isVisible, naturalWidth, ownDisabled, placeOnFirstRead, reflowBaselineY, setChildPosition, textColor, tooltipSupplierMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface PanelElement
extraLayoutHeight, fillHeight, fillsHeight, getActiveOverlayBounds, hitTest, inBand, inDialog, isHovered, isInteractive, keyPressed, mouseClicked, mouseReleased, mouseScrolled, notifyClickOutsideOverlay, onAttach, onDetach, presentsSlotAt, queueTooltip, renderCulled, renderOverlay, screenKind, takeRevealRequest, wrapHeight, yieldHeight
-
Field Details
-
DEFAULT_SIZE
public static final int DEFAULT_SIZEVanilla's item size.- See Also:
-
-
Constructor Details
-
Method Details
-
builder
-
getCurrentStack
public net.minecraft.world.item.ItemStack getCurrentStack()The stack the display would draw right now. -
layoutWithin
public void layoutWithin(int budget) Description copied from class:AbstractPanelElementCaps the live width to the room the panel gives, reversibly.- Specified by:
layoutWithinin interfacePanelElement- Overrides:
layoutWithinin classAbstractPanelElement- Parameters:
budget- horizontal pixels available to this element, in panel content space. Always>= 1.
-
fillWidth
public void fillWidth(int width) Description copied from class:AbstractPanelElementColumn fill: the column's widest extent becomes this element's authored width.- Specified by:
fillWidthin interfacePanelElement- Overrides:
fillWidthin classAbstractPanelElement- Parameters:
width- the column's widest-child extent to stretch to, in pixels
-