From 203ea34ee7423249685b9f3c4388ee5f2634aa76 Mon Sep 17 00:00:00 2001 From: Username404-59 Date: Fri, 23 Apr 2021 23:21:50 +0200 Subject: [PATCH] Add a method to the SnowyScreen companion object --- .../main/kotlin/fr/username404/snowygui/gui/SnowyScreen.kt | 7 +++++++ 1 file changed, 7 insertions(+) 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 7f0a26a..92fef4e 100644 --- a/common/src/main/kotlin/fr/username404/snowygui/gui/SnowyScreen.kt +++ b/common/src/main/kotlin/fr/username404/snowygui/gui/SnowyScreen.kt @@ -5,6 +5,13 @@ import net.minecraft.client.gui.screens.Screen import net.minecraft.network.chat.TranslatableComponent abstract class SnowyScreen(translatableString: String = "screen.snowy.gui", private val willPauseScreen: Boolean = false): Screen(TranslatableComponent(translatableString)) { + companion object { + fun fromRenderable(r: Renderable, x: Int, y: Int, width: Int, height: Int): Element { + return object: Element(x.toDouble(), y.toDouble(), width, height) { + override fun render(poseStack: PoseStack?) = r.render(poseStack) + } + } + } open val components: MutableSet? = null override fun render(poseStack: PoseStack?, i: Int, j: Int, f: Float) { if (poseStack != null) {