aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorjani270 <69345714+jani270@users.noreply.github.com>2025-06-04 15:48:31 +0200
committerLinnea Gräf <nea@nea.moe>2025-06-04 19:05:09 +0200
commit6b697b8936c41b14b005704553de7004f6c7ce18 (patch)
tree28c7910d11027464a21b672230397d1193e15f7d /src
parent3695589a47c7434f4c5abbe2ebead052c0d07ba6 (diff)
downloadFirmament-6b697b8936c41b14b005704553de7004f6c7ce18.tar.gz
Firmament-6b697b8936c41b14b005704553de7004f6c7ce18.tar.bz2
Firmament-6b697b8936c41b14b005704553de7004f6c7ce18.zip
feat: Hover Text to Inventory Buttons
Diffstat (limited to 'src')
-rw-r--r--src/main/kotlin/features/inventory/buttons/InventoryButtons.kt16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/main/kotlin/features/inventory/buttons/InventoryButtons.kt b/src/main/kotlin/features/inventory/buttons/InventoryButtons.kt
index 92640c8..f443323 100644
--- a/src/main/kotlin/features/inventory/buttons/InventoryButtons.kt
+++ b/src/main/kotlin/features/inventory/buttons/InventoryButtons.kt
@@ -5,6 +5,8 @@ package moe.nea.firmament.features.inventory.buttons
import me.shedaniel.math.Rectangle
import kotlinx.serialization.Serializable
import kotlinx.serialization.serializer
+import net.minecraft.client.MinecraftClient
+import net.minecraft.text.Text
import moe.nea.firmament.annotations.Subscribe
import moe.nea.firmament.events.HandledScreenClickEvent
import moe.nea.firmament.events.HandledScreenForegroundEvent
@@ -15,6 +17,7 @@ import moe.nea.firmament.util.MC
import moe.nea.firmament.util.ScreenUtil
import moe.nea.firmament.util.data.DataHolder
import moe.nea.firmament.util.accessors.getRectangle
+import moe.nea.firmament.util.gold
object InventoryButtons : FirmamentFeature {
override val identifier: String
@@ -24,6 +27,7 @@ object InventoryButtons : FirmamentFeature {
val _openEditor by button("open-editor") {
openEditor()
}
+ val hoverText by toggle("hover-text") { true }
}
object DConfig : DataHolder<Data>(serializer(), identifier, ::Data)
@@ -63,12 +67,24 @@ object InventoryButtons : FirmamentFeature {
@Subscribe
fun onRenderForeground(it: HandledScreenForegroundEvent) {
val bounds = it.screen.getRectangle()
+
for (button in getValidButtons()) {
val buttonBounds = button.getBounds(bounds)
it.context.matrices.push()
it.context.matrices.translate(buttonBounds.minX.toFloat(), buttonBounds.minY.toFloat(), 0F)
button.render(it.context)
it.context.matrices.pop()
+
+ if (buttonBounds.contains(it.mouseX, it.mouseY) && TConfig.hoverText) {
+ it.context.drawText(
+ MinecraftClient.getInstance().textRenderer,
+ Text.literal(button.command).gold(),
+ buttonBounds.minX - 15,
+ buttonBounds.minY + 20,
+ 0xFFFF00,
+ false
+ )
+ }
}
lastRectangle = bounds
}