diff options
author | Linnea Gräf <nea@nea.moe> | 2025-03-10 23:39:04 +0100 |
---|---|---|
committer | Linnea Gräf <nea@nea.moe> | 2025-03-10 23:39:04 +0100 |
commit | 0765c8aee181dda89b08f89c4a7deb301f00f656 (patch) | |
tree | e881cfd8b933ee0392122ff089bc4e105b08e98a /src/main/kotlin | |
parent | 700f6c1cb2198f9b2a3c8c91f50fcba937a6c4c3 (diff) | |
download | Firmament-0765c8aee181dda89b08f89c4a7deb301f00f656.tar.gz Firmament-0765c8aee181dda89b08f89c4a7deb301f00f656.tar.bz2 Firmament-0765c8aee181dda89b08f89c4a7deb301f00f656.zip |
Diffstat (limited to 'src/main/kotlin')
-rw-r--r-- | src/main/kotlin/events/IsSlotProtectedEvent.kt | 11 | ||||
-rw-r--r-- | src/main/kotlin/util/textutil.kt | 2 |
2 files changed, 12 insertions, 1 deletions
diff --git a/src/main/kotlin/events/IsSlotProtectedEvent.kt b/src/main/kotlin/events/IsSlotProtectedEvent.kt index eac2d9b..8fe0a96 100644 --- a/src/main/kotlin/events/IsSlotProtectedEvent.kt +++ b/src/main/kotlin/events/IsSlotProtectedEvent.kt @@ -6,6 +6,10 @@ import net.minecraft.screen.slot.SlotActionType import net.minecraft.text.Text import moe.nea.firmament.util.CommonSoundEffects import moe.nea.firmament.util.MC +import moe.nea.firmament.util.grey +import moe.nea.firmament.util.hover +import moe.nea.firmament.util.red +import moe.nea.firmament.util.tr data class IsSlotProtectedEvent( val slot: Slot?, @@ -35,6 +39,7 @@ data class IsSlotProtectedEvent( INVENTORY_MOVE ; } + companion object : FirmamentEventBus<IsSlotProtectedEvent>() { @JvmStatic @JvmOverloads @@ -47,7 +52,11 @@ data class IsSlotProtectedEvent( val event = IsSlotProtectedEvent(slot, action, false, itemStackOverride, origin) publish(event) if (event.isProtected && !event.silent) { - MC.sendChat(Text.translatable("firmament.protectitem").append(event.itemStack.name)) + MC.sendChat(tr("firmament.protectitem", "Firmament protected your item: ${event.itemStack.name}.\n") + .red() + .append(tr("firmament.protectitem.hoverhint", "Hover for more info.").grey()) + .hover(tr("firmament.protectitem.hint", + "To unlock this item use the Lock Slot or Lock Item keybind from Firmament while hovering over this item."))) CommonSoundEffects.playFailure() } return event.isProtected diff --git a/src/main/kotlin/util/textutil.kt b/src/main/kotlin/util/textutil.kt index c295ae0..806f61e 100644 --- a/src/main/kotlin/util/textutil.kt +++ b/src/main/kotlin/util/textutil.kt @@ -2,6 +2,7 @@ package moe.nea.firmament.util import java.util.Optional import net.minecraft.text.ClickEvent +import net.minecraft.text.HoverEvent import net.minecraft.text.MutableText import net.minecraft.text.OrderedText import net.minecraft.text.PlainTextContent @@ -126,6 +127,7 @@ fun MutableText.darkGrey() = withColor(Formatting.DARK_GRAY) fun MutableText.red() = withColor(Formatting.RED) fun MutableText.white() = withColor(Formatting.WHITE) fun MutableText.bold(): MutableText = styled { it.withBold(true) } +fun MutableText.hover(text: Text): MutableText = styled {it.withHoverEvent(HoverEvent(HoverEvent.Action.SHOW_TEXT, text))} fun MutableText.clickCommand(command: String): MutableText { |