Class GuiElement<T extends GuiElement<T>>
- All Implemented Interfaces:
ElementEvents,GuiParent<T>,TooltipHandler<T>
- Direct Known Subclasses:
GuiButton,GuiColourPicker.ColourPreview,GuiColourPicker.SliderBG,GuiContextMenu,GuiDialog,GuiDVD,GuiEnergyBar,GuiEntityRenderer,GuiEventProvider,GuiFluidTank,GuiItemStack,GuiList,GuiManipulable,GuiProgressIcon,GuiRectangle,GuiScrolling,GuiSlider,GuiSlots,GuiText,GuiTextField,GuiTextList,GuiTexture
In v2 this vas a massive monolithic class that had way too much crammed into it. The primary goals of v3 are the following:
GuiParent and ConstrainedGeometry
GuiGraphics system showed me a good way to implement this.
Created by brandon3055 on 04/07/2023
This can be useful when rendering a lot of high z depth elements such as ItemStacks.
As long as you know for sure none of the elements intersect, it should be safe to disable stacking.
Note: After the render is complete, the poseStack's z pos will be offset by the total depth of this element and its children.
This is intended behavior,
When rendering overlay content, always use the
To check if the cursor is over this element, use 'render.hoveredElement() == this'
Field Summary
Constructor Summary
Method Summary
voidaddChildList<GuiElement<?>>addJeiDropTargetsList<GuiElement<?>>addJeiExclusionsvoidadoptChildprotected voidbooleanbooleanblockMouseOverisMouseOver() method of its children.voidbringChildToForegroundnet.minecraft.client.gui.Fontfont()List<GuiElement<?>>doubleBackgroundRender.getBackgroundDepth() and ForegroundRender.getForegroundDepth()Consumer<net.minecraft.world.item.ItemStack>@NotNull GuiParent<?>intintvoidinitElementbooleanisDescendantOfbooleanbooleanbooleanbooleanbooleanisOpaque()booleanbooleannet.minecraft.client.Minecraftmc()voidonScreenInitvoidremoveChildvoidprotected booleanrenderChildbooleanrenderOverlayintintvoidsendChildToBackgroundvoidsendChildToIndexsetEnabledsetEnabledsetEnableToolTipsetJeiDropTargetsetJeiExcludedsetOpaquesetRenderCullsetTooltipsetTooltipDelaysetZStackingbooleanvoidticktoString()booleanupdateMouseOverprotected voidupdateScreenDatabooleanMethods 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
Field Details
initialized
hoverTime
Constructor Details
GuiElement
parent - parent GuiParent.Method Details
getParent
getParent in class ConstrainedGeometry<T extends GuiElement<T>>getChildren
getChildren in interface ElementEventsgetChildren in interface GuiParent<T extends GuiElement<T>>addChild
addChild in interface GuiParent<T extends GuiElement<T>>child - The child element to be added.applyQueuedChildUpdates
initElement
adoptChild
GuiParent
adoptChild in interface GuiParent<T extends GuiElement<T>>child - The child element to be adopted.removeChild
GuiParent
removeChild in interface GuiParent<T extends GuiElement<T>>child - The child element to be removed.bringChildToForeground
sendChildToIndex
sendChildToBackground
isDescendantOf
GuiParent
isDescendantOf in interface GuiParent<T extends GuiElement<T>>mc
mc in interface GuiParent<T extends GuiElement<T>>font
font in interface GuiParent<T extends GuiElement<T>>scaledScreenWidth
scaledScreenWidth in interface GuiParent<T extends GuiElement<T>>scaledScreenHeight
scaledScreenHeight in interface GuiParent<T extends GuiElement<T>>getModularGui
getModularGui in interface GuiParent<T extends GuiElement<T>>onScreenInit
GuiParent
onScreenInit in interface GuiParent<T extends GuiElement<T>>mc - The Minecraft instance.font - The active font.screenWidth - The current guiScaledWidth.screenHeight - The current guiScaledHeight.updateScreenData
setEnabled
setEnabled
isEnabled
isRemoved
setEnableToolTip
isTooltipEnabled
blockMouseOver
GuiParentisMouseOver() method of its children.
This is primarily used for things like scroll elements where mouseover interactions need to be blocked outside the view area.
blockMouseOver in interface GuiParent<T extends GuiElement<T>>element - The element on which isMouseOver is getting called.blockMouseEvents
blockMouseEvents in interface ElementEventsisMouseOver
isOpaque
setOpaque
hoverTime
toString
setRenderCull
setZStacking
zStacking - Enable z stacking (default true)zStacking
getCombinedElementDepth
BackgroundRender.getBackgroundDepth() and ForegroundRender.getForegroundDepth()
render
BackgroundRender and / or ForegroundRender in or order to implement
its rendering.
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 ticksrenderChild
renderOverlay
PoseStack available via the provided GuiRender
This stack will already have the correct Z translation to ensure the overlay renders above everything else on the screen.
isMouseOver() Will also work, but may be problematic when multiple, stacked elements have overlay content.
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.showToolTip
tick
mouseX - Current mouse X positionmouseY - Current mouse Y positionupdateMouseOver
mouseX - Mouse X positionmouseY - Mouse Y positionconsumed - True if mouseover event has been consumed.getTooltip
getTooltip in interface TooltipHandler<T extends GuiElement<T>>setTooltipDelay
TooltipHandler
setTooltipDelay in interface TooltipHandler<T extends GuiElement<T>>getTooltipDelay
getTooltipDelay in interface TooltipHandler<T extends GuiElement<T>>setTooltip
TooltipHandler
setTooltip in interface TooltipHandler<T extends GuiElement<T>>tooltip - The tooltip lines. If null or the returned list is empty, hover text will be disabledjeiExclude
setJeiExcluded
isJeiExcluded
setJeiDropTarget
getJeiDropConsumer
isJeiDropTarget
addJeiExclusions
addJeiDropTargets