Creating your own Widget class
public class MyWidget extends Widget
{
/**
* Constructs a Widget object.
*
* @param client The Minecraft client instance
*/
public MyWidget(MinecraftClient client, <Other Parameters>) {
super(client);
}
@Override
public WidgetBox getWidgetBox() {
// x1,y1,x2,y2 are used to define the box around the widget
// scale variable to use the value from user or set your own scale
return new WidgetBox(x1,y1,x2,y2,scale);
}
@Override
public void render(DrawContext drawContext) {
}
}You can render whatever you want within the render() method
render() methodYou can use this to add a widget using: Widgets.
If you want to save and load this widget then you can add the following:
To save and load this Widget, you can implement the WidgetLoading class in your main class: