diff --git a/src/main/java/net/ccbluex/liquidbounce/injection/forge/mixins/gui/MixinGuiDisconnected.java b/src/main/java/net/ccbluex/liquidbounce/injection/forge/mixins/gui/MixinGuiDisconnected.java index e916ffd8533..b36a1a301c8 100644 --- a/src/main/java/net/ccbluex/liquidbounce/injection/forge/mixins/gui/MixinGuiDisconnected.java +++ b/src/main/java/net/ccbluex/liquidbounce/injection/forge/mixins/gui/MixinGuiDisconnected.java @@ -5,7 +5,6 @@ */ package net.ccbluex.liquidbounce.injection.forge.mixins.gui; -import com.google.gson.JsonObject; import com.mojang.authlib.Agent; import com.mojang.authlib.yggdrasil.YggdrasilAuthenticationService; import com.mojang.authlib.yggdrasil.YggdrasilUserAuthentication; @@ -28,7 +27,7 @@ import net.minecraft.client.gui.GuiDisconnected; import net.minecraft.client.gui.GuiMainMenu; import net.minecraft.client.gui.GuiMultiplayer; -import net.minecraft.util.IChatComponent; +import net.minecraft.util.ChatComponentText; import net.minecraft.util.Session; import net.minecraftforge.fml.client.config.GuiSlider; import org.spongepowered.asm.mixin.Mixin; @@ -47,8 +46,6 @@ @Mixin(GuiDisconnected.class) public abstract class MixinGuiDisconnected extends MixinGuiScreen { - private static final DecimalFormat DECIMAL_FORMAT = new DecimalFormat("#0"); - @Shadow private int field_175353_i; @@ -113,10 +110,7 @@ private void actionPerformed(GuiButton button, CallbackInfo callbackInfo) throws return null; }, e -> { mc.addScheduledTask(() -> { - final JsonObject jsonObject = new JsonObject(); - jsonObject.addProperty("text", e.getMessage()); - - mc.displayGuiScreen(new GuiDisconnected(new GuiMultiplayer(new GuiMainMenu()), e.getMessage(), IChatComponent.Serializer.jsonToComponent(jsonObject.toString()))); + mc.displayGuiScreen(new GuiDisconnected(new GuiMultiplayer(new GuiMainMenu()), e.getMessage(), new ChatComponentText(e.getMessage()))); }); return null; }, () -> null)); @@ -171,7 +165,7 @@ private void updateSliderText() { if (!AutoReconnect.INSTANCE.isEnabled()) { autoReconnectDelaySlider.displayString = "AutoReconnect: Off"; } else { - autoReconnectDelaySlider.displayString = "AutoReconnect: " + DECIMAL_FORMAT.format(AutoReconnect.INSTANCE.getDelay() / 1000.0) + "s"; + autoReconnectDelaySlider.displayString = "AutoReconnect: " + Math.floor(AutoReconnect.INSTANCE.getDelay() / 1000.0) + "s"; } } diff --git a/src/main/java/net/ccbluex/liquidbounce/utils/client/ClientUtils.kt b/src/main/java/net/ccbluex/liquidbounce/utils/client/ClientUtils.kt index e9b94cd83c4..f245a58c097 100644 --- a/src/main/java/net/ccbluex/liquidbounce/utils/client/ClientUtils.kt +++ b/src/main/java/net/ccbluex/liquidbounce/utils/client/ClientUtils.kt @@ -5,13 +5,12 @@ */ package net.ccbluex.liquidbounce.utils.client -import com.google.gson.JsonObject import net.ccbluex.liquidbounce.LiquidBounce.CLIENT_NAME import net.minecraft.client.settings.GameSettings import net.minecraft.network.NetworkManager import net.minecraft.network.login.client.C01PacketEncryptionResponse import net.minecraft.network.login.server.S01PacketEncryptionRequest -import net.minecraft.util.IChatComponent +import net.minecraft.util.ChatComponentText import net.minecraftforge.fml.relauncher.Side import net.minecraftforge.fml.relauncher.SideOnly import org.apache.logging.log4j.LogManager @@ -51,15 +50,8 @@ object ClientUtils : MinecraftInstance { } fun displayChatMessage(message: String) { - if (mc.thePlayer == null) { - LOGGER.info("(MCChat) $message") - return - } - - val prefixMessage = "§8[§9§l$CLIENT_NAME§8]§r $message" - val jsonObject = JsonObject() - jsonObject.addProperty("text", prefixMessage) - mc.thePlayer.addChatMessage(IChatComponent.Serializer.jsonToComponent(jsonObject.toString())) + mc.thePlayer?.addChatMessage(ChatComponentText("§8[§9§l$CLIENT_NAME§8]§r $message")) + ?: LOGGER.info("(MCChat) $message") } }