I am using Fabric 0.58.4+1.19.1 (MC 1.19.1) and I was wondering how I could draw a colored rectangle with an alpha value as an HUD element. I am new to fabric modding and I need to draw a black rectangle with low opacity on the screen as HUD. I have used HudRenderCallback to draw a black rectangle as a texture and I was wondering if there is a better way to do this.
public class TestScreen implements HudRenderCallback {
@Override
public void onHudRender(MatrixStack matrixStack, float tickDelta) {
RenderSystem.setShaderTexture(0, new Identifier("mymodname","textures/gui/black.png"));
DrawableHelper.drawTexture(matrixStack, 0, 0, 0f, 0f, 100, 50, 700, 652);
}
}
In case anyone needs this I figured it out: DrawableHelper.fill
will create a rectangle.