Skip to content

Commit

Permalink
chat rendering broke in two, overlay message is taking in everything …
Browse files Browse the repository at this point in the history
…now isn't it huh
  • Loading branch information
yurisuika committed Jan 11, 2024
1 parent 38f9c73 commit 9436ec1
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 11 deletions.
15 changes: 15 additions & 0 deletions src/main/java/dev/yurisuika/raised/client/gui/RaisedGui.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package dev.yurisuika.raised.client.gui;

import net.minecraft.client.gui.DrawContext;

public class RaisedGui {

public static void start(DrawContext context, int x, int y, int z) {
context.getMatrices().translate(x, -y, +z);
}

public static void end(DrawContext context, int x, int y, int z) {
context.getMatrices().translate(x, +y, -z);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.invoke.arg.Args;

import static dev.yurisuika.raised.client.gui.RaisedGui.*;
import static dev.yurisuika.raised.client.option.RaisedConfig.*;

public abstract class InGameHudMixin {
Expand All @@ -21,48 +22,59 @@ public abstract static class Pre {
@Inject(method = "render", at = @At("HEAD"))
private void startHeadTranslate(DrawContext context, float tickDelta, CallbackInfo ci) {
if (getSupport()) {
context.getMatrices().translate(0, -getHud(), 0);
start(context, 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);
start(context, 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);
end(context, 0, getHud(), 0);
}

// OVERLAY MESSAGE
@Inject(method = "renderOverlayMessage", at = @At(value = "HEAD"))
private void startOverlayMessageTranslate(DrawContext context, float tickDelta, CallbackInfo ci) {
context.getMatrices().translate(0, -getHud(), 0);
start(context, 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);
end(context, 0, getHud(), 0);
}

// TITLE AND SUBTITLES
@Inject(method = "renderOverlayMessage", at = @At(value = "HEAD"))
private void startTitleAndSubtitlesTranslate(DrawContext context, float tickDelta, CallbackInfo ci) {
end(context, 0, getHud(), 0);
}

@Inject(method = "renderOverlayMessage", at = @At(value = "TAIL"))
private void endTitleAndSubtitlesTranslate(DrawContext context, float tickDelta, CallbackInfo ci) {
start(context, 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);
start(context, 0, getSync() ? getHud() : getChat(), 0);
}

@Inject(method = "renderChat", at = @At(value = "TAIL"))
private void endChatTranslate(DrawContext context, float tickDelta, CallbackInfo ci) {
context.getMatrices().translate(0, +(getSync() ? getHud() : getChat()), -300);
end(context, 0, getSync() ? getHud() : getChat(), 0);
}

// TAIL
@Inject(method = "render", at = @At("TAIL"))
private void startTailTranslate(DrawContext context, float tickDelta, CallbackInfo ci) {
if (getSupport()) {
context.getMatrices().translate(0, -getHud(), 0);
start(context, 0, getHud(), 0);
}
}

Expand All @@ -82,15 +94,15 @@ public abstract static class Post {
@Inject(method = "render", at = @At("HEAD"))
private void endHeadTranslate(DrawContext context, float tickDelta, CallbackInfo ci) {
if (getSupport()) {
context.getMatrices().translate(0, +getHud(), 0);
end(context, 0, getHud(), 0);
}
}

// TAIL
@Inject(method = "render", at = @At("TAIL"))
private void endTailTranslate(DrawContext context, float tickDelta, CallbackInfo ci) {
if (getSupport()) {
context.getMatrices().translate(0, +getHud(), 0);
end(context, 0, getHud(), 0);
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package dev.yurisuika.raised.mixin.client.gui.screen;

import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.screen.ChatScreen;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

import static dev.yurisuika.raised.client.gui.RaisedGui.*;
import static dev.yurisuika.raised.client.option.RaisedConfig.*;

@Mixin(ChatScreen.class)
public class ChatScreenMixin {

// CHAT
@Inject(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/hud/ChatHud;render(Lnet/minecraft/client/gui/DrawContext;IIIZ)V"))
private void startChatTranslate(DrawContext context, int mouseX, int mouseY, float delta, CallbackInfo ci) {
start(context, 0, getSync() ? getHud() : getChat(), 0);
}

@Inject(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/hud/ChatHud;render(Lnet/minecraft/client/gui/DrawContext;IIIZ)V", shift = At.Shift.AFTER))
private void endChatTranslate(DrawContext context, int mouseX, int mouseY, float delta, CallbackInfo ci) {
end(context, 0, getSync() ? getHud() : getChat(), 0);
}

}
3 changes: 2 additions & 1 deletion src/main/resources/raised.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"client": [
"client.gui.hud.ChatHudMixin",
"client.gui.hud.InGameHudMixin$Post",
"client.gui.hud.InGameHudMixin$Pre"
"client.gui.hud.InGameHudMixin$Pre",
"client.gui.screen.ChatScreenMixin"
],
"injectors": {
"defaultRequire": 1
Expand Down

0 comments on commit 9436ec1

Please sign in to comment.