Add tools for copying id, texture id and nbt data
This commit is contained in:
28
src/main/kotlin/moe/nea/firmament/util/ClipboardUtils.kt
Normal file
28
src/main/kotlin/moe/nea/firmament/util/ClipboardUtils.kt
Normal file
@@ -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 ""
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user