Skip to content

Commit

Permalink
feat: optimized font rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
opZywl committed Nov 20, 2024
1 parent e4f96cd commit 12eff28
Show file tree
Hide file tree
Showing 20 changed files with 167 additions and 102 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import net.ccbluex.liquidbounce.features.module.modules.client.ChatControl;
import net.ccbluex.liquidbounce.features.module.modules.client.HUDModule;
import net.ccbluex.liquidbounce.file.FileManager;
import net.ccbluex.liquidbounce.ui.font.AWTFontRenderer;
import net.ccbluex.liquidbounce.utils.render.RenderUtils;
import net.minecraft.client.gui.Gui;
import net.minecraft.client.gui.GuiChat;
Expand Down Expand Up @@ -164,6 +165,8 @@ private void onAutocompleteResponse(String[] autoCompleteResponse, CallbackInfo
*/
@Overwrite
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
AWTFontRenderer.Companion.setAssumeNonVolatile(true);

Gui.drawRect(2, height - (int) fade, width - 2, height, Integer.MIN_VALUE);
inputField.drawTextBox();

Expand All @@ -175,6 +178,8 @@ public void drawScreen(int mouseX, int mouseY, float partialTicks) {
mc.fontRendererObj.drawStringWithShadow(trimmedString, inputField.xPosition + mc.fontRendererObj.getStringWidth(inputField.getText()), inputField.yPosition, new Color(165, 165, 165).getRGB());
}

AWTFontRenderer.Companion.setAssumeNonVolatile(false);

IChatComponent ichatcomponent =
mc.ingameGUI.getChatGUI().getChatComponent(Mouse.getX(), Mouse.getY());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@ private void injectCustomHotbar(ScaledResolution resolution, float delta, Callba
boolean isGradient = hud.getHotbarMode().equals("Gradient");
boolean isRainbow = hud.getHotbarMode().equals("Rainbow");

AWTFontRenderer.Companion.setAssumeNonVolatile(true);

if (isGradient) {
GradientShader.begin(
true,
Expand Down Expand Up @@ -181,6 +183,8 @@ private void injectCustomHotbar(ScaledResolution resolution, float delta, Callba
disableRescaleNormal();
disableBlend();

AWTFontRenderer.Companion.setAssumeNonVolatile(false);

ci.cancel();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
package net.ccbluex.liquidbounce.injection.forge.mixins.gui;

import net.ccbluex.liquidbounce.injection.implementations.IMixinGuiSlot;
import net.ccbluex.liquidbounce.ui.font.AWTFontRenderer;
import net.ccbluex.liquidbounce.utils.render.RenderUtils;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Gui;
Expand Down Expand Up @@ -96,6 +97,8 @@ public abstract class MixinGuiSlot implements IMixinGuiSlot {
@Overwrite
public void drawScreen(int mouseXIn, int mouseYIn, float p_148128_3_) {
if (field_178041_q) {
AWTFontRenderer.Companion.setAssumeNonVolatile(true);

mouseX = mouseXIn;
mouseY = mouseYIn;
drawBackground();
Expand Down Expand Up @@ -179,6 +182,7 @@ public void drawScreen(int mouseXIn, int mouseYIn, float p_148128_3_) {
shadeModel(7424);
enableAlpha();
disableBlend();
AWTFontRenderer.Companion.setAssumeNonVolatile(false);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import net.ccbluex.liquidbounce.file.FileManager.accountsConfig
import net.ccbluex.liquidbounce.file.FileManager.saveConfig
import net.ccbluex.liquidbounce.ui.client.altmanager.menus.GuiLoginIntoAccount
import net.ccbluex.liquidbounce.ui.client.altmanager.menus.GuiSessionLogin
import net.ccbluex.liquidbounce.ui.font.AWTFontRenderer.Companion.assumeNonVolatile
import net.ccbluex.liquidbounce.ui.font.Fonts
import net.ccbluex.liquidbounce.utils.ClientUtils.LOGGER
import net.ccbluex.liquidbounce.utils.MinecraftInstance.Companion.mc
Expand Down Expand Up @@ -89,6 +90,9 @@ class GuiAltManager(private val prevGui: GuiScreen) : GuiScreen() {
}

override fun drawScreen(mouseX: Int, mouseY: Int, partialTicks: Float) {

assumeNonVolatile = true

drawBackground(0)
altsList.drawScreen(mouseX, mouseY, partialTicks)
this.drawCenteredString(mc.fontRendererObj, "Alt Manager", width / 2, 6, 0xffffff)
Expand Down Expand Up @@ -122,6 +126,8 @@ class GuiAltManager(private val prevGui: GuiScreen) : GuiScreen() {

drawBloom(mouseX - 5, mouseY - 5, 10, 10, 16, Color(guiColor))

assumeNonVolatile = false

super.drawScreen(mouseX, mouseY, partialTicks)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import net.ccbluex.liquidbounce.features.module.modules.client.HUDModule.guiColo
import net.ccbluex.liquidbounce.file.FileManager.accountsConfig
import net.ccbluex.liquidbounce.file.FileManager.saveConfig
import net.ccbluex.liquidbounce.ui.client.altmanager.GuiAltManager
import net.ccbluex.liquidbounce.ui.font.AWTFontRenderer.Companion.assumeNonVolatile
import net.ccbluex.liquidbounce.ui.font.Fonts
import net.ccbluex.liquidbounce.utils.misc.RandomUtils.randomUsername
import net.ccbluex.liquidbounce.utils.render.RenderUtils.drawBloom
Expand Down Expand Up @@ -54,6 +55,9 @@ class GuiLoginIntoAccount(private val prevGui: GuiAltManager, val directLogin: B
}

override fun drawScreen(mouseX: Int, mouseY: Int, partialTicks: Float) {

assumeNonVolatile = true

drawBackground(0)

drawRect(30, 30, width - 30, height - 30, Int.MIN_VALUE)
Expand All @@ -68,6 +72,8 @@ class GuiLoginIntoAccount(private val prevGui: GuiAltManager, val directLogin: B

drawBloom(mouseX - 5, mouseY - 5, 10, 10, 16, Color(guiColor))

assumeNonVolatile = false

super.drawScreen(mouseX, mouseY, partialTicks)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ package net.ccbluex.liquidbounce.ui.client.altmanager.menus
import me.liuli.elixir.account.MinecraftAccount
import net.ccbluex.liquidbounce.features.module.modules.client.HUDModule.guiColor
import net.ccbluex.liquidbounce.ui.client.altmanager.GuiAltManager.Companion.login
import net.ccbluex.liquidbounce.ui.font.AWTFontRenderer.Companion.assumeNonVolatile
import net.ccbluex.liquidbounce.utils.render.RenderUtils.drawBloom
import net.ccbluex.liquidbounce.utils.render.RenderUtils.drawLoadingCircle
import net.minecraft.client.gui.GuiScreen
Expand All @@ -20,12 +21,17 @@ class GuiLoginProgress(minecraftAccount: MinecraftAccount, success: () -> Unit,
}

override fun drawScreen(mouseX: Int, mouseY: Int, partialTicks: Float) {

assumeNonVolatile = true

drawDefaultBackground()
drawLoadingCircle(width / 2f, height / 4f + 70)
drawCenteredString(fontRendererObj, "Logging into account...", width / 2, height / 2 - 60, 16777215)

drawBloom(mouseX - 5, mouseY - 5, 10, 10, 16, Color(guiColor))

assumeNonVolatile = false

super.drawScreen(mouseX, mouseY, partialTicks)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,18 @@ package net.ccbluex.liquidbounce.ui.client.altmanager.menus

import me.liuli.elixir.account.MicrosoftAccount
import me.liuli.elixir.compat.OAuthServer
import net.ccbluex.liquidbounce.features.module.modules.client.HUDModule.guiColor
import net.ccbluex.liquidbounce.file.FileManager.accountsConfig
import net.ccbluex.liquidbounce.file.FileManager.saveConfig
import net.ccbluex.liquidbounce.ui.font.AWTFontRenderer.Companion.assumeNonVolatile
import net.ccbluex.liquidbounce.ui.font.Fonts
import net.ccbluex.liquidbounce.utils.ClientUtils.LOGGER
import net.ccbluex.liquidbounce.utils.misc.MiscUtils
import net.ccbluex.liquidbounce.utils.render.RenderUtils.drawBloom
import net.ccbluex.liquidbounce.utils.render.RenderUtils.drawLoadingCircle
import net.minecraft.client.gui.GuiButton
import net.minecraft.client.gui.GuiScreen
import java.awt.Color
import java.net.BindException

class GuiMicrosoftLoginProgress(val updateStatus: (String) -> Unit, val done: () -> Unit) : GuiScreen() {
Expand Down Expand Up @@ -80,9 +84,17 @@ class GuiMicrosoftLoginProgress(val updateStatus: (String) -> Unit, val done: ()
}

override fun drawScreen(mouseX: Int, mouseY: Int, partialTicks: Float) {

assumeNonVolatile = true

drawDefaultBackground()
drawLoadingCircle(width / 2f, height / 4f + 70)
Fonts.font40.drawCenteredStringWithShadow("Logging into account...", width / 2f, height / 2 - 60f, 0xffffff)

drawBloom(mouseX - 5, mouseY - 5, 10, 10, 16, Color(guiColor))

assumeNonVolatile = false

super.drawScreen(mouseX, mouseY, partialTicks)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ package net.ccbluex.liquidbounce.ui.client.altmanager.menus

import net.ccbluex.liquidbounce.features.module.modules.client.HUDModule.guiColor
import net.ccbluex.liquidbounce.ui.client.altmanager.GuiAltManager
import net.ccbluex.liquidbounce.ui.font.AWTFontRenderer.Companion.assumeNonVolatile
import net.ccbluex.liquidbounce.ui.font.Fonts
import net.ccbluex.liquidbounce.utils.login.LoginUtils
import net.ccbluex.liquidbounce.utils.render.RenderUtils.drawBloom
Expand Down Expand Up @@ -57,6 +58,9 @@ class GuiSessionLogin(private val prevGui: GuiAltManager) : GuiScreen() {
* Draw screen
*/
override fun drawScreen(mouseX: Int, mouseY: Int, partialTicks: Float) {

assumeNonVolatile = true

// Draw background to screen
drawBackground(0)
drawRect(30f, 30f, width - 30f, height - 30f, Integer.MIN_VALUE)
Expand All @@ -73,6 +77,7 @@ class GuiSessionLogin(private val prevGui: GuiAltManager) : GuiScreen() {

drawBloom(mouseX - 5, mouseY - 5, 10, 10, 16, Color(guiColor))

assumeNonVolatile = false
// Call sub method
super.drawScreen(mouseX, mouseY, partialTicks)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
package net.ccbluex.liquidbounce.ui.client.gui

import net.ccbluex.liquidbounce.features.module.modules.client.HUDModule.guiColor
import net.ccbluex.liquidbounce.ui.font.AWTFontRenderer.Companion.assumeNonVolatile
import net.ccbluex.liquidbounce.ui.font.Fonts
import net.ccbluex.liquidbounce.utils.APIConnecter
import net.ccbluex.liquidbounce.utils.render.RenderUtils
Expand All @@ -14,10 +15,12 @@ import net.ccbluex.liquidbounce.value.choices
import net.minecraft.client.gui.GuiButton
import net.minecraft.client.gui.GuiScreen
import net.minecraft.client.renderer.GlStateManager
import net.minecraft.client.renderer.GlStateManager.*
import net.minecraft.client.renderer.OpenGlHelper
import net.minecraft.client.renderer.RenderHelper
import net.minecraft.util.ResourceLocation
import org.lwjgl.opengl.GL11
import org.lwjgl.opengl.GL11.*
import java.awt.Color
import java.util.*

Expand Down Expand Up @@ -101,33 +104,36 @@ object GuiCapeManager : GuiScreen() {
}

override fun drawScreen(mouseX: Int, mouseY: Int, partialTicks: Float) {

assumeNonVolatile = false

this.drawDefaultBackground()

GL11.glPushMatrix()
glPushMatrix()
Fonts.font35.drawCenteredStringWithShadow(
if (nowCape == null) "§cNONE" else "§a${nowCape!!.name}",
width * 0.50f,
height * 0.23f,
-1
)
GL11.glScalef(2f, 2f, 2f)
glScalef(2f, 2f, 2f)
Fonts.font35.drawCenteredStringWithoutShadow("Cape Manager", width * 0.25f, height * 0.03f, -1)
GL11.glPopMatrix()
glPopMatrix()

super.drawScreen(mouseX, mouseY, partialTicks)

mc.thePlayer ?: return
GL11.glEnable(GL11.GL_CULL_FACE)
GlStateManager.resetColor()
GL11.glColor4f(1F, 1F, 1F, 1F)
GlStateManager.enableColorMaterial()
GlStateManager.pushMatrix()
GL11.glTranslatef(width * 0.5f - 60, height * 0.3f, 0f)
GL11.glScalef(2f, 2f, 2f)
GL11.glTranslatef(30f, 100f, 0f)
GlStateManager.translate(0F, 0F, 50F)
GlStateManager.scale(-50F, 50F, 50F)
GlStateManager.rotate(180F, 0F, 0F, 1F)
glEnable(GL_CULL_FACE)
resetColor()
glColor4f(1F, 1F, 1F, 1F)
enableColorMaterial()
pushMatrix()
glTranslatef(width * 0.5f - 60, height * 0.3f, 0f)
glScalef(2f, 2f, 2f)
glTranslatef(30f, 100f, 0f)
translate(0F, 0F, 50F)
scale(-50F, 50F, 50F)
rotate(180F, 0F, 0F, 1F)

val renderYawOffset = mc.thePlayer.renderYawOffset
val rotationYaw = mc.thePlayer.rotationYaw
Expand All @@ -140,10 +146,10 @@ object GuiCapeManager : GuiScreen() {
val armor3 = mc.thePlayer.inventory.armorInventory[3]
val current = mc.thePlayer.inventory.mainInventory[mc.thePlayer.inventory.currentItem]

GlStateManager.rotate(135F, 0F, 1F, 0F)
rotate(135F, 0F, 1F, 0F)
RenderHelper.enableStandardItemLighting()
GlStateManager.rotate(-135F, 0F, 1F, 0F)
GlStateManager.rotate(0f, 1F, 0F, 0F)
rotate(-135F, 0F, 1F, 0F)
rotate(0f, 1F, 0F, 0F)

mc.thePlayer.renderYawOffset = 180f
mc.thePlayer.rotationYaw = 180f
Expand All @@ -156,7 +162,7 @@ object GuiCapeManager : GuiScreen() {
mc.thePlayer.inventory.armorInventory[3] = null
mc.thePlayer.inventory.mainInventory[mc.thePlayer.inventory.currentItem] = null

GlStateManager.translate(0F, 0F, 0F)
translate(0F, 0F, 0F)

val renderManager = mc.renderManager
renderManager.setPlayerViewY(180F)
Expand All @@ -175,15 +181,17 @@ object GuiCapeManager : GuiScreen() {
mc.thePlayer.inventory.armorInventory[3] = armor3
mc.thePlayer.inventory.mainInventory[mc.thePlayer.inventory.currentItem] = current

GlStateManager.popMatrix()
popMatrix()
RenderHelper.disableStandardItemLighting()
GlStateManager.disableRescaleNormal()
GlStateManager.setActiveTexture(OpenGlHelper.lightmapTexUnit)
GlStateManager.disableTexture2D()
GlStateManager.setActiveTexture(OpenGlHelper.defaultTexUnit)
GlStateManager.resetColor()
disableRescaleNormal()
setActiveTexture(OpenGlHelper.lightmapTexUnit)
disableTexture2D()
setActiveTexture(OpenGlHelper.defaultTexUnit)
resetColor()

RenderUtils.drawBloom(mouseX - 5, mouseY - 5, 10, 10, 16, Color(guiColor))

assumeNonVolatile = false
}

override fun doesGuiPauseGame() = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import net.ccbluex.liquidbounce.file.FileManager.saveConfig
import net.ccbluex.liquidbounce.file.FileManager.valuesConfig
import net.ccbluex.liquidbounce.handler.lang.LanguageManager
import net.ccbluex.liquidbounce.handler.lang.translationMenu
import net.ccbluex.liquidbounce.ui.font.AWTFontRenderer.Companion.assumeNonVolatile
import net.ccbluex.liquidbounce.ui.font.Fonts
import net.ccbluex.liquidbounce.utils.Background
import net.ccbluex.liquidbounce.utils.MinecraftInstance.Companion.mc
Expand Down Expand Up @@ -246,6 +247,9 @@ class GuiClientConfiguration(val prevGui: GuiScreen) : GuiScreen() {
}

override fun drawScreen(mouseX: Int, mouseY: Int, partialTicks: Float) {

assumeNonVolatile = true

drawBackground(0)
Fonts.fontBold180.drawCenteredString(
translationMenu("configuration"), width / 2F, height / 8F + 5F, 4673984, true
Expand All @@ -272,6 +276,8 @@ class GuiClientConfiguration(val prevGui: GuiScreen) : GuiScreen() {

drawBloom(mouseX - 5, mouseY - 5, 10, 10, 16, Color(guiColor))

assumeNonVolatile = false

super.drawScreen(mouseX, mouseY, partialTicks)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import net.ccbluex.liquidbounce.handler.payload.ClientFixes.blockResourcePackExp
import net.ccbluex.liquidbounce.handler.payload.ClientFixes.fmlFixesEnabled
import net.ccbluex.liquidbounce.file.FileManager.saveConfig
import net.ccbluex.liquidbounce.file.FileManager.valuesConfig
import net.ccbluex.liquidbounce.ui.font.AWTFontRenderer.Companion.assumeNonVolatile
import net.ccbluex.liquidbounce.ui.font.Fonts
import net.ccbluex.liquidbounce.utils.render.RenderUtils.drawBloom
import net.minecraft.client.gui.GuiButton
Expand Down Expand Up @@ -86,11 +87,16 @@ class GuiClientFixes(private val prevGui: GuiScreen) : GuiScreen() {
}

override fun drawScreen(mouseX: Int, mouseY: Int, partialTicks: Float) {

assumeNonVolatile = true

drawBackground(0)
Fonts.fontBold180.drawCenteredString("Fixes", width / 2f, height / 8f + 5f, 4673984, true)

drawBloom(mouseX - 5, mouseY - 5, 10, 10, 16, Color(guiColor))

assumeNonVolatile = false

super.drawScreen(mouseX, mouseY, partialTicks)
}

Expand Down
Loading

0 comments on commit 12eff28

Please sign in to comment.