Class ItemModelComponent
Passive retained component that renders an item or block inventory model on
managed GUI and HUD surfaces.
The component owns a snapshot of its configured stack. All synchronized data components, including custom models, custom model data, profile data, tint, and glint state, are retained by that copy. Its 16-by-16 intrinsic size is a layout default only; larger boxes rasterize through Minecraft's oversized-item path at their actual device resolution.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionblock(net.minecraft.world.level.block.Block block) Uses the block's inventory-item model.customModelData(net.minecraft.world.item.component.CustomModelData customModelData) Replaces the stack's custom-model-data component.displayContext(net.minecraft.world.item.ItemDisplayContext displayContext) Selects the vanilla item display transform.item(net.minecraft.world.item.Item item) Uses a new stack for the supplied item.item(net.minecraft.world.item.ItemStack itemStack) Snapshots the complete supplied stack for subsequent rendering.itemModel(net.minecraft.resources.Identifier modelId) Overrides the stack'sDataComponents.ITEM_MODELcomponent.offset(float x, float y) Offsets the centered model in component design-space units.offsetX(float offsetX) Sets the horizontal model offset in component design-space units.offsetY(float offsetY) Sets the vertical model offset in component design-space units.playerHead(com.mojang.authlib.GameProfile profile) Renders a player head from a resolved authentication profile.playerHead(String playerName) Renders a player head resolved from a player name.playerHead(UUID uuid) Renders a player head resolved from a UUID.playerHead(net.minecraft.world.item.component.ResolvableProfile profile) Renders a player head from Minecraft's resolvable profile component.playerHeadTexture(String texturesProperty) Renders a player head from a Mojang base64texturesproperty.playerHeadTexture(String texturesProperty, @Nullable String signature) Renders a player head from a Mojang base64texturesproperty.protected floatpreferredHeight(com.render.api.gui.GuiRenderContext context) protected floatpreferredWidth(com.render.api.gui.GuiRenderContext context) protected voidrenderSelf(com.render.api.gui.GuiRenderContext context) resourceMode(ItemModelResourceMode resourceMode) Selects active resource packs or the isolated built-in resource runtime.rotation(float x, float y, float z) Sets additional model-space rotations in degrees.rotationX(float rotationX) Sets additional x-axis model rotation in degrees.rotationY(float rotationY) Sets additional y-axis model rotation in degrees.rotationZ(float rotationZ) Sets additional z-axis model rotation in degrees.seed(int seed) Sets the deterministic model-selection seed.zoom(float zoom) Scales the vanilla 16-by-16 item slot within the content box.Methods inherited from class GuiComponent
activeStateStyle, add, alignContent, alignItems, alignSelf, anchor, anchorName, anchorPlacement, animatedBorder, animation, applyStyle, aspectRatio, autoHeight, autoSize, autoWidth, backdropFilters, backfaceVisibility, backgroundColor, backgroundColor, backgroundLayer, backgroundLayers, backgroundLayers, border, borderCollapse, borderColor, borderColor, borderSpacing, borderWidth, boxDecorationBreak, boxGlow, boxShadow, boxShadows, boxShadows, boxSizing, breakAfter, breakBefore, breakInside, cancel, captionSide, caretStyle, centered, childGap, childLayout, childLayoutViewport, childOffsetX, childOffsetY, children, clearChildren, clipChildren, clipPath, clipsChildren, color, color, columnCount, columnFill, columnGap, columnRule, columnSpan, columnWidth, computedStyle, containsChildClipPoint, contextMenu, cornerRadius, defaultDisplay, dirtyCategories, disabled, display, emptyCells, enabled, enabled, filters, findById, findById, flexBasis, flexDirection, flexGrow, flexShrink, flexWrap, focused, focused, fragmentTree, glow, gradient, gridAutoFlow, gridPlacement, gridTemplate, handlesMouseClick, handlesMouseScroll, height, height, height, hovered, id, id, indeterminate, indeterminate, inlineStyle, inset, inset, intrinsicSize, invalidateModernLayout, isClippingChildren, isFocusable, justifyContent, justifyItems, justifySelf, lastInvalidationReason, layoutChildren, layoutFragments, listStyleImage, listStylePosition, listStyleType, margin, margin, margin, marginBreak, markerGap, markerSide, maskLayers, maskLayers, matchesStyleState, maxHeight, maxWidth, minHeight, minWidth, motionPath, onCharTyped, onFocusChanged, onKeyPressed, onModernLayoutComplete, onMouseClicked, onMouseDragged, onMouseReleased, onMouseScrolled, opacity, order, orphans, outline, padding, padding, padding, pageName, paint, parent, pause, play, position, position, preferredHeightForWidth, pressed, pseudoElementBox, pseudoElementStyle, quotes, rangeState, rangeState, readOnly, readOnly, remove, removeStyleClass, renderChildren, renderClippedChildren, renderOverlay, requestFocus, required, required, resolveBaseProperties, resume, rowGap, scrollMargin, scrollMargin, scrollSnapStop, self, shadow, shouldRouteToChildren, size, size, startingStyle, stateProvider, styleAttribute, styleAttribute, styleClass, styleClasses, styledPseudoElements, styleOpen, styleState, styleState, tabIndex, tabIndex, tableLayout, tick, tooltip, transform, transformBox, transformOrigin, transformStyle, transition, transition, transition, transition, transition, transition, transitionAll, transitionAll, transitionAll, translate, translateX, translateY, validity, validity, verticalAlign, viewTransitionName, viewTransitionName, visible, visible, widows, width, width, width, writeModernInline, writeTextShadow, writingState, x, x, y, y, zIndex
-
Constructor Details
-
ItemModelComponent
public ItemModelComponent()
-
-
Method Details
-
item
Uses a new stack for the supplied item.- Parameters:
item- item to render- Returns:
- this component
-
item
Snapshots the complete supplied stack for subsequent rendering.- Parameters:
itemStack- stack to copy- Returns:
- this component
-
block
Uses the block's inventory-item model.- Parameters:
block- block whose inventory item should be rendered- Returns:
- this component
- Throws:
IllegalArgumentException- when the block has no inventory item
-
itemModel
Overrides the stack'sDataComponents.ITEM_MODELcomponent.Configure a base item or stack before selecting a model. Active resource packs may supply the identifier; vanilla-only mode intentionally cannot resolve server-only namespaces.
- Parameters:
modelId- item-model identifier- Returns:
- this component
-
customModelData
public ItemModelComponent customModelData(net.minecraft.world.item.component.CustomModelData customModelData) Replaces the stack's custom-model-data component.- Parameters:
customModelData- custom resource-pack selection data- Returns:
- this component
-
playerHead
Renders a player head resolved from a UUID.- Parameters:
uuid- player UUID- Returns:
- this component
-
playerHead
Renders a player head resolved from a player name.- Parameters:
playerName- player name- Returns:
- this component
-
playerHead
Renders a player head from a resolved authentication profile.- Parameters:
profile- profile to snapshot- Returns:
- this component
-
playerHead
Renders a player head from Minecraft's resolvable profile component.- Parameters:
profile- profile component- Returns:
- this component
-
playerHeadTexture
Renders a player head from a Mojang base64texturesproperty.- Parameters:
texturesProperty- base64 property value- Returns:
- this component
-
playerHeadTexture
Renders a player head from a Mojang base64texturesproperty.This accepts the property value supplied by servers, not an arbitrary image URL.
- Parameters:
texturesProperty- base64 property valuesignature- optional Mojang signature- Returns:
- this component
-
resourceMode
Selects active resource packs or the isolated built-in resource runtime.- Parameters:
resourceMode- resource policy- Returns:
- this component
-
displayContext
public ItemModelComponent displayContext(net.minecraft.world.item.ItemDisplayContext displayContext) Selects the vanilla item display transform.- Parameters:
displayContext- display transform- Returns:
- this component
-
seed
Sets the deterministic model-selection seed.- Parameters:
seed- model seed- Returns:
- this component
-
rotation
Sets additional model-space rotations in degrees.- Parameters:
x- x-axis rotationy- y-axis rotationz- z-axis rotation- Returns:
- this component
-
rotationX
Sets additional x-axis model rotation in degrees.- Parameters:
rotationX- x-axis rotation- Returns:
- this component
-
rotationY
Sets additional y-axis model rotation in degrees.- Parameters:
rotationY- y-axis rotation- Returns:
- this component
-
rotationZ
Sets additional z-axis model rotation in degrees.- Parameters:
rotationZ- z-axis rotation- Returns:
- this component
-
offset
Offsets the centered model in component design-space units.- Parameters:
x- horizontal offsety- vertical offset- Returns:
- this component
-
offsetX
Sets the horizontal model offset in component design-space units.- Parameters:
offsetX- horizontal offset- Returns:
- this component
-
offsetY
Sets the vertical model offset in component design-space units.- Parameters:
offsetY- vertical offset- Returns:
- this component
-
zoom
Scales the vanilla 16-by-16 item slot within the content box.- Parameters:
zoom- non-negative zoom- Returns:
- this component
-
preferredWidth
protected float preferredWidth(com.render.api.gui.GuiRenderContext context) - Overrides:
preferredWidthin classGuiComponent<ItemModelComponent>
-
preferredHeight
protected float preferredHeight(com.render.api.gui.GuiRenderContext context) - Overrides:
preferredHeightin classGuiComponent<ItemModelComponent>
-
renderSelf
protected void renderSelf(com.render.api.gui.GuiRenderContext context) - Overrides:
renderSelfin classGuiComponent<ItemModelComponent>
-