aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLinnea Gräf <nea@nea.moe>2024-03-17 18:22:50 +0100
committerLinnea Gräf <nea@nea.moe>2024-03-17 18:22:50 +0100
commit55586a64d7037cdc557b8b2c337d284ddb1ac981 (patch)
treef2fc8ebddb4f002487629ea699567d3cb909122d
parentec36c211417456f55ee333d86407f12fa9d55872 (diff)
downloadFirmament-55586a64d7037cdc557b8b2c337d284ddb1ac981.tar.gz
Firmament-55586a64d7037cdc557b8b2c337d284ddb1ac981.tar.bz2
Firmament-55586a64d7037cdc557b8b2c337d284ddb1ac981.zip
Add custom skull texture keybind for items
-rw-r--r--gradle/libs.versions.toml2
-rw-r--r--shell.nix6
-rw-r--r--src/main/kotlin/moe/nea/firmament/features/debug/PowerUserTools.kt28
3 files changed, 33 insertions, 3 deletions
diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml
index 388d5c6..912b88c 100644
--- a/gradle/libs.versions.toml
+++ b/gradle/libs.versions.toml
@@ -10,7 +10,7 @@ fabric_kotlin = "1.9.4+kotlin.1.8.21"
yarn = "1.20.4+build.3"
libgui = "9.2.2+1.20.2"
rei = "14.0.688"
-devauth = "1.0.0"
+devauth = "1.2.0"
modmenu = "9.0.0"
ktor = "2.3.0"
dbus_java = "4.2.1"
diff --git a/shell.nix b/shell.nix
index 330a57a..07f9a1c 100644
--- a/shell.nix
+++ b/shell.nix
@@ -11,5 +11,11 @@ pkgs.mkShell {
temurin-bin-17
reuse
pre-commit
+ glfw
+ libGL
];
+ shellHook = ''
+ export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:${pkgs.glfw}/lib"
+ export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:${pkgs.libGL}/lib"
+ '';
}
diff --git a/src/main/kotlin/moe/nea/firmament/features/debug/PowerUserTools.kt b/src/main/kotlin/moe/nea/firmament/features/debug/PowerUserTools.kt
index 3545f21..9341dad 100644
--- a/src/main/kotlin/moe/nea/firmament/features/debug/PowerUserTools.kt
+++ b/src/main/kotlin/moe/nea/firmament/features/debug/PowerUserTools.kt
@@ -9,6 +9,8 @@ package moe.nea.firmament.features.debug
import net.minecraft.block.SkullBlock
import net.minecraft.block.entity.SkullBlockEntity
import net.minecraft.item.ItemStack
+import net.minecraft.item.Items
+import net.minecraft.nbt.NbtHelper
import net.minecraft.text.Text
import net.minecraft.util.hit.BlockHitResult
import net.minecraft.util.hit.HitResult
@@ -25,6 +27,7 @@ import moe.nea.firmament.mixins.accessor.AccessorHandledScreen
import moe.nea.firmament.util.ClipboardUtils
import moe.nea.firmament.util.MC
import moe.nea.firmament.util.focusedItemStack
+import moe.nea.firmament.util.getOrCreateCompoundTag
import moe.nea.firmament.util.skyBlockId
object PowerUserTools : FirmamentFeature {
@@ -105,7 +108,8 @@ object PowerUserTools : FirmamentFeature {
return@subscribe
}
ClipboardUtils.setTextContent(sbId.neuItem)
- lastCopiedStack = Pair(item, Text.stringifiedTranslatable("firmament.tooltip.copied.skyblockid", sbId.neuItem))
+ lastCopiedStack =
+ Pair(item, Text.stringifiedTranslatable("firmament.tooltip.copied.skyblockid", sbId.neuItem))
} else if (it.matches(TConfig.copyTexturePackId)) {
val model = CustomItemModelEvent.getModelIdentifier(item)
if (model == null) {
@@ -113,11 +117,31 @@ object PowerUserTools : FirmamentFeature {
return@subscribe
}
ClipboardUtils.setTextContent(model.toString())
- lastCopiedStack = Pair(item, Text.stringifiedTranslatable("firmament.tooltip.copied.modelid", model.toString()))
+ lastCopiedStack =
+ Pair(item, Text.stringifiedTranslatable("firmament.tooltip.copied.modelid", model.toString()))
} else if (it.matches(TConfig.copyNbtData)) {
val nbt = item.orCreateNbt.toString()
ClipboardUtils.setTextContent(nbt)
lastCopiedStack = Pair(item, Text.translatable("firmament.tooltip.copied.nbt"))
+ } else if (it.matches(TConfig.copySkullTexture)) {
+ if (item.item != Items.PLAYER_HEAD) {
+ lastCopiedStack = Pair(item, Text.translatable("firmament.tooltip.copied.skull-id.fail.no-skull"))
+ return@subscribe
+ }
+ val profile = NbtHelper.toGameProfile(item.orCreateNbt.getOrCreateCompoundTag("SkullOwner"))
+ if (profile == null) {
+ lastCopiedStack = Pair(item, Text.translatable("firmament.tooltip.copied.skull-id.fail.no-profile"))
+ return@subscribe
+ }
+ val skullTexture = CustomSkyBlockTextures.getSkullTexture(profile)
+ if (skullTexture == null) {
+ lastCopiedStack = Pair(item, Text.translatable("firmament.tooltip.copied.skull-id.fail.no-texture"))
+ return@subscribe
+ }
+ ClipboardUtils.setTextContent(skullTexture.toString())
+ lastCopiedStack =
+ Pair(item, Text.stringifiedTranslatable("firmament.tooltip.copied.skull-id", skullTexture.toString()))
+ println("Copied skull id: $skullTexture")
}
}
}