Class GuiItemStack
java.lang.Object
codechicken.lib.gui.modular.lib.geometry.ConstrainedGeometry<T>
codechicken.lib.gui.modular.elements.GuiElement<GuiItemStack>
codechicken.lib.gui.modular.elements.GuiItemStack
- All Implemented Interfaces:
BackgroundRender,ElementEvents,GuiParent<GuiItemStack>,TooltipHandler<GuiItemStack>
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
-
Field Summary
Fields inherited from class codechicken.lib.gui.modular.elements.GuiElement
hoverTime, initialized -
Constructor Summary
ConstructorsConstructorDescriptionGuiItemStack(@NotNull GuiParent<?> parent) GuiItemStack(@NotNull GuiParent<?> parent, Supplier<net.minecraft.world.item.ItemStack> provider) GuiItemStack(@NotNull GuiParent<?> parent, net.minecraft.world.item.ItemStack itemStack) -
Method Summary
Modifier and TypeMethodDescriptionenableStackDecoration(boolean enableDecoration) Enable item stack decorations.enableStackDecoration(Supplier<Boolean> enableDecoration) Enable item stack decorations.enableStackToolTip(boolean enableToolTip) Enable the default item stack tooltip.enableStackToolTip(Supplier<Boolean> enableToolTip) Enable the default item stack tooltip.doubleSpecifies the z depth of the background content.doublevoidrenderBackground(GuiRender render, double mouseX, double mouseY, float partialTicks) Used to render content behind this elements child elements.booleanrenderOverlay(GuiRender render, double mouseX, double mouseY, float partialTicks, boolean consumed) Used to render overlay's such as hover text.setStack(net.minecraft.world.item.ItemStack stack) Methods inherited from class codechicken.lib.gui.modular.elements.GuiElement
addChild, addJeiDropTargets, addJeiExclusions, adoptChild, applyQueuedChildUpdates, blockMouseEvents, blockMouseOver, bringChildToForeground, font, getChildren, getCombinedElementDepth, getJeiDropConsumer, getModularGui, getParent, getTooltip, getTooltipDelay, hoverTime, initElement, isDescendantOf, isEnabled, isJeiDropTarget, isJeiExcluded, isMouseOver, isOpaque, isRemoved, isTooltipEnabled, jeiExclude, mc, onScreenInit, removeChild, render, renderChild, scaledScreenHeight, scaledScreenWidth, sendChildToBackground, sendChildToIndex, setEnabled, setEnabled, setEnableToolTip, setJeiDropTarget, setJeiExcluded, setOpaque, setRenderCull, setTooltip, setTooltipDelay, setZStacking, showToolTip, tick, toString, updateMouseOver, updateScreenData, zStackingMethods inherited from class codechicken.lib.gui.modular.lib.geometry.ConstrainedGeometry
addBoundsToRect, clearConstraints, clearGeometryCache, constrain, get, getChildBounds, getEnclosingRect, getParent, getPosition, getRectangle, placeInside, placeInside, placeOutside, placeOutside, setHeight, setPos, setSize, setWidth, setXPos, setYPos, strictMode, validate, xCenter, xMax, xMin, xSize, yCenter, yMax, yMin, ySizeMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface codechicken.lib.gui.modular.lib.ElementEvents
charTyped, charTyped, keyPressed, keyPressed, keyReleased, keyReleased, mouseClicked, mouseClicked, mouseMoved, mouseReleased, mouseReleased, mouseScrolled, mouseScrolledMethods inherited from interface codechicken.lib.gui.modular.lib.geometry.GuiParent
addChild, getValueMethods inherited from interface codechicken.lib.gui.modular.lib.TooltipHandler
renderTooltip, setTooltip, setTooltip, setTooltip, setTooltipSingle, setTooltipSingle
-
Constructor Details
-
GuiItemStack
-
GuiItemStack
public GuiItemStack(@NotNull @NotNull GuiParent<?> parent, net.minecraft.world.item.ItemStack itemStack) -
GuiItemStack
-
-
Method Details
-
setStack
-
setStack
-
enableStackDecoration
Enable item stack decorations. Meaning, Damage bar, Stack size, Item cool down, etc. (Default Enabled) -
enableStackDecoration
Enable item stack decorations. Meaning, Damage bar, Stack size, Item cool down, etc. (Default Enabled) -
enableStackToolTip
Enable the default item stack tooltip. (Default Enabled) Note: If theGuiItemStackelement has a tooltip applied via one of the element #setTooltip methods, That will override the item stack tool tip. -
enableStackToolTip
Enable the default item stack tooltip. (Default Enabled) Note: If theGuiItemStackelement has a tooltip applied via one of the element #setTooltip methods, That will override the item stack tool tip. -
getStackSize
public double getStackSize() -
getBackgroundDepth
public double getBackgroundDepth()Description copied from interface:BackgroundRenderSpecifies the z depth of the background content. AfterBackgroundRender.renderBackground(GuiRender, double, double, float)is called, the PoseStack will be translated by this amount in the z direction before any assigned child elements are rendered. Recommended minimum depth is 0.01 or 0.035 if this element renders text. (text shadows are rendered with a 0.03 offset)- Specified by:
getBackgroundDepthin interfaceBackgroundRender- Returns:
- the z height of the background content.
-
renderBackground
Description copied from interface:BackgroundRenderUsed to render content behind this elements child elements. When rendering element content, always use thePoseStackavailable via the providedGuiRenderWhere applicable, always use push/pop to ensure the stack is returned to its original state after your rendering is complete.- Specified by:
renderBackgroundin interfaceBackgroundRender- Parameters:
render- Contains gui context information as well as essential render methods/utils including the PoseStack.
-
renderOverlay
public boolean renderOverlay(GuiRender render, double mouseX, double mouseY, float partialTicks, boolean consumed) Description copied from class:GuiElementUsed 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
PoseStackavailable via the providedGuiRenderThis 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:
renderOverlayin classGuiElement<GuiItemStack>- Parameters:
render- Contains gui context information as well as essential render methods/utils including the PoseStack.mouseX- Current mouse X positionmouseY- Current mouse Y positionpartialTicks- Partial render ticksconsumed- Will be true if the overlay render call has already been consumed by another element.- Returns:
- true if the render call has been consumed.
-