aboutsummaryrefslogtreecommitdiff
path: root/src/main
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 /src/main
parentec36c211417456f55ee333d86407f12fa9d55872 (diff)
downloadFirmament-55586a64d7037cdc557b8b2c337d284ddb1ac981.tar.gz
Firmament-55586a64d7037cdc557b8b2c337d284ddb1ac981.tar.bz2
Firmament-55586a64d7037cdc557b8b2c337d284ddb1ac981.zip
Add custom skull texture keybind for items
Diffstat (limited to 'src/main')
-rw-r--r--src/main/kotlin/moe/nea/firmament/features/debug/PowerUserTools.kt28
1 files changed, 26 insertions, 2 deletions
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")
}
}
}