Class ItemModelComponent


public final class ItemModelComponent extends GuiComponent<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 Details

    • ItemModelComponent

      public ItemModelComponent()
  • Method Details

    • item

      public ItemModelComponent item(net.minecraft.world.item.Item item)
      Uses a new stack for the supplied item.
      Parameters:
      item - item to render
      Returns:
      this component
    • item

      public ItemModelComponent item(net.minecraft.world.item.ItemStack itemStack)
      Snapshots the complete supplied stack for subsequent rendering.
      Parameters:
      itemStack - stack to copy
      Returns:
      this component
    • block

      public ItemModelComponent block(net.minecraft.world.level.block.Block 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

      public ItemModelComponent itemModel(net.minecraft.resources.Identifier modelId)
      Overrides the stack's DataComponents.ITEM_MODEL component.

      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

      public ItemModelComponent playerHead(UUID uuid)
      Renders a player head resolved from a UUID.
      Parameters:
      uuid - player UUID
      Returns:
      this component
    • playerHead

      public ItemModelComponent playerHead(String playerName)
      Renders a player head resolved from a player name.
      Parameters:
      playerName - player name
      Returns:
      this component
    • playerHead

      public ItemModelComponent playerHead(com.mojang.authlib.GameProfile profile)
      Renders a player head from a resolved authentication profile.
      Parameters:
      profile - profile to snapshot
      Returns:
      this component
    • playerHead

      public ItemModelComponent playerHead(net.minecraft.world.item.component.ResolvableProfile profile)
      Renders a player head from Minecraft's resolvable profile component.
      Parameters:
      profile - profile component
      Returns:
      this component
    • playerHeadTexture

      public ItemModelComponent playerHeadTexture(String texturesProperty)
      Renders a player head from a Mojang base64 textures property.
      Parameters:
      texturesProperty - base64 property value
      Returns:
      this component
    • playerHeadTexture

      public ItemModelComponent playerHeadTexture(String texturesProperty, @Nullable String signature)
      Renders a player head from a Mojang base64 textures property.

      This accepts the property value supplied by servers, not an arbitrary image URL.

      Parameters:
      texturesProperty - base64 property value
      signature - optional Mojang signature
      Returns:
      this component
    • resourceMode

      public ItemModelComponent resourceMode(ItemModelResourceMode 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

      public ItemModelComponent seed(int seed)
      Sets the deterministic model-selection seed.
      Parameters:
      seed - model seed
      Returns:
      this component
    • rotation

      public ItemModelComponent rotation(float x, float y, float z)
      Sets additional model-space rotations in degrees.
      Parameters:
      x - x-axis rotation
      y - y-axis rotation
      z - z-axis rotation
      Returns:
      this component
    • rotationX

      public ItemModelComponent rotationX(float rotationX)
      Sets additional x-axis model rotation in degrees.
      Parameters:
      rotationX - x-axis rotation
      Returns:
      this component
    • rotationY

      public ItemModelComponent rotationY(float rotationY)
      Sets additional y-axis model rotation in degrees.
      Parameters:
      rotationY - y-axis rotation
      Returns:
      this component
    • rotationZ

      public ItemModelComponent rotationZ(float rotationZ)
      Sets additional z-axis model rotation in degrees.
      Parameters:
      rotationZ - z-axis rotation
      Returns:
      this component
    • offset

      public ItemModelComponent offset(float x, float y)
      Offsets the centered model in component design-space units.
      Parameters:
      x - horizontal offset
      y - vertical offset
      Returns:
      this component
    • offsetX

      public ItemModelComponent offsetX(float offsetX)
      Sets the horizontal model offset in component design-space units.
      Parameters:
      offsetX - horizontal offset
      Returns:
      this component
    • offsetY

      public ItemModelComponent offsetY(float offsetY)
      Sets the vertical model offset in component design-space units.
      Parameters:
      offsetY - vertical offset
      Returns:
      this component
    • zoom

      public ItemModelComponent zoom(float 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:
      preferredWidth in class GuiComponent<ItemModelComponent>
    • preferredHeight

      protected float preferredHeight(com.render.api.gui.GuiRenderContext context)
      Overrides:
      preferredHeight in class GuiComponent<ItemModelComponent>
    • renderSelf

      protected void renderSelf(com.render.api.gui.GuiRenderContext context)
      Overrides:
      renderSelf in class GuiComponent<ItemModelComponent>