aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
authorBrandon <brandon.wamboldt@gmail.com>2023-09-27 08:18:20 -0300
committerGitHub <noreply@github.com>2023-09-27 13:18:20 +0200
commita44214f2d62ef45b44f6da057be37a276ccdce76 (patch)
tree50394eccdc1235bbee8b8a736cd97c41f5ccea64 /src/main
parent91a4c759d9b20c3026c89a0fa0da29fd4967f7e2 (diff)
downloadskyhanni-a44214f2d62ef45b44f6da057be37a276ccdce76.tar.gz
skyhanni-a44214f2d62ef45b44f6da057be37a276ccdce76.tar.bz2
skyhanni-a44214f2d62ef45b44f6da057be37a276ccdce76.zip
Add actual NBT data to /shcopyitem command (#509)
Add actual NBT data to /shcopyitem command #509
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/test/command/CopyItemCommand.kt32
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/SkyBlockItemModifierUtils.kt2
2 files changed, 23 insertions, 11 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/test/command/CopyItemCommand.kt b/src/main/java/at/hannibal2/skyhanni/test/command/CopyItemCommand.kt
index 4fc82bbc3..cb7031f4b 100644
--- a/src/main/java/at/hannibal2/skyhanni/test/command/CopyItemCommand.kt
+++ b/src/main/java/at/hannibal2/skyhanni/test/command/CopyItemCommand.kt
@@ -1,11 +1,13 @@
package at.hannibal2.skyhanni.test.command
-import at.hannibal2.skyhanni.test.SkyHanniDebugsAndTests
import at.hannibal2.skyhanni.utils.InventoryUtils
import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName_old
import at.hannibal2.skyhanni.utils.ItemUtils.getLore
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.OSUtils
+import net.minecraft.item.Item
+import net.minecraft.nbt.NBTTagCompound
+import net.minecraft.util.ResourceLocation
object CopyItemCommand {
@@ -17,6 +19,7 @@ object CopyItemCommand {
resultList.add("display name: '" + itemStack.displayName.toString() + "'")
val itemID = itemStack.getInternalName_old()
resultList.add("internalName: '$itemID'")
+ resultList.add("minecraft id: '" + (Item.itemRegistry.getNameForObject(itemStack.item) as ResourceLocation) + "'")
resultList.add("")
for (line in itemStack.getLore()) {
resultList.add("'$line'")
@@ -25,22 +28,29 @@ object CopyItemCommand {
resultList.add("getTagCompound")
if (itemStack.hasTagCompound()) {
val tagCompound = itemStack.tagCompound
- for (s in tagCompound.keySet) {
- resultList.add(" '$s'")
- }
- if (tagCompound.hasKey("ExtraAttributes")) {
- resultList.add("")
- resultList.add("ExtraAttributes")
- val extraAttributes = tagCompound.getCompoundTag("ExtraAttributes")
- SkyHanniDebugsAndTests.runn(extraAttributes, " . ")
- }
+ recurseTag(tagCompound, " ", resultList)
}
val string = resultList.joinToString("\n")
OSUtils.copyToClipboard(string)
- LorenzUtils.chat("§e[SkyHanni] item info copied into the clipboard!")
+ LorenzUtils.chat("§e[SkyHanni] Item info copied into the clipboard!")
} catch (_: Throwable) {
LorenzUtils.chat("§c[SkyHanni] No item in hand!")
}
}
+
+ private fun recurseTag(compound: NBTTagCompound, text: String, list: MutableList<String>) {
+ for (s in compound.keySet) {
+ val tag = compound.getTag(s)
+
+ if (tag !is NBTTagCompound) {
+ list.add("${text}${s}: $tag")
+ } else {
+ val element = compound.getCompoundTag(s)
+ list.add("${text}${s}:")
+ recurseTag(element, "$text ", list)
+ }
+ }
+ }
+
} \ No newline at end of file
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/SkyBlockItemModifierUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/SkyBlockItemModifierUtils.kt
index 3d33acf3c..4be6dd30a 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/SkyBlockItemModifierUtils.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/SkyBlockItemModifierUtils.kt
@@ -178,6 +178,8 @@ object SkyBlockItemModifierUtils {
fun ItemStack.getItemUuid() = getAttributeString("uuid")
+ fun ItemStack.getItemId() = getAttributeString("id")
+
fun ItemStack.getGemstones() = getExtraAttributes()?.let {
val list = mutableListOf<GemstoneSlot>()
for (attributes in it.keySet) {