Class GuiItemStack

All Implemented Interfaces:
BackgroundRender, ElementEvents, GuiParent<GuiItemStack>, TooltipHandler<GuiItemStack>

public class GuiItemStack extends GuiElement<GuiItemStack> implements BackgroundRender
A simple gui element that renders an item stack. This width and height of this element should be constrained to the same value, The stack size is based on the element size. constrain size to 16x16 for the standard gui stack size.

Created by brandon3055 on 03/09/2023

  • Constructor Details

    • GuiItemStack

      public GuiItemStack(GuiParent<?> parent)
    • GuiItemStack

      public GuiItemStack(GuiParent<?> parent, net.minecraft.world.item.ItemStack itemStack)
    • GuiItemStack

      public GuiItemStack(GuiParent<?> parent, Supplier<net.minecraft.world.item.ItemStack> provider)
  • Method Details

    • setStack

      public GuiItemStack setStack(Supplier<net.minecraft.world.item.ItemStack> stackProvider)
    • setStack

      public GuiItemStack setStack(net.minecraft.world.item.ItemStack stack)
    • enableStackDecoration

      public GuiItemStack enableStackDecoration(boolean enableDecoration)
      Enable item stack decorations. Meaning, Damage bar, Stack size, Item cool down, etc. (Default Enabled)
    • enableStackDecoration

      public GuiItemStack enableStackDecoration(Supplier<Boolean> enableDecoration)
      Enable item stack decorations. Meaning, Damage bar, Stack size, Item cool down, etc. (Default Enabled)
    • enableStackToolTip

      public GuiItemStack enableStackToolTip(boolean enableToolTip)
      Enable the default item stack tooltip. (Default Enabled) Note: If the GuiItemStack element has a tooltip applied via one of the element #setTooltip methods, That will override the item stack tool tip.
    • enableStackToolTip

      public GuiItemStack enableStackToolTip(Supplier<Boolean> enableToolTip)
      Enable the default item stack tooltip. (Default Enabled) Note: If the GuiItemStack element has a tooltip applied via one of the element #setTooltip methods, That will override the item stack tool tip.
    • renderBehind

      public void renderBehind(net.minecraft.client.gui.GuiGraphics render, double mouseX, double mouseY, float partialTicks)
      Description copied from interface: BackgroundRender
      Used to render content behind this elements child elements. When rendering element content, always use the PoseStack available via the provided
      invalid reference
      GuiRender
      Where applicable, always use push/pop to ensure the stack is returned to its original state after your rendering is complete.
      Specified by:
      renderBehind in interface BackgroundRender
      Parameters:
      render - Contains gui context information as well as essential render methods/utils including the PoseStack.
    • renderOverlay

      public boolean renderOverlay(net.minecraft.client.gui.GuiGraphics graphics, double mouseX, double mouseY, float partialTicks, boolean consumed)
      Description copied from class: GuiElement
      Used to render overlay's such as hover text. Anything rendered in this method will be rendered on top of everything else on the screen. Only one overlay should be rendered at a time, When an element renders content via the overlay method it must return true to indicate the render call has been 'consumed' If the render call has already been consumed (Check via the consumed boolean) then this element should avoid rendering its overlay.

      When rendering overlay content, always use the PoseStack available via the provided

      invalid reference
      GuiRender
      This stack will already have the correct Z translation to ensure the overlay renders above everything else on the screen.

      To check if the cursor is over this element, use 'render.hoveredElement() == this' GuiElement.isMouseOver() Will also work, but may be problematic when multiple, stacked elements have overlay content.

      Overrides:
      renderOverlay in class GuiElement<GuiItemStack>
      Parameters:
      graphics - Contains gui context information as well as essential render methods/utils including the PoseStack.
      mouseX - Current mouse X position
      mouseY - Current mouse Y position
      partialTicks - Partial render ticks
      consumed - Will be true if the overlay render call has already been consumed by another element.
      Returns:
      true if the render call has been consumed.