Cleaned up and fixed screen text.

This commit is contained in:
2024-05-15 20:52:35 +01:00
parent bc1db25756
commit 94fbe307d6

View File

@ -27,29 +27,30 @@ public class GuiRenderTickMixin {
} }
// Initialize variables // Initialize variables
double screenHalfWidth = Minecraft.getInstance().getWindow().getGuiScaledWidth() / 2.0; Font font = Minecraft.getInstance().font;
double screenHalfHeight = Minecraft.getInstance().getWindow().getGuiScaledHeight() / 2.0; float guiHalfWidth = Minecraft.getInstance().getWindow().getGuiScaledWidth() / 2f;
float guiHalfHeight = Minecraft.getInstance().getWindow().getGuiScaledHeight() / 2f;
int scale = Config.Client.GUI_SCREEN_TEXT_SCALE.get();
float heightPositionScale = 1.5f;
// Setup // Setup
PoseStack poseStack = guiGraphics.pose(); PoseStack poseStack = guiGraphics.pose();
poseStack.pushPose(); poseStack.pushPose();
poseStack.translate(screenHalfWidth, screenHalfHeight, 0); poseStack.translate(guiHalfWidth, guiHalfHeight, 0);
RenderSystem.enableBlend(); RenderSystem.enableBlend();
RenderSystem.defaultBlendFunc(); RenderSystem.defaultBlendFunc();
// Render player state text // Render player state text
poseStack.pushPose(); poseStack.pushPose();
poseStack.scale(Config.Client.GUI_SCREEN_TEXT_SCALE.get(), Config.Client.GUI_SCREEN_TEXT_SCALE.get(), Config.Client.GUI_SCREEN_TEXT_SCALE.get()); poseStack.scale(scale, scale, scale);
// Check if we should draw the state // Check if we should draw the state
if (Proxy.Client.getPlayerState() != null && !Proxy.Client.getPlayerState().equals(ProtectedPlayer.State.ACTIVE)) { if (Proxy.Client.getPlayerState() != null && !Proxy.Client.getPlayerState().equals(ProtectedPlayer.State.ACTIVE)) {
// Initialize variables // Initialize variables
Font font = Minecraft.getInstance().font;
int textHalfWidth = font.width(Proxy.Client.getPlayerState().toString()) / 2; int textHalfWidth = font.width(Proxy.Client.getPlayerState().toString()) / 2;
int textHalfHeight = font.lineHeight / 2; int textHalfHeight = font.lineHeight / 2;
float positionScale = 1.5f;
int offsetX = -textHalfWidth; int offsetX = -textHalfWidth;
int offsetY = (int)-((textHalfHeight + screenHalfHeight) / positionScale); int offsetY = (int)-(textHalfHeight + ((guiHalfHeight / heightPositionScale) / scale));
int argb = 0xFFFFFFFF; int argb = 0xFFFFFFFF;
// Draw the player's protection state // Draw the player's protection state