#HUD element not filling screen correctly

6 messages · Page 1 of 1 (latest)

neon wigeon
#

public static void drawGraceHUD(DrawContext context) {
MinecraftClient client = MinecraftClient.getInstance();
if (client == null) {return;}

    Identifier GRACEHUD = Identifier.of(TFAGM.MOD_ID, "textures/hud/gracehud.png");

    int screenWidth = client.getWindow().getFramebufferWidth();
    int screenHeight = client.getWindow().getFramebufferHeight();
    
    int textureWidth = 640;
    int textureHeight = 180;
    int frameCount = 2;
    int frameWidth = textureWidth / frameCount;
    
    double CurrentTime = Util.getMeasuringTimeMs() / 1000.0;
    int currentFrame = (int) ((CurrentTime / 1.1) % frameCount);
    float u = currentFrame * frameWidth;

    context.drawTexture(RenderPipelines.GUI_TEXTURED, GRACEHUD , 0, 0, u, 0, screenWidth, screenHeight, textureWidth, textureHeight);
}
#

the texture does load and animate correctly off of the sprite sheet but it just wont fill the screen

#

version is 1.21.8

surreal pumice
#

have you checked if the screen width/height values are correct?

#

hardcode something and test it out

neon wigeon