GuiRenderTickMixin:

- Added more comments
- Removed unnecessary alpha calculations.
- Replaced draw method with drawShadow.
- Cleaned up variables
- Made y offset to scale with window height.
This commit is contained in:
Micle
2022-10-24 18:57:07 +01:00
parent 9f330ba86b
commit f7707b88c8

View File

@ -26,19 +26,23 @@ public class GuiRenderTickMixin {
RenderSystem.enableBlend();
RenderSystem.defaultBlendFunc();
// Render state
// Render player state text
poseStack.pushPose();
poseStack.scale(5, 5, 5);
Font font = Minecraft.getInstance().font;
int titleWidth = font.width(Proxy.Client.getPlayerState().toString());
float offset = -titleWidth / 2f;
int alpha = 255 << 24 & 0xFF000000;
// Initialize variables
Font font = Minecraft.getInstance().font;
float offsetX = -(font.width(Proxy.Client.getPlayerState().toString()) / 2f);
float offsetY = -((font.lineHeight / 2f) + ((Minecraft.getInstance().getWindow().getGuiScaledHeight() / 4f) / 5));
int argb = 0xFFFFFFFF;
// Draw player state if it's not active
if (!Proxy.Client.getPlayerState().equals(ProtectedPlayer.State.ACTIVE)) {
font.draw(poseStack, Proxy.Client.getPlayerState().toString(), offset, -50, 0xFFFFFF | alpha);
font.drawShadow(poseStack, Proxy.Client.getPlayerState().toString(), offsetX, offsetY, argb);
}
poseStack.popPose();
// Finish
RenderSystem.disableBlend();
poseStack.popPose();
}