Use undispatched coroutines and remove the IO dispatcher usage to fix the previous commit

This commit is contained in:
Username404 2021-06-05 23:09:10 +02:00
parent 546a4d118e
commit c992b24b16
Signed by: Username404-59
GPG Key ID: 7AB361FBB257A5D1
2 changed files with 4 additions and 3 deletions

View File

@ -12,7 +12,7 @@ import fr.username404.snowygui.gui.feature.Category
import fr.username404.snowygui.gui.feature.Macro
import io.github.config4k.extract
import io.github.config4k.getValue
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.CoroutineStart
import kotlinx.coroutines.coroutineScope
import kotlinx.coroutines.launch
import kotlinx.coroutines.runBlocking
@ -53,7 +53,7 @@ object Configuration {
private val configDirectory: String = (Minecraft.getInstance().gameDirectory.absolutePath + File.separator + "config").also { File(it).mkdir() }
private val file: File = File(configDirectory + File.separator + "snowy.conf")
private suspend fun writeConfig(c: Config) = coroutineScope {
launch(Dispatchers.IO) {
launch(start = CoroutineStart.UNDISPATCHED) {
file.writeText(
"""
|Snowy {

View File

@ -12,6 +12,7 @@ import fr.username404.snowygui.gui.feature.ButtonImpl
import fr.username404.snowygui.gui.feature.Category
import fr.username404.snowygui.gui.feature.Colors
import io.github.config4k.extract
import kotlinx.coroutines.CoroutineStart
import kotlinx.coroutines.launch
import kotlinx.coroutines.runBlocking
import net.minecraft.client.Minecraft
@ -104,7 +105,7 @@ class ClickBox(
RenderSystem.enableTexture()
RenderSystem.disableBlend()
val renderButtons = if (buttons.isNotEmpty()) launch {
val renderButtons = if (buttons.isNotEmpty()) launch(start = CoroutineStart.UNDISPATCHED) {
buttonsProgressBar.apply {
x = this@ClickBox.x + this@ClickBox.width - 3
y = this@ClickBox.y + this@ClickBox.height + 3