diff options
author | nea <nea@nea.moe> | 2023-09-09 03:37:29 +0200 |
---|---|---|
committer | nea <nea@nea.moe> | 2023-09-09 03:37:29 +0200 |
commit | 255e4f5899642e099e7ec7b1a7fe1e0c32ebbc20 (patch) | |
tree | 11016247a0403d2c1e4bd0de62d3fdf913709eb0 /src/main/kotlin/moe/nea/firmament/util | |
parent | e0f784a1b209e5ec88a07a71e9336790aac1fc7d (diff) | |
download | Firmament-255e4f5899642e099e7ec7b1a7fe1e0c32ebbc20.tar.gz Firmament-255e4f5899642e099e7ec7b1a7fe1e0c32ebbc20.tar.bz2 Firmament-255e4f5899642e099e7ec7b1a7fe1e0c32ebbc20.zip |
Add tools for copying id, texture id and nbt data
Diffstat (limited to 'src/main/kotlin/moe/nea/firmament/util')
-rw-r--r-- | src/main/kotlin/moe/nea/firmament/util/ClipboardUtils.kt | 28 | ||||
-rw-r--r-- | src/main/kotlin/moe/nea/firmament/util/MC.kt | 1 |
2 files changed, 29 insertions, 0 deletions
diff --git a/src/main/kotlin/moe/nea/firmament/util/ClipboardUtils.kt b/src/main/kotlin/moe/nea/firmament/util/ClipboardUtils.kt new file mode 100644 index 0000000..d761a5a --- /dev/null +++ b/src/main/kotlin/moe/nea/firmament/util/ClipboardUtils.kt @@ -0,0 +1,28 @@ +/* + * SPDX-FileCopyrightText: 2023 Linnea Gräf <nea@nea.moe> + * + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +package moe.nea.firmament.util + +import moe.nea.firmament.Firmament + +object ClipboardUtils { + fun setTextContent(string: String) { + try { + MC.keyboard.clipboard = string.ifEmpty { " " } + } catch (e: Exception) { + Firmament.logger.error("Could not write clipboard", e) + } + } + + fun getTextContents(): String { + try { + return MC.keyboard.clipboard ?: "" + } catch (e: Exception) { + Firmament.logger.error("Could not read clipboard", e) + return "" + } + } +} diff --git a/src/main/kotlin/moe/nea/firmament/util/MC.kt b/src/main/kotlin/moe/nea/firmament/util/MC.kt index 602d85a..78f2eec 100644 --- a/src/main/kotlin/moe/nea/firmament/util/MC.kt +++ b/src/main/kotlin/moe/nea/firmament/util/MC.kt @@ -16,6 +16,7 @@ object MC { player?.networkHandler?.sendCommand(command) } + inline val keyboard get() = MinecraftClient.getInstance().keyboard inline val textureManager get() = MinecraftClient.getInstance().textureManager inline val inGameHud get() = MinecraftClient.getInstance().inGameHud inline val font get() = MinecraftClient.getInstance().textRenderer |