From 04b1a8a3e5cf142b0b3a9d089757b92db77dd510 Mon Sep 17 00:00:00 2001 From: kirillsaint Date: Mon, 3 Jul 2023 20:01:12 +0600 Subject: [PATCH] Titles --- .../client/mixin/mixins/GuiInGameMixin.java | 38 +++++++++++++++++-- 1 file changed, 34 insertions(+), 4 deletions(-) diff --git a/src/main/java/net/silentclient/client/mixin/mixins/GuiInGameMixin.java b/src/main/java/net/silentclient/client/mixin/mixins/GuiInGameMixin.java index a9274b6..df13e0a 100644 --- a/src/main/java/net/silentclient/client/mixin/mixins/GuiInGameMixin.java +++ b/src/main/java/net/silentclient/client/mixin/mixins/GuiInGameMixin.java @@ -1,6 +1,7 @@ package net.silentclient.client.mixin.mixins; import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.Gui; import net.minecraft.client.gui.GuiIngame; import net.minecraft.client.gui.ScaledResolution; @@ -16,13 +17,13 @@ import net.silentclient.client.mods.hud.BossBarMod; import net.silentclient.client.mods.hud.ScoreboardMod; import net.silentclient.client.mods.render.CrosshairMod; import net.silentclient.client.mods.render.PackTweaksMod; +import net.silentclient.client.mods.render.TitlesMod; import net.silentclient.client.mods.settings.RenderMod; import net.silentclient.client.utils.ColorUtils; import net.silentclient.client.utils.HUDCaching; import org.lwjgl.opengl.GL11; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Overwrite; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.*; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @@ -109,8 +110,37 @@ public abstract class GuiInGameMixin extends Gui { } } - @ModifyConstant(method = "renderScoreboard", constant = @Constant(intValue = 553648127)) - private int silent$fixTextBlending(int original) { - return -1; + @Redirect(method = "renderGameOverlay", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/GlStateManager;scale(FFF)V", ordinal = 0)) + public void changeScaleOfTitle(float x, float y, float z) { + if(Client.getInstance().getModInstances().getModByClass(TitlesMod.class).isEnabled()) { + float scale = (float) Client.getInstance().getSettingsManager().getSettingByClass(TitlesMod.class, "Scale").getValDouble(); + GlStateManager.scale(x - 1 + scale, y - 1 + scale, z - 1 + scale); + } + } + + @Redirect(method = "renderGameOverlay", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/GlStateManager;scale(FFF)V", ordinal = 1)) + public void changeScaleOfDescription(float x, float y, float z) { + if(Client.getInstance().getModInstances().getModByClass(TitlesMod.class).isEnabled()) { + float scale = (float) Client.getInstance().getSettingsManager().getSettingByClass(TitlesMod.class, "Scale").getValDouble(); + GlStateManager.scale(x - 1 + scale, y - 1 + scale, z - 1 + scale); + } + } + + @Redirect(method = "renderGameOverlay", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/FontRenderer;drawString(Ljava/lang/String;FFIZ)I", ordinal = 0)) + private int cancelTitle(FontRenderer instance, String text, float x, float y, int color, boolean dropShadow) { + if(Client.getInstance().getModInstances().getModByClass(TitlesMod.class).isEnabled()) { + return instance.drawString(text, x, y, color, dropShadow); + } else { + return 0; + } + } + + @Redirect(method = "renderGameOverlay", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/FontRenderer;drawString(Ljava/lang/String;FFIZ)I", ordinal = 1)) + private int cancelDescription(FontRenderer instance, String text, float x, float y, int color, boolean dropShadow) { + if(Client.getInstance().getModInstances().getModByClass(TitlesMod.class).isEnabled()) { + return instance.drawString(text, x, y, color, dropShadow); + } else { + return 0; + } } }