diff options
Diffstat (limited to 'src/main/kotlin/util/accessors')
| -rw-r--r-- | src/main/kotlin/util/accessors/GetRectangle.kt | 6 | ||||
| -rw-r--r-- | src/main/kotlin/util/accessors/castAccessor.kt | 16 | ||||
| -rw-r--r-- | src/main/kotlin/util/accessors/chathud.kt | 6 |
3 files changed, 22 insertions, 6 deletions
diff --git a/src/main/kotlin/util/accessors/GetRectangle.kt b/src/main/kotlin/util/accessors/GetRectangle.kt index 37acfd9..109de94 100644 --- a/src/main/kotlin/util/accessors/GetRectangle.kt +++ b/src/main/kotlin/util/accessors/GetRectangle.kt @@ -3,11 +3,11 @@ package moe.nea.firmament.util.accessors import me.shedaniel.math.Rectangle +import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen import moe.nea.firmament.mixins.accessor.AccessorHandledScreen -import net.minecraft.client.gui.screen.ingame.HandledScreen -fun HandledScreen<*>.getRectangle(): Rectangle { - this as AccessorHandledScreen +fun AbstractContainerScreen<*>.getProperRectangle(): Rectangle { + this.castAccessor() return Rectangle( getX_Firmament(), getY_Firmament(), diff --git a/src/main/kotlin/util/accessors/castAccessor.kt b/src/main/kotlin/util/accessors/castAccessor.kt new file mode 100644 index 0000000..0ac85a2 --- /dev/null +++ b/src/main/kotlin/util/accessors/castAccessor.kt @@ -0,0 +1,16 @@ +@file:OptIn(ExperimentalContracts::class) + +package moe.nea.firmament.util.accessors + +import kotlin.contracts.ExperimentalContracts +import kotlin.contracts.contract +import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen +import moe.nea.firmament.mixins.accessor.AccessorHandledScreen + + +inline fun AbstractContainerScreen<*>.castAccessor(): AccessorHandledScreen { + contract { + returns() implies (this@castAccessor is AccessorHandledScreen) + } + return this as AccessorHandledScreen +} diff --git a/src/main/kotlin/util/accessors/chathud.kt b/src/main/kotlin/util/accessors/chathud.kt index effac7d..7935ad4 100644 --- a/src/main/kotlin/util/accessors/chathud.kt +++ b/src/main/kotlin/util/accessors/chathud.kt @@ -1,8 +1,8 @@ package moe.nea.firmament.util.accessors -import net.minecraft.client.gui.hud.ChatHud -import net.minecraft.client.gui.hud.ChatHudLine +import net.minecraft.client.gui.components.ChatComponent +import net.minecraft.client.GuiMessage import moe.nea.firmament.mixins.accessor.AccessorChatHud -val ChatHud.messages: MutableList<ChatHudLine> +val ChatComponent.messages: MutableList<GuiMessage> get() = (this as AccessorChatHud).messages_firmament |
