Moved some magical numbers into variables.
This commit is contained in:
@ -26,28 +26,34 @@ public class GuiRenderTickMixin {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Initialize variables
|
||||||
|
double screenHalfWidth = Minecraft.getInstance().getWindow().getGuiScaledWidth() / 2.0;
|
||||||
|
double screenHalfHeight = Minecraft.getInstance().getWindow().getGuiScaledHeight() / 2.0;
|
||||||
|
|
||||||
// Setup
|
// Setup
|
||||||
PoseStack poseStack = guiGraphics.pose();
|
PoseStack poseStack = guiGraphics.pose();
|
||||||
poseStack.pushPose();
|
poseStack.pushPose();
|
||||||
poseStack.translate(Minecraft.getInstance().getWindow().getGuiScaledWidth() / 2.0,
|
poseStack.translate(screenHalfWidth, screenHalfHeight, 0);
|
||||||
Minecraft.getInstance().getWindow().getGuiScaledHeight() / 2.0, 0);
|
|
||||||
RenderSystem.enableBlend();
|
RenderSystem.enableBlend();
|
||||||
RenderSystem.defaultBlendFunc();
|
RenderSystem.defaultBlendFunc();
|
||||||
|
|
||||||
// Render player state text
|
// Render player state text
|
||||||
poseStack.pushPose();
|
poseStack.pushPose();
|
||||||
poseStack.scale(5, 5, 5);
|
poseStack.scale(3, 3, 3);
|
||||||
|
|
||||||
// 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;
|
Font font = Minecraft.getInstance().font;
|
||||||
float offsetX = -(font.width(Proxy.Client.getPlayerState().toString()) / 2f);
|
int textHalfWidth = font.width(Proxy.Client.getPlayerState().toString()) / 2;
|
||||||
float offsetY = -((font.lineHeight / 2f) + ((Minecraft.getInstance().getWindow().getGuiScaledHeight() / 4f) / 5));
|
int textHalfHeight = font.lineHeight / 2;
|
||||||
|
float positionScale = 1.5f;
|
||||||
|
int offsetX = -textHalfWidth;
|
||||||
|
int offsetY = (int)-((textHalfHeight + screenHalfHeight) / positionScale);
|
||||||
int argb = 0xFFFFFFFF;
|
int argb = 0xFFFFFFFF;
|
||||||
|
|
||||||
// Draw the player's protection state
|
// Draw the player's protection state
|
||||||
guiGraphics.drawString(font, Proxy.Client.getPlayerState().toString().replace("_", " "), (int)offsetX, (int)offsetY, argb);
|
guiGraphics.drawString(font, Proxy.Client.getPlayerState().toString().replace("_", " "), offsetX, offsetY, argb);
|
||||||
}
|
}
|
||||||
poseStack.popPose();
|
poseStack.popPose();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user