From 78e1081aba5c271093a0371c97b616f1a33b5131 Mon Sep 17 00:00:00 2001 From: Username404-59 Date: Wed, 28 Apr 2021 20:38:59 +0200 Subject: [PATCH] Make SnowyScreen.components not-null --- .../kotlin/fr/username404/snowygui/config/ConfigScreen.kt | 2 +- .../main/kotlin/fr/username404/snowygui/gui/SnowyScreen.kt | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/common/src/main/kotlin/fr/username404/snowygui/config/ConfigScreen.kt b/common/src/main/kotlin/fr/username404/snowygui/config/ConfigScreen.kt index 4e505ed..21f9fec 100644 --- a/common/src/main/kotlin/fr/username404/snowygui/config/ConfigScreen.kt +++ b/common/src/main/kotlin/fr/username404/snowygui/config/ConfigScreen.kt @@ -6,7 +6,7 @@ import fr.username404.snowygui.gui.SnowyScreen import net.minecraft.client.Minecraft open class SnowyConfigScreen: SnowyScreen("screen.snowygui.config") { // TODO Actual config screen - override val components: MutableSet? = mutableSetOf( + override val components: MutableSet = mutableSetOf( object: Element(0.0, 0.0, Minecraft.getInstance().window.width, Minecraft.getInstance().window.height) { override fun render(poseStack: PoseStack?) { renderBackground(poseStack) diff --git a/common/src/main/kotlin/fr/username404/snowygui/gui/SnowyScreen.kt b/common/src/main/kotlin/fr/username404/snowygui/gui/SnowyScreen.kt index 92fef4e..6ca59d8 100644 --- a/common/src/main/kotlin/fr/username404/snowygui/gui/SnowyScreen.kt +++ b/common/src/main/kotlin/fr/username404/snowygui/gui/SnowyScreen.kt @@ -3,6 +3,7 @@ package fr.username404.snowygui.gui import com.mojang.blaze3d.vertex.PoseStack import net.minecraft.client.gui.screens.Screen import net.minecraft.network.chat.TranslatableComponent +import kotlin.properties.Delegates abstract class SnowyScreen(translatableString: String = "screen.snowy.gui", private val willPauseScreen: Boolean = false): Screen(TranslatableComponent(translatableString)) { companion object { @@ -12,10 +13,10 @@ abstract class SnowyScreen(translatableString: String = "screen.snowy.gui", priv } } } - open val components: MutableSet? = null + open val components: MutableSet by Delegates.notNull() override fun render(poseStack: PoseStack?, i: Int, j: Int, f: Float) { if (poseStack != null) { - components?.forEach { + components.forEach { it.display(poseStack) } }