diff options
author | Lorenz <ESs95s3P5z8Pheb> | 2022-07-15 23:59:52 +0200 |
---|---|---|
committer | Lorenz <ESs95s3P5z8Pheb> | 2022-07-15 23:59:52 +0200 |
commit | a0380d6c5ac0237853d06c8e2d92ebfa7ec7a6cd (patch) | |
tree | 9df00c59098528627dc23665afa46d9da7dc79fb /src | |
parent | 3539dbe69a0782c519aa7d0fd38b7b58df154fd8 (diff) | |
download | skyhanni-a0380d6c5ac0237853d06c8e2d92ebfa7ec7a6cd.tar.gz skyhanni-a0380d6c5ac0237853d06c8e2d92ebfa7ec7a6cd.tar.bz2 skyhanni-a0380d6c5ac0237853d06c8e2d92ebfa7ec7a6cd.zip |
added /ii item info command
Diffstat (limited to 'src')
3 files changed, 102 insertions, 19 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.java b/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.java index c2b60515f..4de83ad8a 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.java +++ b/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.java @@ -3,6 +3,7 @@ package at.hannibal2.skyhanni.config.commands; import at.hannibal2.skyhanni.SkyHanniMod; import at.hannibal2.skyhanni.config.config.ConfigEditor; import at.hannibal2.skyhanni.config.core.GuiScreenElementWrapper; +import at.hannibal2.skyhanni.test.LorenzTest; import net.minecraft.command.ICommandSender; import net.minecraftforge.client.ClientCommandHandler; import org.apache.commons.lang3.StringUtils; @@ -24,25 +25,36 @@ public class Commands { ClientCommandHandler.instance.registerCommand(new SimpleCommand("skyhanni", mainMenu)); ClientCommandHandler.instance.registerCommand( - new SimpleCommand( - "shreloadlocalrepo", - new SimpleCommand.ProcessCommandRunnable() { - public void processCommand(ICommandSender sender, String[] args) { - SkyHanniMod.repo.reloadLocalRepo(); - } - } - ) + new SimpleCommand( + "shreloadlocalrepo", + new SimpleCommand.ProcessCommandRunnable() { + public void processCommand(ICommandSender sender, String[] args) { + SkyHanniMod.repo.reloadLocalRepo(); + } + } + ) ); ClientCommandHandler.instance.registerCommand( - new SimpleCommand( - "shupdaterepo", - new SimpleCommand.ProcessCommandRunnable() { - public void processCommand(ICommandSender sender, String[] args) { - SkyHanniMod.repo.updateRepo(); - } - } - ) + new SimpleCommand( + "shupdaterepo", + new SimpleCommand.ProcessCommandRunnable() { + public void processCommand(ICommandSender sender, String[] args) { + SkyHanniMod.repo.updateRepo(); + } + } + ) + ); + + ClientCommandHandler.instance.registerCommand( + new SimpleCommand( + "ii", + new SimpleCommand.ProcessCommandRunnable() { + public void processCommand(ICommandSender sender, String[] args) { + LorenzTest.Companion.printLore(); + } + } + ) ); } } diff --git a/src/main/java/at/hannibal2/skyhanni/test/LorenzTest.kt b/src/main/java/at/hannibal2/skyhanni/test/LorenzTest.kt index 9cde01cc6..b618f41e2 100644 --- a/src/main/java/at/hannibal2/skyhanni/test/LorenzTest.kt +++ b/src/main/java/at/hannibal2/skyhanni/test/LorenzTest.kt @@ -1,10 +1,16 @@ package at.hannibal2.skyhanni.test import at.hannibal2.skyhanni.SkyHanniMod -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import at.hannibal2.skyhanni.utils.GuiRender.renderString +import at.hannibal2.skyhanni.utils.ItemUtil +import at.hannibal2.skyhanni.utils.ItemUtils.getLore +import at.hannibal2.skyhanni.utils.LorenzDebug import at.hannibal2.skyhanni.utils.LorenzLogger +import at.hannibal2.skyhanni.utils.LorenzUtils +import net.minecraft.client.Minecraft +import net.minecraft.nbt.NBTTagCompound import net.minecraftforge.client.event.RenderGameOverlayEvent +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent class LorenzTest { @@ -15,6 +21,72 @@ class LorenzTest { var text = "" val debugLogger = LorenzLogger("debug/test") + + fun printLore() { + val itemStack = Minecraft.getMinecraft().thePlayer.inventory.getCurrentItem()!! + print("===") + print("ITEM LORE") + print("display name: '" + itemStack.displayName.toString() + "'") + val itemID = ItemUtil.getSkyBlockItemID(itemStack) + print("itemID: '$itemID'") +// val rarity: ItemRarityOld = ItemUtils.getRarity(itemStack) +// print("rarity: '$rarity'") + print("") + for (line in itemStack.getLore()) { + print("'$line'") + println(line) + } + print("") + print("getTagCompound") + if (itemStack.hasTagCompound()) { + val tagCompound = itemStack.tagCompound + for (s in tagCompound.keySet) { + print(" '$s'") + } + if (tagCompound.hasKey("ExtraAttributes")) { + print("") + print("ExtraAttributes") + val extraAttributes = tagCompound.getCompoundTag("ExtraAttributes") +// for (s in extraAttributes.keySet) { +// print(" '$s'") +// } +// if (extraAttributes.hasKey("enchantments")) { +// print("") +// print("enchantments") +// val enchantments = extraAttributes.getCompoundTag("enchantments") +// for (s in enchantments.keySet) { +// val level = enchantments.getInteger(s) +// print(" '$s' = $level") +// } +// } +// if (extraAttributes.hasKey("modifier")) { +// print("") +// print("modifier") +// val enchantments = extraAttributes.getCompoundTag("modifier") +// for (s in enchantments.keySet) { +// print(" '$s'") +// } +// } + + runn(extraAttributes, " . ") + } + } + print("") + print("===") + LorenzUtils.debug("item info printed!") + } + + fun runn(compound: NBTTagCompound, text: String) { + print("$text'$compound'") + for (s in compound.keySet) { + val element = compound.getCompoundTag(s) + runn(element, "$text ") + } + } + + private fun print(text: String) { + LorenzDebug.log(text) + } } @SubscribeEvent diff --git a/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt index 6d84c7285..39eefff62 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt @@ -88,8 +88,7 @@ object ItemUtils { if (json.has("attributes")) { return true } - } catch (e: Exception) { - e.printStackTrace() + } catch (_: Exception) { } } } |