aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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) {