aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/util/MC.kt
diff options
context:
space:
mode:
authorLinnea Gräf <nea@nea.moe>2024-11-12 21:38:31 +0100
committerLinnea Gräf <nea@nea.moe>2024-11-12 21:38:31 +0100
commitfc88e54a2e88c87bcfd5e7dbd6866764faa3e503 (patch)
treec5ec7980b67c47ce0d89175cb6ac9a180a94c3f3 /src/main/kotlin/util/MC.kt
parentb774daef5bd961f955d365ce07bd5aa4acb161f4 (diff)
downloadFirmament-fc88e54a2e88c87bcfd5e7dbd6866764faa3e503.tar.gz
Firmament-fc88e54a2e88c87bcfd5e7dbd6866764faa3e503.tar.bz2
Firmament-fc88e54a2e88c87bcfd5e7dbd6866764faa3e503.zip
feat: Add descriptions for config options
Diffstat (limited to 'src/main/kotlin/util/MC.kt')
-rw-r--r--src/main/kotlin/util/MC.kt12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/main/kotlin/util/MC.kt b/src/main/kotlin/util/MC.kt
index 1b7739f..cbcd8ae 100644
--- a/src/main/kotlin/util/MC.kt
+++ b/src/main/kotlin/util/MC.kt
@@ -3,6 +3,7 @@ package moe.nea.firmament.util
import io.github.moulberry.repo.data.Coordinate
import java.util.concurrent.ConcurrentLinkedQueue
import net.minecraft.client.MinecraftClient
+import net.minecraft.client.gui.hud.InGameHud
import net.minecraft.client.gui.screen.Screen
import net.minecraft.client.gui.screen.ingame.HandledScreen
import net.minecraft.client.network.ClientPlayerEntity
@@ -28,9 +29,10 @@ object MC {
init {
TickEvent.subscribe("MC:push") {
- while (true) {
- inGameHud.chatHud.addMessage(messageQueue.poll() ?: break)
- }
+ if (inGameHud.chatHud != null && world != null)
+ while (true) {
+ inGameHud.chatHud.addMessage(messageQueue.poll() ?: break)
+ }
while (true) {
(nextTickTodos.poll() ?: break).invoke()
}
@@ -41,7 +43,7 @@ object MC {
}
fun sendChat(text: Text) {
- if (instance.isOnThread)
+ if (instance.isOnThread && inGameHud.chatHud != null && world != null)
inGameHud.chatHud.addMessage(text)
else
messageQueue.add(text)
@@ -86,7 +88,7 @@ object MC {
inline val interactionManager get() = instance.interactionManager
inline val textureManager get() = instance.textureManager
inline val options get() = instance.options
- inline val inGameHud get() = instance.inGameHud
+ inline val inGameHud: InGameHud get() = instance.inGameHud
inline val font get() = instance.textRenderer
inline val soundManager get() = instance.soundManager
inline val player: ClientPlayerEntity? get() = instance.player