aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/moe/nea/firmament/Firmament.kt
diff options
context:
space:
mode:
authorLinnea Gräf <nea@nea.moe>2024-05-11 03:28:05 +0200
committerLinnea Gräf <nea@nea.moe>2024-05-14 18:45:59 +0200
commit7682534f6fd139b75f24c79b76098fe05f0fa0fe (patch)
tree34d94c8fd7b531da128ff0130bf463393e2560e0 /src/main/kotlin/moe/nea/firmament/Firmament.kt
parent53dc0c3b0a758ce2afff2637a5a5f22aa1733c56 (diff)
downloadFirmament-7682534f6fd139b75f24c79b76098fe05f0fa0fe.tar.gz
Firmament-7682534f6fd139b75f24c79b76098fe05f0fa0fe.tar.bz2
Firmament-7682534f6fd139b75f24c79b76098fe05f0fa0fe.zip
Add custom global textures
Diffstat (limited to 'src/main/kotlin/moe/nea/firmament/Firmament.kt')
-rw-r--r--src/main/kotlin/moe/nea/firmament/Firmament.kt26
1 files changed, 19 insertions, 7 deletions
diff --git a/src/main/kotlin/moe/nea/firmament/Firmament.kt b/src/main/kotlin/moe/nea/firmament/Firmament.kt
index 03d4576..630950a 100644
--- a/src/main/kotlin/moe/nea/firmament/Firmament.kt
+++ b/src/main/kotlin/moe/nea/firmament/Firmament.kt
@@ -8,13 +8,15 @@
package moe.nea.firmament
import com.mojang.brigadier.CommandDispatcher
-import io.ktor.client.*
-import io.ktor.client.plugins.*
-import io.ktor.client.plugins.cache.*
-import io.ktor.client.plugins.compression.*
-import io.ktor.client.plugins.contentnegotiation.*
-import io.ktor.client.plugins.logging.*
-import io.ktor.serialization.kotlinx.json.*
+import io.ktor.client.HttpClient
+import io.ktor.client.plugins.UserAgent
+import io.ktor.client.plugins.cache.HttpCache
+import io.ktor.client.plugins.compression.ContentEncoding
+import io.ktor.client.plugins.contentnegotiation.ContentNegotiation
+import io.ktor.client.plugins.logging.LogLevel
+import io.ktor.client.plugins.logging.Logging
+import io.ktor.serialization.kotlinx.json.json
+import java.io.InputStream
import java.nio.file.Files
import java.nio.file.Path
import net.fabricmc.fabric.api.client.command.v2.ClientCommandRegistrationCallback
@@ -36,11 +38,13 @@ import kotlinx.coroutines.Job
import kotlinx.coroutines.SupervisorJob
import kotlinx.coroutines.plus
import kotlinx.serialization.json.Json
+import kotlinx.serialization.json.decodeFromStream
import kotlin.coroutines.EmptyCoroutineContext
import net.minecraft.command.CommandRegistryAccess
import net.minecraft.util.Identifier
import moe.nea.firmament.commands.registerFirmamentCommand
import moe.nea.firmament.dbus.FirmamentDbusObject
+import moe.nea.firmament.events.ClientStartedEvent
import moe.nea.firmament.events.CommandEvent
import moe.nea.firmament.events.ItemTooltipEvent
import moe.nea.firmament.events.ScreenRenderPostEvent
@@ -133,6 +137,9 @@ object Firmament {
FeatureManager.autoload()
HypixelStaticData.spawnDataCollectionLoop()
ClientCommandRegistrationCallback.EVENT.register(this::registerCommands)
+ ClientLifecycleEvents.CLIENT_STARTED.register(ClientLifecycleEvents.ClientStarted {
+ ClientStartedEvent.publish(ClientStartedEvent())
+ })
ClientLifecycleEvents.CLIENT_STOPPING.register(ClientLifecycleEvents.ClientStopping {
logger.info("Shutting down Firmament coroutines")
globalJob.cancel()
@@ -151,4 +158,9 @@ object Firmament {
fun identifier(path: String) = Identifier(MOD_ID, path)
+ inline fun <reified T : Any> tryDecodeJsonFromStream(inputStream: InputStream): Result<T> {
+ return runCatching {
+ json.decodeFromStream<T>(inputStream)
+ }
+ }
}