Class ItemIcon

java.lang.Object
io.github.cottonmc.cotton.gui.widget.icon.ItemIcon
All Implemented Interfaces:
Icon

public class ItemIcon extends Object implements Icon
An icon that draws an item stack.
Since:
2.2.0
  • Constructor Summary

    Constructors
    Constructor
    Description
    ItemIcon(net.minecraft.world.item.Item item)
    Constructs an item icon with the item's default stack.
    ItemIcon(net.minecraft.world.item.ItemStack stack)
    Constructs an item icon.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Checks whether this icon is a ghost item.
    void
    paint(net.minecraft.client.gui.GuiGraphicsExtractor context, int x, int y, int size)
    Paints this icon.
    setGhost(boolean ghost)
    Marks this icon as a ghost or non-ghost icon.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • ItemIcon

      public ItemIcon(net.minecraft.world.item.ItemStack stack)
      Constructs an item icon.
      Parameters:
      stack - the drawn item stack
      Throws:
      NullPointerException - if the stack is null
    • ItemIcon

      public ItemIcon(net.minecraft.world.item.Item item)
      Constructs an item icon with the item's default stack.
      Parameters:
      item - the drawn item
      Throws:
      NullPointerException - if the item is null
      Since:
      3.2.0
  • Method Details

    • paint

      @Environment(CLIENT) public void paint(net.minecraft.client.gui.GuiGraphicsExtractor context, int x, int y, int size)
      Description copied from interface: Icon
      Paints this icon.
      Specified by:
      paint in interface Icon
      Parameters:
      context - the draw context
      x - the X coordinate
      y - the Y coordinate
      size - the size of this icon in pixels (size N means a N*N square)
    • isGhost

      public boolean isGhost()
      Checks whether this icon is a ghost item. Ghost items are rendered with a pale overlay.
      Returns:
      true if this icon is a ghost item, false otherwise
      Since:
      9.2.0
    • setGhost

      public ItemIcon setGhost(boolean ghost)
      Marks this icon as a ghost or non-ghost icon.
      Parameters:
      ghost - true if this icon is a ghost item, false otherwise
      Returns:
      this icon
      Since:
      9.2.0