Archived Legacy DynamicHUD
  • Dynamic HUD
  • Import using Gradle
  • Widgets
    • Adding Widgets
      • TextWidget
      • ItemWidget
      • ArmorWidget
    • Creating your own Widget class
    • Widget class
    • WidgetManager
    • WidgetBox
  • Saving and Loading
    • Saving and Loading
    • Changing save file name and directory
  • Moveable Screen
    • AbstractMoveableScreen
    • Default Moveable Screen
    • Using the default Moveable Screen
    • Creating and using your own MoveableScreen class
  • ContextMenu
    • ContextMenu class
    • ContextMenuOptionsProvider interface
    • DoubleInputScreen
    • DataInputScreen
  • Slider Widget
    • Slider
  • SliderWidgetBuilder
  • ColorPicker
    • ColorGradientPicker
      • ColorPickerButton
      • GradientBox
      • GradientSlider
  • Helpers
    • ColorHelper
    • DrawHelper
    • TextureHelper
Powered by GitBook
On this page
  • Widget:
  • Fields
  • Constructors
  • Methods
  1. Widgets

Widget class

This page talks about Widget class

PreviousCreating your own Widget classNextWidgetManager

Widget:

The class represents a widget that can be rendered on the screen. It is an abstract class that must be extended by concrete widget classes.

Fields

  • textGenerators: A map of text generators for different labels.

  • client: The Minecraft client instance.

  • enabled: Whether the widget is enabled.

  • isDraggable: Whether the widget is draggable.

  • xPercent: The x position of the widget as a percentage of the screen width.

  • yPercent: The y position of the widget as a percentage of the screen height.

  • label: The label of the widget.

Constructors

  • Widget(MinecraftClient client): Constructs a Widget object with the given Minecraft client instance.

Methods

  • addTextGenerator(String label, TextGenerator textGenerator): Adds a text generator for the given label.

  • setTextGeneratorFromLabel(): Sets the text generator for this widget based on its label.

  • getWidgetBox(): Gets the box around the widget for some purpose.

  • setDraggable(boolean draggable): Sets whether the widget is draggable.

  • isOverlapping(List<Widget> other): Returns whether this widget is overlapping with any of the widgets in the given list.

  • isOverlapping(Widget other): Returns whether this widget is overlapping with the given widget.

  • render(DrawContext drawContext): Renders the widget on the screen.

  • isEnabled(): Returns whether the widget is enabled.

  • getX(): Returns the x position of the widget in pixels.

  • setX(int x): Sets the x position of the widget in pixels.

  • getY(): Returns the y position of the widget in pixels.

  • setY(int y): Sets the y position of the widget in pixels.

  • getHeight(): Returns the font height from TextRenderer.

  • readFromTag(NbtCompound tag): Reads the state of this widget from the given NBT tag.

  • writeToTag(NbtCompound tag): Writes the state of this widget to the given NBT tag.

Widget