From 38f9c73c47483c4adaa330b17f37f1e1927ab711 Mon Sep 17 00:00:00 2001 From: yurisuika Date: Thu, 11 Jan 2024 05:56:39 -0800 Subject: [PATCH] shouldn't have deleted that oops --- .../mixin/client/gui/hud/InGameHudMixin.java | 66 ++++++++++++------- 1 file changed, 42 insertions(+), 24 deletions(-) diff --git a/src/main/java/dev/yurisuika/raised/mixin/client/gui/hud/InGameHudMixin.java b/src/main/java/dev/yurisuika/raised/mixin/client/gui/hud/InGameHudMixin.java index 8f80c461..42d3c7e2 100644 --- a/src/main/java/dev/yurisuika/raised/mixin/client/gui/hud/InGameHudMixin.java +++ b/src/main/java/dev/yurisuika/raised/mixin/client/gui/hud/InGameHudMixin.java @@ -17,22 +17,24 @@ public abstract class InGameHudMixin { @Mixin(value = InGameHud.class, priority = -999999999) public abstract static class Pre { + // HEAD + @Inject(method = "render", at = @At("HEAD")) + private void startHeadTranslate(DrawContext context, float tickDelta, CallbackInfo ci) { + if (getSupport()) { + context.getMatrices().translate(0, -getHud(), 0); + } + } + // MAIN HUD @Inject(method = "renderMainHud", at = @At(value = "HEAD")) private void startSpectatorMenuTranslate(DrawContext context, float tickDelta, CallbackInfo ci) { context.getMatrices().translate(0, -getHud(), 0); } - // SPECTATOR TOOLTIP -// @Inject(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/hud/SpectatorHud;render(Lnet/minecraft/client/gui/DrawContext;)V")) -// private void startSpectatorHudTranslate(DrawContext context, float tickDelta, CallbackInfo ci) { -// context.getMatrices().translate(0, -getHud(), 0); -// } -// -// @Inject(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/hud/SpectatorHud;render(Lnet/minecraft/client/gui/DrawContext;)V", shift = At.Shift.AFTER)) -// private void endSpectatorHudTranslate(DrawContext context, float tickDelta, CallbackInfo ci) { -// context.getMatrices().translate(0, +getHud(), 0); -// } + @Inject(method = "renderMainHud", at = @At(value = "TAIL")) + private void endSpectatorMenuTranslate(DrawContext context, float tickDelta, CallbackInfo ci) { + context.getMatrices().translate(0, +getHud(), 0); + } // OVERLAY MESSAGE @Inject(method = "renderOverlayMessage", at = @At(value = "HEAD")) @@ -40,12 +42,30 @@ private void startOverlayMessageTranslate(DrawContext context, float tickDelta, context.getMatrices().translate(0, -getHud(), 0); } + @Inject(method = "renderOverlayMessage", at = @At(value = "TAIL")) + private void endOverlayMessageTranslate(DrawContext context, float tickDelta, CallbackInfo ci) { + context.getMatrices().translate(0, +getHud(), 0); + } + // CHAT @Inject(method = "renderChat", at = @At(value = "HEAD")) private void startChatTranslate(DrawContext context, float tickDelta, CallbackInfo ci) { context.getMatrices().translate(0, -(getSync() ? getHud() : getChat()), +300); } + @Inject(method = "renderChat", at = @At(value = "TAIL")) + private void endChatTranslate(DrawContext context, float tickDelta, CallbackInfo ci) { + context.getMatrices().translate(0, +(getSync() ? getHud() : getChat()), -300); + } + + // TAIL + @Inject(method = "render", at = @At("TAIL")) + private void startTailTranslate(DrawContext context, float tickDelta, CallbackInfo ci) { + if (getSupport()) { + context.getMatrices().translate(0, -getHud(), 0); + } + } + // HOTBAR SELECTOR @ModifyArgs(method = "renderHotbar", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/DrawContext;drawGuiTexture(Lnet/minecraft/util/Identifier;IIII)V", ordinal = 1)) private void resizeHotbarSelector(Args args) { @@ -58,22 +78,20 @@ private void resizeHotbarSelector(Args args) { @Mixin(value = InGameHud.class, priority = 999999999) public abstract static class Post { - // MAIN HUD - @Inject(method = "renderMainHud", at = @At(value = "TAIL")) - private void endSpectatorMenuTranslate(DrawContext context, float tickDelta, CallbackInfo ci) { - context.getMatrices().translate(0, +getHud(), 0); - } - - // OVERLAY MESSAGE - @Inject(method = "renderOverlayMessage", at = @At(value = "TAIL")) - private void endOverlayMessageTranslate(DrawContext context, float tickDelta, CallbackInfo ci) { - context.getMatrices().translate(0, +getHud(), 0); + // HEAD + @Inject(method = "render", at = @At("HEAD")) + private void endHeadTranslate(DrawContext context, float tickDelta, CallbackInfo ci) { + if (getSupport()) { + context.getMatrices().translate(0, +getHud(), 0); + } } - // CHAT - @Inject(method = "renderChat", at = @At(value = "TAIL")) - private void endChatTranslate(DrawContext context, float tickDelta, CallbackInfo ci) { - context.getMatrices().translate(0, +(getSync() ? getHud() : getChat()), -300); + // TAIL + @Inject(method = "render", at = @At("TAIL")) + private void endTailTranslate(DrawContext context, float tickDelta, CallbackInfo ci) { + if (getSupport()) { + context.getMatrices().translate(0, +getHud(), 0); + } } }