mirror of https://github.com/kami-blue/client
[fix] Fixed negative ms count down in AutoReconnect
This commit is contained in:
parent
872dd15cae
commit
295faf4ca3
|
@ -8,6 +8,7 @@ import me.zeroeightsix.kami.util.event.listener
|
|||
import net.minecraft.client.gui.GuiDisconnected
|
||||
import net.minecraft.client.multiplayer.GuiConnecting
|
||||
import net.minecraft.client.multiplayer.ServerData
|
||||
import kotlin.math.max
|
||||
|
||||
@Module.Info(
|
||||
name = "AutoReconnect",
|
||||
|
@ -20,8 +21,6 @@ object AutoReconnect : Module() {
|
|||
|
||||
private var prevServerDate: ServerData? = null
|
||||
|
||||
private var sToMs = 1000.0f
|
||||
|
||||
init {
|
||||
listener<GuiScreenEvent.Closed> {
|
||||
if (it.screen is GuiConnecting) prevServerDate = mc.currentServerData
|
||||
|
@ -39,14 +38,15 @@ object AutoReconnect : Module() {
|
|||
private val timer = TimerUtils.StopTimer()
|
||||
|
||||
override fun updateScreen() {
|
||||
if (timer.stop() >= (delay.value * sToMs)) {
|
||||
if (timer.stop() >= (delay.value * 1000.0f)) {
|
||||
mc.displayGuiScreen(GuiConnecting(parentScreen, mc, mc.currentServerData ?: prevServerDate ?: return))
|
||||
}
|
||||
}
|
||||
|
||||
override fun drawScreen(mouseX: Int, mouseY: Int, partialTicks: Float) {
|
||||
super.drawScreen(mouseX, mouseY, partialTicks)
|
||||
val text = "Reconnecting in ${((delay.value * sToMs) - timer.stop()).toInt()}ms"
|
||||
val ms = max(delay.value * 1000.0f - timer.stop(), 0.0f).toInt()
|
||||
val text = "Reconnecting in ${ms}ms"
|
||||
fontRenderer.drawString(text, width / 2f - fontRenderer.getStringWidth(text) / 2f, height - 32f, 0xffffff, true)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue